问题
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