Skip to content

Sending events, receiving events, and accessing variables

A state machine reference can be used to interact with the referenced state machine. All elements which are exposed by the state machine type can be used:

  • Raise in events on the referenced state machine.
  • React on out events from referenced state machines.
  • Get and set variables (including referenced state machines).

The statechart TwoWayTrafficControl raises different events on the referenced state machines.

Traffic controller raises events on referenced state machines.

Different states (like Release A) also use outgoing events ( trafficLightA.released) as transition triggers.

A loosely coupled architecture makes use of asynchronous message passing and this perfectly matches to statechart events. A statechart which raises an event should not make any assumptions when the event is processed.

Accessing variables implies a tighter coupling of state machines as these are accessed in a synchronized fashion.

As an example the statechart TwoWayTrafficControl could configure the TrafficLight state machines using variables that these provide.

entry / trafficLightA.config.realeasePeriod = 60

Here the v ariable releasePeriod is set as an entry action. releasePeriod is defined by the named interface config thus it is accessed in two step using the dot expression ‘.’ .