T
tat
Hi all,
Sorry if this question is off-topic. I would like have your
suggestion .
I need to write one application which control a machine via serial
port. There are 5 states in the following sequence: active, set,
check, command, and clear. In each state, there are two sub-states: do
and wait. For example, in active state: do() sub-state performs the
activation and the sub-state wait() waits for signal from serial port.
If it is either timeout or the message has bad CRC, it goes back to
substate do(). Otherwise, it will go to set state, etc.
I think that it is more straightforward to have 10 different states.
Because in this case I can just use state pattern with one abstract
state, one context and 10 concrete states.
I also think that it is nicer to use 5 states and each has substate.
However, I am kind of confused if you want to do it this way because
active state now plays both a role of context and a role of concrete
state. In this case , there seems to be two different abstract states
(one for sub-states do() and wait(), the other for five states).
I am not really sure what to do in this case. I would be appreciate
any suggestion. If you happen to know a similar example, I would
really appreciate if you let me know.
Thanks,
tat
Sorry if this question is off-topic. I would like have your
suggestion .
I need to write one application which control a machine via serial
port. There are 5 states in the following sequence: active, set,
check, command, and clear. In each state, there are two sub-states: do
and wait. For example, in active state: do() sub-state performs the
activation and the sub-state wait() waits for signal from serial port.
If it is either timeout or the message has bad CRC, it goes back to
substate do(). Otherwise, it will go to set state, etc.
I think that it is more straightforward to have 10 different states.
Because in this case I can just use state pattern with one abstract
state, one context and 10 concrete states.
I also think that it is nicer to use 5 states and each has substate.
However, I am kind of confused if you want to do it this way because
active state now plays both a role of context and a role of concrete
state. In this case , there seems to be two different abstract states
(one for sub-states do() and wait(), the other for five states).
I am not really sure what to do in this case. I would be appreciate
any suggestion. If you happen to know a similar example, I would
really appreciate if you let me know.
Thanks,
tat