I have never created/understood completely how to create a state machine diagram based on detailed description so I wanted to start somewhere. The automated booth is for student to return books automatically.
Description:
To return a book, it must be placed on a small conveyor belt and then the user needs to press the check-in button on the touch screen.
The chip reader in the machine then detects which book is being returned. If no book is detected, the conveyor belt returns the item to the user. If a book is detected, the screen displays all the loan information on the screen and the user can confirm the return or cancel it.
If cancelled, the book is returned to the user. If confirmed, the book is taken into the library and the booth prints a physical receipt for the user. Additionally, the machine has a maintenance mode; no books can be returned until the maintenance is completed.
I am not sure if I am describing all the states that the machine has or if I am fundamentally missing the guide lines of state machine diagram rules. I would appreciate any feedback as I am still learning.
In most cases, a state is a situation in which nothing happens and the machine is waiting for an external event to happen. The event may then be a reason to go to another state. Along the transition arrow, you write event [ condition ] / action
. In your case, event
is something the user does and action
is something the machine does in response to the event.
States in which the machine is waiting are in your case: "Idle", "Loan information displayed" and "Maintenance". Although "Out of service" and "Self test" seem logical states, the description does not mention them, so I would not include them.
In some cases, you may wish to use a state to reflect the situation that the machine is busy doing something. The event
may then be the completion of the work or an external interruption. In your case, Scan for book
may be such a state, but you could also regard scanning as an action, for example user presses button / scan for book
.
Both options are valid, but let's choose for Scan for book
as a state (although I think "Busy scanning" would be a more state-like name).
From the description, I assume the machine goes from Idle
to Scan for book
when the user presses the button. So instead of Request book [check-in button pressed]
, I would write user presses check-in button
.
State Scan for book
is left when the machine has finished scanning. Along the arrow towards the decision diamond, you could write finished scanning
. If it is a valid book, the machine will show the loan information and enter the state Loan information displayed
. This transition is [valid book] / display loan information
. Alternatively, you could write display loan information
as an entry action inside the Loan information displayed
state.
If the item is not valid, the machine returns the item. The transition is [else] / return item
and this transition goes from the diamond to the Idle
state.
In the same way, you can model transitions between Idle
and Maintenance
and between Idle
and Loan information displayed
.