ws.h 4.6 KB

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