Skip to content

Instantly share code, notes, and snippets.

@frame-lang
Last active May 31, 2022 04:15
Show Gist options
  • Save frame-lang/222b0edd81b4ff2fba0adb09f6e19c7b to your computer and use it in GitHub Desktop.
Save frame-lang/222b0edd81b4ff2fba0adb09f6e19c7b to your computer and use it in GitHub Desktop.
package trafficlight
import (
"time"
"log"
"github.com/gomodule/redigo/redis"
)
func (m *trafficLightMomStruct) initTrafficLight() {
publishResponse("begin", "", "true")
time.Sleep(2 * time.Second)
}
func (m *trafficLightMomStruct) destroyTrafficLight() {
publishResponse("end", "", "false")
}
func (m *trafficLightMomStruct) enterRed() {
color := m.trafficLight.GetColor()
publishResponse("working", color, "false")
}
func (m *trafficLightMomStruct) enterGreen() {
color := m.trafficLight.GetColor()
publishResponse("working", color, "false")
}
func (m *trafficLightMomStruct) enterYellow() {
color := m.trafficLight.GetColor()
publishResponse("working", color, "false")
}
func (m *trafficLightMomStruct) enterFlashingRed() {
color := m.trafficLight.GetColor()
publishResponse("error", color, "false")
}
func (m *trafficLightMomStruct) startWorkingTimer() {
publishTimerEvent("enableTimer", "workingTimer")
}
func (m *trafficLightMomStruct) stopWorkingTimer() {
publishTimerEvent("disableTimer", "workingTimer")
}
func (m *trafficLightMomStruct) startFlashingTimer() {
publishTimerEvent("enableTimer", "flashingTimer")
}
func (m *trafficLightMomStruct) stopFlashingTimer() {
publishTimerEvent("disableTimer", "flashingTimer")
}
func (m *trafficLightMomStruct) changeFlashingAnimation() {
color := m.trafficLight.GetColor()
publishResponse("error", color, "false")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment