Hi,
I always prefer a state machine with a state buffer. This means, every state
can, potentially, call several other states. In practice, there is a shift
register with an array of strings in it. The first string is called, and
removed. Every state can modify the buffer, so:
+ states can be put before, after or between the buffer
+ states can be removed
+ states can be filtered, sorted etc.
+ buffered states can be copied
This makes programming with state machines a lot easier. You can simply make
a state TurnLaserON, and in the calling state(s) diside what the state after
TurnLaserON has to be. This makes the program a lot clearer.
Some design rules I use (mainlly because if I don't use them, there is no
way of documenting the program):
+ states may only put states before the buffer (I call them sub states)
+ buffered states cannot be removed in a state
Using these rules, I can put the entire program on paper, without any
problem.
Still, I have to transfere information between states. This 'information'
can be a shift register with a bundle, indicators on the front panel (not
visible to the end user), a GLI, buffers, ini file reference, or whatever. I
have never found any big advantage or disadvantage for eny of them, but I
prefer indicators (mixed with buffers when convenient), because they are the
fastest to use (for me), and easiest to debug (IMO).
Regards,
Wiebe.
"O. Zimmermann"
wrote in message
news:3E6CB966.7010503@isn.in2p3.fr...
>
> I have been using the state machine design pattern in programs for a
> while. In this technique, it is a common practice to define boolean
> switches to trigger actions in the next iteration of the machine (eg.
> "TurnLaserON", "Quit", "Compute", "SetAlarm1"...). Thus, the boundary
> between data and processing is easily trespassed.
>
> This sounds to me like a possible source of errors, that should be
> limited by some design rule of thumb. I tend to believe that boolean
> triggers in state machines should be looked at with the same precautions
> as a "GOTO" control structure.
>
> Do you have any experience or theoretical frame to enlighten these
> considerations ?
>
>
> oz
>