123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>{{ title }}</title>
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <!-- <meta http-equiv="refresh" content="5" /> 每 content 秒網頁自動更新-->
- <!-- 新 Bootstrap4 核心 CSS 文件 -->
- <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
- <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
- <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
- <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
- <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
- <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
- <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
- <!--可用來建立使用者小圖示-->
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
- <script language="JavaScript">
- // 指定 秒 刷新網頁一次
- var ftn = '{{tid}}';
- var status = '{{status}}';
- console.log('ftn:' + ftn)
- $(function(){
- $("#ferment_input_page").text('發酵貨櫃入料儲豆槽 FI' + ftn + ' 攝影機畫面 ')
- $('#ferment_input_page').attr("href", "/camera_FI" + ftn)
- $("#ferment_input_title").text('發酵貨櫃入料儲豆槽 FI' + ftn + ' 操作介面')
- $("#coffee_title").text('FI' + ftn + ' 發酵入料儲豆槽操作介面');
- if (status == 2) {
- $('input').prop('disabled', true);
- $('button').prop('disabled', true);
- } else if ( (status == 0) || (status == 1) ) {
- $('input').prop('disabled', false);
- $('button').prop('disabled', false);
- }
- });
- WebUpdate_set = setInterval(function(){WebUpdate(ftn)} , 10 * 1000)
- </script>
- <style>
- .footer{
- position: absolute;
- width: 100%;
- background-color: #eee;
- text-align: center;
- }
- body {
- margin: 0;
- }
- input[type="button"] {
- padding: 4px 15px;
- background: #f3f3f3;
- border: 0 none;
- cursor: pointer;
- -webkit-border-radius: 5px;
- border-radius: 5px;
- }
- .navbar-dark .navbar-nav .nav-link {
- color: white;
- cursor: pointer;
- text-decoration: none;
- width: 110px;
- height: 46px;
- }
- .nav-top {
- line-height: 40px;
- background-color: #C4C4C4;
- }
- .website_title {
- font-family: Roboto;
- font-style: normal;
- font-weight: normal;
- font-size: 30px;
- color: #000000;
- }
- .navbar-nav>li {
- float: none;
- display: inline-block;
- width: 100px;
- margin: 0 auto;
- text-align: center;
- }
- .navbar-nav>li a {
- font-size: 20px;
- }
- .main-page {
- margin-top: 200px;
- }
- .page-title {
- font-family: Roboto;
- font-style: normal;
- font-weight: bold;
- font-size: 36px;
- }
- .flex {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- justify-content: center;
- }
- .set-link {
- display: inline-block;
- width: 350px;
- height: 100px;
- line-height: 100px;
- background: #008CBA;
- border: 1px solid #CFCFCF;
- box-sizing: border-box;
- color: #FFFFFF;
- border-radius: 10px;
- font-size: 36px;
- }
- .cmn-toggle {
- position: absolute;
- margin-left: 0px;
- visibility: hidden;
- }
- .cmn-toggle+label {
- display: block;
- position: relative;
- cursor: pointer;
- outline: none;
- user-select: none;
- }
- input.cmn-toggle-round-flat+label {
- padding: 2px;
- width: 60px;
- height: 30px;
- background-color: #C0C0C0;
- border-radius: 60px;
- transition: background 0.4s;
- }
- input.cmn-toggle-round-flat+label:before,
- input.cmn-toggle-round-flat+label:after {
- display: block;
- position: absolute;
- content: "";
- }
- input.cmn-toggle-round-flat+label:before {
- top: 2px;
- left: 2px;
- bottom: 2px;
- right: 2px;
- background-color: #fff;
- border-radius: 60px;
- transition: background 0.4s;
- }
- input.cmn-toggle-round-flat+label:after {
- top: 4px;
- left: 4px;
- bottom: 4px;
- width: 24px;
- background-color: #dddddd;
- border-radius: 52px;
- transition: margin 0.4s, background 0.4s;
- }
- input.cmn-toggle-round-flat:checked+label {
- background-color: #C0C0C0;
- }
- input.cmn-toggle-round-flat:checked+label:after {
- margin-left: 27px;
- background-color: #008CBA;
- }
- @media(max-width:373px) {
- .card {
- margin-right: 0px;
- }
- .set-link {
- width: 250px;
- }
- }
- @media(max-width:577px) {}
- @media(min-width:576px) {}
- @media(min-width:768px) {
- .navbar-nav>li {
- margin-left: 0px;
- }
- .navbar-nav .li-block {
- display: none;
- }
- }
- @media(min-width:991px) {
- .navbar-nav>li {
- margin-left: 20px;
- }
- .navbar-nav .li-block {
- display: none;
- }
- }
- @media(min-width:1200px) {
- .navbar-nav>li {
- margin-left: 50px;
- }
- .navbar-nav .li-block {
- display: inline-block;
- width: 100px;
- }
- }
- @media(min-width:1400px) {
- .navbar-nav .li-block {
- display: inline-block;
- width: 200px;
- }
- }
- @media(min-width:1689px) {
- .navbar-nav>li {
- margin-left: 50px;
- }
- .navbar-nav .li-block {
- display: inline-block;
- width: 500px;
- }
- }
- </style>
- <script>
- // 發酵槽_制動器控制
- var tank_num = '{{tid}}';
- function inputVacuum() {
- var status = "off";
- var check = $("input[name=input_vacuum_status]:checked"); // 這裡面是 jQuery 撈取資料的方法, jQuery 常使用到 $ 錢字號
- console.log('check:', check);
- //大於0代表有被選中, 如果有多個可以呈現勾取的項目數量
- if (check.length > 0) {
- status = "on";
- $("#cmn-toggle-02").prop('checked', false); // 確認是否勾選
- if (!confirm("你確定要開啟入料儲豆槽真空吸料機嗎?")) {
- return false;
- };
- } else {
- $("#cmn-toggle-02").prop('checked', true);
- if (!confirm("你確定要關閉入料儲豆槽真空吸料機嗎?")) {
- return false;
- };
- };
- var data = { "tank_num": "FI" + tank_num, "command": "input_vacuum_status", "value": status };
- // jquery 請求 '/mqtt/{{tid}}' 頁面
- $.post('/mqtt/{{tid}}', data, function (res) { //res:HTTP response argument to the middleware function
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-02").prop('checked', true);
- setTimeout("alert('入料儲豆槽真空吸料機_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-02").prop('checked', false);
- setTimeout("alert('入料儲豆槽真空吸料機_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- };
- function inputVacuum_ON() {
- var data = { "tank_num": "FI" + tank_num, "command": "input_vacuum_status", "value": "on" };
- // jquery 請求 '/mqtt/{{tid}}' 頁面
- $.post('/mqtt/{{tid}}', data, function (res) { //res:HTTP response argument to the middleware function
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-02").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-02").prop('checked', false);
- } else {
- };
- }, 'text')
- };
- function inputVacuum_OFF() {
- var data = { "tank_num": "FI" + tank_num, "command": "input_vacuum_status", "value": "off" };
- // jquery 請求 '/mqtt/{{tid}}' 頁面
- $.post('/mqtt/{{tid}}', data, function (res) { //res:HTTP response argument to the middleware function
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-02").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-02").prop('checked', false);
- } else {
- };
- }, 'text')
- };
-
- </script>
- </head>
- <body>
- <div id="wrapper">
- <div id="coffee_header">
- <!-- 匯入共同使用的 header.html 內容 -->
- {% include 'header.html' %}
- </div>
-
- <!--
- <div style="text-align: left;">
- <a href="/ferment" style="float: left;"> 返回發酵貨櫃首頁</a>
- </div>
- <div style="text-align: right;">
- <a id="ferment_input_page" href="/index_new" style="float: right;">___________________</a>
- </div>
- <div id="ferment_input_title" style="text-align: center; margin-top: 30px; font-size: 24px; margin-bottom: 15px;">
- 發酵貨櫃入料儲豆槽 FI 操作介面
- </div>
- -->
- 狀態更新時間(秒)
- <input name="webupdate_time" type="text" value="60" style="width:100px;">
- <input type="button" value="設定更新時間" onclick="changeUpdate()">
- <script language="JavaScript">
-
- function changeUpdate() {
- clearInterval(WebUpdate_set);
- var webupdate_time = $("input[name=webupdate_time]").val()
- console.log('webupdate_time' + webupdate_time)
- WebUpdate_set = setInterval(function(){WebUpdate(ftn)} , webupdate_time * 1000);
- }
- // jQuery 更新感測器制動器狀態
- function WebUpdate(ftn) {
- $.get('/loading/FI' + ftn, '', function (res) {
- if (res.input_vacuum == 0) {
- $("#cmn-toggle-02").prop('checked', false);
- } else if (res.input_vacuum == 1) {
- $("#cmn-toggle-02").prop('checked', true);}
- $("#UltraSonic_t_status").text(res.input_UltraSonic);
-
- }, 'json');
- }
- </script>
- <h4>制動器</h4>
- <table border="1" style="font-size:18px; border:2px #cccccc solid; margin-left: 2px; margin-right: 2px;" width=98%>
- <tr>
- <td style="color:red;">Valve</td>
- <td>真空吸料機</td>
- </tr>
- <tr>
- <td>
- <span style="color:#C0C0C0;">off</span>
- <span style="color:#008CBA;">on</span>
- </td>
- <td>
- <div class="switch_div">
- <div class="switch">
- <input id="cmn-toggle-01" class="cmn-toggle cmn-toggle-round" type="checkbox">
- <label for="cmn-toggle-01"></label>
- </div>
- <div class="switch text-center">
- {% if input_vacuum == 1 %}
- <input id="cmn-toggle-02" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
- name="tank_vacuum_status" value="ON" onclick="inputVacuum()">
- {% else %}
- <input id="cmn-toggle-02" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
- name="tank_vacuum_status" value="OFF" onclick="inputVacuum()">
- {% endif %}
- <label for="cmn-toggle-02"></label>
- </div>
- <div class="switch">
- <input id="cmn-toggle-03" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
- <label for="cmn-toggle-03" data-on="Yes" data-off="No"></label>
- </div>
- </div>
- </td>
- </tr>
- <tr>
- <td><span style="color:#008CBA;"><b>ON</b></span></td>
- <td><input type="button" value="ON" name="input_vacuum_ON" onclick="inputVacuum_ON()"></td>
- </tr>
- <tr>
- <td><span style="color:#C0C0C0;"><b>OFF</b></span></td>
- <td><input type="button" value="OFF" name="input_vacuum_OFF" onclick="inputVacuum_OFF()"></td>
- </tr>
- </table>
- <br>
- <h4>感測器</h4>
- <table border="1" style="font-size:18px; border:2px #cccccc solid; margin-left: 2px; margin-right: 2px;" cellpadding="10" width=98%>
- <tr>
- <td>[入料] 生豆高度:<span id="UltraSonic_t_status">{{input_UltraSonic.UltraSonic}}</span> 公分</td>
- </tr>
- </table>
- <br>
- <h4>排程設計</h4>
- <table border="1" style="font-size:18px; border:2px #cccccc solid; margin-left: 2px; margin-right: 2px;" width=98%>
- <tr>
- <td>入料</td>
- <td>循環測試</td>
- </tr>
- <tr>
- <td>
- 指定桶內生豆高度
- <input name="testing_BeanIn_Height" type="text" value="0" style="width: 40px;">公分<br>
- 吸料時間
- <input name="testing_in_vacuum_in" type="text" value="1" style="width: 40px;">秒<br>
- 放料時間
- <input name="testing_in_vacuum_out" type="text" value="10" style="width: 40px;">秒<br>
- 循環次數
- <input name="testing_in_vacuum_loop" type="text" value="3" style="width: 40px;">次<br>
- </td>
- <td>
- ON (開)
- <input name="Testing_starttime" value="3" type="text" style="width: 40px;">秒<br>
- OFF (關)
- <input name="Testing_endtime" value="5" type="text" style="width: 40px;">秒<br>
- 循環
- <input name="Testing_loop" value="3" type="text" style="width: 40px;">次
- </td>
- </tr>
- <tr>
- <td>
- <button type="submit" class="btn btn-primary" onclick="CoffeeIn_testing()">入豆測試</button>
- <script>
- CoffeeIn_Process = 0; // 生豆入豆狀態
- function CoffeeIn_testing() {
- var testing_tank_coffee_height = $("input[name=testing_tank_coffee_height]").val();
- console.log('目標入料高度' + testing_tank_coffee_height)
- var testing_tank_vacuum_in = $("input[name=testing_tank_vacuum_in]").val();
- var testing_tank_vacuum_out = $("input[name=testing_tank_vacuum_out]").val();
- var testing_tank_vacuum_loop = $("input[name=testing_tank_vacuum_loop]").val();
- if (testing_tank_coffee_height != 0) {
- console.log('以目標高度入豆')
- var Coffee_interval = setInterval(tankCoffeeHeight, 5000);
- function tankCoffeeHeight(){
- if (CoffeeIn_Process == 1){
- return;
- }
-
- CoffeeIn_Process = 1;
- $.ajax({
- async:false,
- type:'GET',
- url:'/ferment_LiDAR_' + tank_num,
- dataType:'JSON',
- success:function(response){
- var present_Coffee_height = response.LiDAR
- console.log("目前生豆高度: ", present_Coffee_height)
- if( present_Coffee_height >= testing_tank_coffee_height){
- clearInterval(Coffee_interval);
- console.log("生豆已達目標高度!")
- CoffeeIn_Process = 0;
- } else {
- inputVacuum_ON()
- console.log('inputVacuum_ON')
- var time = new Date();
- while ((new Date() - time) < testing_tank_vacuum_in * 1000) { };
- inputVacuum_OFF()
- console.log('inputVacuum_OFF')
- var time = new Date();
- while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
- CoffeeIn_Process = 0;
- }
- },
- error:function(thrownError){
- console.log("Error: " + thrownError)
- CoffeeIn_Process = 0;
- }
- });
- CoffeeIn_Process = 0;
- };
-
- } else if (testing_tank_coffee_height == 0){
- console.log('開始循環入豆')
- for (step = 1; step <= testing_tank_vacuum_loop; step++) {
- console.log('-- 循環第 ' + step + ' 次 --');
- inputVacuum_ON()
- console.log('inputVacuum_ON')
- var time = new Date();
- while ((new Date() - time) < testing_tank_vacuum_in * 1000) { };
- inputVacuum_OFF()
- console.log('inputVacuum_OFF')
- var time = new Date();
- while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
- }
- console.log('-- 循環入豆結束 --')
- }
- }
- </script>
- </td>
- <td>
- <button type="submit" class="btn btn-primary" onclick="tankVacuumTest()">真空吸料機測試(秒)</button><br>
- <script>
- function tankVacuumTest() {
- clearInterval(WebUpdate_set);
- var Testing_starttime = $("input[name=Testing_starttime]").val();
- var Testing_endtime = $("input[name=Testing_endtime]").val();
- var Testing_loop = $("input[name=Testing_loop]").val();
- alert('測試間隔' + Testing_starttime + ':' + Testing_endtime + ' 次數' + Testing_loop)
- var step;
- for (step = 1; step <= Testing_loop; step++) {
- console.log('循環第 ' + step + ' 次');
- inputVacuum_ON()
- console.log('inputVacuum_ON')
- var time = new Date();
- while ((new Date() - time) < Testing_starttime * 1000) { }
- inputVacuum_OFF()
- console.log('inputVacuum_OFF')
- var time = new Date();
- while ((new Date() - time) < Testing_endtime * 1000) { }
- }
- WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000);
- }
- </script>
- </td>
- </tr>
- </table>
- <br>
- <h4>攝影機畫面</h4>
- <div class="container-fluid">
- <div class="row" style="margin-top:5px;">
- <div class="col flex">
- <div class="col-md-12 row flex" style="text-align:center;margin-top:5px;">
- <div class="col-md-12 row flex">
- <img src="" id="two" width="80%" height="80%">
- </div>
- </div>
- <script>
- // M5 攝影機
- //const img = document.querySelector('#one');
- const img1 = document.querySelector('#two');
- const WS_URL1 = 'ws:///60.250.156.230:8089';
- const ws1 = new WebSocket(WS_URL1);
- let urlObject1;
- ws1.onopen = () => console.log(`Connected to ${WS_URL1}`);
- ws1.onmessage = message1 => {
- const arrayBuffer1 = message1.data;
- if (urlObject1) {
- URL.revokeObjectURL(urlObject1);
- }
- urlObject1 = URL.createObjectURL(new Blob([arrayBuffer1]));
- img1.src = urlObject1;
- }
- </script>
- </div>
- </div>
- </div>
- <br>
- <br>
- <!--
- <footer class="footer">
- <div style="text-align: center; margin-top: 10px; font-size: 13px; margin-bottom: 10px;">
- Copyright © 2021 Gold-in Tech. All Rights Reserved. 金子進科技股份有限公司 版權所有
- <a href="mailto:service.gitc@gmail.com" target="_blank">service.gitc@gmail.com</a>
- </div>
- </footer>
- -->
- <div id="coffee_footer">
- <!-- 匯入共同使用的 footer.html 內容 -->
- {% include 'footer.html' %}
- </div>
- </div>
-
- </body>
- </html>
|