fsm_simple


Overview

The fsm_simple application is a finite state machine (FSM) that interacts with the user through a multiple-choice question. The user must select the correct country to complete the process.

Execution

Run the application with:

python3 fsm_simple/ --auto-run

FSM States

  • RECEIVING_TASK : Plays a sound and moves to ASK_CURRENT_PLACE.

  • ASK_CURRENT_PLACE : Displays a list of countries and waits for user input:

    • If the user selects “Colombia”, transitions to END.

    • Otherwise, moves to WRONG_ANSWER.

  • WRONG_ANSWER : Notifies the user and returns to ASK_CURRENT_PLACE.

  • END : The finite states machine finishes.

State Transitions

  • Start → RECEIVING_TASK

  • RECEIVING_TASK → ASK_CURRENT_PLACE

  • ASK_CURRENT_PLACE → END (if answer is correct)

  • ASK_CURRENT_PLACE → WRONG_ANSWER (if incorrect) → ASK_CURRENT_PLACE (retry)

Example Output

# python3 fsm_simple/ --auto-run
[INFO] [timestamp] [pyraya.fsm_simple]: Auto running the app
[INFO] [timestamp] [pyraya.fsm.DemoFSM]: Initializing FSM
[INFO] [timestamp] [pyraya.fsm.DemoFSM]: Transition:  -> RECEIVING_TASK
[INFO] [timestamp] [pyraya.fsm.DemoFSM]: Transition: RECEIVING_TASK -> ASK_CURRENT_PLACE
[INFO] [timestamp] [pyraya.fsm.DemoFSM]: Transition: ASK_CURRENT_PLACE -> END

If the user selects the wrong answer:

[INFO] [timestamp] [pyraya.fsm.DemoFSM]: Transition: ASK_CURRENT_PLACE -> WRONG_ANSWER
[INFO] [timestamp] [pyraya.fsm.DemoFSM]: Transition: WRONG_ANSWER -> ASK_CURRENT_PLACE