03.08.2013 Views

Dynamic Dataflow Modeling in Ptolemy II - Ptolemy Project ...

Dynamic Dataflow Modeling in Ptolemy II - Ptolemy Project ...

Dynamic Dataflow Modeling in Ptolemy II - Ptolemy Project ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Before proceed<strong>in</strong>g with how this can be achieved with BooleanSelect actor, let’s spend a<br />

few words on sequential fir<strong>in</strong>g rules. Intuitively sequential means that the fir<strong>in</strong>g rules can<br />

be tested <strong>in</strong> a pre-def<strong>in</strong>ed order us<strong>in</strong>g only block<strong>in</strong>g reads. Each block<strong>in</strong>g read can be<br />

expressed as rate <strong>in</strong>formation on the <strong>in</strong>put ports. Upon consum<strong>in</strong>g the token, the actor<br />

determ<strong>in</strong>es the next <strong>in</strong>put port to read token from, and the correspond<strong>in</strong>g rate <strong>in</strong>formation<br />

is updated to reflect that. For a more rigorous treatment of this rather technical def<strong>in</strong>ition<br />

of sequentiality, please refer to [9]. Later on <strong>in</strong> this section, we will give an example of<br />

non-sequential fir<strong>in</strong>g rules.<br />

The fir<strong>in</strong>g rules of BooleanSelect actor are sequential, therefore we can <strong>in</strong>troduce a two-<br />

phase fir<strong>in</strong>gs for this actor. Dur<strong>in</strong>g <strong>in</strong>itialization, the control port sets its rate to 1 and<br />

trueInput/falseInput ports both set their rates to 0.<br />

This code block from DDFBooleanSelect actor shows <strong>in</strong>itialization:<br />

public void <strong>in</strong>itialize() throws IllegalActionException {<br />

super.<strong>in</strong>itialize();<br />

_isControlRead = false;<br />

trueInput_tokenConsumptionRate.setToken(new IntToken(0));<br />

falseInput_tokenConsumptionRate.setToken(new IntToken(0));<br />

control_tokenConsumptionRate.setToken(new IntToken(1));<br />

}<br />

In the first fir<strong>in</strong>g, the actor consumes a Boolean token from control port. Depend<strong>in</strong>g on<br />

the Boolean value of that token (true or false), the correspond<strong>in</strong>g port (trueInput or<br />

falseInput) changes its rate to 1 and the other port keeps its rate at 0. The control port also<br />

needs to change its rate to 0 to declare that it doesn’t consume token <strong>in</strong> the next fir<strong>in</strong>g. In<br />

the second fir<strong>in</strong>g, trueInput port or falseInput port with rate 1 consumes one token and<br />

36

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

Saved successfully!

Ooh no, something went wrong!