led.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package lc
  2. import (
  3. "github.com/sirupsen/logrus"
  4. "net/http"
  5. )
  6. type Programm struct {
  7. Type string `json:"type"` //节目类型
  8. Name string `json:"name"` //节目名
  9. ImageInfo ImageInfo `json:"imageinfo"` //图片,视频资源url
  10. TextInfo Textinfo `json:"textinfo"` //文本内容
  11. }
  12. type Textinfo struct {
  13. Content string `json:"content"`
  14. LfFaceName string `json:"lfFaceName"`
  15. BackColor string `json:"backcolor"`
  16. TextColor string `json:"textcolor"`
  17. Duration string `json:"duration"`
  18. IsScroll string `json:"IsScroll"`
  19. Speed string `json:"Speed"` //滚动速度pixels/秒
  20. }
  21. type ImageInfo struct {
  22. Urls []string `json:"urls"`
  23. Duration string `json:"duration"`
  24. InEffect InEffect `json:"inEffect"`
  25. }
  26. type InEffect struct {
  27. Type string `json:"Type"` //0- No transition, 1-Random, 2-Left unveil, 3-Right unveil
  28. Time string `json:"Time"`
  29. }
  30. // SwitchProgram 切换节目
  31. func SwitchProgram(id int) {
  32. name := "来车new-55"
  33. if id == 0 {
  34. name = "路口new-54"
  35. }
  36. url := "http://192.168.1.213/api/" + "vsns/sources/lan/vsns/" + name + ".vsn/activated"
  37. request, err := http.NewRequest("PUT", url, nil)
  38. if err != nil {
  39. logrus.Errorf("Newrequest出错:%v", err)
  40. return
  41. }
  42. request.Header.Set("Accept", "application/json")
  43. _, err = http.DefaultClient.Do(request)
  44. if err != nil {
  45. logrus.Errorf("http错误%v", err)
  46. return
  47. }
  48. }