12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package timer
- import (
- "github.com/robfig/cron"
- "smart_tunnel_edge/service"
- "smart_tunnel_edge/util/config"
- "time"
- )
- var commandQueue = make(chan []byte, 5)
- func TimeTasks() {
- c := cron.New()
- _ = c.AddFunc("0 */5 * * * ?", func() {
- if config.Instance().Policy.Id == 3 {
- endTime := config.Instance().Policy.EndTime
- startTime := config.Instance().Policy.StartTime
- currentTime := time.Now().Format("15:04")
- if currentTime == startTime {
-
- service.OperationLampSwitchJudge([]int8{1, 2}, service.MediumLightLevel, service.MediumPower)
- } else if currentTime == endTime {
-
- service.OperationLampSwitchJudge([]int8{1, 2}, service.LowLightLevel, service.LowPower)
- }
- }
- })
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- c.Start()
- }
|