23.08.2013 Views

Specification of Reactive Hardware/Software Systems - Electronic ...

Specification of Reactive Hardware/Software Systems - Electronic ...

Specification of Reactive Hardware/Software Systems - Electronic ...

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.

12.3 The Essential <strong>Specification</strong> 395<br />

monitorTransporter<br />

interrupt<br />

( titr?productArrived;piti!productArrived<br />

or piti!currentPosition(position asInitialPosition)<br />

or wake?wakeAt(aPosition,anId);wakeupQueue schedule(aPosition,anId)<br />

or poti?stop;speed setToZero;titre!move(speed)<br />

or poti?start;speed setToMaximum;titre!move(speed)<br />

)<br />

The initialise method starts by initialising the instance variables position, pendingWakeups<br />

and speed. Then it sends the message move(speed) to the Transporter (see also Figure 12.6)<br />

and starts its normal course <strong>of</strong> behaviour. This normal course <strong>of</strong> behaviour consists <strong>of</strong><br />

the monitoring <strong>of</strong> the Transporter. The behaviour is modelled by the monitorTransporter<br />

method. This method can be interrupted at any time by the arrival <strong>of</strong> either the productArrived,<br />

wakeAt, stop or start messages. It can further be interrupted always when<br />

the Product Input Handler reads the current position. In this way the current position is<br />

continuously available. The monitorTransporter method is defined as:<br />

monitorTransporter<br />

titr?encoderPulse;<br />

position increment;<br />

if pendingWakeups firstPosition = position then wakeupPendings fi;<br />

monitorTransporter<br />

The method repeatedly accepts encoderPulses. For each encoderPulse, the position is<br />

increased by one. At each position, it is checked whether there are pending processes<br />

that need to be woken up at this position. If this is so, the method wakeupPendings is<br />

invoked. This method is specified by:<br />

wakeupPendings idSet:Set anId:Id<br />

idSet:=wakeupQueue idSetAtFirstPosition;<br />

do (idSet isEmpty not) then<br />

anId:=idSet pickElement;<br />

wake!wakeup(anId)<br />

od<br />

This method first retrieves and removes the collection <strong>of</strong> process identifiers at the current<br />

position. The pickElement message is used to select and remove an arbitrary element<br />

from the idSet. For each identifier anId in this set, the corresponding process is woken<br />

up through the wakeup(anId) message.<br />

Now that we have specified a number <strong>of</strong> process classes, we show two specifications<br />

<strong>of</strong> data classes. The first data class we will explain is PI. The first part <strong>of</strong> the class<br />

description is as follows:

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

Saved successfully!

Ooh no, something went wrong!