🎰State Machine

The State Machine block allows you to implement your own Mealy state machine: https://en.wikipedia.org/wiki/Mealy_machine

The State machine block updates its state and outputs like other blocks. When all upstream dependencies have updated, it will update before any downstream dependencies.

The State Machines in Collimator operate under a continuous signal flow model. That is to say that the inputs toβ€”and outputs fromβ€”the block have values at every time step, even if they haven't changed since the previous time step. This behavior affects both the way guards on transitions are evaluated, and how blocks that consume State Machine output signals will react.

In practical terms, just remember these two rules to avoid gotchas:

  1. All guards on transitions from a given state are evaluated in order until a match is found (or none is), and this happens at every time step, not just when an input value changes

  2. The outputs of State Machine blocks operate just like any other block with stepped outputsβ€”there are no special output values to indicate whether or not the state has changed.

Basic actions:

  • Double click to enter the state machine editor.

  • Double click in the editor to add a new state.

  • Change state name by typing in the name box.

  • Double click a state to start a new transition start form that state. Double click the desired termination state for the transition.

  • Add a guard to a transition by typing python expression in the [ ] text box.

  • Add actions to a transition by typing python statements in the / text box.

    • Add multiple actions to a transition by either pressing enter to get a new line, or separating statements on the same line with a ;, e.g. out_0=1; out_1=2

  • Create actions that do not result in a state change by connecting a transition back to the same state.

  • Initialize outputs by adding actions to the entry point transition.

Inputs and Outputs

  • Add/remove/rename inputs and outputs using the controls in the right side panel

  • Refer to inputs and outputs by name in guards and actions

  • Inputs may not appear on the left hand side of action statements. Examples below are not valid:

    • in_0 = 10

    • in_0 = in_2

  • Outputs may not appear in guard expressions, examples below are not valid:

    • 10 < out_1

    • out_0 > in_0

Action and Guard supported python syntax:

  • Addition

  • Subtraction

  • Multiplication

  • Relational operators

  • Logical operators

Transition order of evaluation:

  • The exit transitions of an active state are evaluated in the following order:

    • Guarded transitions are evaluated in clockwise order from the top left of the state block, following around sequentially until there are no remaining evaluations.

    • Unguarded transitions are evaluated in the same order.

  • At present, more than one unguarded transition is an error.

Constraints and Limitations:

  • Must contain one, and only one entry point transition, indicating the initial state.

  • At present, the block does not output its state value/enumeration.

  • At present, there are no junction nodes, so each transition goes between two states.

Last updated