| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- 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.134/ws', on_ws_msg);
- //ws = new WS('ws://192.168.1.134/websocket/TMS-WebSocket', on_ws_msg);
|