ws.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. //populateTable(j_data,channel_power)
  19. }
  20. if (js.alarmd != undefined) {
  21. // console.log(js.alarmd)
  22. // alarmd_data = js.alarmd
  23. // systemAlarm(alarmd_data)
  24. }
  25. }
  26. function ws_hdr() {
  27. var proto = window.location.protocol,
  28. ws;
  29. if (proto == 'https:') {
  30. ws = 'wss://';
  31. } else {
  32. ws = 'ws://';
  33. }
  34. return ws;
  35. }
  36. //ws = new WS('ws://'+window.location.host+'/ws',on_ws_msg);
  37. ws = new WS('ws://192.168.1.166/ws', on_ws_msg);