27.07.2013 Views

2 Why We Need Model-Based Testing

2 Why We Need Model-Based Testing

2 Why We Need Model-Based Testing

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Systems with Finite <strong>Model</strong>s 87<br />

// ... Reactive system model program, continued<br />

// Actions and enabling conditions for Controller, from implementation<br />

static bool ResetEnabled()<br />

{<br />

return (cevent == ControlEvent.Timeout<br />

&& waitfor == WaitFor.Timeout<br />

&& sensor == Sensor.Error<br />

&& phase == Phase.HandleEvent);<br />

}<br />

[Action]<br />

static void Reset()<br />

{<br />

ResetSensor(); // send reset command to sensor<br />

StartTimer(); // wait for message from from sensor<br />

waitfor = WaitFor.Message;<br />

phase = Phase.WaitForEvent;<br />

}<br />

static bool PollEnabled()<br />

{<br />

return (cevent == ControlEvent.Timeout<br />

&& waitfor == WaitFor.Timeout<br />

&& sensor == Sensor.OK<br />

&& phase == Phase.HandleEvent);<br />

}<br />

[Action]<br />

static void Poll()<br />

{<br />

PollSensor(); // send poll command to sensor<br />

StartTimer(); // wait for message from sensor<br />

waitfor = WaitFor.Message;<br />

phase = Phase.WaitForEvent;<br />

}<br />

// continued ...<br />

Figure 5.13. Reactive system: model program (part 2).<br />

more free ebooks download links at:<br />

http://www.ebook-x.com

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

Saved successfully!

Ooh no, something went wrong!