Last active
June 8, 2022 04:55
-
-
Save frame-lang/69451614d875d60cd5bd68f07bfa9d96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
package trafficlight | |
import ( | |
"encoding/json" | |
"github.com/frame-lang/cloudtraffic/cloudtraffic_v2/framelang" | |
) | |
``` | |
#[derive(Marshal)] | |
#[managed(TrafficLightManager)] | |
#TrafficLight | |
-interface- | |
stop | |
tick | |
systemError | |
systemRestart | |
changeColor[color:string] | |
getColor:string | |
-machine- | |
$Begin | |
|>| | |
initTrafficLight() | |
startWorkingTimer() | |
-> $Red ^ | |
$Red => $Working | |
|>| | |
enterRed() ^ | |
|tick| | |
-> $Green ^ | |
$Green => $Working | |
|>| | |
enterGreen() ^ | |
|tick| | |
-> $Yellow ^ | |
$Yellow => $Working | |
|>| | |
enterYellow() ^ | |
|tick| | |
-> $Red ^ | |
$FlashingRed | |
|>| | |
enterFlashingRed() | |
stopWorkingTimer() | |
startFlashingTimer() ^ | |
|<| | |
stopFlashingTimer() | |
startWorkingTimer() ^ | |
|tick| | |
changeFlashingAnimation() ^ | |
|changeColor|[color:string] | |
flashColor = color ^ | |
|systemRestart| | |
-> $Red ^ | |
|stop| | |
-> $End ^ | |
|getColor|:string | |
^(flashColor) | |
$End | |
|>| | |
flashColor = "" | |
stopWorkingTimer() | |
destroyTrafficLight() ^ | |
$Working | |
|stop| | |
-> $End ^ | |
|systemError| | |
-> $FlashingRed ^ | |
|changeColor|[color:string] | |
flashColor = color ^ | |
|getColor|:string | |
^(flashColor) | |
-actions- | |
initTrafficLight | |
enterRed | |
enterGreen | |
enterYellow | |
enterFlashingRed | |
startWorkingTimer | |
stopWorkingTimer | |
startFlashingTimer | |
stopFlashingTimer | |
changeFlashingAnimation | |
destroyTrafficLight | |
-domain- | |
var flashColor:string = "" | |
## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment