6: the out-of-range value differs too much from
the in-range value).
5.7.2 Code
The reactive system model program appears in Figures 5.12??“5.18. Compare this to
the implementation code in Chapter 3, Figures 3.2??“3.4. The model program includes
code that models the environment (timer, sensor, and supervisor), which does not
correspond to any code in the implementation Controller class. The following
paragraphs explain some features that might not be obvious.
Both data state variables represent numbers, but buffer is a string and previous
is a double. The conversion is performed by the CheckMessage action method.
The particular values of the two temperature values InRange and OutOfRange do
not matter, but they must differ by more than tol in CheckMessage.
There are two kinds of action methods in the model program. The action
methods that handle events appear first. They also appear in the implementation.
The other action methods raise events. They do not appear in the implementation.
The two kinds of actions alternate, using the phase control state variable.
The events are enabled when phase == Phase.WaitForEvent and assign phase =
Phase.HandleEvent. The handlers are enabled when phase == Phase.HandleEvent
and assign phase = Phase.WaitForEvent.
There must be a dummy handler NoHandler to model what happens in the implementation
when no handler is enabled.
Pages:
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135