ferment_container_input.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  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_input_page").text('發酵貨櫃入料儲豆槽 FI' + ftn + ' 攝影機畫面 ')
  25. $('#ferment_input_page').attr("href", "/camera_FI" + ftn)
  26. $("#ferment_input_title").text('發酵貨櫃入料儲豆槽 FI' + ftn + ' 操作介面')
  27. $("#coffee_title").text('FI' + ftn + ' 發酵入料儲豆槽操作介面');
  28. if (status == 2) {
  29. $('input').prop('disabled', true);
  30. $('button').prop('disabled', true);
  31. } else if ( (status == 0) || (status == 1) ) {
  32. $('input').prop('disabled', false);
  33. $('button').prop('disabled', false);
  34. }
  35. });
  36. WebUpdate_set = setInterval(function(){WebUpdate(ftn)} , 10 * 1000)
  37. </script>
  38. <style>
  39. .footer{
  40. position: absolute;
  41. width: 100%;
  42. background-color: #eee;
  43. text-align: center;
  44. }
  45. body {
  46. margin: 0;
  47. }
  48. input[type="button"] {
  49. padding: 4px 15px;
  50. background: #f3f3f3;
  51. border: 0 none;
  52. cursor: pointer;
  53. -webkit-border-radius: 5px;
  54. border-radius: 5px;
  55. }
  56. .navbar-dark .navbar-nav .nav-link {
  57. color: white;
  58. cursor: pointer;
  59. text-decoration: none;
  60. width: 110px;
  61. height: 46px;
  62. }
  63. .nav-top {
  64. line-height: 40px;
  65. background-color: #C4C4C4;
  66. }
  67. .website_title {
  68. font-family: Roboto;
  69. font-style: normal;
  70. font-weight: normal;
  71. font-size: 30px;
  72. color: #000000;
  73. }
  74. .navbar-nav>li {
  75. float: none;
  76. display: inline-block;
  77. width: 100px;
  78. margin: 0 auto;
  79. text-align: center;
  80. }
  81. .navbar-nav>li a {
  82. font-size: 20px;
  83. }
  84. .main-page {
  85. margin-top: 200px;
  86. }
  87. .page-title {
  88. font-family: Roboto;
  89. font-style: normal;
  90. font-weight: bold;
  91. font-size: 36px;
  92. }
  93. .flex {
  94. display: flex;
  95. flex-direction: row;
  96. flex-wrap: wrap;
  97. justify-content: center;
  98. }
  99. .set-link {
  100. display: inline-block;
  101. width: 350px;
  102. height: 100px;
  103. line-height: 100px;
  104. background: #008CBA;
  105. border: 1px solid #CFCFCF;
  106. box-sizing: border-box;
  107. color: #FFFFFF;
  108. border-radius: 10px;
  109. font-size: 36px;
  110. }
  111. .cmn-toggle {
  112. position: absolute;
  113. margin-left: 0px;
  114. visibility: hidden;
  115. }
  116. .cmn-toggle+label {
  117. display: block;
  118. position: relative;
  119. cursor: pointer;
  120. outline: none;
  121. user-select: none;
  122. }
  123. input.cmn-toggle-round-flat+label {
  124. padding: 2px;
  125. width: 60px;
  126. height: 30px;
  127. background-color: #C0C0C0;
  128. border-radius: 60px;
  129. transition: background 0.4s;
  130. }
  131. input.cmn-toggle-round-flat+label:before,
  132. input.cmn-toggle-round-flat+label:after {
  133. display: block;
  134. position: absolute;
  135. content: "";
  136. }
  137. input.cmn-toggle-round-flat+label:before {
  138. top: 2px;
  139. left: 2px;
  140. bottom: 2px;
  141. right: 2px;
  142. background-color: #fff;
  143. border-radius: 60px;
  144. transition: background 0.4s;
  145. }
  146. input.cmn-toggle-round-flat+label:after {
  147. top: 4px;
  148. left: 4px;
  149. bottom: 4px;
  150. width: 24px;
  151. background-color: #dddddd;
  152. border-radius: 52px;
  153. transition: margin 0.4s, background 0.4s;
  154. }
  155. input.cmn-toggle-round-flat:checked+label {
  156. background-color: #C0C0C0;
  157. }
  158. input.cmn-toggle-round-flat:checked+label:after {
  159. margin-left: 27px;
  160. background-color: #008CBA;
  161. }
  162. @media(max-width:373px) {
  163. .card {
  164. margin-right: 0px;
  165. }
  166. .set-link {
  167. width: 250px;
  168. }
  169. }
  170. @media(max-width:577px) {}
  171. @media(min-width:576px) {}
  172. @media(min-width:768px) {
  173. .navbar-nav>li {
  174. margin-left: 0px;
  175. }
  176. .navbar-nav .li-block {
  177. display: none;
  178. }
  179. }
  180. @media(min-width:991px) {
  181. .navbar-nav>li {
  182. margin-left: 20px;
  183. }
  184. .navbar-nav .li-block {
  185. display: none;
  186. }
  187. }
  188. @media(min-width:1200px) {
  189. .navbar-nav>li {
  190. margin-left: 50px;
  191. }
  192. .navbar-nav .li-block {
  193. display: inline-block;
  194. width: 100px;
  195. }
  196. }
  197. @media(min-width:1400px) {
  198. .navbar-nav .li-block {
  199. display: inline-block;
  200. width: 200px;
  201. }
  202. }
  203. @media(min-width:1689px) {
  204. .navbar-nav>li {
  205. margin-left: 50px;
  206. }
  207. .navbar-nav .li-block {
  208. display: inline-block;
  209. width: 500px;
  210. }
  211. }
  212. </style>
  213. <script>
  214. // 發酵槽_制動器控制
  215. var tank_num = '{{tid}}';
  216. function inputVacuum() {
  217. var status = "off";
  218. var check = $("input[name=input_vacuum_status]:checked"); // 這裡面是 jQuery 撈取資料的方法, jQuery 常使用到 $ 錢字號
  219. console.log('check:', check);
  220. //大於0代表有被選中, 如果有多個可以呈現勾取的項目數量
  221. if (check.length > 0) {
  222. status = "on";
  223. $("#cmn-toggle-02").prop('checked', false); // 確認是否勾選
  224. if (!confirm("你確定要開啟入料儲豆槽真空吸料機嗎?")) {
  225. return false;
  226. };
  227. } else {
  228. $("#cmn-toggle-02").prop('checked', true);
  229. if (!confirm("你確定要關閉入料儲豆槽真空吸料機嗎?")) {
  230. return false;
  231. };
  232. };
  233. var data = { "tank_num": "FI" + tank_num, "command": "input_vacuum_status", "value": status };
  234. // jquery 請求 '/mqtt/{{tid}}' 頁面
  235. $.post('/mqtt/{{tid}}', data, function (res) { //res:HTTP response argument to the middleware function
  236. console.log('data:', data)
  237. if (res == 'on') {
  238. $("#cmn-toggle-02").prop('checked', true);
  239. setTimeout("alert('入料儲豆槽真空吸料機_開啟成功!')", 500);
  240. } else if (res == 'off') {
  241. $("#cmn-toggle-02").prop('checked', false);
  242. setTimeout("alert('入料儲豆槽真空吸料機_關閉成功!')", 500);
  243. } else {
  244. alert(res);
  245. };
  246. }, 'text')
  247. };
  248. function inputVacuum_ON() {
  249. var data = { "tank_num": "FI" + tank_num, "command": "input_vacuum_status", "value": "on" };
  250. // jquery 請求 '/mqtt/{{tid}}' 頁面
  251. $.post('/mqtt/{{tid}}', data, function (res) { //res:HTTP response argument to the middleware function
  252. console.log('data:', data)
  253. if (res == 'on') {
  254. $("#cmn-toggle-02").prop('checked', true);
  255. } else if (res == 'off') {
  256. $("#cmn-toggle-02").prop('checked', false);
  257. } else {
  258. };
  259. }, 'text')
  260. };
  261. function inputVacuum_OFF() {
  262. var data = { "tank_num": "FI" + tank_num, "command": "input_vacuum_status", "value": "off" };
  263. // jquery 請求 '/mqtt/{{tid}}' 頁面
  264. $.post('/mqtt/{{tid}}', data, function (res) { //res:HTTP response argument to the middleware function
  265. console.log('data:', data)
  266. if (res == 'on') {
  267. $("#cmn-toggle-02").prop('checked', true);
  268. } else if (res == 'off') {
  269. $("#cmn-toggle-02").prop('checked', false);
  270. } else {
  271. };
  272. }, 'text')
  273. };
  274. </script>
  275. </head>
  276. <body>
  277. <div id="wrapper">
  278. <div id="coffee_header">
  279. <!-- 匯入共同使用的 header.html 內容 -->
  280. {% include 'header.html' %}
  281. </div>
  282. <!--
  283. <div style="text-align: left;">
  284. <a href="/ferment" style="float: left;">&nbsp;&nbsp;&nbsp;返回發酵貨櫃首頁</a>
  285. </div>
  286. <div style="text-align: right;">
  287. <a id="ferment_input_page" href="/index_new" style="float: right;">___________________</a>
  288. </div>
  289. <div id="ferment_input_title" style="text-align: center; margin-top: 30px; font-size: 24px; margin-bottom: 15px;">
  290. 發酵貨櫃入料儲豆槽 FI 操作介面
  291. </div>
  292. -->
  293. 狀態更新時間(秒)
  294. <input name="webupdate_time" type="text" value="60" style="width:100px;">
  295. <input type="button" value="設定更新時間" onclick="changeUpdate()">
  296. <script language="JavaScript">
  297. function changeUpdate() {
  298. clearInterval(WebUpdate_set);
  299. var webupdate_time = $("input[name=webupdate_time]").val()
  300. console.log('webupdate_time' + webupdate_time)
  301. WebUpdate_set = setInterval(function(){WebUpdate(ftn)} , webupdate_time * 1000);
  302. }
  303. // jQuery 更新感測器制動器狀態
  304. function WebUpdate(ftn) {
  305. $.get('/loading/FI' + ftn, '', function (res) {
  306. if (res.input_vacuum == 0) {
  307. $("#cmn-toggle-02").prop('checked', false);
  308. } else if (res.input_vacuum == 1) {
  309. $("#cmn-toggle-02").prop('checked', true);}
  310. $("#UltraSonic_t_status").text(res.input_UltraSonic);
  311. }, 'json');
  312. }
  313. </script>
  314. <h4>制動器</h4>
  315. <table border="1" style="font-size:18px; border:2px #cccccc solid; margin-left: 2px; margin-right: 2px;" width=98%>
  316. <tr>
  317. <td style="color:red;">Valve</td>
  318. <td>真空吸料機</td>
  319. </tr>
  320. <tr>
  321. <td>
  322. <span style="color:#C0C0C0;">off</span>
  323. <span style="color:#008CBA;">on</span>
  324. </td>
  325. <td>
  326. <div class="switch_div">
  327. <div class="switch">
  328. <input id="cmn-toggle-01" class="cmn-toggle cmn-toggle-round" type="checkbox">
  329. <label for="cmn-toggle-01"></label>
  330. </div>
  331. <div class="switch text-center">
  332. {% if input_vacuum == 1 %}
  333. <input id="cmn-toggle-02" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  334. name="tank_vacuum_status" value="ON" onclick="inputVacuum()">
  335. {% else %}
  336. <input id="cmn-toggle-02" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  337. name="tank_vacuum_status" value="OFF" onclick="inputVacuum()">
  338. {% endif %}
  339. <label for="cmn-toggle-02"></label>
  340. </div>
  341. <div class="switch">
  342. <input id="cmn-toggle-03" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  343. <label for="cmn-toggle-03" data-on="Yes" data-off="No"></label>
  344. </div>
  345. </div>
  346. </td>
  347. </tr>
  348. <tr>
  349. <td><span style="color:#008CBA;"><b>ON</b></span></td>
  350. <td><input type="button" value="ON" name="input_vacuum_ON" onclick="inputVacuum_ON()"></td>
  351. </tr>
  352. <tr>
  353. <td><span style="color:#C0C0C0;"><b>OFF</b></span></td>
  354. <td><input type="button" value="OFF" name="input_vacuum_OFF" onclick="inputVacuum_OFF()"></td>
  355. </tr>
  356. </table>
  357. <br>
  358. <h4>感測器</h4>
  359. <table border="1" style="font-size:18px; border:2px #cccccc solid; margin-left: 2px; margin-right: 2px;" cellpadding="10" width=98%>
  360. <tr>
  361. <td>[入料] 生豆高度:<span id="UltraSonic_t_status">{{input_UltraSonic.UltraSonic}}</span> 公分</td>
  362. </tr>
  363. </table>
  364. <br>
  365. <h4>排程設計</h4>
  366. <table border="1" style="font-size:18px; border:2px #cccccc solid; margin-left: 2px; margin-right: 2px;" width=98%>
  367. <tr>
  368. <td>入料</td>
  369. <td>循環測試</td>
  370. </tr>
  371. <tr>
  372. <td>
  373. 指定桶內生豆高度
  374. <input name="testing_BeanIn_Height" type="text" value="0" style="width: 40px;">公分<br>
  375. 吸料時間
  376. <input name="testing_in_vacuum_in" type="text" value="1" style="width: 40px;">秒<br>
  377. 放料時間
  378. <input name="testing_in_vacuum_out" type="text" value="10" style="width: 40px;">秒<br>
  379. 循環次數
  380. <input name="testing_in_vacuum_loop" type="text" value="3" style="width: 40px;">次<br>
  381. </td>
  382. <td>
  383. ON (開) &nbsp;
  384. <input name="Testing_starttime" value="3" type="text" style="width: 40px;">秒<br>
  385. OFF (關) &nbsp;
  386. <input name="Testing_endtime" value="5" type="text" style="width: 40px;">秒<br>
  387. 循環
  388. <input name="Testing_loop" value="3" type="text" style="width: 40px;">次
  389. </td>
  390. </tr>
  391. <tr>
  392. <td>
  393. <button type="submit" class="btn btn-primary" onclick="CoffeeIn_testing()">入豆測試</button>
  394. <script>
  395. CoffeeIn_Process = 0; // 生豆入豆狀態
  396. function CoffeeIn_testing() {
  397. var testing_tank_coffee_height = $("input[name=testing_tank_coffee_height]").val();
  398. console.log('目標入料高度' + testing_tank_coffee_height)
  399. var testing_tank_vacuum_in = $("input[name=testing_tank_vacuum_in]").val();
  400. var testing_tank_vacuum_out = $("input[name=testing_tank_vacuum_out]").val();
  401. var testing_tank_vacuum_loop = $("input[name=testing_tank_vacuum_loop]").val();
  402. if (testing_tank_coffee_height != 0) {
  403. console.log('以目標高度入豆')
  404. var Coffee_interval = setInterval(tankCoffeeHeight, 5000);
  405. function tankCoffeeHeight(){
  406. if (CoffeeIn_Process == 1){
  407. return;
  408. }
  409. CoffeeIn_Process = 1;
  410. $.ajax({
  411. async:false,
  412. type:'GET',
  413. url:'/ferment_LiDAR_' + tank_num,
  414. dataType:'JSON',
  415. success:function(response){
  416. var present_Coffee_height = response.LiDAR
  417. console.log("目前生豆高度: ", present_Coffee_height)
  418. if( present_Coffee_height >= testing_tank_coffee_height){
  419. clearInterval(Coffee_interval);
  420. console.log("生豆已達目標高度!")
  421. CoffeeIn_Process = 0;
  422. } else {
  423. inputVacuum_ON()
  424. console.log('inputVacuum_ON')
  425. var time = new Date();
  426. while ((new Date() - time) < testing_tank_vacuum_in * 1000) { };
  427. inputVacuum_OFF()
  428. console.log('inputVacuum_OFF')
  429. var time = new Date();
  430. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  431. CoffeeIn_Process = 0;
  432. }
  433. },
  434. error:function(thrownError){
  435. console.log("Error: " + thrownError)
  436. CoffeeIn_Process = 0;
  437. }
  438. });
  439. CoffeeIn_Process = 0;
  440. };
  441. } else if (testing_tank_coffee_height == 0){
  442. console.log('開始循環入豆')
  443. for (step = 1; step <= testing_tank_vacuum_loop; step++) {
  444. console.log('-- 循環第 ' + step + ' 次 --');
  445. inputVacuum_ON()
  446. console.log('inputVacuum_ON')
  447. var time = new Date();
  448. while ((new Date() - time) < testing_tank_vacuum_in * 1000) { };
  449. inputVacuum_OFF()
  450. console.log('inputVacuum_OFF')
  451. var time = new Date();
  452. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  453. }
  454. console.log('-- 循環入豆結束 --')
  455. }
  456. }
  457. </script>
  458. </td>
  459. <td>
  460. <button type="submit" class="btn btn-primary" onclick="tankVacuumTest()">真空吸料機測試(秒)</button><br>
  461. <script>
  462. function tankVacuumTest() {
  463. clearInterval(WebUpdate_set);
  464. var Testing_starttime = $("input[name=Testing_starttime]").val();
  465. var Testing_endtime = $("input[name=Testing_endtime]").val();
  466. var Testing_loop = $("input[name=Testing_loop]").val();
  467. alert('測試間隔' + Testing_starttime + ':' + Testing_endtime + ' 次數' + Testing_loop)
  468. var step;
  469. for (step = 1; step <= Testing_loop; step++) {
  470. console.log('循環第 ' + step + ' 次');
  471. inputVacuum_ON()
  472. console.log('inputVacuum_ON')
  473. var time = new Date();
  474. while ((new Date() - time) < Testing_starttime * 1000) { }
  475. inputVacuum_OFF()
  476. console.log('inputVacuum_OFF')
  477. var time = new Date();
  478. while ((new Date() - time) < Testing_endtime * 1000) { }
  479. }
  480. WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000);
  481. }
  482. </script>
  483. </td>
  484. </tr>
  485. </table>
  486. <br>
  487. <h4>攝影機畫面</h4>
  488. <div class="container-fluid">
  489. <div class="row" style="margin-top:5px;">
  490. <div class="col flex">
  491. <div class="col-md-12 row flex" style="text-align:center;margin-top:5px;">
  492. <div class="col-md-12 row flex">
  493. <img src="" id="two" width="80%" height="80%">
  494. </div>
  495. </div>
  496. <script>
  497. // M5 攝影機
  498. //const img = document.querySelector('#one');
  499. const img1 = document.querySelector('#two');
  500. const WS_URL1 = 'ws:///60.250.156.230:8089';
  501. const ws1 = new WebSocket(WS_URL1);
  502. let urlObject1;
  503. ws1.onopen = () => console.log(`Connected to ${WS_URL1}`);
  504. ws1.onmessage = message1 => {
  505. const arrayBuffer1 = message1.data;
  506. if (urlObject1) {
  507. URL.revokeObjectURL(urlObject1);
  508. }
  509. urlObject1 = URL.createObjectURL(new Blob([arrayBuffer1]));
  510. img1.src = urlObject1;
  511. }
  512. </script>
  513. </div>
  514. </div>
  515. </div>
  516. <br>
  517. <br>
  518. <!--
  519. <footer class="footer">
  520. <div style="text-align: center; margin-top: 10px; font-size: 13px; margin-bottom: 10px;">
  521. Copyright © 2021 Gold-in Tech. All Rights Reserved. 金子進科技股份有限公司 版權所有
  522. <a href="mailto:service.gitc@gmail.com" target="_blank">service.gitc@gmail.com</a>
  523. </div>
  524. </footer>
  525. -->
  526. <div id="coffee_footer">
  527. <!-- 匯入共同使用的 footer.html 內容 -->
  528. {% include 'footer.html' %}
  529. </div>
  530. </div>
  531. </body>
  532. </html>