<!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}}'; $(function(){ $("#coffee_title_pc").text('F' + ftn + ' 發酵槽操作介面'); $("#coffee_title_phone").text('F' + 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> <script> // 發酵槽_致動器控制 var tank_num = '{{tid}}'; function tankVacuum(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + 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-05").prop('checked', false); if (!confirm("你確定要開啟真空吸料機嗎?")) { return false; }; } else { $("#cmn-toggle-05").prop('checked', true); if (!confirm("你確定要關閉真空吸料機嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { $("#cmn-toggle-05").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-05").prop('checked', false); } else { console.log(res) }; }, 'text') } function tankThreeWayValveInput(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": "off" }; } else { var status = "off"; var check = $("input[name=tank_threewayvalve_input_status]:checked"); if (check.length > 0) { status = "on"; $("#cmn-toggle-08").prop('checked', false); if (!confirm("你確定要開啟入料三通閥嗎?")) { return false; }; } else { $("#cmn-toggle-08").prop('checked', true); if (!confirm("你確定要關閉入料三通閥嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { $("#cmn-toggle-08").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-08").prop('checked', false); } else { console.log(res) }; }, 'text') } function tankDiskValve(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "off" }; } else { var status = "off"; var check = $("input[name=tank_diskvalve_status]:checked"); if (check.length > 0) { status = "on"; $("#cmn-toggle-11").prop('checked', false); if (!confirm("你確定要開啟蝴蝶閥嗎?")) { return false; }; } else { $("#cmn-toggle-11").prop('checked', true); if (!confirm("你確定要關閉蝴蝶閥嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { $("#cmn-toggle-11").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-11").prop('checked', false); } else { console.log(res) }; }, 'text') } function tankSolenoidPump(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "solenoid_tank_pump_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + tank_num, "command": "solenoid_tank_pump_status", "value": "off" }; } else { var status = "off"; var check = $("input[name=solenoid_tank_pump_status]:checked"); //大於0代表有被選中 if (check.length > 0) { status = "on"; $("#cmn-toggle-14").prop('checked', false); if (!confirm("你確定要開啟水泵逆洗電磁閥嗎?")) { return false; }; } else { $("#cmn-toggle-14").prop('checked', true); if (!confirm("你確定要關閉水泵逆洗電磁閥嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "solenoid_tank_pump_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { $("#cmn-toggle-14").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-14").prop('checked', false); } else { console.log(res) }; }, 'text') } function tankSolenoidDisinfect(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": "off" }; } else { var status = "off"; var check = $("input[name=tank_solenoid_disinfect_status]:checked"); //大於0代表有被選中 if (check.length > 0) { status = "on"; $("#cmn-toggle-17").prop('checked', false); if (!confirm("你確定要開啟消毒電磁閥嗎?")) { return false; }; } else { $("#cmn-toggle-17").prop('checked', true); if (!confirm("你確定要關閉消毒電磁閥嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { $("#cmn-toggle-17").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-17").prop('checked', false); } else { console.log(res) }; }, 'text') } function outerSolenoidWater(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": "off" }; } else { var status = "off"; var check = $("input[name=outer_solenoid_water_status]:checked"); //大於0代表有被選中 if (check.length > 0) { status = "on"; $("#cmn-toggle-38").prop('checked', false); if (!confirm("你確定要開啟\"桶外\"進水電磁閥嗎?")) { return false; }; } else { $("#cmn-toggle-38").prop('checked', true); if (!confirm("你確定要關閉\"桶外\"進水電磁閥嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { $("#cmn-toggle-38").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-38").prop('checked', false); } else { console.log(res) }; }, 'text') } function tankSolenoidWaterIn(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": "off" }; } else { var status = "off"; var check = $("input[name=tank_solenoid_water_in_status]:checked"); //大於0代表有被選中 if (check.length > 0) { status = "on"; $("#cmn-toggle-50").prop('checked', false); if (!confirm("你確定要開啟\"桶內\"進水電磁閥嗎?")) { return false; }; } else { $("#cmn-toggle-50").prop('checked', true); if (!confirm("你確定要關閉\"桶內\"進水電磁閥嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { $("#cmn-toggle-50").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-50").prop('checked', false); } else { console.log(res) }; }, 'text') } function tankSolenoidWaterOut(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_out_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_out_status", "value": "off" }; } else { var status = "off"; var check = $("input[name=tank_solenoid_water_out_status]:checked"); //大於0代表有被選中 if (check.length > 0) { status = "on"; $("#cmn-toggle-53").prop('checked', false); if (!confirm("你確定要開啟\"桶內排水\"電磁閥嗎?")) { return false; }; } else { $("#cmn-toggle-53").prop('checked', true); if (!confirm("你確定要關閉\"桶內排水\"電磁閥嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_out_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { $("#cmn-toggle-53").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-53").prop('checked', false); } else { console.log(res) }; }, 'text') } function tankPumpSensor(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": "off" }; } else { var status = "off"; var check = $("input[name=tank_pump_sensor_status]:checked"); //大於0代表有被選中 if (check.length > 0) { status = "on"; $("#cmn-toggle-41").prop('checked', false); if (!confirm("你確定要開啟感測器用 pump 雙核隔膜泵嗎?")) { return false; }; } else { $("#cmn-toggle-41").prop('checked', true); if (!confirm("你確定要關閉感測器用 pump 雙核隔膜泵嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { $("#cmn-toggle-41").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-41").prop('checked', false); } else { console.log(res) }; }, 'text') } function outerThreeWayValveFloat(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": "off" }; } else { var status = "off"; var check = $("input[name=outer_threewayvalve_float_status]:checked"); //大於0代表有被選中 if (check.length > 0) { status = "on"; $("#cmn-toggle-47").prop('checked', false); if (!confirm("你確定要開啟外桶浮選三通閥嗎?")) { return false; }; } else { $("#cmn-toggle-47").prop('checked', true); if (!confirm("你確定要關閉外桶浮選三通閥嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { $("#cmn-toggle-47").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-47").prop('checked', false); } else { console.log(res) }; }, 'text') } function tankMotor_set() { 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"; if (motor_data != 0) { value = motor_data; if (!confirm("你確定要開啟攪拌馬達,運轉速度為 " + motor_data + " RPM 嗎?")) { return false; }; } else { if (!confirm("你確定要關閉攪拌馬達嗎?")) { return false; }; }; var data = { "tank_num": "F" + 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": "F" + 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); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?) } else if (res == 'off') { clearInterval(timer); // 取消 timer 的不斷執行 $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號 } else { console.log(res) }; }, 'text') } function Rotate() { $.get('/peel', '', function (res) { //console.log(res.peeling); $("#motor_rpm_status-status").text(res.peeling + ' rpm(每1分鐘更新一次)'); }, 'json'); }; function tankHeater1(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": "off" }; } else { var status = "off"; var check = $("input[name=tank_heater1_status]:checked"); //大於0代表有被選中 if (check.length > 0) { status = "on"; $("#cmn-toggle-26").prop('checked', false); if (!confirm("你確定要開啟電熱管1嗎?")) { return false; }; } else { $("#cmn-toggle-26").prop('checked', true); if (!confirm("你確定要關閉電熱管1嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { $("#cmn-toggle-26").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-26").prop('checked', false); } else { console.log(res) }; }, 'text') } function tankHeater2(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": "off" }; } else { var status = "off"; var check = $("input[name=tank_heater2_status]:checked"); //大於0代表有被選中 if (check.length > 0) { status = "on"; $("#cmn-toggle-29").prop('checked', false); if (!confirm("你確定要開啟電熱管2嗎?")) { return false; }; } else { $("#cmn-toggle-29").prop('checked', true); if (!confirm("你確定要關閉電熱管2嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { $("#cmn-toggle-29").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-29").prop('checked', false); } else { console.log(res) }; }, 'text') } function tankTempEnable(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": "off" }; } else { var status = "off"; var check = $("input[name=tank_temp_enable_status]:checked"); //大於0代表有被選中 if (check.length > 0) { status = "on"; $("#cmn-toggle-35").prop('checked', false); if (!confirm("你確定要開啟溫度控制嗎?")) { return false; }; } else { $("#cmn-toggle-35").prop('checked', true); if (!confirm("你確定要關閉溫度控制嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { $("#cmn-toggle-35").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-35").prop('checked', false); } else { console.log(res) }; }, 'text') } // 判斷是否整數 function isInteger(obj) { return obj % 1 === 0 } isInteger(3) // true // 設定溫度 function tankTemp_set() { var temp_data = $("input[id=tank_temp_data]").val(); if (temp_data == '') { //$("#cmn-toggle-20").prop('checked', false); alert("請先輸入設定溫度!"); return false; } else if (!isInteger(temp_data)) { //$("#cmn-toggle-20").prop('checked', false); alert("溫度設定僅限整數,請重新輸入!" + !Number(temp_data)); return false; }; var value = "0"; //var check = $("input[name=peeling-machine-on]:checked"); if ($("#cmn-toggle-35").prop('checked')) { value = temp_data; //$("#cmn-toggle-20").prop('checked', false); if (!confirm("你確定要設定內桶溫度為 " + temp_data + " ℃ 嗎?")) { return false; }; } else { //$("#cmn-toggle-20").prop('checked', true); //你確定要停止桶內溫度設定嗎 if (!confirm("請先開啟溫控開關, 再設定桶內溫度")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": temp_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 tankTemp(params) { var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": params }; $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { } else if (res == 'off') { } else { console.log(res) }; }, 'text') } function outputVacuum(params) { if (params == '1') { var data = { "tank_num": "F" + tank_num, "command": "output_vacuum_status", "value": "on" }; } else if (params == '0') { var data = { "tank_num": "F" + 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-32").prop('checked', false); if (!confirm("你確定要開啟出料儲豆槽真空吸料機嗎?")) { return false; }; } else { $("#cmn-toggle-32").prop('checked', true); if (!confirm("你確定要關閉出料儲豆槽真空吸料機嗎?")) { return false; }; }; var data = { "tank_num": "F" + tank_num, "command": "output_vacuum_status", "value": status }; } $.post('/mqtt/{{tid}}', data, function (res) { if (res == 'on') { $("#cmn-toggle-32").prop('checked', true); } else if (res == 'off') { $("#cmn-toggle-32").prop('checked', false); } else { console.log(res) }; }, 'text') } </script> <script language="JavaScript"> function changeUpdate() { // aaa 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/F' + ftn, '', function (res) { if (res.tank_vacuum == 0) { $("#cmn-toggle-05").prop('checked', false); } else if (res.tank_vacuum == 1) { $("#cmn-toggle-05").prop('checked', true);} if (res.tank_threewayvalve_input == 0) { $("#cmn-toggle-08").prop('checked', false); } else if (res.tank_threewayvalve_input == 1) { $("#cmn-toggle-08").prop('checked', true);} if (res.tank_diskvalve == 0) { $("#cmn-toggle-11").prop('checked', false); } else if (res.tank_diskvalve == 1) { $("#cmn-toggle-11").prop('checked', true);} if (res.solenoid_tank_pump == 0) { $("#cmn-toggle-14").prop('checked', false); } else if (res.solenoid_tank_pump == 1) { $("#cmn-toggle-14").prop('checked', true);} if (res.tank_solenoid_disinfect == 0) { $("#cmn-toggle-17").prop('checked', false); } else if (res.tank_solenoid_disinfect == 1) { $("#cmn-toggle-17").prop('checked', true);} if (res.outer_solenoid_water == 0) { $("#cmn-toggle-38").prop('checked', false); } else if (res.outer_solenoid_water == 1) { $("#cmn-toggle-38").prop('checked', true);} if (res.tank_solenoid_water_in == 0) { $("#cmn-toggle-50").prop('checked', false); } else if (res.tank_solenoid_water_in == 1) { $("#cmn-toggle-50").prop('checked', true);} if (res.tank_solenoid_water_out == 0) { $("#cmn-toggle-53").prop('checked', false); } else if (res.tank_solenoid_water_out == 1) { $("#cmn-toggle-53").prop('checked', true);} if (res.tank_pump_sensor == 0) { $("#cmn-toggle-41").prop('checked', false); } else if (res.tank_pump_sensor == 1) { $("#cmn-toggle-41").prop('checked', true);} if (res.outer_threewayvalve_float == 0) { $("#cmn-toggle-47").prop('checked', false); } else if (res.outer_threewayvalve_float == 1) { $("#cmn-toggle-47").prop('checked', true);} if (res.tank_heater1 == 0) { $("#cmn-toggle-26").prop('checked', false); } else if (res.tank_heater1 == 1) { $("#cmn-toggle-26").prop('checked', true);} if (res.tank_heater2 == 0) { $("#cmn-toggle-29").prop('checked', false); } else if (res.tank_heater2 == 1) { $("#cmn-toggle-29").prop('checked', true);} if (res.tank_temp_enable == 0) { $("#cmn-toggle-35").prop('checked', false); } else if (res.tank_temp_enable == 1) { $("#cmn-toggle-35").prop('checked', true);} $("#motor_rpm_data").attr("placeholder", res.tank_motor); $("#tank_temp_data").attr("placeholder", res.tank_temp); $("#SHT11_Temp_t_status").text(res.SHT11_Temp); $("#SHT11_Humidity_t_status").text(res.SHT11_Humidity); $("#CO2_t_status").text(res.CO2); $("#PH_t_status").text(res.PH); $("#ORP_t_status").text(res.ORP); $("#DO_t_status").text(res.DO); $("#EC_t_status").text(res.EC); $("#PA_t_status").text(res.PA); if (res.WaterLevel == '1') { $("#WaterLevel_t_status").text('滿'); } else if (res.WaterLevel == '0') { $("#WaterLevel_t_status").text('可注水'); } else { $("#WaterLevel_t_status").text('ERROR'); } $("[name = UltraSonic_t_status]").text(res.UltraSonic); $("[name = PressureWaterLevel_t_status]").text(res.PressureWaterLevel); if (res.WaterLevel == '1' && res.outer_solenoid_water == '1'){ outerSolenoidWater('0'); console.log('桶外注水 OFF') }; $("#motorEncoder_t_status").text(res.motorEncoder); }, 'json'); } </script> </head> <body> <div id="wrapper"> <div id="coffee_header"> <!-- 匯入共同使用的 header.html 內容 --> {% include 'header.html' %} </div> <!-- <div style="width: 500px; margin: 0px auto; background-color: lightgreen;"> test <table> <tr> <td style="color:red;">Valve</td> <td>桶內<br>真空吸料機</td> <td>入料三通閥</td> <td>水泵逆洗<br>電磁閥</td> <td>桶內消毒<br>電磁閥</td> <td>桶外進水<br>電磁閥</td> <td>桶內進水<br>電磁閥</td> <td>桶內排水<br>電磁閥</td> <td>感測器<br>雙核隔膜泵</td> <td>外桶浮選<br>三通閥</td> <td>馬達</td> <td>加熱器 1</td> <td>加熱器 2</td> <td>溫控開關</td> <td>溫度設定</td> <td>蝴蝶閥</td> </tr> </table> </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> <td>桶外進水<br>電磁閥</td> <td>桶內進水<br>電磁閥</td> <td>感測器<br>雙核隔膜泵</td> <td>外桶浮選<br>三通閥</td> <td>馬達</td> <td>加熱器 1</td> <td>加熱器 2</td> <td>溫控開關</td> <td>溫度設定</td> <td>水泵逆洗<br>電磁閥</td> <td>桶內排水<br>電磁閥</td> <td>桶內消毒<br>電磁閥</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-04"> </div> <div class="switch text-center"> {% if tank_vacuum=='ON' %} <input id="cmn-toggle-05" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked name="tank_vacuum_status" value="ON" onclick="tankVacuum()"> {% else %} <input id="cmn-toggle-05" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" name="tank_vacuum_status" value="OFF" onclick="tankVacuum()"> {% endif %} <label class="label_ActuatorStatus" for="cmn-toggle-05"></label> </div> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-06"> </div> </div> </td> <td> <div class="switch_div"> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-07"> </div> <div class="switch text-center"> {% if tank_threewayvalve_input=='ON' %} <input id="cmn-toggle-08" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked name="tank_threewayvalve_input_status" value="ON" onclick="tankThreeWayValveInput()"> {% else %} <input id="cmn-toggle-08" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" name="tank_threewayvalve_input_status" value="OFF" onclick="tankThreeWayValveInput()"> {% endif %} <label class="label_ActuatorStatus" for="cmn-toggle-08"></label> </div> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-09"> </div> </div> </td> <td> <div class="switch_div"> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-37"> </div> <div class="switch text-center"> {% if outer_solenoid_water=='ON' %} <input id="cmn-toggle-38" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox" name="outer_solenoid_water_status" value="ON" onclick="outerSolenoidWater()"> {% else %} <input id="cmn-toggle-38" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" name="outer_solenoid_water_status" value="OFF" onclick="outerSolenoidWater()"> {% endif %} <label class="label_ActuatorStatus" for="cmn-toggle-38"></label> </div> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-39"> </div> </div> </td> <td> <div class="switch_div"> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-49"> </div> <div class="switch text-center"> {% if tank_solenoid_water_in=='ON' %} <input id="cmn-toggle-50" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox" name="tank_solenoid_water_in_status" value="ON" onclick="tankSolenoidWaterIn()"> {% else %} <input id="cmn-toggle-50" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" name="tank_solenoid_water_in_status" value="OFF" onclick="tankSolenoidWaterIn()"> {% endif %} <label class="label_ActuatorStatus" for="cmn-toggle-50"></label> </div> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-51"> </div> </div> </td> <td> <div class="switch_div"> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-40"> </div> <div class="switch text-center"> {% if tank_pump_sensor=='ON' %} <input id="cmn-toggle-41" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox" name="tank_pump_sensor_status" value="ON" onclick="tankPumpSensor()"> {% else %} <input id="cmn-toggle-41" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" name="tank_pump_sensor_status" value="OFF" onclick="tankPumpSensor()"> {% endif %} <label class="label_ActuatorStatus" for="cmn-toggle-41"></label> </div> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-42"> </div> </div> </td> <td> <div class="switch_div"> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-46"> </div> <div class="switch text-center"> {% if outer_threewayvalve_float=='ON' %} <input id="cmn-toggle-47" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox" name="outer_threewayvalve_float_status" value="ON" onclick="outerThreeWayValveFloat()"> {% else %} <input id="cmn-toggle-47" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" name="outer_threewayvalve_float_status" value="OFF" onclick="outerThreeWayValveFloat()"> {% endif %} <label class="label_ActuatorStatus" for="cmn-toggle-47"></label> </div> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-48"> </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" onclick="tankMotor_set()"> </td> <td> <div class="switch_div"> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-25"> </div> <div class="switch text-center"> {% if tank_heater1=='ON' %} <input id="cmn-toggle-26" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked name="tank_heater1_status" value="ON" onclick="tankHeater1()"> {% else %} <input id="cmn-toggle-26" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" name="tank_heater1_status" value="OFF" onclick="tankHeater1()"> {% endif %} <label class="label_ActuatorStatus" for="cmn-toggle-26"></label> </div> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-27"> </div> </div> </td> <td> <div class="switch_div"> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-28"> </div> <div class="switch text-center"> {% if tank_heater2=='ON' %} <input id="cmn-toggle-29" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked name="tank_heater2_status" value="ON" onclick="tankHeater2()"> {% else %} <input id="cmn-toggle-29" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" name="tank_heater2_status" value="OFF" onclick="tankHeater2()"> {% endif %} <label class="label_ActuatorStatus" for="cmn-toggle-29"></label> </div> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-30"> </div> </div> </td> <td> <div class="switch_div"> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-34"> </div> <div class="switch text-center"> {% if tank_temp_enable=='ON' %} <input id="cmn-toggle-35" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked name="tank_temp_enable_status" value="ON" onclick="tankTempEnable()"> {% else %} <input id="cmn-toggle-35" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" name="tank_temp_enable_status" value="OFF" onclick="tankTempEnable()"> {% endif %} <label class="label_ActuatorStatus" for="cmn-toggle-35"></label> </div> <div class="switch"> <input id="cmn-toggle-36" class="cmn-toggle cmn-toggle-yes-no" type="checkbox"> <label class="label_ActuatorStatus" for="cmn-toggle-36" data-on="Yes" data-off="No"></label> </div> </div> </td> <td> <input type="text" class="input-text" id="tank_temp_data" placeholder="{{tank_temp}}" value="">℃<br> <input type="button" class="input-button" value="Confirm" onclick="tankTemp_set()"> </td> <td> <div class="switch_div"> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-13"> </div> <div class="switch text-center"> {% if solenoid_tank_pump =='ON' %} <input id="cmn-toggle-14" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked name="solenoid_tank_pump_status" value="ON" onclick="tankSolenoidPump()"> {% else %} <input id="cmn-toggle-14" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" name="solenoid_tank_pump_status" value="OFF" onclick="tankSolenoidPump()"> {% endif %} <label class="label_ActuatorStatus" for="cmn-toggle-14"></label> </div> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-15"> </div> </div> </td> <td> <div class="switch_div"> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-52"> </div> <div class="switch text-center"> {% if tank_solenoid_water_out =='ON' %} <input id="cmn-toggle-53" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox" name="tank_solenoid_water_out_status" value="ON" onclick="tankSolenoidWaterOut()"> {% else %} <input id="cmn-toggle-53" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" name="tank_solenoid_water_in_status" value="OFF" onclick="tankSolenoidWaterOut()"> {% endif %} <label class="label_ActuatorStatus" for="cmn-toggle-53"></label> </div> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-54"> </div> </div> </td> <td> <div class="switch_div"> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-16"> </div> <div class="switch text-center"> {% if tank_solenoid_disinfect=='ON' %} <input id="cmn-toggle-17" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox" name="tank_solenoid_disinfect_status" value="ON" onclick="tankSolenoidDisinfect()"> {% else %} <input id="cmn-toggle-17" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" name="tank_solenoid_disinfect_status" value="OFF" onclick="tankSolenoidDisinfect()"> {% endif %} <label class="label_ActuatorStatus" for="cmn-toggle-17"></label> </div> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-18"> </div> </div> </td> <td> <div class="switch_div"> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-10"> </div> <div class="switch text-center"> {% if tank_diskvalve=='ON' %} <input id="cmn-toggle-11" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked name="tank_diskvalve_status" value="ON" onclick="tankDiskValve()"> {% else %} <input id="cmn-toggle-11" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" name="tank_diskvalve_status" value="OFF" onclick="tankDiskValve()"> {% endif %} <label class="label_ActuatorStatus" for="cmn-toggle-11"></label> </div> <div class="switch"> <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-12"> </div> </div> </td> </tr> <tr> <td><span style="color:#008CBA;"><b>ON</b></span></td> <td><input type="button" class="input-button-on" value="ON" name="tank_vacuum_ON" onclick="tankVacuum('1')"></td> <td><input type="button" class="input-button-on" value="ON" name="tank_threewayvalve_input_ON" onclick="tankThreeWayValveInput('1')"></td> <td><input type="button" class="input-button-on" value="ON" name="outer_solenoid_water_ON" onclick="outerSolenoidWater('1')"> </td> <td><input type="button" class="input-button-on" value="ON" name="tank_solenoid_water_in_ON" onclick="tankSolenoidWaterIn('1')"> </td> <td><input type="button" class="input-button-on" value="ON" name="tank_pump_sensor_ON" onclick="tankPumpSensor('1')"> </td> <td><input type="button" class="input-button-on" value="ON" name="outer_threewayvalve_float_ON" onclick="outerThreeWayValveFloat('1')"> </td> <td><input type="button" class="input-button-on" value="20" name="tank_motor_ON" onclick="tankMotor('20')"></td> <td><input type="button" class="input-button-on" value="ON" name="tank_heater1_ON" onclick="tankHeater1('1')"></td> <td><input type="button" class="input-button-on" value="ON" name="tank_heater2_ON" onclick="tankHeater2('1')"></td> <td><input type="button" class="input-button-on" value="ON" name="tank_temp_enable_ON" onclick="tankTempEnable('1')"></td> <td><input type="button" class="input-button-on" value="30" name="tank_temp_ON" onclick="tankTemp('30')"></td> <td><input type="button" class="input-button-on" value="ON" name="tank_solenoid_water_in_ON" onclick="tankSolenoidPump('1')"> </td> <td><input type="button" class="input-button-on" value="ON" name="tank_solenoid_water_out_ON" onclick="tankSolenoidWaterOut('1')"> </td> <td><input type="button" class="input-button-on" value="ON" name="tank_solenoid_disinfect_ON" onclick="tankSolenoidDisinfect('1')"> </td> <td><input type="button" class="input-button-on" value="ON" name="tank_diskvalve_ON" onclick="tankDiskValve('1')"></td> </tr> <tr> <td><span style="color:#C0C0C0;"><b>OFF</b></span></td> <td><input type="button" class="input-button-off" value="OFF" name="tank_vacuum_OFF" onclick="tankVacuum('0')"></td> <td><input type="button" class="input-button-off" value="OFF" name="tank_threewayvalve_input_OFF" onclick="tankThreeWayValveInput('0')"></td> <td><input type="button" class="input-button-off" value="OFF" name="outer_solenoid_water_OFF" onclick="outerSolenoidWater('0')"> </td> <td><input type="button" class="input-button-off" value="OFF" name="tank_solenoid_water_in_OFF" onclick="tankSolenoidWaterIn('0')"> </td> <td><input type="button" class="input-button-off" value="OFF" name="tank_pump_sensor_OFF" onclick="tankPumpSensor('0')"></td> <td><input type="button" class="input-button-off" value="OFF" name="outer_threewayvalve_float_OFF" onclick="outerThreeWayValveFloat('0')"></td> <td><input type="button" class="input-button-off" value="0" name="tank_motor_OFF" onclick="tankMotor('0')"></td> <td><input type="button" class="input-button-off" value="OFF" name="tank_heater1_OFF" onclick="tankHeater1('0')"></td> <td><input type="button" class="input-button-off" value="OFF" name="tank_heater2_OFF" onclick="tankHeater2('0')"></td> <td><input type="button" class="input-button-off" value="OFF" name="tank_temp_enable_OFF" onclick="tankTempEnable('0')"></td> <td><input type="button" class="input-button-off" value="0" name="tank_temp_OFF" onclick="tankTemp('0.0')"></td> <td><input type="button" class="input-button-off" value="OFF" name="tank_solenoid_water_in_OFF" onclick="tankSolenoidPump('0')"></td> <td><input type="button" class="input-button-off" value="OFF" name="tank_solenoid_water_out_OFF" onclick="tankSolenoidWaterOut('0')"> </td> <td><input type="button" class="input-button-off" value="OFF" name="tank_solenoid_disinfect_OFF" onclick="tankSolenoidDisinfect('0')"></td> <td><input type="button" class="input-button-off" value="OFF" name="tank_diskvalve_OFF" onclick="tankDiskValve('0')"></td> </tr> </table> <br> <h4>感測器</h4> <table border="1" class="table-all" cellpadding="3"> <tr> <td style="background-color:#f3f3f3">[桶內] 生豆/水位高度</td> <td><span name="UltraSonic_t_status">{{tank_UltraSonic.UltraSonic}}</span> 公分</td> <td style="background-color:#f3f3f3">[桶外] 水位高度</td> <td><span id="WaterLevel_t_status">{{WaterLevel}}</span></td> <td style="background-color:#f3f3f3">馬達編碼器</td> <td><span id="motorEncoder_t_status">{{tank_motorEncoder.motorEncoder}}</span> RPM</td> </tr> <tr> <td style="background-color:#f3f3f3">溫度</td> <td><span id="SHT11_Temp_t_status">{{tank_SHT11.SHT11_Temp}}</span> ℃</td> <td style="background-color:#f3f3f3">濕度</td> <td><span id="SHT11_Humidity_t_status">{{tank_SHT11.SHT11_Humidity}}</span> %</td> <td style="background-color:#f3f3f3">二氧化碳</td> <td><span id="CO2_t_status">{{tank_CO2.CO2}}</span> ppm</td> <td style="background-color:#f3f3f3">氣壓</td> <td><span id="PA_t_status">{{tank_PA.PA}}</span> Pa</td> </tr> <tr> <td style="background-color:#f3f3f3">pH</td> <td><span id="PH_t_status">{{tank_PH.PH}}</span></td> <td style="background-color:#f3f3f3">ORP</td> <td><span id="ORP_t_status">{{tank_ORP.ORP}}</span> mV</td> <td style="background-color:#f3f3f3">DO</td> <td><span id="DO_t_status">{{tank_DO.DO}}</span> mg/L</td> <td style="background-color:#f3f3f3">EC</td> <td><span id="EC_t_status">{{tank_EC.EC}}</span> μS/cm</td> </tr> </table> <br> <h4>排程測試</h4> <table border="1" class="table-all" cellpadding="3"> <tr> <td>發酵</td> <td>入豆</td> <td>入水</td> <td>水質測量 (攪拌、加熱)</td> </tr> <tr> <td> -- 入豆 --<br> 指定桶內生豆高度 <input type="text" class="input-text" name="testing_tank_bean_height_F" value="10">公分<br> -- 入水 --<br> 桶外加滿水<br> 指定桶內水位高度 <input type="text" class="input-text" name="testing_tank_water_height_F" value="20">公分<br> -- 發酵 --<br> 指定溫度 <input type="text" class="input-text" name="testing_tank_temp_F" value="21">℃<br> 指定時間 <input type="text" class="input-text" name="testing_tank_time_F" value="10">秒<br> -- 出料 --<br> 設定空桶高度 <input type="text" class="input-text" name="testing_tank_empty_height_F" value="1">公分<br> <!-- 入料吸料時間(秒) <input type="text" class="input-text" name="testing_tank_vacuum_in_F" value="1"> <br> 入料放料時間(>10秒) <input type="text" class="input-text" name="testing_tank_vacuum_out_F" value="10"> <br> 入料循環次數 <input type="text" class="input-text" name="testing_tank_vacuum_loop_F" value="4"> <br> 桶外注水 <br> 桶外滿水時加熱 <br> 溫度達設定溫度時, 停止加熱 <br> 馬達 rpm <input type="text" class="input-text" name="testing_motor_rpm_F" value="20" style="width:100px;"> <br> 出料吸料時間(秒) <input type="text" class="input-text" name="testing_out_vacuum_in_F" value="1" style="width: 40px;"> <br> 出料放料時間(>10秒) <input type="text" class="input-text" name="testing_out_vacuum_out_F" value="10" style="width: 40px;"> <br> 出料循環次數 <input type="text" class="input-text" name="testing_out_vacuum_loop_F" value="4" style="width: 40px;"> --> </td> <td> [桶內] 生豆/水位高度:<span name="UltraSonic_t_status">{{tank_UltraSonic.UltraSonic}}</span> 公分<br> 指定咖啡豆高度 <input type="text" class="input-text" name="testing_tank_coffee_height" id="testing_tank_coffee_height" value="0" style="width: 40px;">公分<br> 入料吸料時間 <input type="text" class="input-text" name="testing_tank_vacuum_in" id="testing_tank_vacuum_in" value="1" style="width: 40px;">秒<br> 入料放料時間(>10) <input type="text" class="input-text" name="testing_tank_vacuum_out" id="testing_tank_vacuum_out" value="10" style="width: 40px;">秒<br> 入料循環次數 <input type="text" class="input-text" name="testing_tank_vacuum_loop" id="testing_tank_vacuum_loop" value="3" style="width: 40px;">次 </td> <td> [桶內] 生豆/水位高度:<span name="UltraSonic_t_status">{{tank_UltraSonic.UltraSonic}}</span> 公分<br> 指定水量高度 <input type="text" class="input-text" name="testing_tank_water_height" id="testing_tank_water_height" value="100" style="width: 40px;">公分 </td> <td> 馬達 <input type="text" class="input-text" name="testing_motor_rpm" id="testing_motor_rpm" value="0">rpm<br> <!-- 發酵時間(秒) <input type="text" class="input-text" name="testing_tank_dry_time" id="testing_tank_dry_time"> <br> 溫度控制(℃) <input type="text" class="input-text" name="AAA" id="AAA"> --> 加熱器 1、2 ON <br> pump 開啟時間 <input type="text" class="input-text" name="testing_tank_pump_on" id="testing_tank_pump_on" value="10">秒<br> pump 關閉時間 <input type="text" class="input-text" name="testing_tank_pump_off" id="testing_tank_pump_off" value="10">秒<br> pump 循環次數 <input type="text" class="input-text" name="testing_tank_pump_loop" id="testing_tank_pump_loop" value="3">次<br> </td> </tr> <tr> <td> <button type="submit" class="btn btn-primary" onclick="testing_F()">發酵測試</button> <script> // 入水狀態 var WaterIn_F_Process = 0; // 入豆狀態 var BeanIn_F_Process = 0; // 發酵狀態 var Fermenting_F_Process = 0; // 出料狀態 var WaterBeanOut_F_Process = 0; // 發酵 function testing_F() { // aaa clearInterval(WebUpdate_set); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // -- 入豆 -- var testing_tank_bean_height_F = $("input[name=testing_tank_bean_height_F]").val(); var BeanIn_F_interval = setInterval(BeanIn_F, 5000); // -- 入水 -- var WaterIn_F_interval function BeanIn_F(){ if (BeanIn_F_Process == 1) { return; // 若還在處理就取消, 函式立即停止 } var testing_tank_water_height_F = $("input[name=testing_tank_water_height_F]").val(); // 取得桶內生豆高度 BeanIn_F_Process = 1; $.ajax({ async:false, type:"GET", url:"/ferment_UltraSonic_" + tank_num, dataType:'json', success:function(response){ var present_Bean_height = response.UltraSonic console.log("目前豆高: " + present_Bean_height) console.log("指定豆高: " + testing_tank_bean_height_F) if ( parseInt(present_Bean_height) >= parseInt(testing_tank_bean_height_F) ) { clearInterval(BeanIn_F_interval); console.log("已達生豆高度!") // 讀取指定水高 var testing_tank_water_height_F = $("input[name=testing_tank_water_height_F]").val(); console.log("指定水高: " + testing_tank_water_height_F) // 若桶內水還沒滿, 開啟桶內入水 $.get('/ferment_UltraSonic_' + tank_num, '', function (res) { if ( res.UltraSonic < testing_tank_water_height_F ){ console.log('桶內開始入水') tankSolenoidWaterIn('1'); console.log('tankSolenoidWaterIn_ON') console.log('請開啟水龍頭進水') }; }, 'json'); // 若桶外水還沒滿, 開啟桶外入水 $.get('/ferment_WaterLevel_' + tank_num, '', function (res) { if ( res.WaterLevel != 1 ){ console.log('桶外開始入水') outerSolenoidWater('1'); console.log('tankSolenoidWaterIn_ON') console.log('請開啟水龍頭進水') }; }, 'json'); // 入水每五秒判斷 WaterIn_F_interval = setInterval(WaterIn_F, 5000); } else { tankVacuum('1') console.log("tankVacuum_ON") var time = new Date(); while ((new Date() - time) < 2 * 1000) { }; tankVacuum('0') console.log("tankVacuum_OFF") } BeanIn_F_Process = 0; }, error:function(thrownError){ console.log("Error: " + thrownError) BeanIn_F_Process = 0; } }); }; // 入豆排程 var Fermenting_F_interval function WaterIn_F(){ if(WaterIn_F_Process == 1){ return; // 若還在處理就取消, 函式立即停止 } // 取得桶內目前水位、取得桶外是否達水位計 WaterIn_F_Process = 1; $.ajax({ async:false, type:"GET", url:"/ferment_WaterIn_" + tank_num, dataType:"JSON", success:function(response){ var testing_tank_water_height_F = parseInt($("input[name=testing_tank_water_height_F]").val()); var present_tank_water_height = parseInt(response.UltraSonic) var present_WaterLevel = response.WaterLevel if (present_WaterLevel == 1 && present_tank_water_height >= testing_tank_water_height_F) { clearInterval(WaterIn_F_interval); console.log("入水完成!") var testing_tank_temp_F = $("input[name=testing_tank_temp_F]").val(); var testing_tank_time_F = $("input[name=testing_tank_time_F]").val(); console.log("指定溫度: " + testing_tank_temp_F) console.log("指定時間: " + testing_tank_time_F) tankMotor('20') console.log("tankMotor_ON") // 取得桶內溫度, 若低於指定溫度則開啟加熱器 $.get('/ferment_SHT11_' + tank_num, '', function(res){ if (res.SHT11_Temp < testing_tank_temp_F){ tankHeater1('1') console.log("tankHeater1_ON") tankHeater2('1') console.log("tankHeater2_ON") } }); // -- 發酵 -- console.log("進入發酵流程") Fermenting_F_interval = setInterval(Fermenting_F, 5000); } else if (present_WaterLevel == 1) { outerSolenoidWater('0') console.log("outerSolenoidWater_OFF") console.log("桶外入水完成, 桶內加水中") } else if (present_tank_water_height > testing_tank_water_height_F) { tankSolenoidWaterIn('0') console.log("tankSolenoidWaterIn_OFF") console.log("桶內入水完成, 桶外加水中") } WaterIn_F_Process = 0; }, error:function(thrownError){ console.log("Error: " + thrownError) WaterIn_F_Process = 0; } }); WaterIn_F_Process = 0; } // 出水排豆排程 var WaterBeanOut_F_interval function Fermenting_F(){ var testing_tank_temp_F = $("input[name=testing_tank_temp_F]").val(); var testing_tank_time_F = $("input[name=testing_tank_time_F]").val(); if (Fermenting_F_Process == 1) { return; } // 取得現在溫度 Fermenting_F_Process = 1; $.ajax({ async:false, type:"GET", url:"/ferment_SHT11_" + tank_num, dataType:"json", success:function(response){ var present_Temp = response.SHT11_Temp console.log("現在溫度: " + present_Temp) if (present_Temp >= testing_tank_temp_F) { clearInterval(Fermenting_F_interval) console.log("已達指定溫度!") tankHeater1('0') console.log("tankHeater1_OFF") tankHeater2('0') console.log("tankHeater2_OFF") console.log("發酵 " + testing_tank_time_F + " 秒") var time = new Date(); while ((new Date() - time) < testing_tank_time_F * 1000) { }; tankMotor('0') console.log("tankMotor_OFF") WaterBeanOut_F_interval = setInterval(WaterBeanOut_F, 5000); } Fermenting_F_Process = 0; }, error:function(thrownError){ console.log("Error: " + thrownError) Fermenting_F_Process = 0; } }); }; function WaterBeanOut_F(){ // -- 出料 -- // 設定空桶高度 var testing_tank_empty_height_F = $("input[name=testing_tank_empty_height_F]").val(); console.log("設定空桶高度: " + testing_tank_empty_height_F) if (WaterBeanOut_F_Process == 1){ return; } // 取得桶內生豆高度 WaterBeanOut_F_Process = 1; $.ajax({ async:false, type:"GET", url:"/ferment_UltraSonic_" + tank_num, dataType:"json", success:function(response){ var present_Bean_height = response.UltraSonic console.log("目前發酵豆高/水位: " + present_Bean_height) if (present_Bean_height > testing_tank_empty_height_F) { outputVacuum('1') console.log("outputVacuum_ON") var time = new Date(); while ((new Date() - time) < 2 * 1000) { }; outputVacuum('0') console.log("outputVacuum_OFF") } else { clearInterval(WaterBeanOut_F_interval); console.log("發酵完成!槽內已無生豆") } WaterBeanOut_F_Process = 0; }, error:function(thrownError){ console.log("Error: " + thrownError) WaterBeanOut_F_Process = 0; } }) }; } </script> </td> <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_UltraSonic_' + tank_num, dataType:'JSON', success:function(response){ var present_Coffee_height = response.UltraSonic console.log("目前生豆高度: ", present_Coffee_height) if( present_Coffee_height >= testing_tank_coffee_height){ clearInterval(Coffee_interval); console.log("生豆已達目標高度!") } else { tankVacuum('1') console.log('tankVacuum_ON') var time = new Date(); while ((new Date() - time) < testing_tank_vacuum_in * 1000) { }; tankVacuum('0') console.log('tankVacuum_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; } }); }; } else if (testing_tank_coffee_height == 0){ console.log('開始循環入豆') for (step = 1; step <= testing_tank_vacuum_loop; step++) { console.log('-- 循環第 ' + step + ' 次 --'); tankVacuum('1') console.log('tankVacuum_ON') var time = new Date(); while ((new Date() - time) < testing_tank_vacuum_in * 1000) { }; tankVacuum('0') console.log('tankVacuum_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="WaterIn_testing()">入水測試</button> <script> var WaterIn_Process = 0; // 發酵槽入水狀態 function WaterIn_testing() { var testing_tank_water_height = $("input[name=testing_tank_water_height]").val(); console.log('testing_tank_water_height: ' + testing_tank_water_height) $.get('/ferment_UltraSonic_' + tank_num, '', function (res) { if ( res.UltraSonic < testing_tank_water_height ){ console.log('開始入水') tankSolenoidWaterIn('1'); console.log('tankSolenoidWaterIn_ON') console.log('請開啟水龍頭進水') var time = new Date(); while ((new Date() - time) < 1000) { }; }; }, 'json'); var WaterIn_interval = setInterval(tankWaterIn, 5000); function tankWaterIn(){ if(WaterIn_Process == 1){ return; } WaterIn_Process = 1; $.ajax({ type:"GET", url:'/ferment_UltraSonic_' + tank_num, dataType:'json', success:function(response){ var present_water_height = response.UltraSonic console.log('目前水位高度: ' + present_water_height) if( parseInt(present_water_height) >= parseInt(testing_tank_water_height) ){ clearInterval(WaterIn_interval); console.log('達到目標水位!') console.log('請關閉水龍頭') var time = new Date(); while ((new Date() - time) < 1000) { }; tankSolenoidWaterIn('0'); console.log('tankSolenoidWaterIn_OFF') } WaterIn_Process = 0; }, error:function(thrownError){ console.log("Error: " + thrownError) WaterIn_Process = 0; } }); WaterIn_Process = 0; } }; </script> </td> <td> <button type="submit" class="btn btn-primary" onclick="WATER_testing()">水質測量(攪拌、加熱)</button> <script> function WATER_testing() { var set_motor_rpm = $("input[name=testing_motor_rpm]").val(); var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": set_motor_rpm }; $.post('/mqtt/{{tid}}', data, function (res) { console.log('data:', data) if (res == 'on') { var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?) } else if (res == 'off') { clearInterval(timer); // 取消 timer 的不斷執行 } else { }; }, 'text') // setTimeout(function () { location.reload(); }, 500); console.log('motor rpm:' + set_motor_rpm) var time = new Date(); while ((new Date() - time) < testing_tank_vacuum_out * 1000) { }; tankHeater1('1') console.log('tankHeater1_ON') var time = new Date(); while ((new Date() - time) < testing_tank_vacuum_out * 1000) { }; tankHeater2('1') console.log('tankHeater2_ON') console.log('暫停 5 秒鐘') var time = new Date(); while ((new Date() - time) < 5 * 1000) { }; var testing_tank_pump_on = $("input[name=testing_tank_pump_on]").val(); var testing_tank_pump_off = $("input[name=testing_tank_pump_off]").val(); var testing_tank_pump_loop = $("input[name=testing_tank_pump_loop]").val(); for (step = 1; step <= testing_tank_pump_loop; step++) { console.log('-- pump 循環第 ' + step + ' 次 --') tankPumpSensor('1') console.log('tankPumpSensor_ON') var time = new Date(); while ((new Date() - time) < testing_tank_pump_on * 1000) { }; tankPumpSensor('0') console.log('tankPumpSensor_OFF') var time = new Date(); while ((new Date() - time) < testing_tank_pump_off * 1000) { }; } console.log('暫停 5 秒鐘') var time = new Date(); while ((new Date() - time) < 5 * 1000) { }; tankMotor('0') console.log('tankMotor_OFF') var time = new Date(); while ((new Date() - time) < testing_tank_vacuum_out * 1000) { }; tankHeater1('0') console.log('tankHeater1_OFF') var time = new Date(); while ((new Date() - time) < testing_tank_vacuum_out * 1000) { }; tankHeater2('0') console.log('tankHeater2_OFF') }; </script> </td> </tr> </table> <br> <h4>水路排程測試</h4> [桶外] 水位高度:<span id="WaterLevel_t_status">{{WaterLevel}}</span> <table border="1" class="table-all" cellpadding="3"> <tr> <td colspan="2">桶內進水</td> <td colspan="2">桶外進水</td> <td colspan="2">消毒/打菌</td> <td colspan="2">感測器 pump 進水</td> </tr> <tr> <td>桶內進水 ON</td> <td>桶內進水 OFF</td> <td>桶外進水 ON</td> <td>桶外進水 OFF</td> <td>消毒/打菌 ON</td> <td>消毒/打菌 OFF</td> <td>感測器 pump 進水 ON</td> <td>感測器 pump 進水 OFF</td> </tr> <tr> <td>桶外電磁閥 OFF<br>桶內電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font></td> <td><font color="#FF0000">水龍頭 OFF</font><br>桶內電磁閥 OFF</td> <td>桶內電磁閥 OFF<br>桶外電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font></td> <td><font color="#FF0000">水龍頭 OFF</font><br>桶外電磁閥 OFF</td> <td>消毒電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font></td> <td><font color="#FF0000">水龍頭 OFF</font><br>消毒電磁閥 OFF</td> <td>桶內電磁閥 ON<br>pump ON</td> <td>pump OFF<br>桶內電磁閥 OFF</td> </tr> <tr> <td> <button type="submit" class="btn btn-primary" onclick="tank_WaterIn_ON_testing()">桶內進水 ON</button> <script> // 桶外電磁閥 OFF<br>桶內電磁閥 ON<br>水泵逆洗電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font> function tank_WaterIn_ON_testing(){ outerSolenoidWater('0') console.log('outerSolenoidWater_OFF') var time = new Date(); while ((new Date() - time) < 1000) { }; tankSolenoidWaterIn('1') console.log('tankSolenoidWaterIn_ON') console.log('請開啟水龍頭進水') } </script> </td> <td> <button type="submit" class="btn btn-primary" onclick="tank_WaterIn_OFF_testing()">桶內進水 OFF</button> <script> // <font color="#FF0000">水龍頭 OFF</font><br>水泵逆洗電磁閥 OFF<br>桶內電磁閥 OFF function tank_WaterIn_OFF_testing(){ console.log('請關閉水龍頭進水') var time = new Date(); while ((new Date() - time) < 1000) { }; tankSolenoidWaterIn('0') console.log('tankSolenoidWaterIn_OFF') } </script> </td> <td> <button type="submit" class="btn btn-primary" onclick="outer_WaterIn_ON_testing()">桶外進水 ON</button> <script> // 桶內電磁閥 OFF<br>桶外電磁閥 ON<br>水泵逆洗電磁閥 ON<br><font color="#FF0000">水龍頭 ON function outer_WaterIn_ON_testing(){ tankSolenoidWaterIn('0') console.log('tankSolenoidWaterIn_OFF') var time = new Date(); while ((new Date() - time) < 1000) { }; outerSolenoidWater('1') console.log('outerSolenoidWater_ON') var time = new Date(); while ((new Date() - time) < 1000) { }; console.log('請開啟水龍頭進水') } </script> </td> <td> <button type="submit" class="btn btn-primary" onclick="outer_WaterIn_OFF_testing()">桶外進水 OFF</button> <script> // <font color="#FF0000">水龍頭 OFF</font><br>水泵逆洗電磁閥 OFF<br>桶外電磁閥 OFF function outer_WaterIn_OFF_testing(){ console.log('請關閉水龍頭進水') var time = new Date(); while ((new Date() - time) < 1000) { }; outerSolenoidWater('0') console.log('outerSolenoidWater_OFF') } </script> </td> <td> <button type="submit" class="btn btn-primary" onclick="tank_Disinfect_ON_testing()">消毒/打菌 ON</button> <script> // 消毒電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font> function tank_Disinfect_ON_testing(){ tankSolenoidDisinfect('1') console.log('tankSolenoidDisinfect_ON') var time = new Date(); while ((new Date() - time) < 1000) { }; console.log('請開啟水龍頭進水') } </script> </td> <td> <button type="submit" class="btn btn-primary" onclick="tank_Disinfect_OFF_testing()">消毒/打菌 OFF</button> <script> // <font color="#FF0000">水龍頭 OFF</font><br>消毒電磁閥 OFF function tank_Disinfect_OFF_testing(){ console.log('請關閉水龍頭進水') var time = new Date(); while ((new Date() - time) < 1000) { }; tankSolenoidDisinfect('0') console.log('tankSolenoidDisinfect_OFF') } </script> </td> <td> <button type="submit" class="btn btn-primary" onclick="tank_SensorPump_ON_testing()">感測器 pump 進水 ON</button> <script> // 桶內電磁閥 ON<br>pump ON function tank_SensorPump_ON_testing(){ tankSolenoidWaterIn('1') console.log('tankSolenoidWaterIn_ON') var time = new Date(); while ((new Date() - time) < 2 * 1000) { }; tankPumpSensor('1') console.log('tankPumpSensor_ON') } </script> </td> <td> <button type="submit" class="btn btn-primary" onclick="tank_SensorPump_OFF_testing()">感測器 pump 進水 OFF</button> <script> // pump OFF<br>桶內電磁閥 OFF function tank_SensorPump_OFF_testing(){ tankPumpSensor('0') console.log('tankPumpSensor_OFF') var time = new Date(); while ((new Date() - time) < 2 * 1000) { }; tankSolenoidWaterIn('0') console.log('tankSolenoidWaterIn_OFF') } </script> </td> </tr> </table> <div id="coffee_footer"> <!-- 匯入共同使用的 footer.html 內容 --> {% include 'footer.html' %} </div> </div> </body> </html>