01.01.2015 Views

UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Session 22—Modeling the Extended Features of the Statechart 233<br />

control is shown by a single transition divided into multiple arrows pointing to multiple<br />

states or substates. The divide is accomplished with the fork bar you used in the Activity<br />

diagram and is illustrated in Figure 22-8.<br />

Merge of control can be modeled as multiple transition arrows pointing to a synchronization<br />

bar, as you saw earlier in learning about the Activity diagram. Synchronization is not<br />

shown in Figure 22-8.<br />

when temperature received(temperature)<br />

[temperature>76F]/<br />

^AirConditioner.turnOn()<br />

Cooling<br />

after tempdelay(seconds)<br />

^Thermometer.getTemperature()<br />

Monitor Cooling<br />

Monitor Device<br />

Exit:^AirConditioner.turnOff()<br />

Figure 22-8<br />

Split of control<br />

Concurrency<br />

By allowing multiple Statecharts within a state, the <strong>UML</strong> supports concurrency within a<br />

state. <strong>To</strong> model concurrency, simply split the superstate internal transition compartment<br />

into as many separate compartments as needed, one for each sub-Statechart. In the thermostat<br />

example, the Thermostat is doing two jobs at the same time: monitoring the cooling<br />

device and watching for problems with the device. So the Cooling state internal transition<br />

compartment is split in two by a line.<br />

Note that in this particular example each substate provides a different transition out of<br />

the superstate. The Monitor Cooling substate is watching for the event “when temperature<br />

received(temperature) [temperature < 70].” If it receives this event, it takes the Thermostat<br />

out of the Cooling state and back to monitoring the temperature. So what happens to the<br />

other substate Well, this hits on the definition of substate. A substate is a state within a<br />

state — in this case, Monitor Device within Cooling. If the Thermostat leaves the Cooling<br />

state, by definition it also leaves the Monitor Device state. This is illustrated in Figure 22-9.<br />

The same is true if the Monitor Device state receives the event it is waiting for.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!