dry_container_input.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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="300" /><!-- <meta http-equiv="refresh" content="5" /> 每 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. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  18. <script language="JavaScript">
  19. // 指定 秒 刷新網頁一次
  20. var dtn = '{{tid}}';
  21. var status = '{{status}}';
  22. console.log('dtn:' + dtn)
  23. $(function(){
  24. $("#dry_input_page").text('乾燥貨櫃入料儲豆槽 DI' + dtn + ' 攝影機畫面 ')
  25. $('#dry_input_page').attr("href", "/camera_DI" + dtn)
  26. $("#dry_input_title").text('乾燥貨櫃入料儲豆槽 DI' + dtn + ' 操作介面')
  27. $("#coffee_title_pc").text('DI' + dtn + ' 乾燥入料儲豆槽操作介面');
  28. $("#coffee_title_phone").text('DI' + dtn + ' 操作介面');
  29. if (status == 2) {
  30. $('input').prop('disabled', true);
  31. $('button').prop('disabled', true);
  32. } else if ( (status == 0) || (status == 1) ) {
  33. $('input').prop('disabled', false);
  34. $('button').prop('disabled', false);
  35. }
  36. });
  37. WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000)
  38. </script>
  39. <script>
  40. // Rita 制動器運作
  41. var tank_num = '{{tid}}';
  42. // Benson 真空吸料機 (START)入料儲豆槽
  43. function inputVacuum() {
  44. var status = "off";
  45. var check = $("input[name=input_vacuum_status]:checked"); // 這裡面是 jQuery 撈取資料的方法, jQuery 常使用到 $ 錢字號
  46. console.log('check:', check);
  47. //大於0代表有被選中, 如果有多個可以呈現勾取的項目數量
  48. if (check.length > 0) {
  49. status = "on";
  50. $("#cmn-toggle-02").prop('checked', false); // 設定為不要勾選
  51. if (!confirm("你確定要開啟入料儲豆槽真空吸料機嗎?")) {
  52. return false;
  53. };
  54. } else {
  55. $("#cmn-toggle-02").prop('checked', true); // 設定為勾選
  56. if (!confirm("你確定要關閉入料儲豆槽真空吸料機嗎?")) {
  57. return false;
  58. };
  59. };
  60. var data = { "tank_num": "DI" + tank_num, "command": "input_vacuum_status", "value": status };
  61. // jquery 請求 '/mqtt/{{tid}}' 頁面
  62. $.post('/mqtt/{{tid}}', data, function (res) { //res:HTTP response argument to the middleware function
  63. console.log('data:', data)
  64. if (res == 'on') {
  65. $("#cmn-toggle-02").prop('checked', true);
  66. setTimeout("alert('入料儲豆槽真空吸料機_開啟成功!')", 500);
  67. } else if (res == 'off') {
  68. $("#cmn-toggle-02").prop('checked', false);
  69. setTimeout("alert('入料儲豆槽真空吸料機_關閉成功!')", 500);
  70. } else {
  71. alert(res);
  72. };
  73. }, 'text')
  74. };
  75. function inputVacuum(params) {
  76. if (params == '1') {
  77. var data = { "tank_num": "DI" + tank_num, "command": "input_vacuum_status", "value": "on" };
  78. } else if (params == '0') {
  79. var data = { "tank_num": "DI" + tank_num, "command": "input_vacuum_status", "value": "off" };
  80. } else {
  81. var data = { "tank_num": "DI" + tank_num, "command": "input_vacuum_status", "value": params };
  82. }
  83. $.post('/mqtt/{{tid}}', data, function (res) {
  84. console.log('data:', data)
  85. if (res == 'on') {
  86. $("#cmn-toggle-02").prop('checked', true);
  87. } else if (res == 'off') {
  88. $("#cmn-toggle-02").prop('checked', false);
  89. } else {
  90. console.log('res error')
  91. };
  92. }, 'text')
  93. };
  94. // Benson 真空吸料機 (END)入料儲豆槽
  95. </script>
  96. <script language="JavaScript">
  97. function changeUpdate() {
  98. clearInterval(WebUpdate_set);
  99. var webupdate_time = $("input[name=webupdate_time]").val()
  100. console.log('webupdate_time' + webupdate_time)
  101. WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , webupdate_time * 1000);
  102. }
  103. // jQuery 更新感測器制動器狀態
  104. function WebUpdate(dtn) {
  105. $.get('/loading/DI' + dtn, '', function (res) {
  106. if (res.input_vacuum == 0) {
  107. $("#input_vacuum_status").css("background-color", "#C0C0C0")
  108. } else if (res.input_vacuum == 1) {
  109. $("#input_vacuum_status").css("background-color", "forestgreen")
  110. } else { $("#input_vacuum_status").css("background-color", "crimson")
  111. }
  112. $("#UltraSonic_t_status").text(res.input_UltraSonic);
  113. }, 'json');
  114. }
  115. </script>
  116. </head>
  117. <body>
  118. <div id="wrapper">
  119. <div id="coffee_header">
  120. <!-- 匯入共同使用的 header.html 內容 -->
  121. {% include 'header.html' %}
  122. </div>
  123. <h4>制動器</h4>
  124. <table border="1" class="table-all" cellpadding="3" style="text-align: center;">
  125. <tr>
  126. <td style="color:red;">Valve</td>
  127. <td>真空吸料機</td>
  128. </tr>
  129. <tr>
  130. <td>
  131. <span style="color:#C0C0C0;">off</span>
  132. <span style="color:#008CBA;">on</span>
  133. </td>
  134. <td>
  135. <div class="switch_div">
  136. <div class="switch">
  137. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-01">
  138. </div>
  139. <div class="switch text-center">
  140. {% if input_vacuum == 1 %}
  141. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-02" checked
  142. name="input_vacuum_status" value="ON" onclick="inputVacuum()">
  143. {% else %}
  144. <input id="cmn-toggle-02" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  145. name="input_vacuum_status" value="OFF" onclick="inputVacuum()">
  146. {% endif %}
  147. <label class="label_ActuatorStatus" for="cmn-toggle-02"></label>
  148. </div>
  149. <div class="switch">
  150. <input id="cmn-toggle-03" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  151. </div>
  152. </div>
  153. </td>
  154. </tr>
  155. <tr>
  156. <td><span style="color:#008CBA;"><b>ON</b></span></td>
  157. <td><input type="button" class="input-button-on" value="ON" onclick="inputVacuum('1')"></td>
  158. </tr>
  159. <tr>
  160. <td><span style="color:#C0C0C0;"><b>OFF</b></span></td>
  161. <td><input type="button" class="input-button-off" value="OFF" onclick="inputVacuum('0')"></td>
  162. </tr>
  163. </table>
  164. <br>
  165. <h4>感測器</h4>
  166. <table border="1" class="table-all" cellpadding="3">
  167. <tr>
  168. <td colspan="6">[入料儲豆槽] 生豆高度:<span id="UltraSonic_t_status">{{input_UltraSonic.UltraSonic}}</span> 公分</td>
  169. </tr>
  170. </table>
  171. <br>
  172. <h4>排程設計</h4>
  173. <table border="1" class="table-all" cellpadding="3">
  174. <tr>
  175. <td>入料</td>
  176. <td>循環測試</td>
  177. </tr>
  178. <tr>
  179. <td>
  180. 指定桶內生豆高度
  181. <input type="text" class="input-text" name="testing_BeanIn_Height" value="0">公分<br>
  182. 吸料時間
  183. <input type="text" class="input-text" name="testing_in_vacuum_in" value="1">秒<br>
  184. 放料時間
  185. <input type="text" class="input-text" name="testing_in_vacuum_out" value="10">秒<br>
  186. 循環次數
  187. <input type="text" class="input-text" name="testing_in_vacuum_loop" value="3">次<br>
  188. </td>
  189. <td>
  190. ON (開) &nbsp;
  191. <input type="text" class="input-text" name="Testing_starttime" value="3">秒<br>
  192. OFF (關) &nbsp;
  193. <input type="text" class="input-text" name="Testing_endtime" value="5">秒<br>
  194. 循環
  195. <input type="text" class="input-text" name="Testing_loop" value="3">次
  196. </td>
  197. </tr>
  198. <tr>
  199. <td>
  200. <button type="submit" class="btn btn-primary" onclick="BeanInput()">入料測試</button>
  201. <script>
  202. var BeanIn_Process = 0;
  203. var BeanIn_interval;
  204. function BeanInput() {
  205. clearInterval(WebUpdate_set);
  206. var testing_BeanIn_Height = $("input[name=testing_BeanIn_Height]").val();
  207. var testing_in_vacuum_in = $("input[name=testing_in_vacuum_in]").val();
  208. var testing_in_vacuum_out = $("input[name=testing_in_vacuum_out]").val();
  209. var testing_in_vacuum_loop = $("input[name=testing_in_vacuum_loop]").val();
  210. if (testing_BeanIn_Height != 0) {
  211. console.log('以指定高度入豆')
  212. var BeanIn_interval = setInterval(BeanInHeight, 5000);
  213. function BeanInHeight(){
  214. if (BeanIn_Process == 1) {
  215. return;
  216. }
  217. BeanIn_Process == 1;
  218. $.ajax({
  219. async:false,
  220. type:"GET",
  221. url:"/dry_input_UltraSonic_" + tank_num,
  222. dataType:"json",
  223. success:function(response){
  224. var present_Bean_height = response.UltraSonic
  225. console.log('目前生豆高度: ' + present_Bean_height)
  226. if ( parseInt(present_Bean_height) < parseInt(testing_BeanIn_Height) ) {
  227. inputVacuum('1')
  228. console.log('inputVacuum_ON')
  229. var time = new Date();
  230. while ((new Date() - time) < testing_in_vacuum_in * 1000) { };
  231. inputVacuum('0')
  232. console.log('inputVacuum_OFF')
  233. var time = new Date();
  234. while ((new Date() - time) < testing_in_vacuum_out * 1000) { };
  235. } else {
  236. clearInterval(BeanIn_interval)
  237. console.log('生豆已達指定高度!')
  238. }
  239. BeanIn_Process == 0;
  240. },
  241. error:function(thrownError){
  242. console.log('Error: ' + thrownError)
  243. BeanIn_Process = 0;
  244. }
  245. })
  246. };
  247. } else if (testing_BeanIn_Height == 0) {
  248. console.log('以循環次數入豆')
  249. for (step = 1; step <= testing_in_vacuum_loop; step++) {
  250. console.log('-- 循環第 ' + step + ' 次 --');
  251. inputVacuum('1')
  252. console.log('inputVacuum_ON')
  253. var time = new Date();
  254. while ((new Date() - time) < testing_in_vacuum_in * 1000) { };
  255. inputVacuum('0')
  256. console.log('inputVacuum_OFF')
  257. var time = new Date();
  258. while ((new Date() - time) < testing_in_vacuum_out * 1000) { };
  259. }
  260. console.log('循環入豆結束')
  261. }
  262. WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000);
  263. }
  264. </script>
  265. </td>
  266. <td>
  267. <button type="submit" class="btn btn-primary" onclick="tankVacuumTest()">真空吸料機測試(秒)</button><br>
  268. <script>
  269. function tankVacuumTest() {
  270. clearInterval(WebUpdate_set);
  271. var Testing_starttime = $("input[name=Testing_starttime]").val();
  272. var Testing_endtime = $("input[name=Testing_endtime]").val();
  273. var Testing_loop = $("input[name=Testing_loop]").val();
  274. alert('測試間隔' + Testing_starttime + ':' + Testing_endtime + ' 次數' + Testing_loop)
  275. var step;
  276. for (step = 1; step <= Testing_loop; step++) {
  277. console.log('循環第 ' + step + ' 次');
  278. inputVacuum('1')
  279. console.log('inputVacuum_ON')
  280. var time = new Date();
  281. while ((new Date() - time) < Testing_starttime * 1000) { }
  282. inputVacuum('0')
  283. console.log('inputVacuum_OFF')
  284. var time = new Date();
  285. while ((new Date() - time) < Testing_endtime * 1000) { }
  286. }
  287. WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000);
  288. }
  289. </script>
  290. </td>
  291. </tr>
  292. </table>
  293. <div id="coffee_footer">
  294. <!-- 匯入共同使用的 footer.html 內容 -->
  295. {% include 'footer.html' %}
  296. </div>
  297. </div>
  298. </body>
  299. </html>