operation.js 946 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. function all_open()
  2. {
  3. ws.send(mk_hdr(PKT_TYPE.PKT_TYPE_CH_ALL,1));
  4. }
  5. function all_close()
  6. {
  7. ws.send(mk_hdr(PKT_TYPE.PKT_TYPE_CH_ALL,0));
  8. }
  9. function single_open(j_data,channel_power_infro,j)
  10. {
  11. j_c_data = j_data
  12. data = channel_power_infro
  13. j_status = data[j].power[0].status
  14. if(j_status == 0)
  15. {
  16. data[j].power[0].status = 1
  17. }
  18. a = pkt_to_bin(PKT_TYPE.PKT_TYPE_POWER_CH,SUB_TYPE.SUB_TYPE_POWER_SWITCH,data[j])
  19. var b = bin_to_pkt(a)
  20. ws.send(a)
  21. }
  22. function single_close(j_data,channel_power_infro,j)
  23. {
  24. j_c_data = j_data
  25. data = channel_power_infro
  26. j_status = data[j].power[0].status
  27. if(j_status == 1)
  28. {
  29. data[j].power[0].status = 0
  30. }
  31. a = pkt_to_bin(PKT_TYPE.PKT_TYPE_POWER_CH,SUB_TYPE.SUB_TYPE_POWER_SWITCH,data[j])
  32. var b = bin_to_pkt(a)
  33. ws.send(a)
  34. }
  35. function threshold_update(orgin_data)
  36. {
  37. translate_data = orgin_data
  38. send_data(translate_data)
  39. }