I am playing around with http://boost-experimental.github.io/msm-lite/tutorial/index.html (tag is for boost-msm because there is not tag for msm-lite but similar question applies) and I have a question wrt designing state machines with many possible inputs.
Imagine you are modelling elevator. Beside obvious states like moving, stopped, door_open, door_closed I wonder how to model button pressed(that is a number from -2 to 39) since it is not feasible to have that many events(42 just for every button pressed).
答案 0 :(得分:0)
You can use guard conditions on transitions. They look like [currentFloor != requested floor]
. Perhaps a better way is to model events like upper floor selected
, lower floor selected
, current floor selected
. That collapses 42 buttons into three categories rather neatly.
答案 1 :(得分:0)
I guess if you design a floor selection with 42 buttons you would probably not map them each to a single input, but make a matrix (nobody will put 42 buttons on top of each other, would one?). Then of course you would not model each row an column but only two so you can show the sequential polling of each row column. Maybe you could also use "intelligent" buttons today that have a microchip which sends some "I have been pressed" information a serial line. Or you introduce a voice recognition设置不同的超链接。
列举了这几个例子之后,我倾向于将这个问题视为过于宽泛。