增加待机报文缓存,无网状态也能执行待机任务;投影仪指令结果以设备状态为准

This commit is contained in:
2025-04-29 13:48:35 +08:00
parent 40293e5e9b
commit e1384504f1
13 changed files with 266 additions and 32 deletions

View File

@@ -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) {

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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