Skip to content

Instantly share code, notes, and snippets.

@frame-lang
Last active June 8, 2022 04:55
Show Gist options
  • Save frame-lang/69451614d875d60cd5bd68f07bfa9d96 to your computer and use it in GitHub Desktop.
Save frame-lang/69451614d875d60cd5bd68f07bfa9d96 to your computer and use it in GitHub Desktop.
```
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