tower.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. var xhr = new XMLHttpRequest();
  2. var url = "tower/org";
  3. obj="";
  4. xhr.open("GET",url);
  5. xhr.onload = function(){
  6. obj = JSON.parse(xhr.responseText);
  7. //insertHTML();
  8. start();
  9. onChangeColumn1();
  10. onChangeColumn2();
  11. onChangeColumn3();
  12. click_button();
  13. };
  14. xhr.send();
  15. function insertHTML(data){
  16. var tower_select = document.getElementById('tower');
  17. //aria.innerHTML=data[0].tower_name;
  18. var inner='';
  19. for(var i=0;i<data.length;i++){
  20. if(i>=3){
  21. inner=inner+'<button type="button" class="btn btn-primary m-1" onclick="tower_info(\''+data[0].tower_name+'\');">'+data[i].tower_name+'</button>';
  22. }
  23. else{
  24. inner=inner+'<button type="button" class="btn btn-primary m-1" onclick="tower_info(\''+data[i].tower_name+'\');">'+data[i].tower_name+'</button>';
  25. }
  26. console.log(inner);
  27. }
  28. tower_select.innerHTML=inner;
  29. }
  30. obj2 = "";
  31. function click_button() {
  32. //alert("click");
  33. companySelect=document.getElementById("company-list");
  34. factorySelect=document.getElementById("factory-list");
  35. departmentSelect=document.getElementById("department-list");
  36. towerGroupSelect=document.getElementById("towerGroup-list");
  37. if(companySelect.value!=0 && factorySelect.value!=0 && departmentSelect.value!=0 && towerGroupSelect.value!=0){
  38. var url2 = "tower/?company="+ companySelect.value + "&factory=" + factorySelect.value + "&department=" +departmentSelect.value + "&towerGroup=" +towerGroupSelect.value ;
  39. var xhr2 = new XMLHttpRequest();
  40. xhr2.open("GET",url2);
  41. xhr2.onload = function(){
  42. obj2 = JSON.parse(xhr2.responseText);
  43. insertHTML(obj2);
  44. tower_info(obj2[0].tower_name);
  45. };
  46. xhr2.send();
  47. }
  48. }
  49. function tower_info(tower_str){
  50. tower = tower_str;
  51. console.log(tower);
  52. inner = "";
  53. for(var i=0;i<obj2.length;i++){
  54. if(obj2[i].tower_name == tower){
  55. // inner = '<p> DCS </P> '+
  56. // '<p> 入水溫度 = '+ obj2[i].tower_data.DCS.hotTemp + ' </P> ' +
  57. // '<p> 出水溫度 = '+ obj2[i].tower_data.DCS.coldTemp + ' </P> ' +
  58. // '<p> 水流量 = '+ obj2[i].tower_data.DCS.waterFlow + ' </P> ' +
  59. // '<p> 風扇馬達電流 = '+ obj2[i].tower_data.DCS.fanMotorCur + ' </P> ' +
  60. // '<p> 風扇馬達轉速頻率 = '+ obj2[i].tower_data.DCS.fanMotorSpeedFreq + ' </P><br> ' +
  61. // '<p> 風扇震動 </P> '+
  62. // '<p> 馬達震動 = '+ obj2[i].tower_data.Moter.ch01.Vrms + ' </P> ' +
  63. // '<p> 減速機震動 = '+ obj2[i].tower_data.Fan.reducer + ' </P> ' +
  64. // '<p> 靜壓機 = '+ obj2[i].tower_data.Fan.staticPressure + ' </P> ' +
  65. // '<p> 水流量 = '+ obj2[i].tower_data.Fan.waterFlow + ' </P> ' +
  66. // '<p> 濕求溫度 = '+ obj2[i].tower_data.Fan.wetTemp + ' </P> ' +
  67. // '<p> 水冷槽溫度1 = '+ obj2[i].tower_data.Fan.coldTempData1 + ' </P> ' +
  68. // '<p> 水冷槽溫度2 = '+ obj2[i].tower_data.Fan.coldTempData2 + ' </P><br> ' +
  69. // '<p> 馬達震動 </P> '+
  70. // '<p> ch001,通道1'+ obj2[i].tower_data.Moter.ch01.Vrms + ',' + obj2[i].tower_data.Moter.ch01.CV+' </P> ' +
  71. // '<p> ch002,通道2'+ obj2[i].tower_data.Moter.ch02.Vrms + ',' + obj2[i].tower_data.Moter.ch02.CV+' </P> '
  72. // ;
  73. inner =' <h1 class="ms-3"><i style="color:#0174c7;" class="fas fa-file-signature me-1"></i>中控室DSC訊號</h1>\
  74. <div class="row px-0 mx-0">\
  75. <div class="card col-lg-2">\
  76. <p class="data-title fw-bold">入水溫度</p>\
  77. <div>\
  78. <h2 class="text-center">'+ obj2[i].tower_data.DCS.hotTemp +'</h2>\
  79. <P class="unit text-end">°C</P>\
  80. </div>\
  81. </div>\
  82. <div class="card col-lg-2">\
  83. <p class="data-title fw-bold">出水溫度</p>\
  84. <div>\
  85. <h2 class="text-center">'+ obj2[i].tower_data.DCS.coldTemp + '</h2>\
  86. <P class="unit text-end">°C</P>\
  87. </div>\
  88. </div>\
  89. <div class="card col-lg-2">\
  90. <p class="data-title fw-bold ">水流量</p>\
  91. <div>\
  92. <h2 class="text-center">'+ obj2[i].tower_data.DCS.waterFlow + '</h2>\
  93. <P class="unit text-end">M³/H</P>\
  94. </div>\
  95. </div>\
  96. <div class="card col-lg-2">\
  97. <p class="data-title fw-bold">風扇馬達電流</p>\
  98. <div>\
  99. <h2 class="text-center">'+ obj2[i].tower_data.DCS.fanMotorCur + '</h2>\
  100. <P class="unit text-end">A</P>\
  101. </div>\
  102. </div>\
  103. <div class="card col-lg-2">\
  104. <p class="data-title fw-bold ">風扇馬達轉速頻率</p>\
  105. <div>\
  106. <h2 class="text-center">'+ obj2[i].tower_data.DCS.fanMotorSpeedFreq + '&ensp;</h2>\
  107. <P class="unit text-end">Hz</P>\
  108. </div>\
  109. </div>\
  110. </div>\
  111. <div class="card mt-5">\
  112. <div class="row">\
  113. <div class="col-lg-6">\
  114. <h1><i style="color:#0174c7;" class="fas fa-tachometer-alt me-2"></i>風扇震動</h1>\
  115. </div>\
  116. <div class="col-lg-6">\
  117. <h1><i style=" color:#0174c7;" class="fas fa-cogs me-2"></i>馬達震動</h1>\
  118. </div>\
  119. </div>\
  120. <div>\
  121. <div class="row px-0 mx-0">\
  122. <div class="col-lg-6">\
  123. <table class="table">\
  124. <thead>\
  125. <tr>\
  126. <th scope="col">數據名稱</th>\
  127. <th scope="col">值</th>\
  128. <th scope="col">單位</th>\
  129. </tr>\
  130. </thead>\
  131. <tbody>\
  132. <tr>\
  133. <td>馬達震動</td>\
  134. <td>'+ obj2[i].tower_data.Moter[0].Vrms + '</td>\
  135. <td>mm/s</td>\
  136. </tr>\
  137. <tr>\
  138. <td>減速機震動</td>\
  139. <td>'+ obj2[i].tower_data.Fan.reducer + '</td>\
  140. <td>mm/s</td>\
  141. </tr>\
  142. <tr>\
  143. <td>靜壓機</td>\
  144. <td>'+ obj2[i].tower_data.Fan.staticPressure + '</td>\
  145. <td>pa</td>\
  146. </tr>\
  147. <tr>\
  148. <td>水流量</td>\
  149. <td>'+ obj2[i].tower_data.Fan.waterFlow + '</td>\
  150. <td>M³/H</td>\
  151. </tr>\
  152. <tr>\
  153. <td>濕求溫度</td>\
  154. <td>'+ obj2[i].tower_data.Fan.wetTemp + '</td>\
  155. <td>°C</td>\
  156. </tr>\
  157. <tr>\
  158. <td>水冷槽溫度1</td>\
  159. <td>'+ obj2[i].tower_data.Fan.coldTempData1 + '</td>\
  160. <td>°C</td>\
  161. </tr>\
  162. <tr>\
  163. <td>水冷槽溫度2</td>\
  164. <td>'+ obj2[i].tower_data.Fan.coldTempData2 + '</td>\
  165. <td>°C</td>\
  166. </tr>\
  167. </tbody>\
  168. </table>\
  169. </div>\
  170. <div class="col-lg-6">\
  171. <div class="row px-0 mx-0">\
  172. <div class="card col-lg-5">\
  173. <p class="fw-bold ">ch001,通道1</p>\
  174. <div>\
  175. <p class="text-center">'+ obj2[i].tower_data.Moter[0].Vrms + ',' + obj2[i].tower_data.Moter[0].CV+'</p>\
  176. </div>\
  177. </div>\
  178. <div class="card col-lg-5">\
  179. <p class="fw-bold ">ch002,通道2</p>\
  180. <div>\
  181. <p class="text-center">'+ obj2[i].tower_data.Moter[1].Vrms + ',' + obj2[i].tower_data.Moter[1].CV+'</p>\
  182. </div>\
  183. </div>\
  184. <div class="card col-lg-5">\
  185. <p class="fw-bold ">ch003,通道3</p>\
  186. <div>\
  187. <p class="text-center">'+ obj2[i].tower_data.Moter[2].Vrms + ',' + obj2[i].tower_data.Moter[2].CV+'</p>\
  188. </div>\
  189. </div>\
  190. <div class="card col-lg-5">\
  191. <p class="fw-bold ">ch004,通道4</p>\
  192. <div>\
  193. <p class="text-center">'+ obj2[i].tower_data.Moter[3].Vrms + ',' + obj2[i].tower_data.Moter[3].CV+'</p>\
  194. </div>\
  195. </div>\
  196. </div>\
  197. </div>\
  198. </div>\
  199. </div>\
  200. </div>';
  201. console.log(obj2[i].tower_data.Moter[3].Vrms);
  202. }
  203. }
  204. document.getElementById("tower_info").innerHTML = inner;
  205. console.log(inner);
  206. get_tower_perfrom('dev001');
  207. }
  208. //document就是這html文件。
  209. //getElementById是裡面的方法,參數給"college-list"抓到這id標籤列
  210. function start(){
  211. companySelect=document.getElementById("company-list");
  212. factorySelect=document.getElementById("factory-list");
  213. departmentSelect=document.getElementById("department-list");
  214. towerGroupSelect=document.getElementById("towerGroup-list");
  215. var inner='';
  216. var company_arr = new Array();
  217. for(var i=0;i<obj.length;i++){
  218. if(company_arr.indexOf(obj[i].company)==-1 && obj[i].able==1){
  219. inner=inner+'<option value="'+obj[i].company+'">公司'+obj[i].company+'</option>';
  220. company_arr.push(obj[i].company);
  221. }
  222. }
  223. //innerHTML 賦值inner給這element屬性
  224. companySelect.innerHTML=inner;
  225. }
  226. //製造一個字串,以html的語法填入院的陣列
  227. function onChangeColumn1() {
  228. companySelect=document.getElementById("company-list");
  229. factorySelect=document.getElementById("factory-list");
  230. departmentSelect=document.getElementById("department-list");
  231. towerGroupSelect=document.getElementById("towerGroup-list");
  232. factorySelect.innerHTML='';
  233. let factory_arr = new Array();
  234. let factory_inner = '';
  235. for(var i=0;i<obj.length;i++){
  236. if( companySelect.value == obj[i].company){
  237. if(factory_arr.indexOf(obj[i].factory)==-1 && obj[i].able==1){
  238. factory_inner=factory_inner+'<option value="'+obj[i].factory+'">廠區'+obj[i].factory+'</option>';
  239. factory_arr.push(obj[i].factory);
  240. }
  241. }
  242. //alert(companySelect.value);
  243. }
  244. factorySelect.innerHTML=factory_inner;
  245. }
  246. function onChangeColumn2() {
  247. companySelect=document.getElementById("company-list");
  248. factorySelect=document.getElementById("factory-list");
  249. departmentSelect=document.getElementById("department-list");
  250. towerGroupSelect=document.getElementById("towerGroup-list");
  251. departmentSelect.innerHTML='';
  252. let department_arr = new Array();
  253. let department_inner = '';
  254. for(var i=0;i<obj.length;i++){
  255. if( companySelect.value == obj[i].company && factorySelect.value == obj[i].factory){
  256. if(department_arr.indexOf(obj[i].department)==-1 && obj[i].able==1){
  257. department_inner=department_inner+'<option value="'+obj[i].department+'">課'+obj[i].department+'</option>';
  258. department_arr.push(obj[i].department);
  259. }
  260. }
  261. }
  262. document.getElementById("department-list").innerHTML=department_inner;
  263. }
  264. function onChangeColumn3() {
  265. companySelect=document.getElementById("company-list");
  266. factorySelect=document.getElementById("factory-list");
  267. departmentSelect=document.getElementById("department-list");
  268. towerGroupSelect=document.getElementById("towerGroup-list");
  269. towerGroupSelect.innerHTML='';
  270. let towerGroup_inner = '';
  271. for(var i=0;i<obj.length;i++){
  272. if( companySelect.value == obj[i].company && factorySelect.value == obj[i].factory && departmentSelect.value == obj[i].department){
  273. if( obj[i].able==1){
  274. for(var ii=0;ii<obj[i].group.length;ii++){
  275. towerGroup_inner=towerGroup_inner+'<option value="'+obj[i].group[ii]+'">機組'+obj[i].group[ii]+'</option>';
  276. }
  277. }
  278. }
  279. }
  280. document.getElementById("towerGroup-list").innerHTML= towerGroup_inner;
  281. }
  282. function get_tower_perfrom(tower_id){
  283. var xhr3 = new XMLHttpRequest();
  284. var url3 = "tower/performance/"+tower_id;
  285. console.log("sss");
  286. obj3="";
  287. xhr3.open("GET",url3);
  288. xhr3.onload = function(){
  289. obj3 = JSON.parse(xhr3.responseText);
  290. console.log(obj3);
  291. tower_perform_show(obj3);
  292. };
  293. xhr3.send();
  294. }
  295. function tower_perform_show(obj_tmp){
  296. inner = "設計條件<br>" +
  297. "水流量: " + obj_tmp[0].designWFR + "<br>" +
  298. "風車馬力: " + obj_tmp[0].designHP + "<br>" +
  299. "額定電流: " + obj_tmp[0].designCurrent + "<br>" +
  300. "入水溫度: " + obj_tmp[0].designHWT + "<br>" +
  301. "出水溫度: " + obj_tmp[0].designCWT + "<br>" +
  302. "濕求溫度: " + obj_tmp[0].designWBT + "<br>" +
  303. "測試狀態<br> " +
  304. "水流量: " + obj_tmp[0].testWFR + "<br>" +
  305. "風車馬力: " + obj_tmp[0].testBHP + "<br>" +
  306. "運轉電流: " + obj_tmp[0].testCurrent + "<br>" +
  307. "入水溫度: " + obj_tmp[0].testHWT + "<br>" +
  308. "出水溫度: " + obj_tmp[0].testCorrectCWT + "<br>" +
  309. "濕球溫度: " + obj_tmp[0].testWBT + "<br>" +
  310. "風速: " + obj_tmp[0].testWindSpeed + "<br>" +
  311. "補充水量: " + obj_tmp[0].testMakeupWFR + "<br>" +
  312. "補充水溫: " + obj_tmp[0].testMakeupCWT + "<br>" +
  313. "CORRECT CWT: " + obj_tmp[0].testCorrectCWT + "<br>" +
  314. "COLLING RANGE: " + obj_tmp[0].testCoolingRange + "<br>" ;
  315. document.getElementById('tower_perfrom').innerHTML=inner;
  316. }