data_process.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. channle_datas = []
  2. let currentNumber = 1;
  3. let resultArray = [];
  4. const cyclesPerNumber = 3;
  5. let button_status = [];
  6. const data = [];
  7. const datas = []
  8. const finall_data = []
  9. const processing_data = {}
  10. // function data_process()
  11. // {
  12. // //chaannle_length = pageData.length
  13. // // for(let i = 1;i<chaannle_length;i++)
  14. // // {
  15. // // channle_datas.push(pageData[i])
  16. // // }
  17. // //const totalIterations = channle_datas.length;
  18. // const text_length = data_arr.length
  19. // // for (let i = 0; i < totalIterations; i++) {
  20. // // resultArray.push(currentNumber);
  21. // // if ((i + 1) % cyclesPerNumber === 0) {
  22. // // // 如果是,则递增数字
  23. // // currentNumber++;
  24. // // }
  25. // // }
  26. // channle_datas = data_arr
  27. // for(let j = 0;j < text_length;j++)
  28. // {
  29. // j_type = channle_datas[j].info.type
  30. // if(j_type = 1)
  31. // {
  32. // j_c_type = '直流'
  33. // }
  34. // if(j_type = 3)
  35. // {
  36. // j_c_type = '三相'
  37. // }
  38. // if(j_type = 5)
  39. // {
  40. // j_c_type = '单相'
  41. // }
  42. // j_open_time = channle_datas[j].info.start_delay
  43. // j_close_time = channle_datas[j].info.stop_delay
  44. // j_device_name = 'SmartPDU'
  45. // j_channle_name = `CH${j+1}`
  46. // for(let i = 0;i<3;i++)
  47. // {
  48. // j_status = channle_datas[j].power[i].status
  49. // j_channle = channle_datas[j].power[i]
  50. // j_infor = channle_datas[j].info
  51. // if(j_status = 0)
  52. // {
  53. // j_c_status = '关闭'
  54. // datas.push(j_device_name),
  55. // datas.push(j_channle_name),
  56. // datas.push(j),
  57. // datas.push(j_c_type),
  58. // datas.push(j_c_status),
  59. // datas.push(j_open_time),
  60. // datas.push(j_close_time),
  61. // datas.push(j_channle.voltage),
  62. // datas.push(j_channle.current),
  63. // datas.push(j_channle.power),
  64. // datas.push(j_channle.freq),
  65. // datas.push(j_channle.consump)
  66. // datas.push(j_channle.factor)
  67. // num = datas
  68. // }
  69. // if(j_status = 1)
  70. // {
  71. // j_c_status = '关闭'
  72. // datas.push(j_device_name),
  73. // datas.push(j_channle_name),
  74. // datas.push(j),
  75. // datas.push(j_c_type),
  76. // datas.push(j_c_status),
  77. // datas.push(j_open_time),
  78. // datas.push(j_close_time),
  79. // datas.push(j_channle.voltage),
  80. // datas.push(j_channle.current),
  81. // datas.push(j_channle.power),
  82. // datas.push(j_channle.freq),
  83. // datas.push(j_channle.consump)
  84. // datas.push(j_channle.factor)
  85. // num = datas
  86. // }
  87. // for(let n = 0;n<num.length;n++)
  88. // {
  89. // processing_data[chanle_data_process[n]] = num[n];
  90. // }
  91. // finall_data.push(processing_data)
  92. // }
  93. // }
  94. // j_processed_data = finall_data
  95. // }
  96. const result = [];
  97. function alarm_process(alarmd_data)
  98. {
  99. const alarmProperties = alarmd_data.alarm;
  100. const baseProperties = {
  101. "ch": alarmd_data.ch,
  102. "time": alarmd_data.time
  103. };
  104. let idCounter = 1;
  105. for (const key in alarmProperties) {
  106. if (alarmProperties.hasOwnProperty(key) && alarmProperties[key] == 1) {
  107. const newObj = { ...baseProperties, [key]: alarmProperties[key], "id": idCounter++ };
  108. result.push(newObj);
  109. }
  110. }
  111. return result;
  112. }