123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- <!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">
- var ptid = '{{tid}}';
- $(document).ready(function(){
- $("#coffee_title_pc").text('P' + ptid + ' 脫皮機操作介面');
- $("#coffee_title_phone").text('P' + ptid + ' 操作介面');
- });
- </script>
- <script>
- // 清洗浮選 致動器開關
- var tank_num = '{{tid}}';
- // 入料 真空吸料機
- function inputVacuum(params) {
- if (params == '1') {
- var data = { "tank_num": "P" + tank_num, "command": "input_vacuum_status", "value": "on" };
- } else if (params == '0') {
- var data = { "tank_num": "P" + tank_num, "command": "input_vacuum_status", "value": "off" };
- } else {
- 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 };
- }
- $.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 tankVacuum(params) {
- if (params == '1') {
- var data = { "tank_num": "P" + tank_num, "command": "tank_vacuum_status", "value": "on" };
- } else if (params == '0') {
- var data = { "tank_num": "P" + tank_num, "command": "tank_vacuum_status", "value": "off" };
- } else {
- 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);
- } else if (res == 'off') {
- $("#cmn-toggle-65").prop('checked', false);
- } else {
- };
- }, 'text')
- }
- // 馬達
- function tankMotor_set() {
- var motor_data = $("#motor_rpm_data").val();
- console.log("motor_data: " + motor_data)
- 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')
- };
- function tankMotor(params) {
- var data = { "tank_num": "P" + tank_num, "command": "tank_motor_status", "value": params };
- $.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('/peel', '', function (res) {
- //console.log(res.peeling);
- $("#motor_rpm_status").text(res.peeling + ' rpm(每1分鐘更新一次)');
- }, 'json');
- setTimeout(function () { location.reload(); }, 500);
- };
- // 馬達 反轉
- function tankMotor_Reverse() {
- $("#input").attr('placeholder');
- var tankMotor_now = ($('#motor_rpm_data').attr('placeholder'))*-1
- console.log('tankMotor_now: ' + tankMotor_now)
- tankMotor(String(tankMotor_now))
- setTimeout(function () { location.reload(); }, 3*1000);
- }
- // 出料 真空吸料機
- function outputVacuum(params) {
- if (params == '1') {
- var data = { "tank_num": "P" + tank_num, "command": "output_vacuum_status", "value": "on" };
- } else if (params == '0') {
- var data = { "tank_num": "P" + tank_num, "command": "output_vacuum_status", "value": "off" };
- } else {
- 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 };
- }
- $.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>
- <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>
- </head>
- <body>
- <div id="wrapper">
- <div id="coffee_header">
- <!-- 匯入共同使用的 header.html 內容 -->
- {% include 'header.html' %}
- </div>
-
- <h4>致動器</h4>
- <table border="1" class="table-all" cellpadding="3" style="text-align: center;">
- <tr>
- <td style="color:red;">Valve</td>
- <td>真空吸料機</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 type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-64">
- </div>
- <div class="switch text-center">
- {% if tank_vacuum== 1 %}
- <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-65" checked
- name="tank_vacuum_status" value="ON" onclick="tankVacuum()">
- {% else %}
- <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-65"
- name="tank_vacuum_status" value="OFF" onclick="tankVacuum()">
- {% endif %}
- <label class="label_ActuatorStatus" for="cmn-toggle-65"></label>
- </div>
- <div class="switch">
- <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-66">
- </div>
- </div>
- </td>
- <td>
- <input type="text" class="input-text" id="motor_rpm_data" placeholder="{{tank_motor}}" value="">RPM<br>
- <input type="button" class="input-button" value="Confirm" name="tank_motor_status" onclick="tankMotor_set()">
- </td>
- </tr>
- <tr>
- <td><span style="color:#008CBA;"><b>ON</b></span></td>
- <td><input type="button" class="input-button-on" value="ON" onclick="tankVacuum('1')"></td>
- <td>
- <input type="button" class="input-button-on" value="40" onclick="tankMotor('40')">
- <input type="button" class="input-button-on" value="-40" onclick="tankMotor('-40')">
- <input type="button" class="input-button-on" value="20" onclick="tankMotor('20')">
- <input type="button" class="input-button-on" value="Rev." onclick="tankMotor_Reverse()">
- </td>
- </tr>
- <tr>
- <td><span style="color:#C0C0C0;"><b>OFF</b></span></td>
- <td><input type="button" class="input-button-off" value="OFF" onclick="tankVacuum('0')"></td>
- <td><input type="button" class="input-button-off" value="0" onclick="tankMotor('0')"></td>
- </tr>
- </table>
- <br>
- <h4>感測器</h4>
- <table border="1" class="table-all" cellpadding="3">
- <tr>
- <td style="background-color:#f3f3f3">
- 生豆高度
- </td>
- <td><span id="UltraSonic_t_status">{{tank_UltraSonic.UltraSonic}}</span> 公分</td>
- <td style="background-color:#f3f3f3">
- 馬達編碼器
- </td>
- <td><span id="motorEncoder_t_status">{{tank_motorEncoder.motorEncoder}}</span> RPM</td>
- </tr>
- </table>
- <br>
- <h4>排程測試</h4>
- <table border="1" class="table-all" cellpadding="3">
- <tr>
- <td>生豆高度
- <input type="text" class="input-text" name="Peel_Tank_bean_height" value="20">公分<br>
- 馬達轉速
- <input type="text" class="input-text" name="Peel_Tank_motor_rpm" value="30">rpm<br>
- 吸料
- <input type="text" class="input-text" name="Peel_Tank_vacuumON_time" value="10">秒,
- 放料
- <input type="text" class="input-text" name="Peel_Tank_vacuumOFF_time" value="10">秒<br>
- </td>
- </tr>
- <tr>
- <td>
- <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="peel_auto_status_testing()">
- <u>[測試] 脫皮自動化_狀態判斷</u></button>
- <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="peel_auto_status_stop()">
- <u>狀態判斷_停止</u></button>
- <script>
- var peel_status_process = 0;
- var data;
- function getting_parameters_P(){
- var Peel_Tank_bean_height = $('input[name=Peel_Tank_bean_height]').val();
- var Peel_Tank_motor_rpm = $('input[name=Peel_Tank_motor_rpm]').val();
- var Peel_Tank_vacuumON_time = $('input[name=Peel_Tank_vacuumON_time]').val();
- var Peel_Tank_vacuumOFF_time = $('input[name=Peel_Tank_vacuumOFF_time]').val();
- data = {"Peel_Tank_bean_height":Peel_Tank_bean_height,
- "Peel_Tank_motor_rpm":Peel_Tank_motor_rpm,
- "Peel_Tank_vacuumON_time":Peel_Tank_vacuumON_time,
- "Peel_Tank_vacuumOFF_time":Peel_Tank_vacuumOFF_time
- }
- }
- function peel_auto_status_stop(){
- clearInterval(peel_status_interval)
- console.log("------- 狀態自動化判斷 停止 -------")
- }
- function peel_auto_status_testing(){
- console.log("------- 狀態自動化判斷 開始 -------")
- getting_parameters_P()
- // 更新桶槽狀態
- peel_status_interval = setInterval(peel_auto_status, 5*1000);
- function peel_auto_status(){
- if (peel_status_process == 1) { return }
- peel_status_process = 1;
- $.get('/peel_auto_status', data, function (res){
- P1 = res.Peel_Tank_1
- PO1 = res.Peel_Output_1
- console.log('P1: ' + P1)
- console.log('PO1: ' + PO1)
- peel_status_process = 0;
- }, 'json');
- }
- }
- </script>
- </td>
- </tr>
- </table>
- <div id="coffee_footer">
- <!-- 匯入共同使用的 footer.html 內容 -->
- {% include 'footer.html' %}
- </div>
-
- </div>
- </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>
|