johnchau123
Member level 1
I have some confusions about state machine.
Let take an example.
Suppose I have a very calculator in which I can enter a menu to select functions. I can select calculation modes from modes A to E from menu. If I have to select mode A, I have to press the bottom MENU for once, and for mode E, I have to press MENU for five times. After selecting the mode, I have to press the button CALCULATION to start calculator. The calculation algorithm for different modes are different. So, I propose the state machine is as follows.
S0-------->S1-------->S2-------->S3-------->S4-------->S5
.................|................|..............|..............|...............|
.................|................|..............|..............|...............|
.................-->S6.........-->S7.......-->S8.......-->S9.......-->S10
The dots can be ignored. Sorry for my poor representation.
S0-->S1: triggered by pressing MENU for once
S1-->S2: triggered by pressing MENU for once
....
S4-->S5: triggered by pressing MENU for once
S1-->S6: triggered by pressing CALCULATION for once, and start calculation
S2-->S7: triggered by pressing CALCULATION for once, and start calculation
....
S5-->S10: triggered by pressing CALCULATION for once, and start calculation
That starting point and the end of the program is ignored in this case.
So, I would like to ask is my state machine correct?
If not, what's wrong and could you give me some suggestions??
Thanks all!!
John
Let take an example.
Suppose I have a very calculator in which I can enter a menu to select functions. I can select calculation modes from modes A to E from menu. If I have to select mode A, I have to press the bottom MENU for once, and for mode E, I have to press MENU for five times. After selecting the mode, I have to press the button CALCULATION to start calculator. The calculation algorithm for different modes are different. So, I propose the state machine is as follows.
S0-------->S1-------->S2-------->S3-------->S4-------->S5
.................|................|..............|..............|...............|
.................|................|..............|..............|...............|
.................-->S6.........-->S7.......-->S8.......-->S9.......-->S10
The dots can be ignored. Sorry for my poor representation.
S0-->S1: triggered by pressing MENU for once
S1-->S2: triggered by pressing MENU for once
....
S4-->S5: triggered by pressing MENU for once
S1-->S6: triggered by pressing CALCULATION for once, and start calculation
S2-->S7: triggered by pressing CALCULATION for once, and start calculation
....
S5-->S10: triggered by pressing CALCULATION for once, and start calculation
That starting point and the end of the program is ignored in this case.
So, I would like to ask is my state machine correct?
If not, what's wrong and could you give me some suggestions??
Thanks all!!
John