Sunday, 11 August 2019

Rational Rhapsody Tip #62 - Orthogonal/parallel regions in state machines

This 4 min silent video explores some of the executable semantics around the use of orthogonal regions in state machines. Most of these semantics come from work done by Dr David Harel and his colleagues in the 1980/90's on statecharts, which were subsequently subsumed into the Unified Modeling Language, and inherited by SysML. Essentially orthogonal regions in a state machine are regions that execute concurrently as part of an owning state. Each region becomes active when its owning state is entered. In Rhapsody we can create any number of these using an And Line. It's possible for orthogonal regions to influence each other. These video explores 3 ways:

  1. We could get one of the regions to generate an event. Essentially, the event would be placed on the event queue for the thread and then consumed as a trigger in another parallel region. 
  2. A second approach would be for a parallel/orthogonal region to query the state of another region using IBM Rational Rhapsody's IS_IN macro. This macro allows you to query if the state machine is in a particular state. 
  3. A third approach would be to query the state of an attribute. As the scope of the state machine is a classifier, the attribute would be visible in the state machine and could be used in a guard-based transition. There's a caveat here. Guard-based transitions are tested on entry to a state or when an orthogonal region performs a transition. To get guard-based transition to be re-tested then a transition needs to be performed in one of the orthogonal regions. This silent video with captions highlights this.


No comments:

Post a Comment