Solution for Radio Alarm Clock
It’s time to put down your pens!
We hope this exercise has allowed you to expand on the use of our toolchain in a simple real-life case of a two-service communication system.
Below you will find our solution (here is the link to our model).
Do not hesitate to compare the Sequences, look at the body of the activities, play our scenarios, read the comments below, in order to fully appropriate this exercise.
We emphasize that there is no one solution.
CLOCK RADIO SOLUTION HINTS
-
The radio receives continuously a list of radio stations based on the given type (in our model, we used 3 radio stations for our debug).
-
Don’t forget to add feedback flows to the user, in order to display alarm state and radio state.
-
The alarm is triggered by comparing hours and minutes of the clock time with these of the programmed alarm.
-
The difficulty of the exercise is to model correctly the alarm trigger: the alarm needs to be triggered one time at the alarm time. Otherwise, the radio sound is reactivated during an all minute, because the alarm trigger condition is still valid.
If the trigger condition is only the equality condition between hours and minutes of the clock time with these of the alarm time, the alarm will activate continuously the radio during one minute, the elapsed time during which the trigger condition is valid.
This unexpected behavior is illustrated below:

Unexpected recorded alarm behavior: reactivation of the radio sound during one minute because of the easiest alarm trigger condition (equality between hours and minutes)
Two implementations are suggested to model correctly the alarm trigger:
-
The first one is based on the comparison between alarm time and clock time on the smallest available time scale of the simulation executed by 40 ms step. At this time granularity, the time equality condition is valid only one time per day. Concretly, comparing hours, minutes, seconds and milliseconds of the alarm time and these of the clock time triggers one event per day at the alarm time.
-
The second one uses a flag variable to add in the guard condition : ready_to_ring (solution used in our model solution, cf "Activate the radio sound" Use Case, in Alarm Service).
- When the alarm is programmed, the alarm state is ready to ring,
- When the alarm is triggered, the alarm state is no more ready to ring,
- When the clock time is one minute later than the alarm time, the alarm state is again ready to ring
- Be carefull of the midnight case (23:59 -> 00:00).
EXPECTED SCENARIOS BEHAVIOUR TO CHECK
Based on the scenarios we presented to you in the statement, here are the behaviours we expect.
Radio scenario 1
-
The user turns on the radio sound.
See Radio state changes to ON. -
The user tunes the frequency:
- If the frequency is in the list of radio stations, then the clock radio displays the radio station name.
- If the frequency is out, then the clock radio displays “unknown radio station”.
-
The user turns off the radio sound.
See Radio state changes to OFF.
Alarm scenario 1
-
The user programs the alarm.
See Alarm state changes and alarm time appears. -
Wait when clock time has reached the alarm time.
See Radio state changes to ON. -
The user turns off the radio sound.
See Radio state changes to OFF and stays OFF. -
The user deprograms the alarm.
See Alarm state changes and alarm time disappears.
Alarm scenario 2
-
The user programs the alarm.
See Alarm state changes and alarm time appears. -
Wait when clock time has reached the alarm time.
See Radio state changes to ON. -
The user turns off the radio sound.
See Radio state changes to OFF. -
The user advance or adapt clock time to simulate alarm time 24 hours later.
See Radio state changes to ON when clock time has reached the alarm time. -
The user deprograms the alarm.
See Alarm state changes and alarm time disappears. -
The user turns off the radio sound.
See Radio state changes to OFF. -
The user adjusts clock time to the last alarm time programed.
Radio state stays to OFF when clock time has reached the alarm time.
Alarm scenario 3
-
The user turns on the radio sound.
See Radio state changes to ON. -
The user programs the alarm.
See Alarm state changes and alarm time appears. -
Wait when clock time has reached the alarm time.
Radio state stays to ON.