Modeling FSM with conditions?

北城余情 提交于 2019-12-24 11:08:00

问题


I am supposed to model a FSM but I am unsure how to model conditions. Let's take the simple ATM example:

  • If user presses "Confirm" AND PIN is correct, go to State 2.

  • If user presses "Confirm" AND PIN is not correct, go to State 3.

Or could I simply use input called "wrong pin" and "correct pin"? I would need it to be formal so that I can employ FSM testing procedures, like cover set generation etc. But I do not know if FSM can be modeled this way (maybe with adding states representing additional conditions?)


回答1:


I'd suggest to use the choice element and not to put information about the 'possible' inputs into the model. By doing this you can parameterize your state machine externaly. You can simulate it with correct PIN and incorrect PIN. The statechart shall be independent.




回答2:


Is there a requirement about the modeling technique or language to be used?

If not, I agree with Svenja Wendler's answer and would recommend using UML state machine diagrams for this purpose, allowing you to use choices and also to model guard conditions and actions on your state transitions.



来源:https://stackoverflow.com/questions/46292969/modeling-fsm-with-conditions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!