let productTypeData = { }; let data_alarm = []; let sensorc_list = []; let network_data = {} // 485配置 let cas_data = {} // snmp let snmp_data = {} // 设备信息 let lang_data = {} let sensor_data = {} let his_alarm = [] function on_ws_msg(js) { // console.log("执行") // debugger //总电源数据显示 if (js.powert != undefined) { total_data = js.powert.total type = js.powert.type productTypeData.productType = type; total_Infor(js, total_data, type) } //通道电源数据显示 if (js.powerc != undefined) { channel_power_infro = js.powerc channel_infro = channel_power_infro.power alarm = js.powerc.alarm channel_number = js.powerc.info // 通道基础信息 channel_power = js.powerc.power j_data = js // 通道号 Channel_Info(j_data, channel_power_infro) // 阈值设置 threshold_mannage(js, channel_power_infro) // systemAlarm(alarm) //populateTable(j_data,channel_power) } // 警告 if (js.alarmd != undefined) { alarmd_data = js.alarmd data_alarm = []; data_alarm = alarm_process(alarmd_data) } // 配置信息(网络配置,485配置,snmp,设备信息) if (js.cas != undefined) { cas_data = js.cas; } if (js.network != undefined) { network_data = js.network } if (js.snmp != undefined) { snmp_data = js.snmp console.log("snmp数据--》") console.log(snmp_data) } if (js.sensorc != undefined) { sensor_data = js.sensorc; } // if (js.paras != undefined) { // // 设备信息 // lang_data = js.paras.lang // } if (js.sensorc != undefined) { sensorc_list = []; // 传感器 sensorc_list = js.sensorc // console.log(sensorc_list) } if (js.sys != undefined) { lang_data = js.sys // console.log(lang_data) } if (js.his_alarmd != undefined) { his_alarm = js.his_alarmd; console.log(his_alarm) } } function alarm_process(alarmd_data) { const result = []; const alarmProperties = alarmd_data.alarm; const baseProperties = { "ch": alarmd_data.ch, "time": alarmd_data.time }; let idCounter = 1; for (const key in alarmProperties) { if (alarmProperties.hasOwnProperty(key) && alarmProperties[key] == 1) { const newObj = {...baseProperties, [key]: alarmProperties[key], "id": idCounter++ }; result.push(newObj); } } return result; } function ws_hdr() { var proto = window.location.protocol, ws; if (proto == 'https:') { ws = 'wss://'; } else { ws = 'ws://'; } return ws; } function setActivePage(pageFunction, intervalTime) { // 停止之前活动的页面定时函数 if (activePageIntervalId != null) { clearInterval(activePageIntervalId); } activePageIntervalId = setInterval(pageFunction, intervalTime); } ws = new WS('ws://' + window.location.host + '/ws', on_ws_msg); // ws = new WS('ws://192.168.1.166/ws', on_ws_msg); // ws = new WS('ws://192.168.1.79/websocket/TMS-WebSocket', on_ws_msg);