加入 pjlink 控制
This commit is contained in:
@@ -28,7 +28,7 @@ type ResponseBody struct {
|
||||
}
|
||||
|
||||
func PushCard(ctx context.Context) leaf.HandlerFunc {
|
||||
g := (game.G).(game.ConfigPush)
|
||||
g := (game.C).(game.ConfigPush)
|
||||
|
||||
readers := make([]card_reader.Reader, len(g.PushGroups))
|
||||
devices := make([]*card_pusher.Device, len(g.PushGroups))
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func WaitCard(ctx context.Context) leaf.HandlerFunc {
|
||||
g := (game.G).(game.ConfigWait)
|
||||
g := (game.C).(game.ConfigWait)
|
||||
|
||||
reader, err := card_reader.NewReader(g.Addr)
|
||||
if err != nil {
|
||||
|
||||
@@ -3,11 +3,13 @@ package routes
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"game-driver/config/wait"
|
||||
"game-driver/internal/middleware"
|
||||
"game-driver/internal/schema"
|
||||
"game-driver/leaf"
|
||||
"game-driver/pkg/audio"
|
||||
"game-driver/pkg/browser"
|
||||
"game-driver/pkg/pjlink"
|
||||
"game-driver/pkg/relay"
|
||||
"game-driver/pkg/tts"
|
||||
"game-driver/pkg/utils"
|
||||
@@ -151,6 +153,13 @@ func WaitAction(c *leaf.Context) {
|
||||
defer wait.Done()
|
||||
runAction(c, item, rules, webAction)
|
||||
}()
|
||||
case schema.WaitPJLink:
|
||||
// 执行投影仪打开
|
||||
wait.Add(1)
|
||||
go func() {
|
||||
defer wait.Done()
|
||||
runAction(c, item, rules, pjlinkAction)
|
||||
}()
|
||||
default:
|
||||
zap.S().Infof("不支持的类型: %d\n", item.Type)
|
||||
}
|
||||
@@ -255,3 +264,29 @@ func webAction(c context.Context, item schema.WaitItemModel) error {
|
||||
browser.OpenApp(c, item.Data)
|
||||
return nil
|
||||
}
|
||||
|
||||
func pjlinkAction(c context.Context, _ schema.WaitItemModel) error {
|
||||
cfg := (wait.C).(wait.PJLink)
|
||||
pjc := pjlink.NewClient(cfg.Ip, cfg.Port, cfg.Password, cfg.Id)
|
||||
err := pjc.Connect()
|
||||
if err != nil {
|
||||
return fmt.Errorf("连接 PJLink 设备异常: %w", err)
|
||||
}
|
||||
defer pjc.Close()
|
||||
|
||||
zap.S().Infoln("打开待机投影仪")
|
||||
err = pjc.PowerOn()
|
||||
if err != nil {
|
||||
return fmt.Errorf("打开投影仪异常: %w", err)
|
||||
}
|
||||
|
||||
<-c.Done()
|
||||
|
||||
zap.S().Infoln("关闭待机投影仪")
|
||||
err = pjc.PowerOff()
|
||||
if err != nil {
|
||||
return fmt.Errorf("关闭投影仪异常: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ const (
|
||||
WaitTTS
|
||||
WaitRelay
|
||||
WaitWeb
|
||||
WaitPJLink
|
||||
)
|
||||
|
||||
type WaitItemModel struct {
|
||||
|
||||
Reference in New Issue
Block a user