增加待机报文缓存,无网状态也能执行待机任务;投影仪指令结果以设备状态为准
This commit is contained in:
@@ -13,8 +13,8 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// WaitAction 待机任务,支持音乐、TTS、继电器、视频、网页、投影仪、大型激光秀 ctrl
|
||||
func WaitAction(ctrl *common.CtrlWait, device *common.Device) leaf.HandlerFunc {
|
||||
// StandbyAction 待机任务,支持音乐、TTS、继电器、视频、网页、投影仪、大型激光秀 ctrl
|
||||
func StandbyAction(ctrl *common.CtrlWait, device *common.Device) leaf.HandlerFunc {
|
||||
ps := common.NewPauseSub(ctrl)
|
||||
|
||||
return func(c *leaf.Context) {
|
||||
@@ -15,20 +15,20 @@ func PJLink(_ schema.WaitItemModel) func(c context.Context) error {
|
||||
pjc := pjlink.NewClient(cfg.Ip, cfg.Port, cfg.Password, cfg.Id)
|
||||
|
||||
zap.S().Infoln("打开待机投影仪")
|
||||
resp, err := pjc.PowerOn()
|
||||
resp, err := pjc.PowerOnSync()
|
||||
if err != nil {
|
||||
return fmt.Errorf("打开投影仪异常: %w", err)
|
||||
}
|
||||
zap.S().Infoln("投影仪返回报文:", resp)
|
||||
zap.S().Infoln("打开投影仪结果:", resp)
|
||||
|
||||
<-c.Done()
|
||||
|
||||
zap.S().Infoln("关闭待机投影仪")
|
||||
resp, err = pjc.PowerOff()
|
||||
resp, err = pjc.PowerOffSync()
|
||||
if err != nil {
|
||||
return fmt.Errorf("关闭投影仪异常: %w", err)
|
||||
}
|
||||
zap.S().Infoln("投影仪返回报文:", resp)
|
||||
zap.S().Infoln("关闭投影仪结果:", resp)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Device 设备锁定控制器
|
||||
func Device(d *common.Device, lock bool, play func(c context.Context) error) func(c context.Context) error {
|
||||
return func(c context.Context) error {
|
||||
if lock {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Interval 循环间隔控制器
|
||||
func Interval(interval int64, play func(c context.Context) error) func(c context.Context) error {
|
||||
return func(c context.Context) error {
|
||||
zap.S().Infoln("待机间隔控制器: ", interval)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Pause 暂停控制器
|
||||
func Pause(ps *common.PauseSub, isPause bool, play func(c context.Context) error) func(c context.Context) error {
|
||||
return func(c context.Context) error {
|
||||
var cancel context.CancelFunc
|
||||
|
||||
Reference in New Issue
Block a user