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 89<br />

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

static bool ReportLostMessageEnabled()<br />

{<br />

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

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

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

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

}<br />

[Action]<br />

static void ReportLostMessage()<br />

{<br />

StartTimer(); // wait for next time to poll<br />

waitfor = WaitFor.Timeout;<br />

phase = Phase.WaitForEvent;<br />

}<br />

// NoHandler is enabled when no other handler is enabled<br />

static bool NoHandlerEnabled()<br />

{<br />

return (phase == Phase.HandleEvent<br />

&& !ResetEnabled()<br />

&& !PollEnabled()<br />

&& !CalibrateEnabled()<br />

&& !CheckMessageEnabled()<br />

&& !ReportLostMessageEnabled());<br />

}<br />

[Action]<br />

static void NoHandler()<br />

{<br />

phase = Phase.WaitForEvent;<br />

}<br />

// continued ...<br />

Figure 5.15. Reactive system: model program (part 4).<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!