dry_auto.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>{{ title }}</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7. <!-- <meta http-equiv="refresh" content="10" />每 content 秒網頁自動更新-->
  8. <!-- 新 Bootstrap4 核心 CSS 文件 -->
  9. <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
  10. <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
  11. <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  12. <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
  13. <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
  14. <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
  15. <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  16. <!--
  17. <script src="../static/js/sign_in.js"></script>
  18. <link rel="stylesheet" href="../static/css/sign_in.css">
  19. -->
  20. <script>
  21. $(document).ready(function(){
  22. $("#coffee_title").text('乾燥自動化');
  23. // 桶槽入料顯示
  24. dry_input_status_N = ['{{DI1}}', '{{DI2}}']
  25. console.log('dry_input_status_N: ' + dry_input_status_N)
  26. for (let i=0; i<dry_input_status_N.length; i++) {
  27. // 顯示對應乾燥桶槽號碼 D1~D6 和目前狀態
  28. // console.log(i+1 + ' : '+ dry_input_status_N[i])
  29. // 1 : F_InputtingBean
  30. // 2 : F_Waiting
  31. if (dry_input_status_N[i] == 'DI_InputtingBean') {
  32. $("#DI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  33. $("#DI"+parseInt(i+1)+"_status").text("DI" + parseInt(i+1) + " 入豆中")
  34. } else if (dry_input_status_N[i] == 'DI_Waiting') {
  35. $("#DI"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  36. $("#DI"+parseInt(i+1)+"_status").text("DI" + parseInt(i+1) + " 空桶等待")
  37. } else if (dry_input_status_N[i] == 'DI_OutputtingBean') {
  38. $("#DI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  39. $("#DI"+parseInt(i+1)+"_status").text("DI" + parseInt(i+1) + " 可出豆")
  40. } else {
  41. console.log('pass')
  42. }
  43. }
  44. // 桶槽狀態顯示
  45. dry_tank_status_N = ['{{D1}}', '{{D2}}', '{{D3}}', '{{D4}}', '{{D5}}', '{{D6}}',
  46. '{{D7}}', '{{D8}}', '{{D9}}', '{{D10}}', '{{D11}}', '{{D12}}']
  47. console.log('dry_tank_status_N: ' + dry_tank_status_N)
  48. for (let i=0; i<dry_tank_status_N.length; i++) {
  49. // 顯示對應乾燥桶槽號碼 D1~D6 和目前狀態
  50. // console.log(i+1 + ' : '+ dry_tank_status_N[i])
  51. // 1 : D_InputtingBean
  52. // 2 : D_Waiting
  53. if (dry_tank_status_N[i] == 'D_InputtingBean') {
  54. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  55. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 入豆中")
  56. } else if (dry_tank_status_N[i] == 'D_InputtingBean_Pause') {
  57. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  58. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 入豆暫停")
  59. } else if (dry_tank_status_N[i] == 'D_InputtingBean_Finish') {
  60. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  61. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 入豆完成")
  62. } else if (dry_tank_status_N[i] == 'D_Waiting') {
  63. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  64. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 空桶等待")
  65. } else if (dry_tank_status_N[i] == 'D_Cleaning') {
  66. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "plum")
  67. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 清洗中")
  68. } else if (dry_tank_status_N[i] == 'D_Drying') {
  69. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  70. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 乾燥中")
  71. } else if (dry_tank_status_N[i] == 'D_OutputtingBean') {
  72. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  73. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 可出豆")
  74. } else if (dry_tank_status_N[i] == 'D_Warning') {
  75. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "crimson")
  76. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 發生錯誤")
  77. $("#D"+parseInt(i+1)+"_status").css("color", "crimson")
  78. } else {
  79. console.log('pass')
  80. }
  81. }
  82. // 桶槽出料顯示
  83. dry_output_status_N = ['{{DO1}}', '{{DO2}}']
  84. console.log('dry_output_status_N: ' + dry_output_status_N)
  85. for (let i=0; i<dry_output_status_N.length; i++) {
  86. // 顯示對應乾燥桶槽號碼 D1~D6 和目前狀態
  87. // console.log(i+1 + ' : '+ dry_output_status[i])
  88. // 1 : D_InputtingBean
  89. // 2 : D_Waiting
  90. if (dry_output_status_N[i] == 'DO_InputtingBean') {
  91. $("#DO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  92. $("#DO"+parseInt(i+1)+"_status").text("DO" + parseInt(i+1) + " 入豆中")
  93. } else if (dry_output_status_N[i] == 'DO_Waiting') {
  94. $("#DO"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  95. $("#DO"+parseInt(i+1)+"_status").text("DO" + parseInt(i+1) + " 空桶等待")
  96. } else if (dry_output_status_N[i] == 'DO_OutputtingBean') {
  97. $("#DO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  98. $("#DO"+parseInt(i+1)+"_status").text("DO" + parseInt(i+1) + " 可出豆")
  99. } else {
  100. console.log('pass')
  101. }
  102. }
  103. // css
  104. // height: 185px; 取代成 height: 210px;
  105. // DI2 DO2 top: 620px; 取代成 top: 645px;
  106. });
  107. </script>
  108. <style>
  109. .D_status_css {
  110. font-weight: bold;
  111. text-align: center;
  112. }
  113. .DryContainer_position {
  114. position: absolute;
  115. top: 95px;
  116. left: 53px;
  117. }
  118. .D1_position {
  119. width: 110px;
  120. }
  121. .D2_position {
  122. width: 110px;
  123. }
  124. .D3_position {
  125. width: 110px;
  126. }
  127. .D4_position {
  128. width: 110px;
  129. }
  130. .D5_position {
  131. width: 110px;
  132. }
  133. .D6_position {
  134. width: 110px;
  135. }
  136. .D7_position {
  137. width: 110px;
  138. }
  139. .D8_position {
  140. width: 110px;
  141. }
  142. .D9_position {
  143. width: 110px;
  144. }
  145. .D10_position {
  146. width: 110px;
  147. }
  148. .D11_position {
  149. width: 110px;
  150. }
  151. .D12_position {
  152. width: 110px;
  153. }
  154. .DI1_position {
  155. width: 110px;
  156. }
  157. .DI2_position {
  158. width: 110px;
  159. }
  160. .DO1_position {
  161. width: 110px;
  162. }
  163. .DO2_position {
  164. width: 110px;
  165. }
  166. .footer{
  167. position: absolute;
  168. bottom: 0px;
  169. width: 100%;
  170. background-color: #eee;
  171. text-align: center;
  172. }
  173. </style>
  174. <script language="JavaScript">
  175. // 指定 10秒 刷新網頁一次
  176. var WebUpdate_set
  177. // WebUpdate_set = setInterval(function(){WebUpdate()} , 60 * 1000)
  178. function WebUpdate(){
  179. console.log("-- 狀態更新 start --")
  180. /*
  181. $.get('/loading_container_status/D', '', function (res) {
  182. }, 'json');
  183. */
  184. console.log("-- 狀態更新 end --")
  185. };
  186. </script>
  187. </head>
  188. <body>
  189. <div id="wrapper">
  190. <div id="coffee_header">
  191. <!-- 匯入共同使用的 header.html 內容 -->
  192. {% include 'header.html' %}
  193. </div>
  194. <div>
  195. <!-- 乾燥貨櫃 狀態表格-->
  196. <table style="border: 3px lightsteelblue solid; margin-right: auto; margin-left: auto; text-align: center; margin-top: 10px;" cellpadding="5" border="1">
  197. <tr>
  198. <td style="border: lightsteelblue 1px solid;">
  199. <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">
  200. <tr>
  201. <td>
  202. <!-- 乾燥槽入料儲豆槽 DI1 -->
  203. <div id="DI1" tabindex="0" class="DI1_position" role="button" style="text-align: center;">
  204. <span id="DI1_status" class="D_status_css">DI1 status</span>
  205. <div id="DI1_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  206. </div>
  207. </td>
  208. </tr>
  209. </table>
  210. </td>
  211. <td style="border: lightsteelblue 1px solid;">
  212. <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">
  213. <tr>
  214. <td>
  215. <!-- 乾燥槽 D1 -->
  216. <div id="D1" tabindex="0" class="D1_position" role="button">
  217. <span id="D1_status" class="D_status_css">D1 status</span>
  218. <!-- D1 狀態點點-->
  219. <div id="D1_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  220. </div>
  221. </td>
  222. <td>
  223. <!-- 乾燥槽 D2 -->
  224. <div id="D2" tabindex="0" class="D2_position" role="button">
  225. <span id="D2_status" class="D_status_css">D2 status</span>
  226. <div id="D2_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  227. </div>
  228. </td>
  229. <td>
  230. <!-- 乾燥槽 D3 -->
  231. <div id="D3" tabindex="0" class="D3_position" role="button">
  232. <span id="D3_status" class="D_status_css">D3 status</span>
  233. <div id="D3_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  234. </div>
  235. </td>
  236. <td>
  237. <!-- 乾燥槽 D4 -->
  238. <div id="D4" tabindex="0" class="D4_position" role="button">
  239. <span id="D4_status" class="D_status_css">D4 status</span>
  240. <div id="D4_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  241. </div>
  242. </td>
  243. <td>
  244. <!-- 乾燥槽 D5 -->
  245. <div id="D5" tabindex="0" class="D5_position" role="button">
  246. <span id="D5_status" class="D_status_css">D5 status</span>
  247. <div id="D5_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  248. </div>
  249. </td>
  250. <td>
  251. <!-- 乾燥槽 D6 -->
  252. <div id="D6" tabindex="0" class="D6_position" role="button">
  253. <span id="D6_status" class="D_status_css">D6 status</span>
  254. <div id="D6_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  255. </div>
  256. </td>
  257. </tr>
  258. </table>
  259. </td>
  260. <td style="border: lightsteelblue 1px solid;">
  261. <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">
  262. <tr>
  263. <td>
  264. <!-- 乾燥槽出料儲豆槽 DO1 -->
  265. <div id="DO1" tabindex="0" class="DO1_position" role="button">
  266. <span id="DO1_status" class="D_status_css">DO1 status</span>
  267. <div id="DO1_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  268. </div>
  269. </td>
  270. </tr>
  271. </table>
  272. </td>
  273. </tr>
  274. <tr>
  275. <td style="border: lightsteelblue 1px solid;">
  276. 入料儲豆槽
  277. </td>
  278. <td style="border: lightsteelblue 1px solid;">
  279. 乾燥桶槽
  280. </td>
  281. <td style="border: lightsteelblue 1px solid;">
  282. 出料儲豆槽
  283. </td>
  284. </tr>
  285. <tr>
  286. <td style="border: lightsteelblue 1px solid;">
  287. <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">
  288. <tr>
  289. <td>
  290. <!-- 乾燥槽入料儲豆槽 DI2 -->
  291. <div id="DI2" tabindex="0" class="DI2_position" role="button">
  292. <span id="DI2_status" class="D_status_css">DI2 status</span>
  293. <div id="DI2_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  294. </div>
  295. </td>
  296. </tr>
  297. </table>
  298. </td>
  299. <td style="border: lightsteelblue 1px solid;">
  300. <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">
  301. <tr>
  302. <td>
  303. <!-- 乾燥槽 D7 -->
  304. <div id="D7" tabindex="0" class="D7_position" role="button" style="vertical-align: bottom;">
  305. <span id="D7_status" class="D_status_css">D7 status</span>
  306. <div id="D7_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  307. </div>
  308. </td>
  309. <td>
  310. <!-- 乾燥槽 D8 -->
  311. <div id="D8" tabindex="0" class="D8_position" role="button">
  312. <span id="D8_status" class="D_status_css">D8 status</span>
  313. <div id="D8_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  314. </div>
  315. </td>
  316. <td>
  317. <!-- 乾燥槽 D9 -->
  318. <div id="D9" tabindex="0" class="D9_position" role="button">
  319. <span id="D9_status" class="D_status_css">D9 status</span>
  320. <div id="D9_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  321. </div>
  322. </td>
  323. <td>
  324. <!-- 乾燥槽 D10 -->
  325. <div id="D10" tabindex="0" class="D10_position" role="button">
  326. <span id="D10_status" class="D_status_css">D10 status</span>
  327. <div id="D10_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  328. </div>
  329. </td>
  330. <td>
  331. <!-- 乾燥槽 D11 -->
  332. <div id="D11" tabindex="0" class="D11_position" role="button">
  333. <span id="D11_status" class="D_status_css">D11 status</span>
  334. <div id="D11_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  335. </div>
  336. </td>
  337. <td>
  338. <!-- 乾燥槽 D12 -->
  339. <div id="D12" tabindex="0" class="D12_position" role="button">
  340. <span id="D12_status" class="D_status_css">D12 status</span>
  341. <div id="D12_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  342. </div>
  343. </td>
  344. </tr>
  345. </table>
  346. </td>
  347. <td style="border: lightsteelblue 1px solid;">
  348. <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">
  349. <tr>
  350. <td>
  351. <!-- 乾燥槽出料儲豆槽 DO2 -->
  352. <div id="DO2" tabindex="0" class="DO2_position" role="button">
  353. <span id="DO2_status" class="D_status_css">DO2 status</span>
  354. <div id="DO2_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  355. </div>
  356. </td>
  357. </tr>
  358. </table>
  359. </td>
  360. </tr>
  361. </table>
  362. <!-- 乾燥貨櫃 參數設定-->
  363. <table style="border: 3px lightsteelblue solid; margin-right: auto; margin-left: auto; text-align: center; margin-top: 10px;" cellpadding="5" border="1">
  364. <tr>
  365. <td>
  366. 入料儲豆槽<br>
  367. 參數設定
  368. </td>
  369. <td>
  370. 桶槽<br>
  371. 參數設定
  372. </td>
  373. <td>
  374. 出料儲豆槽<br>
  375. 參數設定
  376. </td>
  377. </tr>
  378. <tr>
  379. <td style="padding: 10px; text-align: left; vertical-align: text-top;">
  380. 吸料時間&nbsp;
  381. <input name="Dry_Input_vacuumON_time" type="text" value="10" style="width:50px;">&nbsp; 秒<br>
  382. 放料時間&nbsp;
  383. <input name="Dry_Input_vacuumOFF_time" type="text" value="10" style="width:50px;">&nbsp; 秒<br>
  384. </td>
  385. <td style="padding: 10px; text-align: left; vertical-align: text-top;">
  386. 指定生豆高度&nbsp;
  387. <input name="Dry_Tank_bean_height" type="text" value="100" style="width:50px;">&nbsp; 公分<br>
  388. 吸料時間&nbsp;
  389. <input name="Dry_Tank_vacuumON_time" type="text" value="10" style="width:50px;">&nbsp; 秒,&nbsp;
  390. 放料時間&nbsp;
  391. <input name="Dry_Tank_vacuumOFF_time" type="text" value="10" style="width:50px;">&nbsp; 秒<br>
  392. 馬達轉速&nbsp;
  393. <input name="Dry_Tank_motor_rpm" type="text" value="30" style="width:50px;">&nbsp; rpm<br>
  394. ----- 溫度權重設定 ----------------------------------------------<br>
  395. [上]桶內溫度×權重&nbsp;
  396. <input name="Dry_Tank_TempWeight_SHT11" type="text" value="0.5" style="width:50px;">
  397. +
  398. [下]生豆溫度×權重&nbsp;
  399. <input name="Dry_Tank_TempWeight_soil" type="text" value="0.5" style="width:50px;">
  400. <br>
  401. ----- 乾燥完成條件 (輸入 0 代表不設定) ------------------------<br>
  402. 指定乾燥溫度&nbsp;
  403. <input name="Dry_Tank_drying_temp" type="text" value="40" style="width:50px;">&nbsp; ℃
  404. , 且指定持溫時間&nbsp;
  405. <input name="Dry_Tank_drying_time" type="text" value="30" style="width:50px;">&nbsp; 分鐘<br>
  406. 指定 EC &nbsp;
  407. <input name="Dry_Tank_drying_EC" type="text" value="300" style="width:50px;">&nbsp;&nbsp;/&nbsp;
  408. 指定濕度 &nbsp;
  409. <input name="Dry_Tank_drying_Humidity" type="text" value="30" style="width:50px;">&nbsp;%<br>
  410. </td>
  411. <td style="padding: 10px; text-align: left; vertical-align: text-top;">
  412. 吸料時間&nbsp;
  413. <input name="Dry_Output_vacuumON_time" type="text" value="10" style="width:50px;">&nbsp; 秒<br>
  414. 放料時間&nbsp;
  415. <input name="Dry_Output_vacuumOFF_time" type="text" value="10" style="width:50px;">&nbsp; 秒<br>
  416. </td>
  417. </tr>
  418. </table>
  419. <center><button style="margin: 15px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="dry_auto()">
  420. [測試] MQTT + 每 60 秒更新貨櫃狀態</button></center>
  421. <script>
  422. function dry_auto(){
  423. var Dry_Input_vacuumON_time = $("input[name=Dry_Input_vacuumON_time]").val();
  424. var Dry_Input_vacuumOFF_time = $("input[name=Dry_Input_vacuumOFF_time]").val();
  425. var Dry_Tank_bean_height = $("input[name=Dry_Tank_bean_height]").val();
  426. var Dry_Tank_vacuumON_time = $("input[name=Dry_Tank_vacuumON_time]").val();
  427. var Dry_Tank_vacuumOFF_time = $("input[name=Dry_Tank_vacuumOFF_time]").val();
  428. var Dry_Tank_drying_temp = $("input[name=Dry_Tank_drying_temp]").val();
  429. var Dry_Tank_drying_time = $("input[name=Dry_Tank_drying_time]").val();
  430. var Dry_Tank_drying_EC = $("input[name=Dry_Tank_drying_EC]").val();
  431. var Dry_Tank_motor_rpm = $("input[name=Dry_Tank_motor_rpm]").val();
  432. var Dry_Tank_TempWeight_SHT11 = $("input[name=Dry_Tank_TempWeight_SHT11]").val();
  433. var Dry_Tank_TempWeight_soil = $("input[name=Dry_Tank_TempWeight_soil]").val();
  434. var Dry_Tank_drying_Humidity = $("input[name=Dry_Tank_drying_Humidity]").val();
  435. var Dry_Output_vacuumON_time = $("input[name=Dry_Output_vacuumON_time]").val();
  436. var Dry_Output_vacuumOFF_time = $("input[name=Dry_Output_vacuumOFF_time]").val();
  437. var data = { "command": "Dry_auto_parameter",
  438. "Dry_Input_vacuumON_time": Dry_Input_vacuumON_time,
  439. "Dry_Input_vacuumOFF_time": Dry_Input_vacuumOFF_time,
  440. "Dry_Tank_bean_height": Dry_Tank_bean_height,
  441. "Dry_Tank_vacuumON_time": Dry_Tank_vacuumON_time,
  442. "Dry_Tank_vacuumOFF_time": Dry_Tank_vacuumOFF_time,
  443. "Dry_Tank_drying_temp": Dry_Tank_drying_temp,
  444. "Dry_Tank_drying_time": Dry_Tank_drying_time,
  445. "Dry_Tank_drying_EC": Dry_Tank_drying_EC,
  446. "Dry_Tank_motor_rpm": Dry_Tank_motor_rpm,
  447. "Dry_Tank_TempWeight_SHT11": Dry_Tank_TempWeight_SHT11,
  448. "Dry_Tank_TempWeight_soil": Dry_Tank_TempWeight_soil,
  449. "Dry_Tank_drying_Humidity": Dry_Tank_drying_Humidity,
  450. "Dry_Output_vacuumON_time": Dry_Output_vacuumON_time,
  451. "Dry_Output_vacuumOFF_time": Dry_Output_vacuumOFF_time };
  452. $.post('/mqtt/101', data, function (res) {
  453. console.log('data: ', data)
  454. console.log('res: ', res)
  455. }, 'text')
  456. var dry_interval = setInterval(testing_D_auto, 30*1000)
  457. }
  458. </script>
  459. <center><button style="margin: 15px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="testing_D_auto()">
  460. [測試] 乾燥貨櫃狀態</button></center>
  461. <script>
  462. function testing_D_auto(){
  463. $.get('/dry_auto_status', '', function (res) {
  464. Dry_Input_1_STATUS = res.Dry_Input_1
  465. console.log('DI1: ' + res.Dry_Input_1)
  466. console.log('D1: ' + res.Dry_Tank_1)
  467. console.log('D2: ' + res.Dry_Tank_2)
  468. console.log('D3: ' + res.Dry_Tank_3)
  469. console.log('D4: ' + res.Dry_Tank_4)
  470. console.log('D5: ' + res.Dry_Tank_5)
  471. console.log('D6: ' + res.Dry_Tank_6)
  472. console.log('DO1: ' + res.Dry_Output_1)
  473. // ----- 乾燥入料 FI1 狀態 --------------------------------------------------------------
  474. dry_input_status = [res.Dry_Input_1]
  475. console.log('dry_input_status: ' + dry_input_status)
  476. for (let i=0; i<dry_input_status.length; i++) {
  477. // 顯示對應乾燥桶槽號碼 D1~D6 和目前狀態
  478. // console.log(i+1 + ' : '+ dry_input_status[i])
  479. // 1 : F_InputtingBean
  480. // 2 : F_Waiting
  481. if (dry_input_status[i] == 'DI_InputtingBean') {
  482. console.log('[動作] 乾燥入料 DI' + parseInt(i+1) + ' 入豆中')
  483. $("#DI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  484. $("#DI"+parseInt(i+1)+"_status").text("DI" + parseInt(i+1) + " 入豆中")
  485. } else if (dry_input_status[i] == 'DI_Waiting') {
  486. console.log('[動作] 乾燥入料 DI' + parseInt(i+1) + ' 空桶等待')
  487. $("#DI"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  488. $("#DI"+parseInt(i+1)+"_status").text("DI" + parseInt(i+1) + " 空桶等待")
  489. } else if (dry_input_status[i] == 'DI_OutputtingBean') {
  490. console.log('[動作] 乾燥入料 DI' + parseInt(i+1) + ' 可出豆')
  491. $("#DI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  492. $("#DI"+parseInt(i+1)+"_status").text("DI" + parseInt(i+1) + " 可出豆")
  493. } else {
  494. console.log('pass')
  495. }
  496. }
  497. // ----- 乾燥桶槽 F1~F6 狀態 --------------------------------------------------------------
  498. dry_tank_status = [res.Dry_Tank_1, res.Dry_Tank_2, res.Dry_Tank_3, res.Dry_Tank_4, res.Dry_Tank_5, res.Dry_Tank_6]
  499. console.log('dry_tank_status: ' + dry_tank_status)
  500. for (let i=0; i<dry_tank_status.length; i++) {
  501. // 顯示對應乾燥桶槽號碼 D1~D6 和目前狀態
  502. // console.log(i+1 + ' : '+ dry_tank_status[i])
  503. // 1 : D_InputtingBean
  504. // 2 : D_Waiting
  505. if (dry_tank_status[i] == 'D_InputtingBean') {
  506. console.log('[動作] 乾燥桶槽 D' + parseInt(i+1) + ' 入豆中')
  507. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  508. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 入豆中")
  509. } else if (dry_tank_status[i] == 'D_InputtingBean_Pause') {
  510. console.log('[動作] 乾燥桶槽 D' + parseInt(i+1) + ' 入豆暫停')
  511. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  512. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 入豆暫停")
  513. } else if (dry_tank_status[i] == 'D_InputtingBean_Finish') {
  514. console.log('[動作] 乾燥桶槽 D' + parseInt(i+1) + ' 入豆完成')
  515. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  516. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 入豆完成")
  517. } else if (dry_tank_status[i] == 'D_Waiting') {
  518. console.log('[動作] 乾燥桶槽 D' + parseInt(i+1) + ' 空桶等待')
  519. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  520. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 空桶等待")
  521. } else if (dry_tank_status[i] == 'D_Cleaning') {
  522. console.log('[動作] 乾燥桶槽 D' + parseInt(i+1) + ' 清洗中')
  523. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "plum")
  524. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 清洗中")
  525. } else if (dry_tank_status[i] == 'D_Drying') {
  526. console.log('[動作] 乾燥桶槽 D' + parseInt(i+1) + ' 乾燥中')
  527. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  528. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 乾燥中")
  529. } else if (dry_tank_status[i] == 'D_OutputtingBean') {
  530. console.log('[動作] 乾燥桶槽 D' + parseInt(i+1) + ' 可出豆')
  531. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  532. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 可出豆")
  533. } else if (dry_tank_status[i] == 'D_Warning') {
  534. console.log('[動作] 乾燥桶槽 D' + parseInt(i+1) + ' 發生錯誤')
  535. $("#D"+parseInt(i+1)+"_status_dot").css("background-color", "crimson")
  536. $("#D"+parseInt(i+1)+"_status").text("D" + parseInt(i+1) + " 發生錯誤")
  537. $("#D"+parseInt(i+1)+"_status").css("color", "crimson")
  538. } else {
  539. console.log('pass')
  540. }
  541. }
  542. // ----- 乾燥出料 FO1 狀態 --------------------------------------------------------------
  543. dry_output_status = [res.Dry_Output_1]
  544. console.log('dry_output_status: ' + dry_output_status)
  545. for (let i=0; i<dry_output_status.length; i++) {
  546. // 顯示對應乾燥桶槽號碼 D1~D6 和目前狀態
  547. // console.log(i+1 + ' : '+ dry_output_status[i])
  548. // 1 : D_InputtingBean
  549. // 2 : D_Waiting
  550. if (dry_output_status[i] == 'DO_InputtingBean') {
  551. console.log('[動作] 乾燥出料 DO' + parseInt(i+1) + ' 入豆中')
  552. $("#DO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  553. $("#DO"+parseInt(i+1)+"_status").text("DO" + parseInt(i+1) + " 入豆中")
  554. } else if (dry_output_status[i] == 'DO_Waiting') {
  555. console.log('[動作] 乾燥出料 DO' + parseInt(i+1) + ' 空桶等待')
  556. $("#DO"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  557. $("#DO"+parseInt(i+1)+"_status").text("DO" + parseInt(i+1) + " 空桶等待")
  558. } else if (dry_output_statu[i] == 'DO_OutputtingBean') {
  559. console.log('[動作] 乾燥出料 DO' + parseInt(i+1) + ' 可出豆')
  560. $("#DO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  561. $("#DO"+parseInt(i+1)+"_status").text("DO" + parseInt(i+1) + " 可出豆")
  562. } else {
  563. console.log('pass')
  564. }
  565. }
  566. /*
  567. console.log(res.Dry_Input_2)
  568. console.log(res.Dry_Tank_7)
  569. console.log(res.Dry_Tank_8)
  570. console.log(res.Dry_Tank_9)
  571. console.log(res.Dry_Tank_10)
  572. console.log(res.Dry_Tank_11)
  573. console.log(res.Dry_Tank_12)
  574. console.log(res.Dry_Output_1)
  575. console.log(res.Dry_Output_2)
  576. */
  577. }, 'json');
  578. // console.log("-- 自動化程式 end --")
  579. }
  580. </script>
  581. </div>
  582. <div id="coffee_footer">
  583. <!-- 匯入共同使用的 footer.html 內容 -->
  584. {% include 'footer.html' %}
  585. </div>
  586. </div>
  587. </body>
  588. </html>