modelWristWatch

Diagram of WristWatch

Extends from Modelica.Icons.Example (Icon for runnable examples).

Information

This example is a StateGraph2 implementation of David Harel's Wristwatch presented in "Statecharts: A Visual Formalism for Complex Systems", see literature.

As an application example, D. Harel used a Citizen Quartz Multi-Alarm III wristwatch as a case study to prove that his new formalism was flexible and powerful enough to describe a behavior that contains numerous modes with only four input signals coming from the buttons of the watch.

The watch display comprises six different displays showing time, 12/24h time setting, AM/PM setting, alarm on/off, chime on/offand stop watch indication. It is operated by four buttons: A, B, C and D. The watch can display time and date (day of month, weekday, date, month, year). It has a chime function, display back-light for improved illumination, low-battery warning, a stop watch with lap/reg mode options and two alarms.

Button A works as a switch between display modes of the watch. The different display modes are: Time (default), alarm1, alarm2, and stopwatch. In each of these, button C will enter update mode where the current time or the alarm time can be set. Inside the update modes, C will flip through different time entities and finally return from update mode. Button B is used to exit update regardless of which internal state being active. In stopwatch mode, button B is used as on/off switch. Additionally, the illumination is turned on every time B is pressed down, and shut off on release. Button D serves as an on/off switch of the current active display mode. If in time mode, pressing button D will result in display of the current date. In stopwatch mode, button D works as a selector between reg/lap display mode.

To run model interactively, enable Realtime in the Experiment setup and set load result interval to 0.01.

Components

TypeNameDefaultDescription
Parallelmain
Modelica_StateGraph2.Stepdead
Modelica_StateGraph2.Transitionbattery_removed
Parallelalarms_beep
Modelica_StateGraph2.Blocks.Interactive.TrigButtoninsert_battery
Modelica_StateGraph2.Blocks.Interactive.TrigButtonremove_battery
Modelica_StateGraph2.Blocks.Interactive.TrigButtonkill_battery
Modelica_StateGraph2.Stepalarm1_beeps
Modelica_StateGraph2.Stepalarm1_status_disabled
Modelica_StateGraph2.Stepalarm1_status_enabled
Modelica_StateGraph2.Transitionalarm1_disabled_d
Modelica_StateGraph2.Transitionalarm1_enabled_d
Modelica_StateGraph2.Stepalarm2_beeps
Modelica_StateGraph2.Stepboth_beep
Modelica_StateGraph2.Transitiont_hits_t2_p2
Modelica_StateGraph2.Transitiont_hits_t1_p
Modelica_StateGraph2.Stepchoose_alarm
Modelica_StateGraph2.Transitionp_or_p1_or_p2
Modelica_StateGraph2.Transitionany_button_pressed
Modelica_StateGraph2.Transitionthirty_secs_in_alarms_beep
Modelica_StateGraph2.Blocks.Interactive.TrigButtonweaken_battery
Modelica_StateGraph2.Stepalarm2_status_disabled
Modelica_StateGraph2.Stepalarm2_status_enabled
Modelica_StateGraph2.Transitionalarm2_disabled_d
Modelica_StateGraph2.Transitionalarm2_enabled_d
Modelica_StateGraph2.Steplight_off
Modelica_StateGraph2.Steplight_on
Modelica_StateGraph2.Transitionlight_off_b_down
Modelica_StateGraph2.Transitionlight_on_b_up
Modelica_StateGraph2.Stepchime_enabled_quiet
Modelica_StateGraph2.Stepchime_enabled_beep
Modelica_StateGraph2.Transitionchime_enabled_quiet_t_is_whole_hour
Modelica_StateGraph2.Transitiontwo_secs_in_chime_enabled_beeps
Parallelchime_enabled
Modelica_StateGraph2.Stepchime_disabled
Modelica_StateGraph2.Transitionchime_disabled_d
Modelica_StateGraph2.Transitionchime_enabled_d
Modelica_StateGraph2.Steppower_ok
Modelica_StateGraph2.Steppower_blink
Modelica_StateGraph2.Transitionpower_ok_battery_weakens
Modelica_StateGraph2.Transitionbattery_dies
Paralleldisplays
Regularregular
Outout
Stopwatchstopwatch
Modelica_StateGraph2.Transitionregular_a
Modelica_StateGraph2.Transitiontwo_min_in_out
Modelica_StateGraph2.Transitionout_a
Modelica_StateGraph2.Transitionstopwatch_a
Modelica_StateGraph2.Blocks.Interactive.PressButtonC
Modelica_StateGraph2.Blocks.Interactive.PressButtonD
Modelica_StateGraph2.Blocks.Interactive.PressButtonB
Modelica_StateGraph2.Blocks.Interactive.PressButtonA
Modelica_StateGraph2.Transitionbattery_inserted
Modelica_StateGraph2.Transitiont_hits_t1
Modelica.Blocks.Logical.Andand1
Modelica.Blocks.Logical.Andand2
Modelica_StateGraph2.Transitionregular_time_c
Modelica_StateGraph2.Stepwait
Modelica_StateGraph2.Transitiontwo_sec_in_wait
Modelica_StateGraph2.Transitionwait_c_up_1
Modelica.Blocks.Logical.Notnot1
Modelica.Blocks.Logical.Andand3
Modelica.Blocks.Logical.Edgeedge1
Modelica.Blocks.Logical.Prepre1
Modelica.Blocks.Logical.Edgeedge2
Modelica.Blocks.Logical.Edgeedge3
Modelica.Blocks.Logical.Notnot2
Modelica.Blocks.Logical.Edgeedge4
Modelica.Blocks.Logical.Andand4
Modelica.Blocks.Logical.Andand5
Modelica.Blocks.Logical.Andand6
Modelica.Blocks.Logical.Andand7
Modelica.Blocks.Logical.Edgeedge5
Utilities.WatchDisplaywatchDisplay
Modelica_StateGraph2.Blocks.MathInteger.MultiSwitchset_illumination
Modelica.Blocks.Logical.Edgeedge6
Utilities.AlarmTriggeralarmTrigger
Modelica.Blocks.Logical.Edgeedge7
Utilities.WatchControllerwatchController
Modelica_StateGraph2.Blocks.MathBoolean.ShowValueshowValue
Modelica_StateGraph2.Blocks.MathBoolean.ShowValueshowValue1
Modelica_StateGraph2.Blocks.MathBoolean.ShowValueshowValue2
Modelica_StateGraph2.Blocks.MathBoolean.ShowValueshowValue3
Modelica_StateGraph2.Blocks.MathBoolean.ShowValueshowValue4
Modelica_StateGraph2.Blocks.MathBoolean.Oror1
Modelica_StateGraph2.Blocks.MathBoolean.Oror2