123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095 |
- // '/mqtt/' + tank_num 取代成 '/mqtt/' + tank_num
- 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": "DI" + tank_num, "command": "input_vacuum_status", "value": status };
- // jquery 請求 '/mqtt/{{tid}}' 頁面
- $.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 {
- alert(res);
- };
- }, 'text')
-
- };
- function inputVacuum_ON() {
- var data = { "tank_num": "DI" + tank_num, "command": "input_vacuum_status", "value": "on" };
- $.post('/mqtt/' + tank_num, data, function (res) {
- 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": "DI" + tank_num, "command": "input_vacuum_status", "value": "off" };
- $.post('/mqtt/' + tank_num, data, function (res) {
- 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')
- }
- // Benson 真空吸料機 (END)入料儲豆槽
- // Benson 真空吸料機 (START)
- 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": "D" + 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')
- $.get('/loading/D' + tank_num, '', 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);
- }
- }, 'json');
- // window.location.reload();
- };
- function tankVacuum_ON() {
- var data = { "tank_num": "D" + 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')
- // window.location.reload();
- }
- function tankVacuum_OFF() {
- var data = { "tank_num": "D" + 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')
- // window.location.reload();
- }
- // Benson 真空吸料機 (END)
- function tankThreeWayValve() {
- //<!--setInterval(Relay,10000);-->
- var status = "off";
- var check = $("input[name=tank_threewayvalve_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": "D" + tank_num, "command": "tank_threewayvalve_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')
- $.get('/loading/D' + tank_num, '', function (res) {
- if (res.tank_threewayvalve == 0) {
- $("#cmn-toggle-08").prop('checked', false);
- } else if (res.tank_threewayvalve == 1) {
- $("#cmn-toggle-08").prop('checked', true);
- }
- }, 'json');
- // window.location.reload();
- };
- function tankThreeWayValve_ON() {
- var data = { "tank_num": "D" + tank_num, "command": "tank_threewayvalve_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')
- // window.location.reload();
- }
- function tankThreeWayValve_OFF() {
- var data = { "tank_num": "D" + tank_num, "command": "tank_threewayvalve_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')
- // window.location.reload();
- }
- function tankThreeWayValveInput(params) {
- if (params == '1') {
- var data = { "tank_num": "D" + tank_num, "command": "tank_threewayvalve_input_status", "value": "on" };
- } else if (params == '0') {
- var data = { "tank_num": "D" + 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": "D" + 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 error')
- };
- }, 'text')
- }
- function tankThreeWayValveBean(params) {
- if (params == '1') {
- var data = { "tank_num": "D" + tank_num, "command": "tank_threewayvalve_bean_status", "value": "on" };
- } else if (params == '0') {
- var data = { "tank_num": "D" + tank_num, "command": "tank_threewayvalve_bean_status", "value": "off" };
- } else {
- var status = "off";
- var check = $("input[name=tank_threewayvalve_bean_status]:checked");
- 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": "D" + tank_num, "command": "tank_threewayvalve_bean_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 error')
- };
- }, 'text')
- }
- // 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": "D" + 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')
- $.get('/loading/D' + tank_num, '', function (res) {
- if (res.tank_diskvalve == 0) {
- $("#cmn-toggle-11").prop('checked', false);
- } else if (res.tank_diskvalve == 1) {
- $("#cmn-toggle-11").prop('checked', true);
- }
- }, 'json');
- // window.location.reload();
- };
- function tankDiskValve_ON() {
- var data = { "tank_num": "D" + 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')
- // window.location.reload();
- }
- function tankDiskValve_OFF() {
- var data = { "tank_num": "D" + 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')
- // window.location.reload();
- }
- // Benson cargo2_actuator.html 控制蝴蝶閥函數 (END)
- // 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-14").prop('checked', false);
- if (!confirm("你確定要開啟電磁閥消毒嗎?")) {
- return false;
- };
- } else {
- $("#cmn-toggle-14").prop('checked', true);
- if (!confirm("你確定要關閉消毒電磁閥嗎?")) {
- return false;
- };
- };
- var data = { "tank_num": "D" + 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-14").prop('checked', true);
- setTimeout("alert('電磁閥消毒_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-14").prop('checked', false);
- setTimeout("alert('電磁閥消毒_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- $.get('/loading/D' + tank_num, '', function (res) {
- if (res.tank_solenoid_disinfect == 0) {
- $("#cmn-toggle-14").prop('checked', false);
- } else if (res.tank_solenoid_disinfect == 1) {
- $("#cmn-toggle-14").prop('checked', true);
- }
- }, 'json');
- // window.location.reload();
- };
- function tankSolenoidDisinfect_ON() {
- var data = { "tank_num": "D" + 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-14").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-14").prop('checked', false);
- } else {
- console.log('res error')
- };
- }, 'text')
- // window.location.reload();
- }
- function tankSolenoidDisinfect_OFF() {
- var data = { "tank_num": "D" + 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-14").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-14").prop('checked', false);
- } else {
- console.log('res error')
- };
- }, 'text')
- // window.location.reload();
- }
- // Benson cargo2_actuator.html 閥 (END) 電磁閥消毒
- // Benson cargo2_actuator.html 閥 (START) 電磁閥排水
- function tankSolenoidWater() {
- var status = "off";
- var check = $("input[name=tank_solenoid_water_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": "D" + tank_num, "command": "tank_solenoid_water_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')
- $.get('/loading/D' + tank_num, '', function (res) {
- if (res.tank_solenoid_water == 0) {
- $("#cmn-toggle-17").prop('checked', false);
- } else if (res.tank_solenoid_water == 1) {
- $("#cmn-toggle-17").prop('checked', true);
- }
- }, 'json');
- // window.location.reload();
- };
- function tankSolenoidWater_ON() {
- var data = { "tank_num": "D" + tank_num, "command": "tank_solenoid_water_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')
- // window.location.reload();
- }
- function tankSolenoidWater_OFF() {
- var data = { "tank_num": "D" + tank_num, "command": "tank_solenoid_water_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')
- // window.location.reload();
- }
- // Benson cargo2_actuator.html 閥 (END) 電磁閥排水
- /*
- function Motor() {
- $.get('/peeling', '', function (res) {
- //console.log(res.peeling);
- $("#motor_rpm_status").text(res.peeling + ' rpm(每1分鐘更新一次)');
- }, 'json');
- };
- function ChangeMotor() {
- var motor_data = $("input[name=tank_motor_status]").val();
- if (!confirm("你確定要更改轉速為" + motor_data + "嗎?")) {
- return false;
- };
- var data = { "tank_num": "D" + tank_num, "command": "tank_motor_status", "value": motor_data };
- console.log('data:', data)
- $.post('/mqtt/' + tank_num, data, function (res) {
- if (res == 'on') {
- alert('更改成功');
- } else {
- alert(res);
- };
- }, 'text');
- setTimeout(function(){ location.reload(); }, 500);
- };
- */
- // Benson cargo2_actuator.html 脫皮機馬達 (START) 馬達攪拌棒
- function ChangeMotor() {
- var motor_data = $("input[id=motor_rpm_data]").val();
- if (motor_data == '') {
- //$("#cmn-toggle-20").prop('checked', false);
- alert("請先輸入要運轉的值!");
- return false;
- } else if (motor_data == 0) {
- alert("轉速 0 為關閉馬達");
- } else if (Number(motor_data) < -50 || Number(motor_data) > 50 || !Number(motor_data)) {
- //
- //$("#cmn-toggle-20").prop('checked', false);
- alert("您輸入的值已超過範圍,請重新輸入!" + !Number(motor_data));
- return false;
- };
- var value = "off";
- //var check = $("input[name=peeling-machine-on]:checked");
- if (motor_data != 0) {
- value = motor_data;
- //$("#cmn-toggle-20").prop('checked', false);
- if (!confirm("你確定要開啟攪拌馬達,運轉速度為 " + motor_data + " RPM 嗎?")) {
- return false;
- };
- } else {
- //$("#cmn-toggle-20").prop('checked', true);
- if (!confirm("你確定要關閉攪拌馬達嗎?")) {
- return false;
- };
- };
- var data = { "tank_num": "D" + 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')
- $.get('/loading/D' + tank_num, '', function (res) {
- $("#motor_rpm_data").attr("placeholder", res.tank_motor)
- }, 'json');
- // window.location.reload();
- };
- function setMotor(RPMData) {
- var data = { "tank_num": "D" + tank_num, "command": "tank_motor_status", "value": RPMData };
- $.post('/mqtt/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- //$("#cmn-toggle-14").prop('checked', true); // prop 設置元素屬型與元素值, 設定 checked 屬性為 true
- var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
- } else if (res == 'off') {
- //$("#cmn-toggle-14").prop('checked', false);
- $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
- } else {
- console.log(res)
- };
- }, 'text')
- $.get('/loading/D' + tank_num, '', function (res) {
- $("#motor_rpm_data").attr("placeholder", res.tank_motor)
- }, 'json');
- // window.location.reload();
- };
- function ChangeMotor_ON() {
- var data = { "tank_num": "D" + 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);
- } else if (res == 'off') {
- clearInterval(timer);
- $("#motor_rpm_status").text('');
- } else {
- console.log('res error')
- };
- }, 'text')
- // window.location.reload();
- }
- function ChangeMotor_OFF() {
- var data = { "tank_num": "D" + 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);
- } else if (res == 'off') {
- clearInterval(timer);
- $("#motor_rpm_status").text('');
- } else {
- console.log('res error')
- };
- }, 'text')
- // window.location.reload();
- }
- 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 脫皮機馬達 (END) 馬達攪拌棒
- // Benson cargo2_actuator.html 鼓風機機 (START)
- // 鼓風機函數
- function tankBlower() {
- var status = "off";
- var check = $("input[name=tank_blower_status]:checked");
- //大於0代表有被選中
- if (check.length > 0) {
- status = "on";
- $("#cmn-toggle-23").prop('checked', false);
- if (!confirm("你確定要開啟鼓風機嗎?")) {
- return false;
- };
- } else {
- $("#cmn-toggle-23").prop('checked', true);
- if (!confirm("你確定要關閉鼓風機嗎?")) {
- return false;
- };
- };
- var data = { "tank_num": "D" + tank_num, "command": "tank_blower_status", "value": status };
- $.post('/mqtt/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-23").prop('checked', true);
- setTimeout("alert('鼓風機_開啟成功!')", 500);
- } else if (res == 'off') {
- $("#cmn-toggle-23").prop('checked', false);
- setTimeout("alert('鼓風機_關閉成功!')", 500);
- } else {
- alert(res);
- };
- }, 'text')
- $.get('/loading/D' + tank_num, '', function (res) {
- if (res.tank_blower == 0) {
- $("#cmn-toggle-23").prop('checked', false);
- } else if (res.tank_blower == 1) {
- $("#cmn-toggle-23").prop('checked', true);
- }
- }, 'json');
- // window.location.reload();
- };
- function tankBlower_ON() {
- var data = { "tank_num": "D" + tank_num, "command": "tank_blower_status", "value": "on" };
- $.post('/mqtt/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-23").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-23").prop('checked', false);
- } else {
- console.log('res error')
- };
- }, 'text')
- // window.location.reload();
- }
- function tankBlower_OFF() {
- var data = { "tank_num": "D" + tank_num, "command": "tank_blower_status", "value": "off" };
- $.post('/mqtt/' + tank_num, data, function (res) {
- console.log('data:', data)
- if (res == 'on') {
- $("#cmn-toggle-23").prop('checked', true);
- } else if (res == 'off') {
- $("#cmn-toggle-23").prop('checked', false);
- } else {
- console.log('res error')
- };
- }, 'text')
- // window.location.reload();
- }
- // 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": "D" + 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')
- $.get('/loading/D' + tank_num, '', function (res) {
- if (res.tank_heater1 == 0) {
- $("#cmn-toggle-26").prop('checked', false);
- } else if (res.tank_heater1 == 1) {
- $("#cmn-toggle-26").prop('checked', true);
- }
- }, 'json');
- // window.location.reload();
- };
- function tankHeater1_ON() {
- var data = { "tank_num": "D" + 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')
- // window.location.reload();
- }
- function tankHeater1_OFF() {
- var data = { "tank_num": "D" + 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')
- // window.location.reload();
- }
- //電熱管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": "D" + 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')
- $.get('/loading/D' + tank_num, '', function (res) {
- if (res.tank_heater2 == 0) {
- $("#cmn-toggle-29").prop('checked', false);
- } else if (res.tank_heater2 == 1) {
- $("#cmn-toggle-29").prop('checked', true);
- }
- }, 'json');
- // window.location.reload();
- };
- function tankHeater2_ON() {
- var data = { "tank_num": "D" + 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')
- // window.location.reload();
- }
- function tankHeater2_OFF() {
- var data = { "tank_num": "D" + 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')
- // window.location.reload();
- }
- // 溫度控制
- function tankTemp1Enable() {
- var status = "off";
- var check = $("input[name=tank_temp1_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": "D" + tank_num, "command": "temp1_enable", "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')
- $.get('/loading/D' + tank_num, '', function (res) {
- if (res.tank_temp1_enable == 0) {
- $("#cmn-toggle-35").prop('checked', false);
- } else if (res.tank_temp1_enable == 1) {
- $("#cmn-toggle-35").prop('checked', true);
- }
- }, 'json');
- // window.location.reload();
- };
- function tankTemp1Enable_ON() {
- var data = { "tank_num": "D" + tank_num, "command": "tank_temp_enable", "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')
- // window.location.reload();
- }
- function tankTemp1Enable_OFF() {
- var data = { "tank_num": "D" + tank_num, "command": "temp1_enable", "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')
- // window.location.reload();
- }
- /* 判斷是否整數
- function isInteger(obj) {
- return obj % 1 === 0
- }
- isInteger(3) // true
- */
- // 設定溫度
- /*
- <h2>溫度控制設定(單位 ℃):(目前設定溫度) {{tank_temp1}}</h2>
- <input name="tank_temp1_data" type="text" placeholder="{{tank_temp1}}" style="width: 40px;">℃ (限整數數值)
- <span id="tank_temp1_status" style="color:red;"></span>
- <input type="button" value="送出(設定溫度時請點擊)" name="tank_temp1_status" onclick="ChangeTemp1()">
- */
- function ChangeTemp1() {
- var temp_data = $("input[id=tank_temp1_data]").val();
- if (temp_data == '') {
- //$("#cmn-toggle-20").prop('checked', false);
- alert("請先輸入設定溫度!");
- 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": "D" + tank_num, "command": "temp1", "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);
- clearInterval(timer); // 取消 timer 的不斷執行
- $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
- } else {
- alert(res);
- };
- }, 'text')
- $.get('/loading/D' + tank_num, '', function (res) {
- $("#tank_temp1_data").attr("placeholder", res.tank_temp1);
- }, 'json');
- // window.location.reload();
- };
- // Rita 設定溫度時直接開啟溫控開關
- function setTemp1(temp_data, temp_duration) {
- // var temp_data = $("input[id=tank_temp1_data]").val();
- if (temp_data == '') {
- alert("請先輸入設定溫度!");
- return false;
- } else if (temp_duration == '') {
- alert("請先輸入持溫時間!");
- return false;
- }
- // var value = "0";
- // var value = temp_data;
- // if (!confirm("你確定要設定內桶溫度為 " + temp_data + " ℃ 嗎?")) {
- // return false;
- // };
- tankTemp1Enable_ON()
- var data = { "tank_num": "D" + tank_num, "command": "temp1", "value": temp_data, "duration": temp_duration };
- $.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);
- clearInterval(timer); // 取消 timer 的不斷執行
- $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
- } else {
- alert(res);
- };
- }, 'text')
- $.get('/loading/D' + tank_num, '', function (res) {
- $("#tank_temp1_data").attr("placeholder", res.tank_temp1);
- }, 'json');
- // window.location.reload();
- };
- function ChangeTemp1_ON() {
- var data = { "tank_num": "D" + tank_num, "command": "temp1", "value": "30" };
- $.post('/mqtt/' + tank_num, data, function (res) {
- console.log('data:', data)
- }, 'text')
- // window.location.reload();
- }
- function ChangeTemp1_OFF() {
- var data = { "tank_num": "D" + tank_num, "command": "temp1", "value": "25" };
- $.post('/mqtt/' + tank_num, data, function (res) {
- console.log('data:', data)
- }, 'text')
- // window.location.reload();
- }
- // 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": "DO" + 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": "DO" + 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": "DO" + 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')
- }
- // Benson 真空吸料機 (END) 出料儲豆槽
|