Last active
May 31, 2022 04:15
-
-
Save frame-lang/222b0edd81b4ff2fba0adb09f6e19c7b 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 ( | |
"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