Referencing state machines

First of all – in order to enable collaboration between separate state machines it must be possible that state machines can reference other state machines. To establish such a reference two steps are required:

  1. The external statechart must be made visible by defining an import scope using import: "xyz.sct" in the statecharts declaration area. Specify relative paths if the statecharts are not located in the same directory.
  2. Define a variable of the desired state machine type: var otherMachine : SomeMachineType

For our example statechart TwoWayTrafficControl the declarations look like this:

import: "TrafficLight.sct"
interface: 
    var trafficLightA : TrafficLight
    var trafficLightB : TrafficLight

According to the steps described above the statechart TrafficLight.sct is imported. As two instances of this referenced statechart are required, two variables are defined. So if you want to implement a three or four way traffic control you can simply define as many variables for state machine references as you require.