display_data.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. function total_Infor(j,total_data){
  2. len = total_data.length
  3. //显示总信息
  4. for(let i = 0;i<=len-1;i++)
  5. {
  6. num = i + 1
  7. voltage = total_data[i].voltage.toFixed(2)
  8. current = total_data[i].current.toFixed(2)
  9. power = total_data[i].power
  10. power = power / 1000
  11. power = power.toFixed(3)
  12. consump = total_data[i].consump
  13. if(consump <= 0)
  14. {
  15. consump = 0
  16. }
  17. consump = consump / 1000
  18. consump = consump.toFixed(3)
  19. freq = total_data[i].freq.toFixed(2)
  20. Voltage = document.getElementById("L"+num+"_voltage")
  21. Current = document.getElementById("L"+num+"_current")
  22. Power = document.getElementById("L"+num+"_power")
  23. Consump = document.getElementById("L"+num+"_power_consumption")
  24. Freq = document.getElementById("L"+num+"_freq")
  25. Voltage.textContent = voltage
  26. Current.textContent = current
  27. Power.textContent = power
  28. Consump.textContent = consump
  29. Freq.textContent = freq
  30. }
  31. }
  32. function Channel_Info(j_data,channel_power_infro)
  33. {
  34. channel_length = channel_power_infro.length
  35. channel_display(j_data,channel_power_infro,channel_infro)
  36. }
  37. function threshold_mannage(orgin_data,channel_power_infro,threshold)
  38. {
  39. // 获取要插入新行的DOM元素
  40. const dataList = document.getElementById('threshold_mannage');
  41. // 清空现有的列表项
  42. dataList.innerHTML = '';
  43. channel_length = threshold.c_upper.act_para.length
  44. current_upper = threshold.c_upper.act_para
  45. voltage_upper = threshold.v_upper.act_para
  46. voltage_lower = threshold.v_lower.act_para
  47. power_upper = threshold.p_upper.act_para
  48. consump_upper = threshold.w_upper.act_para
  49. //遍历数据数组
  50. for(let i = 0;i<=channel_length-1;i++)
  51. {
  52. j = i + 1
  53. // 创建一个新的列表项元素
  54. const listItem = document.createElement('tr');
  55. dataList.appendChild(listItem);
  56. //自动生成电源类型列
  57. const power_type_td = document.createElement('td');
  58. power_type_td.textContent = "通道"
  59. dataList.appendChild(power_type_td);
  60. //自动生成名称列
  61. const Chananl_name_td = document.createElement('td');
  62. Chananl_name_td.textContent = "CH"+j
  63. dataList.appendChild(Chananl_name_td);
  64. //自动生成编号列
  65. const Chananl_num_td = document.createElement('td');
  66. Chananl_num_td.textContent = j
  67. dataList.appendChild(Chananl_num_td);
  68. //自动生成电流上限列
  69. const current_max_td = document.createElement('td');
  70. current_max_td.textContent = current_upper[i]
  71. dataList.appendChild(current_max_td);
  72. // 自动生成电压上限列
  73. const voltage_max_td = document.createElement('td');
  74. voltage_max_td.textContent = voltage_upper[i];
  75. dataList.appendChild(voltage_max_td);
  76. // 自动生成电压下限列
  77. const voltage_min_td = document.createElement('td');
  78. voltage_min_td.textContent = voltage_lower[i];
  79. dataList.appendChild(voltage_min_td);
  80. // 自动生成功率上限列
  81. const power_max_td = document.createElement('td');
  82. power_max_td.textContent = power_upper[i];
  83. dataList.appendChild(power_max_td);
  84. // 自动生成耗电量上限列
  85. const consump_td = document.createElement('td');
  86. consump_td.textContent = consump_upper[i];
  87. dataList.appendChild(consump_td);
  88. // 自动生成配置按钮列
  89. const operation_td = document.createElement('button');
  90. operation_td.textContent = '配置';
  91. operation_td.id = "edite"+{i}
  92. operation_td.addEventListener('click', function() {
  93. editRow(orgin_data,threshold,i,channel_power_infro)
  94. });
  95. dataList.appendChild(operation_td);
  96. }
  97. }
  98. function now_time()
  99. {
  100. const now = new Date();
  101. // 获取年、月、日、小时、分钟和秒
  102. const year = now.getFullYear();
  103. const month = now.getMonth() + 1;
  104. const day = now.getDate();
  105. const hours = now.getHours();
  106. const minutes = now.getMinutes();
  107. const seconds = now.getSeconds();
  108. formattedTime = `${year}-${month < 10 ? '0' : ''}${month}-${day < 10 ? '0' : ''}${day} ${hours < 10 ? '0' : ''}${hours}:${minutes < 10 ? '0' : ''}${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
  109. return formattedTime
  110. }