优化逻辑
This commit is contained in:
@@ -13,7 +13,8 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
func WaitAction(ctrl *common.CtrlWait) leaf.HandlerFunc {
|
||||
// WaitAction 待机任务,支持音乐、TTS、继电器、视频、网页、投影仪、大型激光秀 ctrl
|
||||
func WaitAction(ctrl *common.CtrlWait, device *common.Device) leaf.HandlerFunc {
|
||||
ps := common.NewPauseSub(ctrl)
|
||||
|
||||
return func(c *leaf.Context) {
|
||||
@@ -49,7 +50,15 @@ func WaitAction(ctrl *common.CtrlWait) leaf.HandlerFunc {
|
||||
if f == nil {
|
||||
return
|
||||
}
|
||||
f = standby_ctrl.Time(rules, item.Cron, f)
|
||||
f = standby_ctrl.Duration(item.Duration, f)
|
||||
if f == nil {
|
||||
return
|
||||
}
|
||||
f = standby_ctrl.Device(device, item.Lock, f)
|
||||
if f == nil {
|
||||
return
|
||||
}
|
||||
f = standby_ctrl.Interval(item.Interval, f)
|
||||
if f == nil {
|
||||
return
|
||||
}
|
||||
@@ -57,6 +66,10 @@ func WaitAction(ctrl *common.CtrlWait) leaf.HandlerFunc {
|
||||
if f == nil {
|
||||
return
|
||||
}
|
||||
f = standby_ctrl.Cron(rules, item.Cron, f)
|
||||
if f == nil {
|
||||
return
|
||||
}
|
||||
e := f(c)
|
||||
if e != nil {
|
||||
zap.S().Errorf("%s异常: %s\n", title, e)
|
||||
@@ -75,9 +88,11 @@ func WaitAction(ctrl *common.CtrlWait) leaf.HandlerFunc {
|
||||
case schema.WaitVideo:
|
||||
handleItem("视频待机控制", item, standby.Video(item))
|
||||
case schema.WaitWeb:
|
||||
handleItem("视频待机控制", item, standby.Web(item))
|
||||
handleItem("网页待机控制", item, standby.Web(item))
|
||||
case schema.WaitPJLink:
|
||||
handleItem("视频待机控制", item, standby.PJLink(item))
|
||||
handleItem("投影仪待机控制", item, standby.PJLink(item))
|
||||
case schema.WaitLaserShow:
|
||||
handleItem("大型激光秀控制", item, standby.LaserShow(item))
|
||||
default:
|
||||
zap.S().Infof("不支持的类型: %d\n", item.Type)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user