SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 126 | Next

Jonathan Jacky, Margus Veanes, Colin Campbell, Wolfram Schulte

"Model-Based Software Testing and Analysis with C#"

Message;
phase = Phase.WaitForEvent;
}
// continued ...
Figure 5.13. Reactive system: model program (part 2).
88 Model Programs
// ... Reactive system model program, continued
static bool CalibrateEnabled()
{
return (cevent == ControlEvent.Command
&& waitfor == WaitFor.Timeout
&& sensor == Sensor.OK
&& phase == Phase.HandleEvent);
}
[Action]
static void Calibrate()
{
double data = double.Parse(buffer);
phase = Phase.WaitForEvent;
}
static bool CheckMessageEnabled()
{
return (cevent == ControlEvent.Message
&& waitfor == WaitFor.Message
&& phase == Phase.HandleEvent);
}
[Action]
static void CheckMessage()
{
double tol = 5.0;
try {
double data = double.Parse(buffer);
if (previous == double.MaxValue) previous = data; // initialize
if (Math.Abs(data - previous) < tol) {
previous = data;
sensor = Sensor.OK;
}
else sensor = Sensor.Error; // retain old previous
}
catch {
sensor = Sensor.Error;
}
CancelTimer(); // cancel messageTimeout
StartTimer(); // wait for next time to poll
waitfor = WaitFor.Timeout;
phase = Phase.WaitForEvent;
}
// continued ...
Figure 5.14. Reactive system: model program (part 3).
Systems with Finite Models 89
// ... Reactive system model program, continued
static bool ReportLostMessageEnabled()
{
return (cevent == ControlEvent.Timeout
&& waitfor == WaitFor.Message
&& sensor == Sensor.OK
&& phase == Phase.


Pages:
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6