123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681 |
- <!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">
- <!-- 新 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">
- // 指定 10秒 刷新網頁一次
- var ptid = '{{tid}}';
- console.log('ptid:' + ptid)
- WebUpdate_set = setInterval(function(){WebUpdate(ptid)} , 5 * 1000)
- </script>
- <style>
- 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: 70px;
- 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: 70px;
- line-height: 70px;
- 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: 70px;
- }
- }
- @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-62").prop('checked', false); // 確認是否勾選
- if (!confirm("你確定要開啟入料儲豆槽真空吸料機嗎?")) {
- return false;
- };
- } else {
- $("#cmn-toggle-62").prop('checked', true);
- if (!confirm("你確定要關閉入料儲豆槽真空吸料機嗎?")) {
- return false;
- };
- };
- var data = { "tank_num": "P" + 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-62").prop('checked', true);
- setTimeout("alert('入料儲豆槽真空吸料機_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-62").prop('checked', false);
- setTimeout("alert('入料儲豆槽真空吸料機_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- };
- function inputVacuum_ON() {
- var data = { "tank_num": "P" + tank_num, "command": "input_vacuum_status", "value": "on" };
- // jquery 請求 '/mqtt/{{tid}}' 頁面
- $.post('/mqtt/{{tid}}', data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-62").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-62").prop('checked', false);
- } else {
- };
- }, 'text')
- };
- function inputVacuum_OFF() {
- var data = { "tank_num": "P" + 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-62").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-62").prop('checked', false);
- } else {
- };
- }, 'text')
- };
- // 桶內 真空吸料機
- function tankVacuum() {
- var status = "off";
- var check = $("input[name=tank_vacuum_status]:checked");
- console.log('check:', check);
- //大於0代表有被選中
- if (check.length > 0) {
- status = "on";
- $("#cmn-toggle-65").prop('checked', false);
- if (!confirm("你確定要開啟真空吸料機嗎?")) {
- return false;
- };
- } else {
- $("#cmn-toggle-65").prop('checked', true);
- if (!confirm("你確定要關閉真空吸料機嗎?")) {
- return false;
- };
- };
- var data = { "tank_num": "P" + tank_num, "command": "tank_vacuum_status", "value": status };
- $.post('/mqtt/{{tid}}', data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-65").prop('checked', true);
- setTimeout("alert('真空吸料機_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-65").prop('checked', false);
- setTimeout("alert('真空吸料機_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
-
- };
- function tankVacuum_ON() {
- var data = { "tank_num": "P" + tank_num, "command": "tank_vacuum_status", "value": "on" };
- $.post('/mqtt/{{tid}}', data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-65").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-65").prop('checked', false);
- } else {
- };
- }, 'text')
-
- };
- function tankVacuum_OFF() {
- var data = { "tank_num": "P" + tank_num, "command": "tank_vacuum_status", "value": "off" };
- $.post('/mqtt/{{tid}}', data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-65").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-65").prop('checked', false);
- } else {
- };
- }, 'text')
- };
- // 馬達
- function ChangeMotor() {
- var motor_data = $("input[id=motor_rpm_data]").val();
- if (motor_data == '') {
- //$("#cmn-toggle-20").prop('checked', false);
- alert("請先輸入要運轉的值!");
- return false;
- } else if (motor_data == 0) {
- alert("轉速 0 為關閉馬達");
- } else if (Number(motor_data) < -50 || Number(motor_data) > 50 || !Number(motor_data)) {
- //
- //$("#cmn-toggle-20").prop('checked', false);
- alert("您輸入的值已超過範圍,請重新輸入!" + !Number(motor_data));
- return false;
- };
- var value = "off";
- //var check = $("input[name=peeling-machine-on]:checked");
- if (motor_data != 0) {
- value = motor_data;
- //$("#cmn-toggle-20").prop('checked', false);
- if (!confirm("你確定要開啟攪拌馬達,運轉速度為 " + motor_data + " RPM 嗎?")) {
- return false;
- };
- } else {
- //$("#cmn-toggle-20").prop('checked', true);
- if (!confirm("你確定要關閉攪拌馬達嗎?")) {
- return false;
- };
- };
- var data = { "tank_num": "P" + tank_num, "command": "tank_motor_status", "value": motor_data };
- $.post('/mqtt/{{tid}}', data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- //$("#cmn-toggle-14").prop('checked', true); // prop 設置元素屬型與元素值, 設定 checked 屬性為 true
- setTimeout("alert('攪拌馬達_開啟成功!')", 500); // 設定時間執行函式 delay(500), 只執行一次
- var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
- } else if (res == 'off') {
- //$("#cmn-toggle-14").prop('checked', false);
- setTimeout("alert('攪拌馬達_關閉成功!')", 500);
- clearInterval(timer); // 取消 timer 的不斷執行
- $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
- } else {
- alert(res);
- };
- }, 'text')
- $.get('/loading/D{{tid}}', '', function (res) {
- $("#motor_rpm_data").attr("placeholder", res.tank_motor)
- }, 'json');
- };
- function ChangeMotor_ON() {
- var data = { "tank_num": "P" + tank_num, "command": "tank_motor_status", "value": "20" };
- $.post('/mqtt/{{tid}}', data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- var timer = setInterval(Rotate, 60000);
- } else if (res == 'off') {
- clearInterval(timer);
- $("#motor_rpm_status").text('');
- } else {
- };
- }, 'text')
- }
- function ChangeMotor_OFF() {
- var data = { "tank_num": "P" + tank_num, "command": "tank_motor_status", "value": "0" };
- $.post('/mqtt/{{tid}}', data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- var timer = setInterval(Rotate, 60000);
- } else if (res == 'off') {
- clearInterval(timer);
- $("#motor_rpm_status").text('');
- } else {
- };
- }, 'text')
- }
- function Rotate() {
- $.get('/peeling', '', function (res) {
- //console.log(res.peeling);
- $("#motor_rpm_status-status").text(res.peeling + ' rpm(每1分鐘更新一次)');
- }, 'json');
- setTimeout(function () { location.reload(); }, 500);
- };
- // 出料 真空吸料機
- function outputVacuum() {
- var status = "off";
- var check = $("input[name=output_vacuum_status]:checked");
- //大於0代表有被選中
- if (check.length > 0) {
- status = "on";
- $("#cmn-toggle-71").prop('checked', false);
- if (!confirm("你確定要開啟出料儲豆槽真空吸料機嗎?")) {
- return false;
- };
- } else {
- $("#cmn-toggle-71").prop('checked', true);
- if (!confirm("你確定要關閉出料儲豆槽真空吸料機嗎?")) {
- return false;
- };
- };
- var data = { "tank_num": "P" + tank_num, "command": "output_vacuum_status", "value": status };
- console.log('data:', data)
- $.post('/mqtt/{{tid}}', data, function (res) {
- if (res == 'on') {
- $("#cmn-toggle-71").prop('checked', true);
- setTimeout("alert('出料儲豆槽真空吸料機_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-71").prop('checked', false);
- setTimeout("alert('出料儲豆槽真空吸料機_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- };
- function outputVacuum_ON() {
- var data = { "tank_num": "P" + tank_num, "command": "output_vacuum_status", "value": "on" };
- console.log('data:', data)
- $.post('/mqtt/{{tid}}', data, function (res) {
- if (res == 'on') {
- $("#cmn-toggle-71").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-71").prop('checked', false);
- } else {
- };
- }, 'text')
- };
- function outputVacuum_OFF() {
- var data = { "tank_num": "P" + tank_num, "command": "output_vacuum_status", "value": "off" };
- console.log('data:', data)
- $.post('/mqtt/{{tid}}', data, function (res) {
- if (res == 'on') {
- $("#cmn-toggle-71").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-71").prop('checked', false);
- } else {
- };
- }, 'text')
- };
- </script>
- </head>
- <body>
- 狀態更新時間(秒):
- <input name="webupdate_time" type="text" value="5" 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(ptid)} , webupdate_time * 1000);
- }
-
- </script>
- <h4>制動器</h4>
- <table border="1px solid black" style="font-size:18px;" width=100%>
- <tr>
- <td style="color:red;">Valve</td>
- <td>入料<br>真空吸料機</td>
- <td>脫皮機入料<br>真空吸料機</td>
- <td>馬達</td>
- <td>出料<br>真空吸料機</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-62" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
- name="input_vacuum_status" value="ON" onclick="inputVacuum()">
- {% else %}
- <input id="cmn-toggle-62" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
- name="input_vacuum_status" value="OFF" onclick="inputVacuum()">
- {% endif %}
- <label for="cmn-toggle-62"></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>
- <td>
- <div class="switch_div">
- <div class="switch">
- <input id="cmn-toggle-04" class="cmn-toggle cmn-toggle-round" type="checkbox">
- <label for="cmn-toggle-04"></label>
- </div>
- <div class="switch text-center">
- {% if tank_vacuum== 1 %}
- <input id="cmn-toggle-65" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
- name="tank_vacuum_status" value="ON" onclick="tankVacuum()">
- {% else %}
- <input id="cmn-toggle-65" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
- name="tank_vacuum_status" value="OFF" onclick="tankVacuum()">
- {% endif %}
- <label for="cmn-toggle-65"></label>
- </div>
- <div class="switch">
- <input id="cmn-toggle-06" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
- <label for="cmn-toggle-06" data-on="Yes" data-off="No"></label>
- </div>
- </div>
- </td>
- <td>
- <input id="motor_rpm_data" type="text" placeholder="{{tank_motor}}" style="width:100px;">RPM (±50)
- <span id="motor_rpm_status" style="color:red;"></span>
- <br>
- <input type="button" value="送出" name="tank_motor_status" onclick="ChangeMotor()">
- </td>
- <td>
- <div class="switch_div">
- <div class="switch">
- <input id="cmn-toggle-25" class="cmn-toggle cmn-toggle-round" type="checkbox">
- <label for="cmn-toggle-25"></label>
- </div>
- <div class="switch text-center">
- {% if output_vacuum== 1 %}
- <input id="cmn-toggle-71" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
- name="output_vacuum_status" value="ON" onclick="outputVacuum()">
- {% else %}
- <input id="cmn-toggle-71" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
- name="output_vacuum_status" value="OFF" onclick="outputVacuum()">
- {% endif %}
- <label for="cmn-toggle-71"></label>
- </div>
- <div class="switch">
- <input id="cmn-toggle-27" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
- <label for="cmn-toggle-27" 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>
- <td><input type="button" value="ON" name="tank_vacuum_ON" onclick="tankVacuum_ON()"></td>
- <td><input type="button" value="ON" onclick="ChangeMotor_ON()"></td>
- <td><input type="button" value="ON" name="output_vacuum_ON" onclick="outputVacuum_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>
- <td><input type="button" value="OFF" name="tank_vacuum_OFF" onclick="tankVacuum_OFF()"></td>
- <td><input type="button" value="OFF" onclick="ChangeMotor_OFF()"></td>
- <td><input type="button" value="OFF" name="output_vacuum_OFF" onclick="outputVacuum_OFF()"></td>
- </tr>
- </table>
- <br>
- <h4>感測器</h4>
- <table style="font-size:18px; border:2px #cccccc solid;" cellpadding="10" border='1' width=100%>
- <tr>
- <td>
- 暫無
- </td>
- </tr>
- </table>
- <br>
- <h4>排程測試</h4>
- <table style="font-size:18px; border:2px #cccccc solid;" cellpadding="10" border='1' width=100%>
- <tr>
- <td>暫無</td>
- </tr>
- </table>
- </body>
- <script>
- // jQuery 更新感測器制動器狀態
- function WebUpdate(ptid) {
- $.get('/loading/P' + ptid, '', function (res) {
- if (res.tank_vacuum == 0) {
- $("#cmn-toggle-65").prop('checked', false);
- } else if (res.tank_vacuum == 1) {
- $("#cmn-toggle-65").prop('checked', true);
- }
- $("#motor_rpm_data").attr("placeholder", res.tank_motor);
- // console.log("res.tank_motor"+res.tank_motor)
-
- }, 'json');
- }
- </script>
- </html>
|