How do state machines deal with events that contain value(like floor number)?

时间:2016-04-04 18:12:47

标签: uml boost-msm

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).

2 个答案:

答案 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)