12345678910111213141516171819202122232425262728293031323334353637 |
- package lc
- import (
- "fmt"
- "github.com/sirupsen/logrus"
- "lc-smartX/util"
- "net"
- )
- // IDevice 抽象设备,包含屏和喇叭
- type IDevice interface {
- Call()
- ReConnect()
- }
- type IntersectionDevice struct {
- Info util.OutputDevice
- S Screen
- L IpCast
- }
- func (id *IntersectionDevice) Call() {
- id.L.Speak()
- id.S.Display()
- }
- func (id *IntersectionDevice) ReConnect() {
- conn, err := net.Dial("tcp", id.Info.ScreenIp+":5000")
- if err != nil {
- logrus.Error("连接", id.Info.ScreenIp, "失败!error:", err)
- return
- }
- logrus.Info("连接", id.Info.ScreenIp, "成功!")
- fmt.Println("连接", id.Info.ScreenIp, "成功!")
- id.S.Conn = conn
- id.S.IsLive = true
- }
|