Difference between revisions of "Wristwatch Example"
(→Download the Wristwatch Example) |
|||
(23 intermediate revisions by 3 users not shown) | |||
Line 11: | Line 11: | ||
! scope="col" width="15%" | LSC | ! scope="col" width="15%" | LSC | ||
|- | |- | ||
− | | when the user clicks the d_button, if the display mode is time, the display mode changes to date, otherwise if the display mode is date, the display mode changes to time. | + | | when the user clicks the d_button, if the display mode is "time", the display mode changes to "date", otherwise if the display mode is "date", the display mode changes to "time". |
| Demonstrates if-else. | | Demonstrates if-else. | ||
| [[Image:WatchModes.png|thumb|left|x50px|LSC]] | | [[Image:WatchModes.png|thumb|left|x50px|LSC]] | ||
|- | |- | ||
− | | when the user clicks the a_button, if the display mode is time, the display mode changes to alarm, otherwise if the display mode is alarm, the display mode changes to chime, otherwise if the display mode is chime, the display mode changes to stopwatch, otherwise if the display mode is stopwatch, the display mode changes to time. | + | | when the user clicks the a_button, if the display mode is "time", the display mode changes to "alarm", otherwise if the display mode is "alarm", the display mode changes to "chime", otherwise if the display mode is "chime", the display mode changes to "stopwatch", otherwise if the display mode is "stopwatch", the display mode changes to "time". |
| | | | ||
| [[Image:Modes.png|thumb|left|x50px|LSC]] | | [[Image:Modes.png|thumb|left|x50px|LSC]] | ||
|- | |- | ||
− | | when the user clicks the c_button , if the display mode is alarm then the display mode changes to "alarm minutes" , otherwise if the display mode is "alarm minutes" then the display mode changes to "alarm hours" , otherwise if the display mode is "alarm hours" then the display mode changes to alarm. | + | | when the user clicks the c_button , if the display mode is "alarm" then the display mode changes to "alarm minutes" , otherwise if the display mode is "alarm minutes" then the display mode changes to "alarm hours" , otherwise if the display mode is "alarm hours" then the display mode changes to "alarm". |
| | | | ||
| [[Image:ModesAlarm.png|thumb|left|x50px|LSC]] | | [[Image:ModesAlarm.png|thumb|left|x50px|LSC]] | ||
|- | |- | ||
− | | when the user clicks the b_button, if the display mode is “alarm minutes”, the display mode changes to alarm. | + | | when the user clicks the b_button, if the display mode is “alarm minutes”, the display mode changes to "alarm". |
| | | | ||
| [[Image:ModeAlarmEnd.png|thumb|left|x50px|LSC]] | | [[Image:ModeAlarmEnd.png|thumb|left|x50px|LSC]] | ||
|- | |- | ||
− | | when the user clicks the b_button, if the display mode is “alarm hours” , the display mode changes to alarm. | + | | when the user clicks the b_button, if the display mode is “alarm hours” , the display mode changes to "alarm". |
| | | | ||
| [[Image:ModeAlarmHoursEnd.png|thumb|left|x50px|LSC]] | | [[Image:ModeAlarmHoursEnd.png|thumb|left|x50px|LSC]] | ||
Line 35: | Line 35: | ||
| [[Image:IncreaseTime.png|thumb|left|x50px|LSC]] | | [[Image:IncreaseTime.png|thumb|left|x50px|LSC]] | ||
|- | |- | ||
− | | when the user clicks the c_button , if the display mode is time , the display mode changes to update and the update type changes to seconds. | + | | when the user clicks the c_button , if the display mode is "time" , the display mode changes to "update" and the update type changes to "seconds". |
| | | | ||
| [[Image:UpdateSeconds.png|thumb|left|x50px|LSC]] | | [[Image:UpdateSeconds.png|thumb|left|x50px|LSC]] | ||
Line 48: | Line 48: | ||
! scope="col" width="15%" | LSC | ! scope="col" width="15%" | LSC | ||
|- | |- | ||
− | | when the user clicks the c_button , if the update type is seconds , the update type changes to minutes otherwise if the update type is minutes , the update type changes to hours otherwise if the update type is hours , the update type changes to date otherwise if the update type is date, the display mode changes to time and the update type changes to none. | + | | when the user clicks the c_button , if the update type is "seconds" , the update type changes to "minutes" otherwise if the update type is "minutes" , the update type changes to "hours" otherwise if the update type is "hours" , the update type changes to "date" otherwise if the update type is "date", the display mode changes to "time" and the update type changes to "none". |
| | | | ||
| [[Image:UpdateType.png|thumb|left|x50px|LSC]] | | [[Image:UpdateType.png|thumb|left|x50px|LSC]] | ||
|- | |- | ||
− | | when the update type changes , if the update type equals seconds , the display blinks seconds , otherwise if the update type equals minutes , the display blinks minutes , otherwise the display blinks none. | + | | when the update type changes , if the update type equals "seconds" , the display blinks seconds , otherwise if the update type equals "minutes" , the display blinks minutes , otherwise the display blinks none. |
| | | | ||
| [[Image:UpdateTypeBlink.png|thumb|left|x50px|LSC]] | | [[Image:UpdateTypeBlink.png|thumb|left|x50px|LSC]] | ||
|- | |- | ||
− | | when the update type changes, the display mode changes to update. | + | | when the update type changes, the display mode changes to "update". |
| | | | ||
− | | [[Image: | + | | [[Image:TypeChangeUpdate.png|thumb|left|x50px|LSC]] |
|} | |} | ||
Line 73: | Line 73: | ||
| [[Image:TimeTicks.png|thumb|left|x50px|LSC]] | | [[Image:TimeTicks.png|thumb|left|x50px|LSC]] | ||
|- | |- | ||
− | | when the time value changes, if the display mode is time, the display text changes to time value. | + | | when the time value changes, if the display mode is "time", the display text changes to time value. |
| Demonstrates a property change as a trigger. | | Demonstrates a property change as a trigger. | ||
| [[Image:ShowTime.png|thumb|left|x50px|LSC]] | | [[Image:ShowTime.png|thumb|left|x50px|LSC]] | ||
Line 105: | Line 105: | ||
| [[Image:AlarmState.png|thumb|left|x50px|LSC]] | | [[Image:AlarmState.png|thumb|left|x50px|LSC]] | ||
|- | |- | ||
− | | when the user clicks the d_button , if the display mode is alarm , if the alarm state is enabled , the alarm state changes to disabled otherwise the alarm state changes to enabled. | + | | when the user clicks the d_button , if the display mode is "alarm" , if the alarm state is enabled , the alarm state changes to disabled otherwise the alarm state changes to enabled. |
| | | | ||
− | | [[Image: | + | | [[Image:EnableAlarm.png|thumb|left|x50px|LSC]] |
|- | |- | ||
− | | when the display mode changes , if the display mode equals "alarm minutes" , the display blinks | + | | when the display mode changes , if the display mode equals "alarm minutes" , the display blinks minutes , otherwise if the display mode equals "alarm hours" , the display blinks hours , otherwise the display blinks none. |
| | | | ||
− | | [[Image: | + | | [[Image:BlinkAlarm.png|thumb|left|x50px|LSC]] |
|- | |- | ||
− | | when the beeper state changes to on, as long as the beeper state is on and two seconds elapse, the beeper beeps, the display mode may not change. | + | | when the beeper state changes to on, as long as the beeper state is on and two seconds elapse, the beeper beeps, the display mode may not change. |
− | + | | Demonstrates loop and forbidden element. | |
| [[Image:AlarmBeep.png|thumb|left|x50px|LSC]] | | [[Image:AlarmBeep.png|thumb|left|x50px|LSC]] | ||
|- | |- | ||
Line 121: | Line 121: | ||
| [[Image:AlarmOff.png|thumb|left|x50px|LSC]] | | [[Image:AlarmOff.png|thumb|left|x50px|LSC]] | ||
|- | |- | ||
− | | when the display mode changes to alarm, the display text changes to the alarm value. | + | | when the display mode changes to "alarm", the display text changes to the alarm value. |
| | | | ||
− | | [[Image: | + | | [[Image:AlarmDisplay.png|thumb|left|x50px|LSC]] |
|} | |} | ||
Line 134: | Line 134: | ||
! scope="col" width="15%" | LSC | ! scope="col" width="15%" | LSC | ||
|- | |- | ||
− | | when the display mode changes to date, the display text changes to the date value. | + | | when the display mode changes to "date", the display text changes to the date value. |
| | | | ||
| [[Image:DisplayDate.png|thumb|left|x50px|LSC]] | | [[Image:DisplayDate.png|thumb|left|x50px|LSC]] | ||
Line 141: | Line 141: | ||
<br> <br> | <br> <br> | ||
− | == | + | == Wristwatch Example == |
− | Below | + | Below is a download of the wristwatch final application, as well as instructions for creating the wristwatch example in PlayGo. |
− | ===Wristwatch final application (runnable jar)=== | + | === Wristwatch final application (runnable jar) === |
− | [ | + | |
+ | [https://weizmann.box.com/s/vm7kdsj3689wnqkpk22i Runnable Wristwatch with Swing GUI] <br><br> | ||
To run the wristwatch, simply extract the downloaded zip and double click the jar file. | To run the wristwatch, simply extract the downloaded zip and double click the jar file. | ||
− | ===Wristwatch LSC project=== | + | === Wristwatch LSC project === |
− | + | ||
− | + | To work with the wristwatch application, you can create it in your PlayGo workspace: | |
− | + | ||
#[[Download PlayGo|Download PlayGo]]. | #[[Download PlayGo|Download PlayGo]]. | ||
− | + | #From the 'File' menu choose New-->Example....-->PlayGo Examples-->Wristwatch | |
− | + | #Click the 'Finish' button. | |
− | + | #The wristwatch example project is now part of your workspace. You can start playing with it. For details refer to [[How%20to%20Play-Out | how to play out]] and [[How_to_Play-In|how to play in]]. | |
− | + | ||
− | + | ||
− | #The | + | |
== References == | == References == | ||
<references /> | <references /> |
Latest revision as of 11:53, 20 December 2015
The wristwatch example is taken from [1], and is a simplified version of the original statecharts watch example of [2]. Generally, the watch displays the time and can switch between different displays that show (and allow changes to) the alarm, date, time and stopwatch. It has an option for turning on the light, and an alarm that beeps when the set time is reached. The following examples demonstrate many constructs in the LSC language and the way they were created in natural lanague play-in. The model was originally described in [3].
Contents
Requirements
Watch Modes
Natural Language Text | Comments | LSC |
---|---|---|
when the user clicks the d_button, if the display mode is "time", the display mode changes to "date", otherwise if the display mode is "date", the display mode changes to "time". | Demonstrates if-else. | |
when the user clicks the a_button, if the display mode is "time", the display mode changes to "alarm", otherwise if the display mode is "alarm", the display mode changes to "chime", otherwise if the display mode is "chime", the display mode changes to "stopwatch", otherwise if the display mode is "stopwatch", the display mode changes to "time". | ||
when the user clicks the c_button , if the display mode is "alarm" then the display mode changes to "alarm minutes" , otherwise if the display mode is "alarm minutes" then the display mode changes to "alarm hours" , otherwise if the display mode is "alarm hours" then the display mode changes to "alarm". | ||
when the user clicks the b_button, if the display mode is “alarm minutes”, the display mode changes to "alarm". | ||
when the user clicks the b_button, if the display mode is “alarm hours” , the display mode changes to "alarm". | ||
when the user clicks the a_button , if the display mode is "alarm minutes" , the alarm increases in one minute , otherwise if the display mode is "alarm hours" , the alarm increases by one hour. | ||
when the user clicks the c_button , if the display mode is "time" , the display mode changes to "update" and the update type changes to "seconds". |
Updates
Natural Language Text | Comments | LSC |
---|---|---|
when the user clicks the c_button , if the update type is "seconds" , the update type changes to "minutes" otherwise if the update type is "minutes" , the update type changes to "hours" otherwise if the update type is "hours" , the update type changes to "date" otherwise if the update type is "date", the display mode changes to "time" and the update type changes to "none". | ||
when the update type changes , if the update type equals "seconds" , the display blinks seconds , otherwise if the update type equals "minutes" , the display blinks minutes , otherwise the display blinks none. | ||
when the update type changes, the display mode changes to "update". |
Time
Natural Language Text | Comments | LSC |
---|---|---|
when the clock ticks, the time increases by one second. | ||
when the time value changes, if the display mode is "time", the display text changes to time value. | Demonstrates a property change as a trigger. |
Light
Natural Language Text | Comments | LSC |
---|---|---|
when the user clicks the b_button, if the light state is on , the light state turns to off , otherwise if the light state is off , the light state turns to on. |
Alarm
Natural Language Text | Comments | LSC |
---|---|---|
when the time value changes , if the time value equals the alarm value and the alarm state is enabled then the beeper state turns to on. | ||
when the user clicks the d_button , if the display mode is "alarm" , if the alarm state is enabled , the alarm state changes to disabled otherwise the alarm state changes to enabled. | ||
when the display mode changes , if the display mode equals "alarm minutes" , the display blinks minutes , otherwise if the display mode equals "alarm hours" , the display blinks hours , otherwise the display blinks none. | ||
when the beeper state changes to on, as long as the beeper state is on and two seconds elapse, the beeper beeps, the display mode may not change. | Demonstrates loop and forbidden element. | |
when the user clicks any WButton , the beeper state turns to off. | Demonstrates symbolic \ non-deterministic objects. | |
when the display mode changes to "alarm", the display text changes to the alarm value. |
Date
Natural Language Text | Comments | LSC |
---|---|---|
when the display mode changes to "date", the display text changes to the date value. |
Wristwatch Example
Below is a download of the wristwatch final application, as well as instructions for creating the wristwatch example in PlayGo.
Wristwatch final application (runnable jar)
Runnable Wristwatch with Swing GUI
To run the wristwatch, simply extract the downloaded zip and double click the jar file.
Wristwatch LSC project
To work with the wristwatch application, you can create it in your PlayGo workspace:
- Download PlayGo.
- From the 'File' menu choose New-->Example....-->PlayGo Examples-->Wristwatch
- Click the 'Finish' button.
- The wristwatch example project is now part of your workspace. You can start playing with it. For details refer to how to play out and how to play in.
References
- ↑ D. Harel. "On Visual Formalisms", Commun. ACM, 31(5):514–530, 1988.
- ↑ D. Harel, "Statecharts: A Visual Formalism for Complex Systems", Sci. Comput. Programming 8, 231-274, 1987.
- ↑ M. Gordon and D. Harel. Generating executable scenarios fromfckLRnatural language. In Proc. 10th Int. Conf. on Computational Linguistics and Intelligent Text Processing, CICLing’09, pages 456–467. Springer-Verlag, 2009.