1
0

dry_container_output.html 23 KB

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