ws.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* 自动生成的文本数据头文件 */
  2. /* 源文件: ws.js */
  3. /* 文件大小: 3174 字节 */
  4. /* 生成时间: 2025-09-12 05:42:14 */
  5. /* 编码: utf-8 */
  6. #ifndef P_WS_H
  7. #define P_WS_H
  8. #include <stddef.h>
  9. // 文本数据(UTF-8编码)
  10. const char *p_ws =
  11. "let productTypeData = {\n"
  12. "};\n"
  13. "let data_alarm = [];\n"
  14. "let sensorc_list = [];\n"
  15. "let network_data = {}\n"
  16. " // 485配置\n"
  17. "let cas_data = {}\n"
  18. " // snmp\n"
  19. "let snmp_data = {}\n"
  20. " // 设备信息\n"
  21. "let lang_data = {}\n"
  22. "let sensor_data = {}\n"
  23. "function on_ws_msg(js) {\n"
  24. " console.log(\"执行\")\n"
  25. " // debugger\n"
  26. " //总电源数据显示\n"
  27. " if (js.powert != undefined) {\n"
  28. " total_data = js.powert.total\n"
  29. " type = js.powert.type\n"
  30. " productTypeData.productType = type;\n"
  31. " total_Infor(js, total_data, type)\n"
  32. " }\n"
  33. " //通道电源数据显示\n"
  34. " if (js.powerc != undefined) {\n"
  35. " channel_power_infro = js.powerc\n"
  36. " channel_infro = channel_power_infro.power\n"
  37. " alarm = js.powerc.alarm\n"
  38. " channel_number = js.powerc.info // 通道基础信息\n"
  39. " channel_power = js.powerc.power\n"
  40. " j_data = js\n"
  41. " // 通道号\n"
  42. " Channel_Info(j_data, channel_power_infro)\n"
  43. " // 阈值设置\n"
  44. " threshold_mannage(js, channel_power_infro)\n"
  45. " // systemAlarm(alarm)\n"
  46. " //populateTable(j_data,channel_power)\n"
  47. " }\n"
  48. " // 警告\n"
  49. " if (js.alarmd != undefined) {\n"
  50. " alarmd_data = js.alarmd\n"
  51. " data_alarm = [];\n"
  52. " data_alarm = alarm_process(alarmd_data)\n"
  53. " }\n"
  54. " // 配置信息(网络配置,485配置,snmp,设备信息)\n"
  55. " if (js.cas != undefined) {\n"
  56. " cas_data = js.cas;\n"
  57. " }\n"
  58. " if (js.network != undefined) {\n"
  59. " network_data = js.network\n"
  60. " }\n"
  61. " if (js.snmp != undefined) {\n"
  62. " snmp_data = js.snmp\n"
  63. " console.log(\"snmp数据--》\")\n"
  64. " console.log(snmp_data)\n"
  65. " }\n"
  66. " if (js.sensorc != undefined) {\n"
  67. " sensor_data = js.sensorc;\n"
  68. " }\n"
  69. " // if (js.paras != undefined) {\n"
  70. " // // 设备信息\n"
  71. " // lang_data = js.paras.lang\n"
  72. " // }\n"
  73. " if (js.sensorc != undefined) {\n"
  74. " sensorc_list = [];\n"
  75. " // 传感器\n"
  76. " sensorc_list = js.sensorc\n"
  77. " console.log(sensorc_list)\n"
  78. " }\n"
  79. " if (js.sys != undefined) {\n"
  80. " lang_data = js.sys\n"
  81. " // console.log(lang_data)\n"
  82. " }\n"
  83. "}\n"
  84. "function alarm_process(alarmd_data) {\n"
  85. " const result = [];\n"
  86. " const alarmProperties = alarmd_data.alarm;\n"
  87. " const baseProperties = {\n"
  88. " \"ch\": alarmd_data.ch,\n"
  89. " \"time\": alarmd_data.time\n"
  90. " };\n"
  91. " let idCounter = 1;\n"
  92. " for (const key in alarmProperties) {\n"
  93. " if (alarmProperties.hasOwnProperty(key) && alarmProperties[key] == 1) {\n"
  94. " const newObj = {...baseProperties, [key]: alarmProperties[key], \"id\": idCounter++ };\n"
  95. " result.push(newObj);\n"
  96. " }\n"
  97. " }\n"
  98. " return result;\n"
  99. "}\n"
  100. "function ws_hdr() {\n"
  101. " var proto = window.location.protocol,\n"
  102. " ws;\n"
  103. " if (proto == 'https:') {\n"
  104. " ws = 'wss://';\n"
  105. " } else {\n"
  106. " ws = 'ws://';\n"
  107. " }\n"
  108. " return ws;\n"
  109. "}\n"
  110. "function setActivePage(pageFunction, intervalTime) {\n"
  111. " // 停止之前活动的页面定时函数\n"
  112. " if (activePageIntervalId != null) {\n"
  113. " clearInterval(activePageIntervalId);\n"
  114. " }\n"
  115. " activePageIntervalId = setInterval(pageFunction, intervalTime);\n"
  116. "}\n"
  117. "ws = new WS('ws://' + window.location.host + '/ws', on_ws_msg);\n"
  118. "// ws = new WS('ws://192.168.1.134/ws', on_ws_msg);\n"
  119. "// ws = new WS('ws://192.168.1.134/websocket/TMS-WebSocket', on_ws_msg);"
  120. ;
  121. // 文本数据大小(包括null终止符)
  122. const size_t p_ws_size = 3175;
  123. // 文本长度(字符数)
  124. const size_t p_ws_length = 3016;
  125. #endif /* P_WS_H */