对投影机打开状态,每半小时轮询检查
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"game-driver/internal/schema"
|
||||
"game-driver/pkg/pjlink"
|
||||
"go.uber.org/zap"
|
||||
"time"
|
||||
)
|
||||
|
||||
func PJLink(_ schema.WaitItemModel) func(c context.Context) error {
|
||||
@@ -21,14 +22,27 @@ func PJLink(_ schema.WaitItemModel) func(c context.Context) error {
|
||||
}
|
||||
zap.S().Infoln("打开投影仪结果:", resp)
|
||||
|
||||
<-c.Done()
|
||||
|
||||
run := true
|
||||
for run {
|
||||
select {
|
||||
case <-c.Done():
|
||||
zap.S().Infoln("关闭待机投影仪")
|
||||
resp, err = pjc.PowerOffSync()
|
||||
if err != nil {
|
||||
return fmt.Errorf("关闭投影仪异常: %w", err)
|
||||
}
|
||||
zap.S().Infoln("关闭投影仪结果:", resp)
|
||||
run = false
|
||||
break
|
||||
case <-time.After(time.Minute * 30):
|
||||
zap.S().Infoln("轮询待机投影仪")
|
||||
resp, err = pjc.PowerOnSync()
|
||||
if err != nil {
|
||||
return fmt.Errorf("轮询投影仪异常: %w", err)
|
||||
}
|
||||
zap.S().Infoln("轮询投影仪结果:", resp)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user