Friday 5 July 2019

Rational Rhapsody Tip #60 - Initializing your history connectors (in state machines)

This video came from a question I got asked in a web-based Rhapsody "hands-on" tool training course this week, which is really what are history connectors and how to use them in Rhapsody when you're building and running with the event driven framework (OxF). Unusual for me, I just banged it out with the microphone running (which worked, well mostly ;-) I've included a summary below in case you can't YouTube the whole 8 mins.
















Firstly if we take this statechart we can see that if I exit and return a state then the default transition will be taken:


A history connector is a way to get the state-chart to remember the state it was in when you exit and return to it when you re-enter. The UML would normally have you drawing it something like this:

The trouble is, this won't work if you want Rhapsody to generate the desirable code, i.e. Rhapsody will still take the default transition if you re-enter the state.

to draw the history connector correctly in Rhapsiody (at least correctly to generate the correct code), you need to a) Draw the default transition to the History Connector, and b) Draw a transition from the history connector to where you want the default transition to go. 

This has the effect of initialization the history connector to the default transition.

.. and then remembering the history, the next time you re-enter the state (and the default transition is called upon).

No comments:

Post a Comment

Note: only a member of this blog may post a comment.