Skip to content

Instantly share code, notes, and snippets.

@frame-lang
Last active June 4, 2022 14:20
Show Gist options
  • Save frame-lang/7291702243f30322cf893707c6e9b5d9 to your computer and use it in GitHub Desktop.
Save frame-lang/7291702243f30322cf893707c6e9b5d9 to your computer and use it in GitHub Desktop.
```
package trafficlight
import (
"github.com/frame-lang/cloudtraffic/cloudtraffic_v2/framelang"
)
```
#TrafficLightManager >[createWorkflow:bool]
-interface-
initTrafficLight
tick
end
enterRed
enterGreen
enterYellow
enterFlashingRed
startWorkingTimer
stopWorkingTimer
startFlashingTimer
stopFlashingTimer
startFlashing
changeFlashingAnimation
systemError
systemRestart
destroyTrafficLight
connectionClosed
-machine-
$Start
|>|[createWorkflow:bool]
createWorkflow ?
-> "Create\nWorkflow" $Create
:
-> "Load\nWorkflow" $Load
:: ^
$Create => $HandleExternalEvents
|>|
trafficLight = NewTrafficLight(#)
trafficLight.Start()
-> "Created" $Save ^
$Load => $HandleExternalEvents
|>|
var savedData = getFromRedis()
trafficLight = LoadTrafficLight(# savedData)
->> "Loaded" $Working ^
$Working => $HandleExternalEvents
$Save
|>|
var jsonData = trafficLight.Marshal()
setInRedis(jsonData)
trafficLight = nil
-> "Stop" $Stop ^
$Stop
$HandleExternalEvents => $HandleControllerEvents
|tick|
trafficLight.Tick() -> "Tick" $Save ^
|systemError|
trafficLight.SystemError() -> "System\nError" $Save ^
|systemRestart|
trafficLight.SystemRestart() -> "System\nRestart" $Save ^
|end|
trafficLight.Stop() -> "End" $Save ^
|connectionClosed|
removeFromRedis() -> "Connection Closed" $Stop ^
$HandleControllerEvents
|initTrafficLight| initTrafficLight() ^
|enterRed| enterRed() ^
|enterGreen| enterGreen() ^
|enterYellow| enterYellow() ^
|enterFlashingRed| enterFlashingRed() ^
|startWorkingTimer| startWorkingTimer() ^
|stopWorkingTimer| stopWorkingTimer() ^
|startFlashingTimer| startFlashingTimer() ^
|stopFlashingTimer| stopFlashingTimer() ^
|changeFlashingAnimation| changeFlashingAnimation() ^
|destroyTrafficLight| destroyTrafficLight() ^
-actions-
enterRed
enterGreen
enterYellow
enterFlashingRed
startWorkingTimer
stopWorkingTimer
startFlashingTimer
stopFlashingTimer
initTrafficLight
changeFlashingAnimation
destroyTrafficLight
removeFromRedis
setInRedis [data:`[]byte`]
getFromRedis: `[]byte`
-domain-
var trafficLight:TrafficLight = null
##
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment