display_data.js 4.7 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. num = i + 1
  6. voltage = total_data[i].voltage.toFixed(2)
  7. current = total_data[i].current.toFixed(2)
  8. power = total_data[i].power
  9. power = power / 1000
  10. power = power.toFixed(3)
  11. consump = total_data[i].consump
  12. if (consump <= 0) {
  13. consump = 0
  14. }
  15. consump = consump / 1000
  16. consump = consump.toFixed(3)
  17. freq = total_data[i].freq.toFixed(2)
  18. Voltage = document.getElementById("L" + num + "_voltage")
  19. Current = document.getElementById("L" + num + "_current")
  20. Power = document.getElementById("L" + num + "_power")
  21. Consump = document.getElementById("L" + num + "_power_consumption")
  22. Freq = document.getElementById("L" + num + "_freq")
  23. Voltage.textContent = voltage
  24. Current.textContent = current
  25. Power.textContent = power
  26. Consump.textContent = consump
  27. Freq.textContent = freq
  28. }
  29. }
  30. function Channel_Info(j_data, channel_power_infro) {
  31. channel_length = channel_power_infro.length
  32. channel_display(j_data, channel_power_infro, channel_infro)
  33. }
  34. function threshold_mannage(orgin_data, channel_power_infro) {
  35. // 获取要插入新行的DOM元素
  36. const dataList = document.getElementById('threshold_mannage');
  37. // 清空现有的列表项
  38. dataList.innerHTML = '';
  39. channel_length = channel_power_infro.length
  40. //遍历数据数组
  41. for (let j = 1; j < channel_length; j++) {
  42. // 创建一个新的列表项元素
  43. const listItem = document.createElement('tr');
  44. dataList.appendChild(listItem);
  45. //自动生成电源类型列
  46. const power_type_td = document.createElement('td');
  47. power_type_td.textContent = "通道"
  48. dataList.appendChild(power_type_td);
  49. //自动生成名称列
  50. const Chananl_name_td = document.createElement('td');
  51. Chananl_name_td.textContent = "CH" + j
  52. dataList.appendChild(Chananl_name_td);
  53. //自动生成编号列
  54. const Chananl_num_td = document.createElement('td');
  55. Chananl_num_td.textContent = j
  56. dataList.appendChild(Chananl_num_td);
  57. //自动生成电流上限列
  58. const current_max_td = document.createElement('td');
  59. c_val = channel_power_infro[j].thr.c_upper / 10.0
  60. current_max_td.textContent = c_val
  61. dataList.appendChild(current_max_td);
  62. // 自动生成电压上限列
  63. const voltage_max_td = document.createElement('td');
  64. u_u_val = channel_power_infro[j].thr.v_upper / 10.0;
  65. //u_u_val = channel_power_infro[j].thr.v_upper.val;
  66. voltage_max_td.textContent = u_u_val;
  67. dataList.appendChild(voltage_max_td);
  68. // 自动生成电压下限列
  69. const voltage_min_td = document.createElement('td');
  70. u_l_val = channel_power_infro[j].thr.v_lower / 10.0;
  71. //u_l_val = channel_power_infro[j].thr.v_lower.val;
  72. voltage_min_td.textContent = u_l_val
  73. dataList.appendChild(voltage_min_td);
  74. // 自动生成功率上限列
  75. const power_max_td = document.createElement('td');
  76. p_val = channel_power_infro[j].thr.p_upper / 1000.0;
  77. //p_val = channel_power_infro[j].thr.p_upper.val;
  78. power_max_td.textContent = p_val
  79. dataList.appendChild(power_max_td);
  80. // 自动生成耗电量上限列
  81. const consump_td = document.createElement('td');
  82. c_val = channel_power_infro[j].thr.w_upper / 1000.0;
  83. //c_val = channel_power_infro[j].thr.w_upper.val;
  84. consump_td.textContent = c_val
  85. dataList.appendChild(consump_td);
  86. // 自动生成配置按钮列
  87. const operation_td = document.createElement('button');
  88. operation_td.textContent = '配置';
  89. operation_td.id = "edite" + j
  90. operation_td.style.width = '70px'
  91. operation_td.style.height = '50px'
  92. const translate = channel_power_infro[j]
  93. operation_td.addEventListener('click', function() {
  94. editRow(orgin_data, j, translate)
  95. })
  96. dataList.appendChild(operation_td);
  97. }
  98. }
  99. function now_time() {
  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. }