12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223 |
- 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 };
- $.post('/mqtt/' + tank_num, 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 {
- console.log('res error');
- };
- }, 'text')
- };
- function inputVacuum_ON() {
- var data = { "tank_num": "FI" + tank_num, "command": "input_vacuum_status", "value": "on" };
- $.post('/mqtt/' + tank_num, 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 {
- console.log('res error');
- };
- }, 'text')
- };
- function inputVacuum_OFF() {
- var data = { "tank_num": "FI" + tank_num, "command": "input_vacuum_status", "value": "off" };
- $.post('/mqtt/' + tank_num, 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 {
- console.log('res error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- 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-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/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-05").prop('checked', true);
- setTimeout("alert('真空吸料機_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-05").prop('checked', false);
- setTimeout("alert('真空吸料機_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankVacuum_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": "on" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankVacuum_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": "off" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- // Benson 真空吸料機 (END)
- function tankThreeWayValveInput() {
- //<!--setInterval(Relay,10000);-->
- var status = "off";
- var check = $("input[name=tank_threewayvalve_input_status]:checked");
- //大於0代表有被選中
- 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/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-08").prop('checked', true);
- setTimeout("alert('入料三通閥入料_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-08").prop('checked', false);
- setTimeout("alert('入料三通閥排氣_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankThreeWayValveInput_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": "on" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankThreeWayValveInput_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": "off" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- // Benson cargo2_actuator.html 控制蝴蝶閥函數 (START)
- function tankDiskValve() {
- //<!--setInterval(Relay,10000);-->
- var status = "off";
- var check = $("input[name=tank_diskvalve_status]:checked");
- //大於0代表有被選中
- 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/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-11").prop('checked', true);
- setTimeout("alert('蝴蝶閥_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-11").prop('checked', false);
- setTimeout("alert('蝴蝶閥_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankDiskValve_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "on" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankDiskValve_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "off" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- // Benson cargo2_actuator.html 閥 (START) 電磁閥 總進水
- function tankSolenoidWaterTotal() {
- var status = "off";
- var check = $("input[name=tank_solenoid_water_total_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": "tank_solenoid_water_total_status", "value": status };
- $.post('/mqtt/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-14").prop('checked', true);
- setTimeout("alert('總進水電磁閥_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-14").prop('checked', false);
- setTimeout("alert('總進水電磁閥_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankSolenoidWaterTotal_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_total_status", "value": "on" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankSolenoidWaterTotal_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_total_status", "value": "off" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- // Benson cargo2_actuator.html 閥 (START) 電磁閥消毒打菌
- function tankSolenoidDisinfect() {
- 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/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-17").prop('checked', true);
- setTimeout("alert('消毒電磁閥_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-17").prop('checked', false);
- setTimeout("alert('消毒電磁閥_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankSolenoidDisinfect_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": "on" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankSolenoidDisinfect_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": "off" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- // 電磁閥 保溫夾層加水
- function outerSolenoidWater() {
- 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/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-38").prop('checked', true);
- setTimeout("alert('\"保溫夾層\"進水電磁閥_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-38").prop('checked', false);
- setTimeout("alert('\"保溫夾層\"進水電磁閥_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function outerSolenoidWater_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": "on" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function outerSolenoidWater_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": "off" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- // 電磁閥 桶內加水
- function tankSolenoidWaterIn() {
- 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/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-50").prop('checked', true);
- setTimeout("alert('\"桶內\"進水電磁閥_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-50").prop('checked', false);
- setTimeout("alert('\"桶內\"進水電磁閥_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankSolenoidWaterIn_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": "on" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankSolenoidWaterIn_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": "off" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- // 感測器用 pump 雙核隔膜泵
- function tankPumpSensor() {
- 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/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-41").prop('checked', true);
- setTimeout("alert('感測器用 pump _開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-41").prop('checked', false);
- setTimeout("alert('感測器用 pump _關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankPumpSensor_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": "on" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- }
- function tankPumpSensor_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": "off" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- }
- // 感測模組下豆三通閥
- function tankThreeWayValveBean() {
- var status = "off";
- var check = $("input[name=tank_threewayvalve_bean_status]:checked");
- //大於0代表有被選中
- if (check.length > 0) {
- status = "on";
- $("#cmn-toggle-44").prop('checked', false);
- if (!confirm("你確定要開啟感測模組下豆三通閥嗎?")) {
- return false;
- };
- } else {
- $("#cmn-toggle-44").prop('checked', true);
- if (!confirm("你確定要關閉感測模組下豆三通閥嗎?")) {
- return false;
- };
- };
- var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_bean_status", "value": status };
- $.post('/mqtt/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-44").prop('checked', true);
- setTimeout("alert('感測模組下豆三通閥_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-44").prop('checked', false);
- setTimeout("alert('感測模組下豆三通閥_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankThreeWayValveBean_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_bean_status", "value": "on" };
- $.post('/mqtt/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-44").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-44").prop('checked', false);
- } else {
- console.log('res error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankThreeWayValveBean_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_bean_status", "value": "off" };
- $.post('/mqtt/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-44").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-44").prop('checked', false);
- } else {
- console.log('res error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- // 外桶浮選三通閥
- function outerThreeWayValveFloat() {
- 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/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-47").prop('checked', true);
- setTimeout("alert('外桶浮選三通閥_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-47").prop('checked', false);
- setTimeout("alert('外桶浮選三通閥_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function outerThreeWayValveFloat_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": "on" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function outerThreeWayValveFloat_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": "off" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- // Benson cargo2_actuator.html 脫皮機馬達 (START) 馬達攪拌棒
- function tankMotor() {
- 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": "F" + tank_num, "command": "tank_motor_status", "value": motor_data };
- $.post('/mqtt/' + tank_num, 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')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankMotor_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": "20" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankMotor_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": "0" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- 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);
- };
- // Benson cargo2_actuator.html 鼓風機 (START)
- //電熱管1函數
- function tankHeater1() {
- 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/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-26").prop('checked', true);
- setTimeout("alert('電熱管1_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-26").prop('checked', false);
- setTimeout("alert('電熱管1_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankHeater1_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": "on" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankHeater1_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": "off" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- //電熱管2函數
- function tankHeater2() {
- 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/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-29").prop('checked', true);
- setTimeout("alert('電熱管2_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-29").prop('checked', false);
- setTimeout("alert('電熱管2_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankHeater2_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": "on" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankHeater2_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": "off" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- // 溫度控制
- function tankTempEnable() {
- 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/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-35").prop('checked', true);
- setTimeout("alert('溫度控制_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-35").prop('checked', false);
- setTimeout("alert('溫度控制_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankTempEnable_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": "on" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankTempEnable_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": "off" };
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- // 判斷是否整數
- function isInteger(obj) {
- return obj % 1 === 0
- }
- isInteger(3) // true
- // 設定溫度
- function tankTemp() {
- 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/' + tank_num, 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')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function setTemp() {
- var temp_data = $("input[id=tank_temp_data]").val();
- if (temp_data == '') {
- alert("請先輸入設定溫度!");
- return false;
- }
- tankTempEnable_ON()
- var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": temp_data };
- $.post('/mqtt/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- //$("#cmn-toggle-14").prop('checked', true); // prop 設置元素屬型與元素值, 設定 checked 屬性為 true
- setTimeout("alert('溫度設定_開啟成功!')", 500); // 設定時間執行函式 delay(500), 只執行一次
- } else if (res == 'off') {
- //$("#cmn-toggle-14").prop('checked', false);
- setTimeout("alert('溫度設定_關閉成功!')", 500);
- } else {
- console.log(res)
- };
- }, 'text')
- /*
- $.get('/loading/F' + tank_num, '', function (res) {
- $("#tank_temp_data").attr("placeholder", res.tank_temp1);
- }, 'json');
- */
- // window.location.reload();
- };
- function tankTemp_ON() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": "30" };
- $.post('/mqtt/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- } else if (res == 'off') {
- } else {
- console.log('res error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- function tankTemp_OFF() {
- var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": "0" };
- $.post('/mqtt/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- } else if (res == 'off') {
- } else {
- console.log('res error');
- };
- }, 'text')
- // setTimeout(function () { location.reload(); }, 500);
- };
- // Benson 真空吸料機 (START) 出料儲豆槽
- function outputVacuum() {
- 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": "FO" + tank_num, "command": "output_vacuum_status", "value": status };
- console.log('data:', data)
- $.post('/mqtt/' + tank_num, data, function (res) {
- if (res == 'on') {
- $("#cmn-toggle-32").prop('checked', true);
- setTimeout("alert('出料儲豆槽真空吸料機_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-32").prop('checked', false);
- setTimeout("alert('出料儲豆槽真空吸料機_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- };
- function outputVacuum_ON() {
- var data = { "tank_num": "FO" + tank_num, "command": "output_vacuum_status", "value": "on" };
- console.log('data:', data)
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- };
- function outputVacuum_OFF() {
- var data = { "tank_num": "FO" + tank_num, "command": "output_vacuum_status", "value": "off" };
- console.log('data:', data)
- $.post('/mqtt/' + tank_num, 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 error');
- };
- }, 'text')
- };
|