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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

36 <strong>Why</strong> <strong>We</strong> <strong>Need</strong> <strong>Model</strong>-<strong>Based</strong> Analysis<br />

// ... continued<br />

bool ResetEnabled()<br />

{<br />

return (cevent == ControlEvent.Timeout && waitfor == WaitFor.Timeout<br />

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

}<br />

void Reset()<br />

{<br />

Console.WriteLine(" Reset");<br />

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

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

waitfor = WaitFor.Message;<br />

}<br />

bool PollEnabled()<br />

{<br />

return (cevent == ControlEvent.Timeout && waitfor == WaitFor.Timeout<br />

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

}<br />

void Poll()<br />

{<br />

Console.WriteLine(" Poll");<br />

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

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

waitfor = WaitFor.Message;<br />

}<br />

bool CalibrateEnabled()<br />

{<br />

return (cevent == ControlEvent.Command && waitfor == WaitFor.Timeout<br />

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

}<br />

void Calibrate()<br />

{<br />

Console.WriteLine(" Calibrate ’{0}’", buffer);<br />

double data = Double.Parse(buffer);<br />

// compute with data (not shown)<br />

}<br />

// to be continued ...<br />

Figure 3.3. Process controller class with dispatcher and handlers (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!