![]() |
|---|
for- or
while-loop to wait for something to occur. So we can use
the following code:
Explanation of the code:
dfa_.while-loop. The
first thing that we do in each pass through this loop is to increment
the time counter if the timer is running. In this simple code we are
not caring about "roll over"s.switch-statement is the heart of the
DFA. Here we make decisions based on the current state.switch-statement that is worth
exploring.
The code for a a typical state like this one
![]() |
|---|
Explanation of the code:
<DFA> tag. The
initial state is given as the start attribute.<STATE>
tag. We can refer to it later using its name.<ON> specifies an input. The
event is any boolean C-expression. The next state is also
specified as an attribute.<T_OFF> turns the timer off.<ONTIMEOUT> is the special input
corresponding to expiration of the timer. This also stops the timer automatically.<T_ON> turns the timer on. Its
time attribute specifies the lifespan. It must be a
strictly positive integer.