State Machines

State machines are a way to model reactive systems. A state machine defines different configurations, or states, of the system and how the system responds to events in each of those states. Moxie uses state machines to define the interactions of the simulated system and environment. Activity diagrams can define similar behavior, but they do not include the same reactive event capability as state machines. This reactivity allows you to embed physics and system effects into the transitions between states in a state machine.

There are three major pieces that make up a state machine:

  • States represent stable configurations or conditions of the system being modeled.
  • Pseudostates help guide the flow of a state machine, but they are not stable configurations like states. When a state machine enters a pseudostate, it immediately transitions out of it.
  • Transitions are triggered by events and describe the ways in which the system can move from one state or pseudostate to another.

When running a simulation, Moxie refers to each independent execution of a state machine as a session. So even though multiple instance specifications of a block share its state machine (if it has one), they are each executed as separate, though potentially simultaneous, sessions.