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)
  38. {
  39. // 获取要插入新行的DOM元素
  40. const dataList = document.getElementById('threshold_mannage');
  41. // 清空现有的列表项
  42. dataList.innerHTML = '';
  43. channel_length = channel_power_infro.length
  44. //遍历数据数组
  45. for(let j = 1;j<channel_length;j++)
  46. {
  47. // 创建一个新的列表项元素
  48. const listItem = document.createElement('tr');
  49. dataList.appendChild(listItem);
  50. //自动生成电源类型列
  51. const power_type_td = document.createElement('td');
  52. power_type_td.textContent = "通道"
  53. dataList.appendChild(power_type_td);
  54. //自动生成名称列
  55. const Chananl_name_td = document.createElement('td');
  56. Chananl_name_td.textContent = "CH"+j
  57. dataList.appendChild(Chananl_name_td);
  58. //自动生成编号列
  59. const Chananl_num_td = document.createElement('td');
  60. Chananl_num_td.textContent = j
  61. dataList.appendChild(Chananl_num_td);
  62. //自动生成电流上限列
  63. const current_max_td = document.createElement('td');
  64. c_val = channel_power_infro[j].thr.c_upper.val
  65. current_max_td.textContent = c_val
  66. dataList.appendChild(current_max_td);
  67. // 自动生成电压上限列
  68. const voltage_max_td = document.createElement('td');
  69. u_u_val = channel_power_infro[j].thr.v_upper.val;
  70. voltage_max_td.textContent = u_u_val;
  71. dataList.appendChild(voltage_max_td);
  72. // 自动生成电压下限列
  73. const voltage_min_td = document.createElement('td');
  74. u_l_val = channel_power_infro[j].thr.v_lower.val;
  75. voltage_min_td.textContent = u_l_val
  76. dataList.appendChild(voltage_min_td);
  77. // 自动生成功率上限列
  78. const power_max_td = document.createElement('td');
  79. p_val = channel_power_infro[j].thr.p_upper.val;
  80. power_max_td.textContent = p_val
  81. dataList.appendChild(power_max_td);
  82. // 自动生成耗电量上限列
  83. const consump_td = document.createElement('td');
  84. c_val = channel_power_infro[j].thr.w_upper.val;
  85. consump_td.textContent = c_val
  86. dataList.appendChild(consump_td);
  87. // 自动生成配置按钮列
  88. const operation_td = document.createElement('button');
  89. operation_td.textContent = '配置';
  90. operation_td.id = "edite"+j
  91. operation_td.style.width = '70px'
  92. operation_td.style.height = '50px'
  93. const translate = channel_power_infro[j]
  94. operation_td.addEventListener('click',function(){
  95. editRow(orgin_data,j,translate)
  96. })
  97. dataList.appendChild(operation_td);
  98. }
  99. }
  100. function now_time()
  101. {
  102. const now = new Date();
  103. // 获取年、月、日、小时、分钟和秒
  104. const year = now.getFullYear();
  105. const month = now.getMonth() + 1;
  106. const day = now.getDate();
  107. const hours = now.getHours();
  108. const minutes = now.getMinutes();
  109. const seconds = now.getSeconds();
  110. formattedTime = `${year}-${month < 10 ? '0' : ''}${month}-${day < 10 ? '0' : ''}${day} ${hours < 10 ? '0' : ''}${hours}:${minutes < 10 ? '0' : ''}${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
  111. return formattedTime
  112. }