config.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package protocol
  2. // 网关配置
  3. type MqttConfig struct {
  4. Server string `json:"server"`
  5. User string `json:"user"`
  6. Password string `json:"password"`
  7. Timeout uint `json:"timeout"`
  8. }
  9. type RedisConfig struct {
  10. Server string `json:"server"`
  11. Password string `json:"password"`
  12. }
  13. type EdgeConfig struct {
  14. Mqtt MqttConfig `json:"mqtt"`
  15. Redis RedisConfig `json:"redis"`
  16. }
  17. type CloudConfig struct {
  18. Mqtt MqttConfig `json:"mqtt"`
  19. }
  20. type AppConfig struct {
  21. Name string `json:"name"` //应用名称
  22. Tenant string `json:"tenant"` //租户ID
  23. GID string `json:"gid"` //网关ID
  24. SN string `json:"sn"` //序列号
  25. Upgrade bool `json:"upgrade"` //需要升级
  26. Edge EdgeConfig `json:"edge"` //边缘端配置
  27. Cloud CloudConfig `json:"cloud"` //云端配置
  28. }
  29. // --------------------------------------------------------
  30. // 串口配置
  31. type SerialConfig struct {
  32. Serial map[uint8]*SerialPort `json:"serial"`
  33. }
  34. type SerialPort struct {
  35. Code uint8 `json:"code"` //key串口编号,上层应用使用,网关下唯一
  36. Interface string `json:"interface"` //串口物理位置,方便维修
  37. Address string `json:"address"` //串口地址
  38. BaudRate int `json:"baudrate"`
  39. DataBits uint8 `json:"databits"`
  40. StopBits uint `json:"stopbits"`
  41. Parity string `json:"parity"`
  42. Timeout uint `json:"timeout"` //毫秒
  43. ProtocolType uint8 `json:"protocoltype"` //0:modbus-rtu;1:长和单灯集控zigbee
  44. }
  45. // 设备配置
  46. type DevInfo struct {
  47. Code uint8 `json:"code"` //串口编号,上层应用使用,网关下唯一
  48. DevID uint8 `json:"devid"` //从设备地址,配置时设定,串口下唯一
  49. DevCode string `json:"devcode"` //设备编码,应用层使用
  50. TID uint16 `json:"tid"` //模型ID
  51. Name string `json:"name"` //从设备名称
  52. SendCloud int `json:"sendcloud"` //毫秒
  53. WaitTime uint `json:"waittime"` //发送后等待多久
  54. ProtocolType uint8 `json:"protocoltype"` //0:modbus-rtu;1:长和单灯集控zigbee;2:裕明485单灯控制器协议
  55. DevType uint8 `json:"devtype"` //设备类型,1-灯控类设备 2-环境监测类设备 3-裕明485单灯控制器 4-液位计 5-路面状况传感器
  56. Height float64 `json:"height"` //离地高度,液位计适用
  57. }
  58. type MapDevConfig struct {
  59. Rtu []DevInfo `json:"dev"`
  60. }
  61. // 摄象机和一键报警(带摄象机功能)的配置
  62. type OnvifDev struct {
  63. Code string `json:"code"`
  64. SN string `json:"sn"`
  65. IP string `json:"ip"`
  66. Name string `json:"name"`
  67. Brand string `json:"brand"`
  68. Model string `json:"model"`
  69. DevType int `json:"devtype"` //3摄象机,4一键报警(带视频)
  70. User string `json:"user"`
  71. Password string `json:"password"`
  72. RtmpServer string `json:"rtmpserver"`
  73. WebServer string `json:"webserver"`
  74. Event string `json:"event"`
  75. Gb28181 bool `json:"gb28181"` //国标28181
  76. }
  77. // 抓拍单元配置
  78. type ITSDev struct {
  79. Code string `json:"code"`
  80. ID string `json:"id"`
  81. TollgateID string `json:"tollgateid"`
  82. Name string `json:"name"`
  83. Brand string `json:"brand"`
  84. Model string `json:"model"`
  85. DevType int `json:"devtype"` //5 抓拍单元
  86. User string `json:"user"`
  87. Password string `json:"password"`
  88. IP string `json:"ip"`
  89. Port uint16 `json:"port"`
  90. }
  91. type ITSDevConfig struct {
  92. IPAddr string `json:"ipaddr"`
  93. SuggestSpeed uint8 `json:"suggestspeed"`
  94. Duration int `json:"duration"`
  95. EnvID string `json:"envid"`
  96. DefProvince string `json:"defprovince"`
  97. DefCity string `json:"defcity"`
  98. RemotePub uint8 `json:"remotepub"`
  99. RemoteSub string `json:"remotesub"`
  100. Its []ITSDev `json:"dev"`
  101. }