ferment_container_output.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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="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 ftn = '{{tid}}';
  21. var status = '{{status}}';
  22. console.log('ftn:' + ftn)
  23. $(function(){
  24. $("#ferment_output_page").text('發酵貨櫃出料儲豆槽 FO' + ftn + ' 攝影機畫面 ')
  25. $('#ferment_output_page').attr("href", "/camera_FO" + ftn)
  26. $("#ferment_container_output_title").text('發酵貨櫃出料儲豆槽 FO' + ftn + ' 操作介面')
  27. $("#coffee_title_pc").text('FO' + ftn + ' 發酵出料儲豆槽操作介面');
  28. $("#coffee_title_phone").text('FO' + ftn + ' 操作介面');
  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(ftn)} , 10 * 1000)
  38. </script>
  39. <script>
  40. // 發酵槽_制動器控制
  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": "FO" + 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(params){
  73. if (params == '1') {
  74. var data = { "tank_num": "DO" + tank_num, "command": "output_vacuum_status", "value": "on" };
  75. } else if (params == '0') {
  76. var data = { "tank_num": "DO" + tank_num, "command": "output_vacuum_status", "value": "off" };
  77. } else {
  78. var data = { "tank_num": "DO" + tank_num, "command": "output_vacuum_status", "value": params };
  79. }
  80. $.post('/mqtt/{{tid}}', data, function (res) {
  81. if (res == 'on') {
  82. $("#cmn-toggle-32").prop('checked', true);
  83. } else if (res == 'off') {
  84. $("#cmn-toggle-32").prop('checked', false);
  85. } else {
  86. console.log('res error')
  87. };
  88. }, 'text')
  89. }
  90. function tankDiskValve(params) {
  91. if (params == '1') {
  92. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "on" };
  93. } else if (params == '0') {
  94. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "off" };
  95. } else {
  96. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": params };
  97. }
  98. $.post('/mqtt/{{tid}}', data, function (res) {
  99. console.log('data:', data)
  100. if (res == 'on') {
  101. $("#cmn-toggle-11").prop('checked', true);
  102. } else if (res == 'off') {
  103. $("#cmn-toggle-11").prop('checked', false);
  104. } else {
  105. };
  106. }, 'text')
  107. }
  108. </script>
  109. <script language="JavaScript">
  110. function changeUpdate() {
  111. clearInterval(WebUpdate_set);
  112. var webupdate_time = $("input[name=webupdate_time]").val()
  113. console.log('webupdate_time' + webupdate_time)
  114. WebUpdate_set = setInterval(function(){WebUpdate(ftn)} , webupdate_time * 1000);
  115. }
  116. // jQuery 更新感測器制動器狀態
  117. function WebUpdate(ftn) {
  118. $.get('/loading/FO' + ftn, '', function (res) {
  119. $("#LiDAR_t_status").text(res.LiDAR);
  120. }, 'json');
  121. }
  122. </script>
  123. </head>
  124. <body>
  125. <div id="wrapper">
  126. <div id="coffee_header">
  127. <!-- 匯入共同使用的 header.html 內容 -->
  128. {% include 'header.html' %}
  129. </div>
  130. <h4>制動器</h4>
  131. <table border="1" class="table-all" cellpadding="3" style="text-align: center;">
  132. <tr>
  133. <td style="color:red;">Valve</td>
  134. <td>真空吸料機</td>
  135. </tr>
  136. <tr>
  137. <td>
  138. <span style="color:#C0C0C0;">off</span>
  139. <span style="color:#008CBA;">on</span>
  140. </td>
  141. <td>
  142. <div class="switch_div">
  143. <div class="switch">
  144. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-31">
  145. </div>
  146. <div class="switch text-center">
  147. {% if output_vacuum == 1 %}
  148. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-32" checked
  149. name="output_vacuum_status" value="ON" onclick="outputVacuum()">
  150. {% else %}
  151. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-32"
  152. name="output_vacuum_status" value="OFF" onclick="outputVacuum()">
  153. {% endif %}
  154. <label class="label_ActuatorStatus" for="cmn-toggle-32"></label>
  155. </div>
  156. <div class="switch">
  157. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-33">
  158. </div>
  159. </div>
  160. </td>
  161. </tr>
  162. <tr>
  163. <td><span style="color:#008CBA;"><b>ON</b></span></td>
  164. <td><input type="button" class="input-button-on" value="ON" onclick="outputVacuum('1')"></td>
  165. </tr>
  166. <tr>
  167. <td><span style="color:#C0C0C0;"><b>OFF</b></span></td>
  168. <td><input type="button" class="input-button-off" value="OFF" onclick="outputVacuum('0')"></td>
  169. </tr>
  170. </table>
  171. <br>
  172. <h4>感測器</h4>
  173. <table border="1" class="table-all" cellpadding="3">
  174. <tr>
  175. <td>[出料儲豆槽] 生豆高度:<span id="UltraSonic_t_status">{{output_UltraSonic.UltraSonic}}</span> 公分</td>
  176. </tr>
  177. </table>
  178. <br>
  179. <h4>排程設計</h4>
  180. <table border="1" class="table-all" cellpadding="3">
  181. <tr>
  182. <td>入料</td>
  183. <td>循環測試</td>
  184. </tr>
  185. <tr>
  186. <td>
  187. <!--
  188. [桶內 F1] 生豆高度:&nbsp;<span id="LiDAR_t_status">{{tank_LiDAR.LiDAR}}</span>&nbsp;公分<br>
  189. 指定空桶高度
  190. <input name="testing_tank_empty_height" id="testing_tank_empty_height" type="text" value="0" style="width: 40px;">公分<br>
  191. 蝴蝶閥 ON
  192. <br>
  193. -->
  194. 生豆高度
  195. <input type="text" class="input-text" name="testing_BeanIn_Height" value="0">公分<br>
  196. 吸料
  197. <input type="text" class="input-text" name="testing_out_vacuum_in" value="1">秒<br>
  198. 放料(>10)
  199. <input type="text" class="input-text" name="testing_out_vacuum_out" value="10">秒<br>
  200. 循環次數
  201. <input type="text" class="input-text" name="testing_out_vacuum_loop" value="3">次
  202. </td>
  203. <td>
  204. ON (開)
  205. <input type="text" class="input-text" name="Testing_starttime" value="3">秒<br>
  206. OFF (關)
  207. <input type="text" class="input-text" name="Testing_endtime" value="5">秒<br>
  208. 循環
  209. <input type="text" class="input-text" name="Testing_loop" value="3">次
  210. </td>
  211. </tr>
  212. <tr>
  213. <td>
  214. <button type="submit" class="btn btn-primary" onclick="CoffeeOut_testing()">排水出豆</button>
  215. <script>
  216. var CoffeeOut_process = 0;
  217. function CoffeeOut_testing() {
  218. var testing_BeanIn_Height = $("input[name=testing_BeanIn_Height]").val();
  219. var testing_out_vacuum_in = $("input[name=testing_out_vacuum_in]").val();
  220. var testing_out_vacuum_out = $("input[name=testing_out_vacuum_out]").val();
  221. var testing_out_vacuum_loop = $("input[name=testing_out_vacuum_loop]").val();
  222. if (testing_BeanIn_Height != 0){
  223. console.log('指定高度 ' + testing_BeanIn_Height + ' 入豆')
  224. $.get('/ferment_LiDAR_' + tank_num, '', function (res) {
  225. if ( parseInt(res.LiDAR) > parseInt(testing_BeanIn_Height) ){
  226. tankDiskValve('1')
  227. console.log('tankDiskValve_ON')
  228. };
  229. }, 'json');
  230. var CoffeeOut_interval = setInterval(tankEmptyHeight, 5000);
  231. function tankEmptyHeight(){
  232. if (CoffeeOut_process == 1) {
  233. return;
  234. }
  235. CoffeeOut_process = 1 ;
  236. $.ajax({
  237. type:"GET",
  238. url:"/ferment_LiDAR_" + tank_num,
  239. dataType:"json",
  240. success:function (response) {
  241. var present_Coffee_height = response.LiDAR
  242. console.log("目前桶內生豆高度: ", present_Coffee_height)
  243. console.log("指定空桶生豆高度: ", testing_BeanIn_Height)
  244. if( parseInt(present_Coffee_height) < parseInt(testing_BeanIn_Height)){
  245. clearInterval(CoffeeOut_interval);
  246. console.log("桶內已淨空!")
  247. CoffeeOut_process = 0;
  248. } else {
  249. outputVacuum('1');
  250. console.log('outputVacuum_ON')
  251. var time = new Date();
  252. while ((new Date() - time) < testing_out_vacuum_in * 1000) { };
  253. outputVacuum('0')
  254. console.log('outputVacuum_OFF')
  255. var time = new Date();
  256. while ((new Date() - time) < testing_out_vacuum_out * 1000) { };
  257. CoffeeOut_process = 0;
  258. }
  259. },
  260. error:function(thrownError){
  261. console.log("Error: " + thrownError)
  262. CoffeeIn_Process = 0;
  263. }
  264. })
  265. }
  266. tankDiskValve('0')
  267. console.log('tankDiskValve_OFF')
  268. } else if ( testing_BeanIn_Height == 0){
  269. console.log('循環方式入豆')
  270. tankDiskValve('1')
  271. console.log('tankDiskValve_ON')
  272. for (step = 1; step <= testing_out_vacuum_loop; step++) {
  273. console.log('-- 循環第 ' + step + ' 次 --')
  274. outputVacuum('1');
  275. console.log('outputVacuum_ON')
  276. var time = new Date();
  277. while ((new Date() - time) < testing_out_vacuum_in * 1000) { };
  278. if (step == 1) {
  279. tankDiskValve('1');
  280. console.log('tankDiskValve_ON')
  281. var time = new Date();
  282. while ((new Date() - time) < testing_out_vacuum_in * 1000) { };
  283. }
  284. outputVacuum('0');
  285. console.log('outputVacuum_OFF')
  286. var time = new Date();
  287. while ((new Date() - time) < testing_out_vacuum_out * 1000) { };
  288. }
  289. tankDiskValve('0');
  290. console.log('tankDiskValve_OFF')
  291. };
  292. };
  293. </script>
  294. </td>
  295. <td>
  296. <button type="submit" class="btn btn-primary" onclick="tankVacuumTest()">真空吸料機測試(秒)</button><br>
  297. <script>
  298. function tankVacuumTest() {
  299. clearInterval(WebUpdate_set);
  300. var Testing_starttime = $("input[name=Testing_starttime]").val();
  301. var Testing_endtime = $("input[name=Testing_endtime]").val();
  302. var Testing_loop = $("input[name=Testing_loop]").val();
  303. alert('測試間隔' + Testing_starttime + ':' + Testing_endtime + ' 次數' + Testing_loop)
  304. var step;
  305. for (step = 1; step <= Testing_loop; step++) {
  306. console.log('循環第 ' + step + ' 次');
  307. outputVacuum('1')
  308. console.log('outputVacuum_ON')
  309. var time = new Date();
  310. while ((new Date() - time) < Testing_starttime * 1000) { }
  311. outputVacuum('0')
  312. console.log('outputVacuum_OFF')
  313. var time = new Date();
  314. while ((new Date() - time) < Testing_endtime * 1000) { }
  315. }
  316. WebUpdate_set = setInterval(function(){WebUpdate(ftn)} , 10 * 1000);
  317. }
  318. </script>
  319. </td>
  320. </tr>
  321. </table>
  322. <div id="coffee_footer">
  323. <!-- 匯入共同使用的 footer.html 內容 -->
  324. {% include 'footer.html' %}
  325. </div>
  326. </div>
  327. </body>
  328. </html>