ctrl_D_Vacuum.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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="60" /> 每 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.60/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. <!-- Rita 乾燥貨櫃 - 入料、桶槽、出料制動器 function-->
  19. <script type="text/javascript" src="../static/js/dry_function.js"></script>
  20. <script language="JavaScript">
  21. // 指定 秒 刷新網頁一次
  22. var tid = '{{tid}}';
  23. console.log('tid:' + tid)
  24. var tank_num = '{{tid}}';
  25. $(function(){
  26. $("#ctrl_D_Vacuum_title").text('乾燥槽 D' + tid + ' 真空吸料機')
  27. $("#dry_tank_page").text('乾燥槽 D' + tid + ' 操作介面 ')
  28. $('#dry_tank_page').attr("href", "/dry_container/" + tid)
  29. $("#coffee_title").text('D' + tid + ' 乾燥槽_真空吸料機');
  30. });
  31. //WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000)
  32. </script>
  33. <style>
  34. .footer{
  35. position: absolute;
  36. width: 100%;
  37. background-color: #eee;
  38. text-align: center;
  39. }
  40. body {
  41. margin: 0;
  42. }
  43. .navbar-dark .navbar-nav .nav-link {
  44. color: white;
  45. cursor: pointer;
  46. text-decoration: none;
  47. width: 110px;
  48. height: 46px;
  49. }
  50. .nav-top {
  51. line-height: 40px;
  52. background-color: #C4C4C4;
  53. }
  54. .website_title {
  55. font-family: Roboto;
  56. font-style: normal;
  57. font-weight: normal;
  58. font-size: 30px;
  59. color: #000000;
  60. }
  61. .navbar-nav>li {
  62. float: none;
  63. display: inline-block;
  64. width: 100px;
  65. margin: 0 auto;
  66. text-align: center;
  67. }
  68. .navbar-nav>li a {
  69. font-size: 20px;
  70. }
  71. .main-page {
  72. margin-top: 200px;
  73. }
  74. .page-title {
  75. font-family: Roboto;
  76. font-style: normal;
  77. font-weight: bold;
  78. font-size: 36px;
  79. }
  80. .flex {
  81. display: flex;
  82. flex-direction: row;
  83. flex-wrap: wrap;
  84. justify-content: center;
  85. }
  86. .set-link {
  87. display: inline-block;
  88. width: 350px;
  89. height: 100px;
  90. line-height: 100px;
  91. background: #008CBA;
  92. border: 1px solid #CFCFCF;
  93. box-sizing: border-box;
  94. color: #FFFFFF;
  95. border-radius: 10px;
  96. font-size: 36px;
  97. }
  98. .cmn-toggle {
  99. position: absolute;
  100. margin-left: 0px;
  101. visibility: hidden;
  102. }
  103. .cmn-toggle+label {
  104. display: block;
  105. position: relative;
  106. cursor: pointer;
  107. outline: none;
  108. user-select: none;
  109. }
  110. input.cmn-toggle-round-flat+label {
  111. padding: 2px;
  112. width: 60px;
  113. height: 30px;
  114. background-color: #C0C0C0;
  115. border-radius: 60px;
  116. transition: background 0.4s;
  117. }
  118. input.cmn-toggle-round-flat+label:before,
  119. input.cmn-toggle-round-flat+label:after {
  120. display: block;
  121. position: absolute;
  122. content: "";
  123. }
  124. input.cmn-toggle-round-flat+label:before {
  125. top: 2px;
  126. left: 2px;
  127. bottom: 2px;
  128. right: 2px;
  129. background-color: #fff;
  130. border-radius: 60px;
  131. transition: background 0.4s;
  132. }
  133. input.cmn-toggle-round-flat+label:after {
  134. top: 4px;
  135. left: 4px;
  136. bottom: 4px;
  137. width: 24px;
  138. background-color: #dddddd;
  139. border-radius: 52px;
  140. transition: margin 0.4s, background 0.4s;
  141. }
  142. input.cmn-toggle-round-flat:checked+label {
  143. background-color: #C0C0C0;
  144. }
  145. input.cmn-toggle-round-flat:checked+label:after {
  146. margin-left: 27px;
  147. background-color: #008CBA;
  148. }
  149. @media(max-width:373px) {
  150. .card {
  151. margin-right: 0px;
  152. }
  153. .set-link {
  154. width: 250px;
  155. }
  156. }
  157. @media(max-width:577px) {}
  158. @media(min-width:576px) {}
  159. @media(min-width:768px) {
  160. .navbar-nav>li {
  161. margin-left: 0px;
  162. }
  163. .navbar-nav .li-block {
  164. display: none;
  165. }
  166. }
  167. @media(min-width:991px) {
  168. .navbar-nav>li {
  169. margin-left: 20px;
  170. }
  171. .navbar-nav .li-block {
  172. display: none;
  173. }
  174. }
  175. @media(min-width:1200px) {
  176. .navbar-nav>li {
  177. margin-left: 50px;
  178. }
  179. .navbar-nav .li-block {
  180. display: inline-block;
  181. width: 100px;
  182. }
  183. }
  184. @media(min-width:1400px) {
  185. .navbar-nav .li-block {
  186. display: inline-block;
  187. width: 200px;
  188. }
  189. }
  190. @media(min-width:1689px) {
  191. .navbar-nav>li {
  192. margin-left: 50px;
  193. }
  194. .navbar-nav .li-block {
  195. display: inline-block;
  196. width: 500px;
  197. }
  198. }
  199. </style>
  200. </head>
  201. <body>
  202. <div id="wrapper">
  203. <div id="coffee_header">
  204. <!-- 匯入共同使用的 header.html 內容 -->
  205. {% include 'header.html' %}
  206. </div>
  207. <!--
  208. <div style="text-align: left;">
  209. <a href="/dry" style="float: left;">&nbsp;&nbsp;&nbsp;返回乾燥貨櫃首頁</a>
  210. </div>
  211. <div style="text-align: right;">
  212. <a id="dry_tank_page" href="/index_new" style="float: right;">___________________</a>
  213. </div>
  214. <div id="ctrl_D_Vacuum_title" style="text-align: center; margin-top: 30px; font-size: 24px; margin-bottom: 15px;">
  215. 乾燥槽 D_ 真空吸料機
  216. </div>
  217. -->
  218. <table border="1" style="margin: auto; font-size:18px; border:2px #cccccc solid;" width=700px cellpadding="8">
  219. <tr>
  220. <!--
  221. <td rowspan="3">
  222. 手動控制
  223. </td>
  224. -->
  225. <td>
  226. 真空吸料機 狀態
  227. </td>
  228. <td>
  229. {% if tank_vacuum == 1 %}
  230. <span style="color:#008CBA; font-size:18px;"><strong>ON</strong></span>
  231. {% elif tank_vacuum == 0 %}
  232. <span style="color:#acacac; font-size:18px;"><strong>OFF</strong></span>
  233. {% else %}
  234. <span style="color: #fc7373;; font-size:18px;">ERROR</span>
  235. {% endif %}
  236. </td>
  237. </tr>
  238. <tr>
  239. <td>開啟 真空吸料機</td>
  240. <td><input type="button" value="ON" onclick="tankVacuum_ON()"></td>
  241. </tr>
  242. <tr>
  243. <td>關閉 真空吸料機</td>
  244. <td><input type="button" value="OFF" onclick="tankVacuum_OFF()"></td>
  245. </tr>
  246. </table>
  247. <br>
  248. <table border="1" style="margin: auto; font-size:18px; border:2px #cccccc solid;" width=700px cellpadding="8">
  249. <tr>
  250. <td colspan="3">
  251. [桶內] 生豆高度:<span id="UltraSonic_t_status">{{UltraSonic}}</span> 公分<br>
  252. </td>
  253. </tr>
  254. <tr>
  255. <!--
  256. <td rowspan="2">
  257. 排程控制
  258. </td>
  259. -->
  260. <td>
  261. 指定高度入料
  262. </td>
  263. <td>
  264. 桶內生豆入料高度&nbsp;
  265. <input name="testing_BeanIn_Height" type="text" value="0" style="width: 40px;">&nbsp;公分<br>
  266. 吸料時間&nbsp;
  267. <input name="testing_in_vacuum_in" type="text" value="1" style="width: 40px;">&nbsp;秒<br>
  268. 放料時間&nbsp;
  269. <input name="testing_in_vacuum_out" type="text" value="10" style="width: 40px;">&nbsp;秒<br>
  270. <span id="testing_in_vacuum_loop" style="color: #f00;"></span>
  271. </td>
  272. <td>
  273. <button type="submit" class="btn btn-primary" onclick="BeanInput()">指定高度入料</button>
  274. <script>
  275. var BeanIn_Process = 0;
  276. var BeanIn_interval;
  277. function BeanInput() {
  278. // clearInterval(WebUpdate_set);
  279. var testing_BeanIn_Height = $("input[name=testing_BeanIn_Height]").val();
  280. var testing_in_vacuum_in = $("input[name=testing_in_vacuum_in]").val();
  281. var testing_in_vacuum_out = $("input[name=testing_in_vacuum_out]").val();
  282. if (testing_BeanIn_Height != 0) {
  283. console.log('以指定高度 ' + testing_BeanIn_Height + ' 入豆')
  284. var BeanIn_interval = setInterval(BeanInHeight, 5000);
  285. function BeanInHeight(){
  286. if (BeanIn_Process == 1) {
  287. return;
  288. }
  289. BeanIn_Process == 1;
  290. $.ajax({
  291. async:false,
  292. type:"GET",
  293. url:"/dry_UltraSonic_" + tank_num,
  294. dataType:"json",
  295. success:function(response){
  296. var present_Bean_height = response.UltraSonic
  297. $('#UltraSonic_t_status').text(present_Bean_height)
  298. console.log('目前生豆高度: ' + present_Bean_height)
  299. if ( parseInt(present_Bean_height) < parseInt(testing_BeanIn_Height) ) {
  300. if (testing_in_vacuum_in == 1) {
  301. step = (parseInt(testing_BeanIn_Height) - parseInt(present_Bean_height)) * 871.2 / 100
  302. } else if (testing_in_vacuum_in > 1) {
  303. step = (parseInt(testing_BeanIn_Height) - parseInt(present_Bean_height)) * 871.2 / (220 * testing_in_vacuum_in)
  304. } else {
  305. step = '請輸入 1 以上的正整數'
  306. }
  307. console.log('step: ' + step + typeof(step))
  308. if (( 2 < testing_in_vacuum_in && testing_in_vacuum_in <= 3 && step < 1 ) ||
  309. ( 3 < testing_in_vacuum_in && testing_in_vacuum_in <= 7 && step < 2 ) ||
  310. ( 7 < testing_in_vacuum_in && testing_in_vacuum_in <=10 && step < 3 )) {
  311. console.log( ( 2 < testing_in_vacuum_in && testing_in_vacuum_in <= 3 && step < 1 ) )
  312. console.log( ( 3 < testing_in_vacuum_in && testing_in_vacuum_in <= 7 && step < 2 ) )
  313. console.log( ( 7 < testing_in_vacuum_in && testing_in_vacuum_in <=10 && step < 3 ) )
  314. $('#testing_in_vacuum_loop').text('改以小量吸料時間入料');
  315. // break 適用在 for、while 的迴圈中, 若不是迴圈則使用 return
  316. // return
  317. // aaa tankVacuum_ON()
  318. console.log('tankVacuum_ON');
  319. var time = new Date();
  320. while ((new Date() - time) < 2 * 1000) { };
  321. // aaa tankVacuum_OFF()
  322. console.log('tankVacuum_OFF');
  323. var time = new Date();
  324. while ((new Date() - time) < 2 * 1000) { };
  325. $('#testing_in_vacuum_loop').text('改以小量吸料時間入料');
  326. // testing_in_vacuum_in = 2
  327. // testing_in_vacuum_out = 2
  328. } else {
  329. $('#testing_in_vacuum_loop').text('預估循環 ' + Math.ceil(step) + ' 次完成入料')
  330. var time = new Date();
  331. while ((new Date() - time) < 1 * 1000) { };
  332. // aaa tankVacuum_ON()
  333. console.log('tankVacuum_ON')
  334. var time = new Date();
  335. while ((new Date() - time) < testing_in_vacuum_in * 1000) { };
  336. // aaa tankVacuum_OFF()
  337. console.log('tankVacuum_OFF')
  338. var time = new Date();
  339. while ((new Date() - time) < testing_in_vacuum_out * 1000) { };
  340. }
  341. } else {
  342. clearInterval(BeanIn_interval);
  343. console.log('生豆已達指定高度!');
  344. $('#testing_in_vacuum_loop').text('入料完成');
  345. }
  346. BeanIn_Process == 0;
  347. },
  348. error:function(thrownError){
  349. console.log('Error: ' + thrownError)
  350. BeanIn_Process = 0;
  351. }
  352. })
  353. };
  354. } else if (testing_BeanIn_Height == 0) {
  355. console.log('請輸入大於 0 的數值')
  356. }
  357. // WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000);
  358. }
  359. </script>
  360. </td>
  361. </tr>
  362. <tr>
  363. <td>循環入料</td>
  364. <td>
  365. 吸料時間 &nbsp;
  366. <input name="Testing_starttime" value="3" type="text" style="width: 40px;">&nbsp;秒<br>
  367. 放料時間 &nbsp;
  368. <input name="Testing_endtime" value="5" type="text" style="width: 40px;">&nbsp;秒<br>
  369. 循環
  370. <input name="Testing_loop" value="3" type="text" style="width: 40px;">&nbsp;次
  371. </td>
  372. <td>
  373. <button type="submit" class="btn btn-primary" onclick="tankVacuumTest()">循環入料</button><br>
  374. <script>
  375. function tankVacuumTest() {
  376. // clearInterval(WebUpdate_set);
  377. var Testing_starttime = $("input[name=Testing_starttime]").val();
  378. var Testing_endtime = $("input[name=Testing_endtime]").val();
  379. var Testing_loop = $("input[name=Testing_loop]").val();
  380. var step;
  381. for (step = 1; step <= Testing_loop; step++) {
  382. console.log('循環第 ' + step + ' 次');
  383. tankVacuum_ON()
  384. console.log('tankVacuum_ON')
  385. var time = new Date();
  386. while ((new Date() - time) < Testing_starttime * 1000) { }
  387. tankVacuum_OFF()
  388. console.log('tankVacuum_OFF')
  389. var time = new Date();
  390. while ((new Date() - time) < Testing_endtime * 1000) { }
  391. }
  392. // WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000);
  393. }
  394. </script>
  395. </td>
  396. </tr>
  397. </table>
  398. <br>
  399. <div style="text-align: center;">
  400. 狀態更新時間(秒):
  401. <input name="webupdate_time" type="text" value="5" style="width: 40px;">
  402. <input type="button" value="設定更新時間" onclick="changeUpdate()">
  403. </div>
  404. <script language="JavaScript">
  405. function changeUpdate() {
  406. // clearInterval(WebUpdate_set);
  407. var webupdate_time = $("input[name=webupdate_time]").val()
  408. console.log('webupdate_time' + webupdate_time)
  409. WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , webupdate_time * 1000);
  410. }
  411. // jQuery 更新感測器制動器狀態
  412. function WebUpdate(dtn) {
  413. $.get('/loading/D' + dtn, '', function (res) {
  414. if (res.tank_vacuum == 0) {
  415. $("#cmn-toggle-05").prop('checked', false);
  416. } else if (res.tank_vacuum == 1) {
  417. $("#cmn-toggle-05").prop('checked', true);
  418. }
  419. $("#UltraSonic_t_status").text(res.UltraSonic);
  420. }, 'json');
  421. }
  422. </script>
  423. <br>
  424. <!--
  425. <footer class="footer">
  426. <div style="text-align: center; margin-top: 10px; font-size: 13px; margin-bottom: 10px;">
  427. Copyright © 2021 Gold-in Tech. All Rights Reserved. 金子進科技股份有限公司 版權所有
  428. <a href="mailto:service.gitc@gmail.com" target="_blank">service.gitc@gmail.com</a>
  429. </div>
  430. </footer>
  431. -->
  432. <div id="coffee_footer">
  433. <!-- 匯入共同使用的 footer.html 內容 -->
  434. {% include 'footer.html' %}
  435. </div>
  436. </div>
  437. </body>
  438. </html>