MqttStruct.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package MqttServer
  2. //////////////////////////
  3. // 实体类
  4. type Ms2_Project struct {
  5. //Sn string `json:"sn"`
  6. Type int `json:"type"`
  7. Msid int64 `json:"mid"`
  8. Data map[string]interface{} `json:"data"`
  9. }
  10. // 实体类
  11. type Ms2m_Project struct {
  12. //Sn string `json:"sn"`
  13. Type int `json:"type"`
  14. Msid int64 `json:"mid"`
  15. Dut int64 `json:"dut"`
  16. }
  17. // 实体类-数值
  18. type Ms2_Project_list struct {
  19. Type int `json:"type"`
  20. Msid int64 `json:"mid"`
  21. Data []map[string]interface{} `json:"data"`
  22. }
  23. // 反馈消息
  24. type Ms2_Return struct {
  25. Type int `json:"type"`
  26. Msid int64 `json:"mid"`
  27. Status int `json:"status"` // 1代表处理成功 0处理异常
  28. }
  29. type Ms_Project2_Device_Parameter struct {
  30. //Sn string `json:"sn"`
  31. Type int `json:"type"` // 4代表参数设置
  32. Msid int64 `json:"mid"` //消息识别ID,随机生成,回复时ID不变
  33. Data Ms_Project_Device_Parameter_Data `json:"data"` //查询基本参数编号,每次参数改变都会有新的编号,若不带此参数,则返回所有参数
  34. }
  35. type Ms_Project_Device_Parameter_Data struct {
  36. T_name string `json:"name"`
  37. T_saveT int `json:"saveT"`
  38. T_overA int `json:"overA"`
  39. T_outA int `json:"outA"`
  40. T_lostA int `json:"lostA"`
  41. T_bat int `json:"bat"`
  42. T_scan int `json:"scan"`
  43. T_warn int `json:"warn"`
  44. T_warnD int `json:"warnD"`
  45. T_dormancy int `json:"dormancy"` // 是否进入休眠 0:关闭 1:开启 默认:0
  46. T_snum int `json:"snum"` // 是否进入休眠 0:关闭 1:开启 默认:0
  47. T_prt string `json:"prt"` //公司名称 (根据 设备 PID 获取)
  48. T_btname string `json:"btname"`
  49. T_btsid int `json:"btsid"`
  50. T_btchar int `json:"btchar"`
  51. }
  52. type Ms_Project2_Sensor_Parameter struct {
  53. //Sn string `json:"sn"`
  54. Type int `json:"type"` // 4代表参数设置
  55. Msid int64 `json:"mid"` //消息识别ID,随机生成,回复时ID不变
  56. Data []Ms_Project_Sensor_Parameter_Data `json:"data"` //查询基本参数编号,每次参数改变都会有新的编号,若不带此参数,则返回所有参数
  57. }
  58. type Ms_Project_Sensor_Parameter_Data struct {
  59. T_id int `json:"id"`
  60. T_name string `json:"name"`
  61. T_Tlower float32 `json:"tl"`
  62. T_Tupper float32 `json:"tu"`
  63. T_RHlower float32 `json:"hl"`
  64. T_RHupper float32 `json:"hu"`
  65. T_en int `json:"en"`
  66. T_enprel int `json:"enprel"`
  67. T_tprel float32 `json:"tprel"`
  68. T_tpreu float32 `json:"tpreu"`
  69. T_hprel float32 `json:"hprel"`
  70. T_hpreu float32 `json:"hpreu"`
  71. T_enprelnote int `json:"enprelnote"`
  72. T_free int `json:"free"`
  73. //T_speed int `json:"speed"`
  74. //T_sense int `json:"sense"`
  75. }
  76. type Ms_Read_DeviceSensorParameter struct {
  77. Type int `json:"type"`
  78. Msid int64 `json:"mid"`
  79. Data []int `json:"data"`
  80. }
  81. /////////////////////////////
  82. // / - 连接 实体
  83. type Ms_Project_Connected struct {
  84. Clientid string `json:"clientid"`
  85. Username string `json:"username"`
  86. Ipaddress string `json:"ipaddress"`
  87. Reason string `json:"reason"` // sha
  88. }
  89. // / - 离线断开 实体
  90. type Ms_Project_Disconnected struct {
  91. Clientid string `json:"clientid"`
  92. Username string `json:"username"`
  93. Ipaddress string `json:"ipaddress"`
  94. Reason string `json:"reason"`
  95. //终端连接断开原因:
  96. //normal:客户端主动断开
  97. //kicked:服务端踢出,通过 REST API
  98. //keepalive_timeout: keepalive 超时
  99. //not_authorized: 认证失败,或者 acl_nomatch = disconnect 时没有权限的 Pub/Sub 会主动断开客户端
  100. //tcp_closed: 对端关闭了网络连接
  101. //internal_error: 畸形报文或其他未知错误
  102. }
  103. // / - 发送 实体
  104. type Rt_Project_Data_Sensor struct {
  105. Id int `json:"id"`
  106. Status int `json:"status"`
  107. }
  108. type Rt_Project_Data struct {
  109. //Sn string `json:"sn"`
  110. Type int `json:"type"`
  111. Msid int64 `json:"msid"`
  112. Sensor []Rt_Project_Data_Sensor `json:"sensor"`
  113. }