ws.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. function on_ws_msg(js) {
  2. console.log(js)
  3. //总电源数据显示
  4. if (js.powert != undefined) {
  5. total_data = js.powert.total
  6. total_Infor(js, total_data)
  7. }
  8. //通道电源数据显示
  9. if (js.powerc != undefined) {
  10. channel_power_infro = js.powerc
  11. channel_infro = channel_power_infro.power
  12. alarm = js.powerc.alarm
  13. channel_number = js.powerc.info
  14. channel_power = js.powerc.power
  15. j_data = js
  16. Channel_Info(j_data, channel_power_infro)
  17. threshold_mannage(js, channel_power_infro)
  18. //systemAlarm(alarm)
  19. //populateTable(j_data,channel_power)
  20. }
  21. if (js.alarmd != undefined) {
  22. // console.log(js.alarmd)
  23. alarmd_data = js.alarmd
  24. systemAlarm(alarmd_data)
  25. }
  26. }
  27. function ws_hdr() {
  28. var proto = window.location.protocol,
  29. ws;
  30. if (proto == 'https:') {
  31. ws = 'wss://';
  32. } else {
  33. ws = 'ws://';
  34. }
  35. return ws;
  36. }
  37. //ws = new WS('ws://'+window.location.host+'/ws',on_ws_msg);
  38. ws = new WS('ws://192.168.1.166/ws', on_ws_msg);