05.11.2014 Views

AN: Capstone Dive Computer Example - Quantum Leaps

AN: Capstone Dive Computer Example - Quantum Leaps

AN: Capstone Dive Computer Example - Quantum Leaps

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.

Application Note:<br />

<strong>Capstone</strong> <strong>Dive</strong> <strong>Computer</strong> <strong>Example</strong><br />

www.state-machine.com<br />

Per the semantics of state nesting, the substate “surfaced” inherits all the behavior from its superstate<br />

“always”. The substate can override the inherited behavior and it can also define new behavior.<br />

2.4.2 AlarmMgr State Machine<br />

The main responsibility of the Alarm Manager (AlarmMgr) state machine is to handle all alarm conditions<br />

autonomously. As shown in the sequence diagram in Figure 4, the <strong>Capstone</strong> active object<br />

sends only alarm requests and silences alarms based on the diving conditions. However, <strong>Capstone</strong><br />

might end up requesting several alarms simultaneously, and it is up to the AlarmMgr to always play<br />

the highest-priority alarm at any one time. This includes the situation when an alarm is silenced,<br />

but others still remain active, in which case the AlarmMgr must keep playing the highest-priority<br />

alarm at that time.<br />

The AlarmMgr is designed generally, to handle any number of alarms (it is not hard-coded to handle<br />

only three alarms specified in the requirements). The design of the AlarmMgr state machine<br />

hinges on the data representation for alarms.<br />

The central data structure is the priority-set, which is provided in the QP framework. The priority<br />

set allows inserting elements numbered 1..n and removing elements. The set also allows discovering<br />

the highest-number event currently present in the priority set quickly and very efficiently.<br />

Figure 6 shows the state machine associated with Alarm active object.<br />

Figure 6 Alarm state machine.<br />

Copyright © <strong>Quantum</strong> <strong>Leaps</strong>, LLC. All Rights Reserved.<br />

15 of 29

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

Saved successfully!

Ooh no, something went wrong!