1
0

dry_container_output.html 16 KB

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