Exercise 8 - Constructing Statecharts
In this exercise, you construct two statecharts that describe behavioral aspects of the rear defog system. The Statechart CALC_REAR_DEFOG_STATE_BHVR and Statechart REAR_DEFOG_RELAY_MGMT_BHVR figures show the two intended statecharts.
1. Click Graphic Editor from the main Rational Statemate window.
2. Create a statechart called 'CALC_REAR_DEFOG_STATE_BHVR' based on the selections shown in the following figure.
●
Type: Statechart
●
Usage: Regular
●
Name Pattern: CALC_REAR_DEFOG_STATE_BHVR
3. Select New from the Open Chart window to create and open a new diagram. The chart is now available for editing. Click Create State drawing.
4. Draw a state called CALC_REAR_DEFOG_STATE_BHVR.
Place the cursor at the location you want for the upper, left-hand corner of the state and drag to the location of the lower, right-hand corner of the state. A ghost image shows the state outline.
5.
Note: Enter the names for boxes using lowercase letters. Rational Statemate, where appropriate, automatically performs the conversion to uppercase letters. Do not select the CAPS LOCK key before typing.
7. Using the Statechart CALC_REAR_DEFOG_STATE_BHVR figure as a guideline, create and name the other states within your chart.
8. Click Create Transition.
9. Draw a transition from the state called 'CALC_REAR_DEFOG_DISABLED' to the state called 'CALC_REAR_DEFOG_ENABLED'.
Locate the state called 'CALC_REAR_DEFOG_DISABLED'. This is the source state. Place the cursor on the edge of the box and click to enter the tail of the arrow.
10. Locate the state called 'CALC_REAR_DEFOG_ENABLED'. This is the target state. Place the cursor on the edge of the state and click to enter the arrowhead.
11. With the Create Transition icon still selected, label the transition 'RDEFOG_SW_STATUS and [LOAD_SHED_IN!=LM_LEVEL3]/ RDEFOG_LED=true; RDEFOG_ON_STATUS=true;
12. With the Create Transition or the Label Existing Transition icon selected, enter the transition label. Click the location you want the text to reside.
13. Click Create Default Transition.
Note: Default transitions do not have a source state and cannot have triggers. Use the Statechart CALC_REAR_DEFOG_STATE_BHVR figure as a guide as where to draw the default transition.
15. With Create Default Transition still selected, label the transition 'RDEFOG_LED=false; RDEFOG_ON_STATUS=false; RD_TIMER=KTIMER1;'
16.
17.
18. Using the steps outlined above, create and design the statechart called 'REAR_DEFOG_RELAY_MGMT_BHVR' as shown in the Statechart REAR_DEFOG_RELAY_MGMT_BHVR figure.
Note: The statecharts that were developed for this tutorial were used to describe the behavior for the activities, 'CALC_REAR_DEFOG_STATE' and 'REAR_DEFOG_RELAY_MGMT'.
19. Open the activity-chart called 'CALC_REAR_DEFOG_STATE'.
20. Click Create Control Activity in the activity-chart.
21. Draw and name the control activity ('@CALC_REAR_DEFOG_STATE') as shown in the following figure.
22.
23. Repeat the above 4 steps and create the association between activity 'REAR_DEFOG_RELAY_MGMT' and the statechart 'REAR_DEFOG_RELAY_MGMT_BHVR'.