screen.go 846 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package lc
  2. import (
  3. "fmt"
  4. "lc-smartX/bx"
  5. "lc-smartX/util/mqtt"
  6. "net"
  7. )
  8. // Screener 屏接口
  9. type Screener interface {
  10. Display(int)
  11. }
  12. type Screen struct {
  13. Name string
  14. Addr string
  15. conn net.Conn
  16. liveState bool
  17. StateInfo *bx.StateInfo //状态信息
  18. Params *bx.Params //屏参
  19. }
  20. func NewScreen(name string, ip, port string) *Screen {
  21. s := &Screen{
  22. Name: name,
  23. Addr: fmt.Sprintf("%s:%s", ip, port),
  24. StateInfo: &bx.StateInfo{},
  25. Params: &bx.Params{},
  26. }
  27. s.Reconnect()
  28. return s
  29. }
  30. func (s *Screen) Display(id int) {
  31. msg := "来车new-55"
  32. if id == 0 {
  33. msg = "路口new-54"
  34. }
  35. GetMQTTMgr().Publish("000000/cltled/LED20230408/down/switch", []byte(msg), mqtt.AtMostOnce, ToCloud)
  36. }
  37. // Correct 校正时间
  38. func (s *Screen) Correct() {
  39. }
  40. // Reconnect 重连
  41. func (s *Screen) Reconnect() {
  42. }