Building Blocks > Domain-Specific Building Blocks > State Machine Building Block > Configurations (State Machine Building Block)
Configurations (State Machine Building Block)
The StateMachineConfiguration configuration table on the PTC.StateMachineImpl.Manager Thing is where individual state machines are defined. This table includes the following fields:
stateMachineName—Name for the state machine. Must be unique.
dataShapeName—If the state machine is associated with a field in a Data Shape, specify the Data Shape name.
fieldName—If the state machine is associated with a field in a Data Shape, specify the name of the field.
stateMachineConfiguration—JSON code defining the state machine. For each state in the state machine, you can specify the following:
initial—If true, then the state is an initial state.
final—If true, then the state is a final state.
transitions—The valid transitions from this state. For a given transition you can also specify the following:
action—An action that can occur when the transition happens.
event—The event that triggers the transition.
The action and event values can be referenced by services that call the state machine.
The following sample code is the stateMachineConfiguration JSON code for the JobOrderDispatchStatus state machine that is provided by the job order building block:
{
"states": {
"Dispatched": {
"initial": true,
"transitions": {
"Running": {
"action": "EndProductionBlock",
"event": "StartJobOrder"
},
"Canceled": {},
"Pending": {}
}
},
"Held": {
"transitions": {
"Running": {
"action": "EndProductionBlock",
"event": "StartJobOrder"
},
"Completed": {},
"Canceled": {}
}
},
"Running": {
"transitions": {
"Held": {
"action": "EndProductionBlock",
"event": "StopJobOrder"
},
"Completed": {
"action": "EndProductionBlock",
"event": "StopJobOrder"
}
}
},
"Completed": {
"final": true
},
"Canceled": {
"final": true
},
"Pending": {
"initial": true,
"transitions": {
"Dispatched": {},
"Canceled": {}
}
}
}
}
Was this helpful?