Skip to content

Instantly share code, notes, and snippets.

@frame-lang
Last active May 25, 2020 14:57
Show Gist options
  • Save frame-lang/ebec407ea6956e1d9dd7d0c3aa6a0df1 to your computer and use it in GitHub Desktop.
Save frame-lang/ebec407ea6956e1d9dd7d0c3aa6a0df1 to your computer and use it in GitHub Desktop.
//-------------------------------------------------//
// //
// FMN //
// //
//-------------------------------------------------//
#Switch3
-machine-
$Off
|turnOn| ->> $On ^
|toggle| ->> $On ^
|status| ^("OFF")
$On
|turnOff| ->> $Off ^
|toggle| ->> $Off ^
|status| ^("ON")
##
//-------------------------------------------------//
// //
// Implementation //
// //
//-------------------------------------------------//
class Switch3 { // #Switch3
// -machine-
var _state(e:FrameEvent) = Off
/**********************************
$Off
|turnOn| ->> $On ^
|toggle| ->> $On ^
|status| ^("OFF")
***********************************/
func Off(e:FrameEvent) {
if (e._msg == "turnOn") { // |turnOn|
_state = On // ->> $On
return // ^
}
if (e._msg == "toggle") { // |toggle|
_state = On // ->> $On
return // ^
}
if (e._msg == "status") { // |status|
e._return = "OFF"
return // ^("OFF")
}
}
/**********************************
$On
|turnOff| ->> $Off ^
|toggle| ->> $Off ^
|status| ^("ON")
***********************************/
func On(e:FrameEvent) {
if (e._msg == "turnOff") { // |turnOff|
_state = Off // ->> $Off
return // ^
}
if (e._msg == "toggle") { // |toggle|
_state = Off // ->> $Off
return // ^
}
if (e._msg == "status") { // |status|
e._return = "ON"
return // ^("ON")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment