3.4 State Machines
Model the internal behaviour of an alarm system installed in a private home using an UML state machine. Be sure to record the conditions, events, outputs and assignments as complete as possible.
The alarm system has a central control unit and sensors for every door and window of the house. Each time the door or a window is opened or closed, the control unit gets an respective signal.
In its initial state, all windows are closed and the alarm system is not active. Windows can now be opened and closed at random, but, only when all windows are closed, the alarm system may be activated. Since the control unit is installed inside the house, the front door can be opened or closed during the alarm is activated. In order to activate the alarm, you need to insert a code.
As soon as the alarm system is activated, there is a short acoustic signal. In case the door was open while activating the alarm system, it is still possible to close it. If the door is reopened, the short acoustic signal sounds as well. Then, 15 seconds and up to 3 attempts are given to deactivate the alarm system with the code that was inserted for activation. If deactivation was successful, a short signal is played as acknowledgement and the alarm systems returns to its inactive state. Otherwise, an alarm is triggered. If a window is opened while the alarm system is active, the alarm is also instantly triggered, even if deactivation is already in process. In the case of an alarm, the alarm signal is emitted continuously.
- Model the insertion of the code using a special trigger "CODE(c)". The parameter c can, during this transition, be assigned to a variable, so that the value can be accessed later.
- You do not need to model how a raised alarm can be deactivated.
- You do not need to differentiate signals for each window, a message if any windows opens or closes is enough.