| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998 | <!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="300" /><!-- <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">    <style>        .footer{            position: absolute;            width: 100%;            background-color: #eee;            text-align: center;        }        body {            margin: 0;        }        input[type="button"] {            padding: 4px 15px;            background: #f3f3f3;            border: 0 none;            cursor: pointer;            -webkit-border-radius: 5px;            border-radius: 5px;        }        .navbar-dark .navbar-nav .nav-link {            color: white;            cursor: pointer;            text-decoration: none;            width: 110px;            height: 46px;        }        .nav-top {            line-height: 40px;            background-color: #C4C4C4;        }        .website_title {            font-family: Roboto;            font-style: normal;            font-weight: normal;            font-size: 30px;            color: #000000;        }        .navbar-nav>li {            float: none;            display: inline-block;            width: 70px;            margin: 0 auto;            text-align: center;        }        .navbar-nav>li a {            font-size: 20px;        }        .main-page {            margin-top: 200px;        }        .page-title {            font-family: Roboto;            font-style: normal;            font-weight: bold;            font-size: 36px;        }        .flex {            display: flex;            flex-direction: row;            flex-wrap: wrap;            justify-content: center;        }        .set-link {            display: inline-block;            width: 350px;            height: 70px;            line-height: 70px;            background: #008CBA;            border: 1px solid #CFCFCF;            box-sizing: border-box;            color: #FFFFFF;            border-radius: 10px;            font-size: 36px;        }        .cmn-toggle {            position: absolute;            margin-left: 0px;            visibility: hidden;        }        .cmn-toggle+label {            display: block;            position: relative;            cursor: pointer;            outline: none;            user-select: none;        }        input.cmn-toggle-round-flat+label {            padding: 2px;            width: 60px;            height: 30px;            background-color: #C0C0C0;            border-radius: 60px;            transition: background 0.4s;        }        input.cmn-toggle-round-flat+label:before,        input.cmn-toggle-round-flat+label:after {            display: block;            position: absolute;            content: "";        }        input.cmn-toggle-round-flat+label:before {            top: 2px;            left: 2px;            bottom: 2px;            right: 2px;            background-color: #fff;            border-radius: 60px;            transition: background 0.4s;        }        input.cmn-toggle-round-flat+label:after {            top: 4px;            left: 4px;            bottom: 4px;            width: 24px;            background-color: #dddddd;            border-radius: 52px;            transition: margin 0.4s, background 0.4s;        }        input.cmn-toggle-round-flat:checked+label {            background-color: #C0C0C0;        }        input.cmn-toggle-round-flat:checked+label:after {            margin-left: 27px;            background-color: #008CBA;        }        @media(max-width:373px) {            .card {                margin-right: 0px;            }            .set-link {                width: 250px;            }        }        @media(max-width:577px) {}        @media(min-width:576px) {}        @media(min-width:768px) {            .navbar-nav>li {                margin-left: 0px;            }            .navbar-nav .li-block {                display: none;            }        }        @media(min-width:991px) {            .navbar-nav>li {                margin-left: 20px;            }            .navbar-nav .li-block {                display: none;            }        }        @media(min-width:1200px) {            .navbar-nav>li {                margin-left: 50px;            }            .navbar-nav .li-block {                display: inline-block;                width: 70px;            }        }        @media(min-width:1400px) {            .navbar-nav .li-block {                display: inline-block;                width: 200px;            }        }        @media(min-width:1689px) {            .navbar-nav>li {                margin-left: 50px;            }            .navbar-nav .li-block {                display: inline-block;                width: 500px;            }        }    </style>    <script language="JavaScript">        // 指定 10秒 刷新網頁一次        var ftid = '{{tid}}';        console.log('ftid:' + ftid)        $(function(){            $("#ferment_tank_page").text('發酵槽 F' + ftid + ' 攝影機畫面   ')            $('#ferment_tank_page').attr("href", "/camera_F" + ftid)            $("#ferment_container_title").text('發酵槽 F' + ftid + ' 操作介面')        });        // WebUpdate_set = setInterval(function(){WebUpdate(ftid)} , 60 * 1000)        var WebUpdate_set    </script>    <script>        // 發酵槽_制動器控制        var tank_num = '{{tid}}';        function inputVacuum() {            var status = "off";            var check = $("input[name=input_vacuum_status]:checked");  // 這裡面是 jQuery 撈取資料的方法, jQuery 常使用到 $ 錢字號            console.log('check:', check);            //大於0代表有被選中, 如果有多個可以呈現勾取的項目數量            if (check.length > 0) {                status = "on";                $("#cmn-toggle-02").prop('checked', false); // 確認是否勾選                if (!confirm("你確定要開啟入料儲豆槽真空吸料機嗎?")) {                    return false;                };            } else {                $("#cmn-toggle-02").prop('checked', true);                if (!confirm("你確定要關閉入料儲豆槽真空吸料機嗎?")) {                    return false;                };            };            var data = { "tank_num": "F" + tank_num, "command": "input_vacuum_status", "value": status };            // jquery 請求 '/mqtt/{{tid}}' 頁面            $.post('/mqtt/{{tid}}', data, function (res) {      //res:HTTP response argument to the middleware function                console.log('data:', data)                if (res == 'on') {                    $("#cmn-toggle-02").prop('checked', true);                    setTimeout("alert('入料儲豆槽真空吸料機_開啟成功!')", 500);                } else if (res == 'off') {                    $("#cmn-toggle-02").prop('checked', false);                    setTimeout("alert('入料儲豆槽真空吸料機_關閉成功!')", 500);                } else {                    alert(res);                };            }, 'text')            // setTimeout(function () { location.reload(); }, 500);        };        function inputVacuum_ON() {            var data = { "tank_num": "F" + tank_num, "command": "input_vacuum_status", "value": "on" };            // jquery 請求 '/mqtt/{{tid}}' 頁面            $.post('/mqtt/{{tid}}', data, function (res) {      //res:HTTP response argument to the middleware function                console.log('data:', data)                if (res == 'on') {                    $("#cmn-toggle-02").prop('checked', true);                } else if (res == 'off') {                    $("#cmn-toggle-02").prop('checked', false);                } else {                };            }, 'text')            // setTimeout(function () { location.reload(); }, 500);        };        function inputVacuum_OFF() {            var data = { "tank_num": "F" + tank_num, "command": "input_vacuum_status", "value": "off" };            // jquery 請求 '/mqtt/{{tid}}' 頁面            $.post('/mqtt/{{tid}}', data, function (res) {      //res:HTTP response argument to the middleware function                console.log('data:', data)                if (res == 'on') {                    $("#cmn-toggle-02").prop('checked', true);                } else if (res == 'off') {                    $("#cmn-toggle-02").prop('checked', false);                } else {                };            }, '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/{{tid}}', 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/{{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 {                };            }, 'text')            // setTimeout(function () { location.reload(); }, 500);        };        function tankVacuum_OFF() {            var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": "off" };            $.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 {                };            }, '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/{{tid}}', 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/{{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 {                };            }, '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/{{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 {                };            }, '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/{{tid}}', 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/{{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 {                };            }, 'text')            // setTimeout(function () { location.reload(); }, 500);        };        function tankDiskValve_OFF() {            var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "off" };            $.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 {                };            }, '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/{{tid}}', 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/{{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 {                };            }, '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/{{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 {                };            }, '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/{{tid}}', 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/{{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 {                };            }, '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/{{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 {                };            }, '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/{{tid}}', 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/{{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 {                };            }, '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/{{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 {                };            }, '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/{{tid}}', 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/{{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 {                };            }, '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/{{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 {                };            }, '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/{{tid}}', 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/{{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 {                };            }, '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/{{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 {                };            }, '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/{{tid}}', 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/{{tid}}', 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 {                };            }, '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/{{tid}}', 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 {                };            }, '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/{{tid}}', 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/{{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 {                };            }, '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/{{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 {                };            }, '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/{{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')            // setTimeout(function () { location.reload(); }, 500);        };        function tankMotor_ON() {            var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": "10" };            $.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 {                };            }, 'text')            // setTimeout(function () { location.reload(); }, 500);        };        function tankMotor_OFF() {            var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": "0" };            $.post('/mqtt/{{tid}}', data, function (res) {                console.log('data:', data)                if (res == 'on') {                    var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)                } else if (res == 'off') {                    clearInterval(timer);                   // 取消 timer 的不斷執行                    $("#motor_rpm_status").text('');        // 設置 #motor_rpm_status 的文字為空, #井字號                } else {                };            }, '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/{{tid}}', 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/{{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 {                };            }, 'text')            // setTimeout(function () { location.reload(); }, 500);        };        function tankHeater1_OFF() {            var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": "off" };            $.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 {                };            }, '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/{{tid}}', 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/{{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 {                };            }, 'text')            // setTimeout(function () { location.reload(); }, 500);        };        function tankHeater2_OFF() {            var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": "off" };            $.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 {                };            }, '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/{{tid}}', 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/{{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 {                };            }, '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/{{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 {                };            }, '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/{{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')            // setTimeout(function () { location.reload(); }, 500);        };        function tankTemp_ON() {            var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": "40" };            $.post('/mqtt/{{tid}}', data, function (res) {                console.log('data:', data)                if (res == 'on') {                } else if (res == 'off') {                } else {                };            }, 'text')            // setTimeout(function () { location.reload(); }, 500);        };        function tankTemp_OFF() {            var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": "0" };            $.post('/mqtt/{{tid}}', data, function (res) {                console.log('data:', data)                if (res == 'on') {                } else if (res == 'off') {                } else {                };            }, '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": "F" + tank_num, "command": "output_vacuum_status", "value": status };            console.log('data:', data)            $.post('/mqtt/{{tid}}', 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')            // setTimeout(function () { location.reload(); }, 500);        };        function outputVacuum_ON() {            var data = { "tank_num": "F" + tank_num, "command": "output_vacuum_status", "value": "on" };            console.log('data:', data)            $.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 {                };            }, 'text')            // setTimeout(function () { location.reload(); }, 500);        };        function outputVacuum_OFF() {            var data = { "tank_num": "F" + tank_num, "command": "output_vacuum_status", "value": "off" };            console.log('data:', data)            $.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 {                };            }, 'text')            // setTimeout(function () { location.reload(); }, 500);        };    </script></head><body>    <div style="text-align: left;">        <a href="/ferment" style="float: left;">   返回發酵貨櫃首頁</a>    </div>    <div style="text-align: right;">        <a id="ferment_tank_page" href="/index_new" style="float: right;">___________________</a>    </div>    <div id="ferment_container_title" style="text-align: center; margin-top: 30px; font-size: 24px; margin-bottom: 15px;">        發酵槽 F 操作介面    </div><!--    指定水位高度:    <input name="testing_water" type="text" value="45" style="width:100px;">    <input type="button" value="桶內水位測試" onclick="testingWater()">    <script>        var proccess = 0;   // 下方用來判斷程式是否執行結束, 避免重疊        function testingWater(){            var testing_water_height = $("input[name=testing_water]").val()            console.log("[start]testing_water_height" + testing_water_height)            var interval = setInterval(tankWaterHeight, 5000);            function tankWaterHeight(){                if (proccess == 1){                    return;     // 若還在處理就取消, 函式立即停止                }                proccess = 1;                $.ajax({                    type:"GET",                    url:'/ferment_PressureWaterLevel_' + tank_num,                    dataType:'json',                    success:function(response){                        var present_water_height = response.PressureWaterLevel                        console.log('present_water_height: ' + present_water_height)                        if(present_water_height > testing_water_height){                            clearInterval(interval);                            console.log('達到目標水位!')                        }                        proccess = 0;                    },                    error:function(thrownError){                        console.log("Error: " + thrownError)                        proccess = 0;                    }                });                proccess = 0;            };        };    </script>    <hr>-->    狀態更新時間(秒)    <input name="webupdate_time" type="text" value="60" style="width:100px;">    <input type="button" value="設定更新時間" onclick="changeUpdate()">    <script language="JavaScript">                function changeUpdate() {            clearInterval(WebUpdate_set);            var webupdate_time = $("input[name=webupdate_time]").val()            console.log('webupdate_time' + webupdate_time)            WebUpdate_set = setInterval(function(){WebUpdate(ftid)} , webupdate_time * 1000);        }        // jQuery 更新感測器制動器狀態        function WebUpdate(ftid) {            $.get('/loading/F' + ftid, '', 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.tank_solenoid_water_total == 0) {                    $("#cmn-toggle-14").prop('checked', false);                } else if (res.tank_solenoid_water_total == 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_pump_sensor == 0) {                    $("#cmn-toggle-41").prop('checked', false);                } else if (res.tank_pump_sensor == 1) {                    $("#cmn-toggle-41").prop('checked', true);}                                if (res.tank_threewayvalve_bean == 0) {                    $("#cmn-toggle-44").prop('checked', false);                } else if (res.tank_threewayvalve_bean == 1) {                    $("#cmn-toggle-44").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 = LiDAR_t_status]").text(res.LiDAR);                $("[name = PressureWaterLevel_t_status]").text(res.PressureWaterLevel);                if (res.WaterLevel == '1' && res.outer_solenoid_water == '1'){                    outerSolenoidWater_OFF();                    console.log('保溫夾層注水 OFF')                };                   }, 'json');        }    </script>    <h4>制動器</h4>    <table border="1px solid black" style="font-size:18px;" width=100%>        <tr>            <td style="color:red;">Valve</td>            <td>入料<br>真空吸料機</td>            <td>桶內<br>真空吸料機</td>            <td>入料三通閥</td>            <td>總進水<br>電磁閥</td>            <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>            <td>出料<br>真空吸料機</td>        </tr>        <tr>            <td>                <span style="color:#C0C0C0;">off</span>                <span style="color:#008CBA;">on</span>            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-01" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-01"></label>                    </div>                    <div class="switch text-center">                        {% if input_vacuum == 1 %}                        <input id="cmn-toggle-02" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked                            name="tank_vacuum_status" value="ON" onclick="inputVacuum()">                        {% else %}                        <input id="cmn-toggle-02" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"                            name="tank_vacuum_status" value="OFF" onclick="inputVacuum()">                        {% endif %}                        <label for="cmn-toggle-02"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-03" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-03" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-04" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-04"></label>                    </div>                    <div class="switch text-center">                        {% if tank_vacuum=='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 for="cmn-toggle-05"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-06" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-06" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-07" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-07"></label>                    </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 for="cmn-toggle-08"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-09" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-09" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-13" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-13"></label>                    </div>                    <div class="switch text-center">                        {% if tank_solenoid_water_total=='ON' %}                        <input id="cmn-toggle-14" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked                            name="tank_solenoid_water_total_status" value="ON" onclick="tankSolenoidWaterTotal()">                        {% else %}                        <input id="cmn-toggle-14" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"                            name="tank_solenoid_water_total_status" value="OFF" onclick="tankSolenoidWaterTotal()">                        {% endif %}                        <label for="cmn-toggle-14"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-15" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-15" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-16" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-16"></label>                    </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 for="cmn-toggle-17"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-18" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-18" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-37" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-37"></label>                    </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 for="cmn-toggle-38"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-39" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-39" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-49" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-49"></label>                    </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 for="cmn-toggle-50"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-51" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-51" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-40" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-40"></label>                    </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 for="cmn-toggle-41"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-42" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-42" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-43" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-43"></label>                    </div>                    <div class="switch text-center">                        {% if tank_threewayvalve_bean=='ON' %}                        <input id="cmn-toggle-44" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox"                            name="tank_threewayvalve_bean_status" value="ON" onclick="tankThreeWayValveBean()">                        {% else %}                        <input id="cmn-toggle-44" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"                            name="tank_threewayvalve_bean_status" value="OFF" onclick="tankThreeWayValveBean()">                        {% endif %}                        <label for="cmn-toggle-44"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-45" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-45" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-46" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-46"></label>                    </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 for="cmn-toggle-47"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-48" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-48" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <input id="motor_rpm_data" type="text" placeholder="{{tank_motor}}" value="" style="width:50px;">RPM                <br>                <span id="motor_rpm_status" style="color:red;"></span>                <input type="button" value="送出" name="tank_motor_status" onclick="tankMotor()">            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-25" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-25"></label>                    </div>                    <div class="switch text-center">                        {% if 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 for="cmn-toggle-26"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-27" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-27" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-28" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-28"></label>                    </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 for="cmn-toggle-29"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-30" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-30" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-34" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-34"></label>                    </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 for="cmn-toggle-35"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-36" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-36" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <input id="tank_temp_data" type="text" placeholder="{{tank_temp}}" value="" style="width:50px;">℃                <span id="tank_temp_status" style="color:red;"></span>                <br>                <input type="button" value="送出" name="tank_temp_status" onclick="tankTemp()">            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-10" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-10"></label>                    </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 for="cmn-toggle-11"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-12" class="cmn-toggle cmn-toggle-on-off" type="checkbox">                        <label for="cmn-toggle-12" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>            <td>                <div class="switch_div">                    <div class="switch">                        <input id="cmn-toggle-31" class="cmn-toggle cmn-toggle-round" type="checkbox">                        <label for="cmn-toggle-31"></label>                    </div>                    <div class="switch text-center">                        {% if output_vacuum == 1 %}                        <input id="cmn-toggle-32" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked                            name="output_vacuum_status" value="ON" onclick="outputVacuum()">                        {% else %}                        <input id="cmn-toggle-32" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"                            name="output_vacuum_status" value="OFF" onclick="outputVacuum()">                        {% endif %}                        <label for="cmn-toggle-32"></label>                    </div>                    <div class="switch">                        <input id="cmn-toggle-33" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">                        <label for="cmn-toggle-33" data-on="Yes" data-off="No"></label>                    </div>                </div>            </td>        </tr>        <tr>            <td><span style="color:#008CBA;"><b>ON</b></span></td>            <td><input type="button" value="ON" name="input_vacuum_ON" onclick="inputVacuum_ON()"></td>            <td><input type="button" value="ON" name="tank_vacuum_ON" onclick="tankVacuum_ON()"></td>            <td><input type="button" value="ON" name="tank_threewayvalve_input_ON"                    onclick="tankThreeWayValveInput_ON()"></td>            <td><input type="button" value="ON" name="tank_solenoid_water_in_ON" onclick="tankSolenoidWaterTotal_ON()">            </td>            <td><input type="button" value="ON" name="tank_solenoid_disinfect_ON" onclick="tankSolenoidDisinfect_ON()">            </td>            <td><input type="button" value="ON" name="outer_solenoid_water_ON" onclick="outerSolenoidWater_ON()">            </td>            <td><input type="button" value="ON" name="tank_solenoid_water_in_ON" onclick="tankSolenoidWaterIn_ON()">            </td>            <td><input type="button" value="ON" name="tank_pump_sensor_ON" onclick="tankPumpSensor_ON()">            </td>            <td><input type="button" value="ON" name="tank_threewayvalve_bean_ON" onclick="tankThreeWayValveBean_ON()">            </td>            <td><input type="button" value="ON" name="outer_threewayvalve_float_ON"                    onclick="outerThreeWayValveFloat_ON()">            </td>            <td><input type="button" value="ON" name="tank_motor_ON" onclick="tankMotor_ON()"></td>            <td><input type="button" value="ON" name="tank_heater1_ON" onclick="tankHeater1_ON()"></td>            <td><input type="button" value="ON" name="tank_heater2_ON" onclick="tankHeater2_ON()"></td>            <td><input type="button" value="ON" name="tank_temp_enable_ON" onclick="tankTempEnable_ON()"></td>            <td><input type="button" value="ON" name="tank_temp_ON" onclick="tankTemp_ON()"></td>            <td><input type="button" value="ON" name="tank_diskvalve_ON" onclick="tankDiskValve_ON()"></td>            <td><input type="button" value="ON" name="output_vacuum_ON" onclick="outputVacuum_ON()"></td>        </tr>        <tr>            <td><span style="color:#C0C0C0;"><b>OFF</b></span></td>            <td><input type="button" value="OFF" name="input_vacuum_OFF" onclick="inputVacuum_OFF()"></td>            <td><input type="button" value="OFF" name="tank_vacuum_OFF" onclick="tankVacuum_OFF()"></td>            <td><input type="button" value="OFF" name="tank_threewayvalve_input_OFF"                    onclick="tankThreeWayValveInput_OFF()"></td>            <td><input type="button" value="OFF" name="tank_solenoid_water_in_OFF"                    onclick="tankSolenoidWaterTotal_OFF()">            </td>            <td><input type="button" value="OFF" name="tank_solenoid_disinfect_OFF"                    onclick="tankSolenoidDisinfect_OFF()"></td>            <td><input type="button" value="OFF" name="outer_solenoid_water_OFF" onclick="outerSolenoidWater_OFF()">            </td>            <td><input type="button" value="OFF" name="tank_solenoid_water_in_OFF" onclick="tankSolenoidWaterIn_OFF()">            </td>            <td><input type="button" value="OFF" name="tank_pump_sensor_OFF" onclick="tankPumpSensor_OFF()"></td>            <td><input type="button" value="OFF" name="tank_threewayvalve_bean_OFF"                    onclick="tankThreeWayValveBean_OFF()">            </td>            <td><input type="button" value="OFF" name="outer_threewayvalve_float_OFF"                    onclick="outerThreeWayValveFloat_OFF()">            </td>            <td><input type="button" value="OFF" name="tank_motor_OFF" onclick="tankMotor_OFF()"></td>            <td><input type="button" value="OFF" name="tank_heater1_OFF" onclick="tankHeater1_OFF()"></td>            <td><input type="button" value="OFF" name="tank_heater2_OFF" onclick="tankHeater2_OFF()"></td>            <td><input type="button" value="OFF" name="tank_temp_enable_OFF" onclick="tankTempEnable_OFF()"></td>            <td><input type="button" value="OFF" name="tank_temp_OFF" onclick="tankTemp_OFF()"></td>            <td><input type="button" value="OFF" name="tank_diskvalve_OFF" onclick="tankDiskValve_OFF()"></td>            <td><input type="button" value="OFF" name="output_vacuum_OFF" onclick="outputVacuum_OFF()"></td>        </tr>    </table>    <br>    <h4>感測器</h4>    <table style="font-size:18px; border:2px #cccccc solid;" cellpadding="5" border='1' width=100%>        <tr>            <td colspan="8">[入料] 生豆高度:{{input_UltraSonic.UltraSonic}} 公分</td>        </tr>        <tr>            <td colspan="4">[桶內] 生豆高度:<span name="LiDAR_t_status">{{tank_LiDAR.LiDAR}}</span> 公分</td>            <td colspan="4">[桶內] 水位高度:<span name="PressureWaterLevel_t_status">{{PressureWaterLevel}}</span> 公分</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>        <tr>            <td colspan="8">[保溫夾層] 水位高度:<span id="WaterLevel_t_status">{{WaterLevel}}</span></td>        </tr>        <tr>            <td colspan="8">[出料] 生豆高度:{{output_UltraSonic.UltraSonic}} 公分</td>        </tr>    </table>    <br>    <h4>排程測試</h4>    <table style="font-size:18px; border:2px #cccccc solid;" cellpadding="5" border='1' width=100%>        <tr>            <td>發酵</td>            <td>入水</td>            <td>入豆</td>            <td>水質測量 (攪拌、加熱)</td>            <td>排水出豆</td>        </tr>        <tr>            <td>                -- 入水 --<br>                保溫夾層加滿水<br>                指定桶內水位高度                <input name="testing_tank_water_height_F" value="100" type="text" style="width: 40px;">公分<br>                -- 入豆 --<br>                指定桶內生豆高度                <input name="testing_tank_bean_height_F" value="20" type="text" style="width: 40px;">公分<br>                -- 發酵 --<br>                指定溫度                <input name="testing_tank_temp_F" value="21" type="text" style="width: 40px;">℃<br>                指定時間                <input name="testing_tank_time_F" value="10" type="text" style="width: 40px;">秒<br>                -- 出料 --<br>                設定空桶高度                <input name="testing_tank_empty_height_F" value="10" type="text" style="width: 40px;">公分<br>                <!--                入料吸料時間(秒)                <input name="testing_tank_vacuum_in_F" value="1" type="text" style="width: 40px;">                <br>                入料放料時間(>10秒)                <input name="testing_tank_vacuum_out_F" value="10" type="text" style="width: 40px;">                <br>                入料循環次數                <input name="testing_tank_vacuum_loop_F" value="4" type="text" style="width: 40px;">                <br>                保溫夾層注水                <br>                保溫夾層滿水時加熱                <br>                溫度達設定溫度時, 停止加熱                <br>                馬達 rpm                <input name="testing_motor_rpm_F" value="20" type="text" style="width:100px;">                <br>                出料吸料時間(秒)                <input name="testing_out_vacuum_in_F" value="1" type="text"                    style="width: 40px;">                <br>                出料放料時間(>10秒)                <input name="testing_out_vacuum_out_F" value="10" type="text"                    style="width: 40px;">                <br>                出料循環次數                <input name="testing_out_vacuum_loop_F" value="4" type="text"                    style="width: 40px;">                -->            </td>            <td>                [桶內] 水位高度 <span name="PressureWaterLevel_t_status">{{PressureWaterLevel}}</span> 公分<br>                指定水量高度                <input name="testing_tank_water_height" id="testing_tank_water_height" type="text" value="100" style="width: 40px;">公分            </td>            <td>                [桶內] 生豆高度 <span name="LiDAR_t_status">{{tank_LiDAR.LiDAR}}</span> 公分<br>                指定咖啡豆高度                <input name="testing_tank_coffee_height" id="testing_tank_coffee_height" type="text" value="0"                    style="width: 40px;">公分<br>                入料吸料時間                <input name="testing_tank_vacuum_in" id="testing_tank_vacuum_in" type="text" value="1" style="width: 40px;">秒<br>                入料放料時間(>10)                <input name="testing_tank_vacuum_out" id="testing_tank_vacuum_out" type="text" value="10" style="width: 40px;">秒<br>                入料循環次數                <input name="testing_tank_vacuum_loop" id="testing_tank_vacuum_loop" type="text" value="3" style="width: 40px;">次            </td>            <td>                馬達                <input name="testing_motor_rpm" id="testing_motor_rpm" value="0" type="text" style="width: 40px;">rpm<br>                <!--                發酵時間(秒)                <input name="testing_tank_dry_time" id="testing_tank_dry_time" type="text" style="width: 40px;">                <br>                溫度控制(℃)                <input name="AAA" id="AAA" type="text" style="width: 40px;">-->                加熱器 1、2 ON                <br>                pump 開啟時間                <input name="testing_tank_pump_on" id="testing_tank_pump_on" value="10" type="text" style="width: 40px;">秒<br>                pump 關閉時間                <input name="testing_tank_pump_off" id="testing_tank_pump_off" value="10" type="text" style="width: 40px;">秒<br>                pump 循環次數                <input name="testing_tank_pump_loop" id="testing_tank_pump_loop" value="3" type="text" style="width: 40px;">次<br>            </td>            <td>                [桶內] 生豆高度 <span name="LiDAR_t_status">{{tank_LiDAR.LiDAR}}</span> 公分<br>                指定空桶高度                <input name="testing_tank_empty_height" id="testing_tank_empty_height" type="text" value="0"                    style="width: 40px;">公分<br>                蝴蝶閥 ON                <br>                出料吸料時間                <input name="testing_out_vacuum_in" id="testing_out_vacuum_in" value="1" type="text" style="width: 40px;">秒<br>                出料放料時間(>10)                <input name="testing_out_vacuum_out" id="testing_out_vacuum_out" value="10" type="text" style="width: 40px;">秒<br>                出料循環次數                <input name="testing_out_vacuum_loop" id="testing_out_vacuum_loop" value="3" type="text" style="width: 40px;">次            </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() {                        clearInterval(WebUpdate);                        var testing_tank_water_height_F = $("input[name=testing_tank_water_height_F]").val();                        console.log("指定水高: " + testing_tank_water_height_F)                        // -- 入水 --                        // 若桶內水還沒滿, 開啟桶內入水                        $.get('/ferment_PressureWaterLevel_' + tank_num, '', function (res) {                            if ( res.PressureWaterLevel < testing_tank_water_height_F ){                                console.log('桶內開始入水')                                tankSolenoidWaterIn_ON();                                console.log('tankSolenoidWaterIn_ON')                                console.log('請開啟水龍頭進水')                            };                        }, 'json');                        // 若夾層水還沒滿, 開啟夾層入水                        $.get('/ferment_WaterLevel_' + tank_num, '', function (res) {                            if ( res.WaterLevel != 1 ){                                console.log('夾層開始入水')                                outerSolenoidWater_ON();                                console.log('tankSolenoidWaterIn_ON')                                console.log('請開啟水龍頭進水')                            };                        }, 'json');                        // 入水每五秒判斷                        var WaterIn_F_interval = setInterval(WaterIn_F, 5000);                        var BeanIn_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 present_tank_water_height = response.PressureWaterLevel                                    var present_WaterLevel = response.WaterLevel                                    if (present_WaterLevel == 1) {                                        outerSolenoidWater_OFF()                                        console.log("outerSolenoidWater_OFF")                                        console.log("保溫夾層入水完成, 桶內加水中")                                    }                                    if (present_tank_water_height > testing_tank_water_height_F) {                                        tankSolenoidWaterIn_OFF()                                        console.log("tankSolenoidWaterIn_OFF")                                        console.log("桶內入水完成, 保溫夾層加水中")                                    }                                    if (present_WaterLevel == 1 &&                                     present_tank_water_height > testing_tank_water_height_F) {                                        clearInterval(WaterIn_F_interval);                                        console.log("入水完成!")                                        // -- 入豆 --                                        BeanIn_F_interval = setInterval(BeanIn_F, 5000);                                    }                                    WaterIn_F_Process = 0;                                },                                error:function(thrownError){                                    console.log("Error: " + thrownError)                                    WaterIn_F_Process = 0;                                }                            });                           }                        // 發酵排程                        var Fermenting_F_interval                        function BeanIn_F(){                            if (BeanIn_F_Process == 1) {                                return; // 若還在處理就取消, 函式立即停止                            }                            // 取得桶內生豆高度                            BeanIn_F_Process = 1;                            $.ajax({                                async:false,                                type:"GET",                                url:"/ferment_LiDAR_" + tank_num,                                dataType:'json',                                success:function(response){                                    var present_Bean_height = response.LiDAR                                    console.log("目前豆高: " + present_Bean_height)                                    var testing_tank_bean_height_F = $("input[name=testing_tank_bean_height_F]").val();                                    console.log("指定豆高: " + testing_tank_bean_height_F)                                    if (present_Bean_height > testing_tank_bean_height_F) {                                        clearInterval(BeanIn_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_ON()                                        console.log("tankMotor_ON")                                        // 取得桶內溫度, 若低於指定溫度則開啟加熱器                                        $.get('/ferment_SHT11_' + tank_num, '', function(res){                                            if (res.SHT11_Temp < testing_tank_temp_F){                                                tankHeater1_ON()                                                console.log("tankHeater1_ON")                                                tankHeater2_ON()                                                console.log("tankHeater2_ON")                                            }                                        });                                                                          Fermenting_F_interval = setInterval(Fermenting_F, 5000);                                    } else {                                        tankVacuum_ON()                                        console.log("tankVacuum_ON")                                        var time = new Date();                                        while ((new Date() - time) < 2 * 1000) { };                                        tankVacuum_OFF()                                        console.log("tankVacuum_OFF")                                    }                                    BeanIn_F_Process = 0;                                },                                error:function(thrownError){                                    console.log("Error: " + thrownError)                                    BeanIn_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_OFF()                                        console.log("tankHeater1_OFF")                                        tankHeater2_OFF()                                        console.log("tankHeater2_OFF")                                        console.log("發酵 " + testing_tank_time_F + " 秒")                                        var time = new Date();                                        while ((new Date() - time) < testing_tank_time_F * 1000) { };                                        tankMotor_OFF()                                        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_LiDAR_" + tank_num,                                dataType:"json",                                success:function(response){                                    var present_Bean_height = response.LiDAR                                    console.log("目前發酵豆高: " + present_Bean_height)                                    if (present_Bean_height > testing_tank_empty_height_F) {                                        outputVacuum_ON()                                        console.log("outputVacuum_ON")                                        var time = new Date();                                        while ((new Date() - time) < 2 * 1000) { };                                        outputVacuum_OFF()                                        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="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_PressureWaterLevel_' + tank_num, '', function (res) {                            if ( res.PressureWaterLevel < testing_tank_water_height ){                                console.log('開始入水')                                tankSolenoidWaterIn_ON();                                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_PressureWaterLevel_' + tank_num,                                dataType:'json',                                success:function(response){                                    var present_water_height = response.PressureWaterLevel                                    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_OFF();                                        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="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_LiDAR_' + tank_num,                                    dataType:'JSON',                                    success:function(response){                                        var present_Coffee_height = response.LiDAR                                        console.log("目前生豆高度: ", present_Coffee_height)                                        if( present_Coffee_height >= testing_tank_coffee_height){                                            clearInterval(Coffee_interval);                                            console.log("生豆已達目標高度!")                                            CoffeeIn_Process = 0;                                        } else {                                            tankVacuum_ON()                                            console.log('tankVacuum_ON')                                            var time = new Date();                                            while ((new Date() - time) < testing_tank_vacuum_in * 1000) { };                                            tankVacuum_OFF()                                            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;                                    }                                });                                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_ON()                                console.log('tankVacuum_ON')                                var time = new Date();                                while ((new Date() - time) < testing_tank_vacuum_in * 1000) { };                                tankVacuum_OFF()                                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="WATER_testing()">水質測量(攪拌、加熱)</button>                <script>                    function WATER_testing() {                        var set_motor_rpm = $("input[name=testing_motor_rpm]").val();                        var data = { "tank_num": "C" + 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_ON()                        console.log('tankHeater1_ON')                        var time = new Date();                        while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };                        tankHeater2_ON()                        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_ON()                            console.log('tankPumpSensor_ON')                            var time = new Date();                            while ((new Date() - time) < testing_tank_pump_on * 1000) { };                            tankPumpSensor_OFF()                            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_OFF()                        console.log('tankMotor_OFF')                        var time = new Date();                        while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };                        tankHeater1_OFF()                        console.log('tankHeater1_OFF')                        var time = new Date();                        while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };                        tankHeater2_OFF()                        console.log('tankHeater2_OFF')                    };                </script>            </td>            <td>                <button type="submit" class="btn btn-primary" onclick="CoffeeOut_testing()">排水出豆</button>                <script>                    var CoffeeOut_process = 0;                    function CoffeeOut_testing() {                        var testing_tank_empty_height = $("input[name=testing_tank_empty_height]").val();                        var testing_out_vacuum_in = $("input[name=testing_out_vacuum_in]").val();                        var testing_out_vacuum_out = $("input[name=testing_out_vacuum_out]").val();                        var testing_out_vacuum_loop = $("input[name=testing_out_vacuum_loop]").val();                        if (testing_tank_empty_height != 0){                            console.log('指定高度 ' + testing_tank_empty_height + ' 入豆')                                                        $.get('/ferment_LiDAR_' + tank_num, '', function (res) {                                if ( parseInt(res.LiDAR) > parseInt(testing_tank_empty_height) ){                                    tankDiskValve_ON()                                    console.log('tankDiskValve_ON')                                };                            }, 'json');                            var CoffeeOut_interval = setInterval(tankEmptyHeight, 5000);                            function tankEmptyHeight(){                                if (CoffeeOut_process == 1) {                                    return;                                }                                CoffeeOut_process = 1 ;                                $.ajax({                                    type:"GET",                                    url:"/ferment_LiDAR_" + tank_num,                                    dataType:"json",                                    success:function (response) {                                        var present_Coffee_height = response.LiDAR                                        console.log("目前桶內生豆高度: ", present_Coffee_height)                                        console.log("指定空桶生豆高度: ", testing_tank_empty_height)                                        if( parseInt(present_Coffee_height) < parseInt(testing_tank_empty_height)){                                            clearInterval(CoffeeOut_interval);                                            console.log("桶內已淨空!")                                            CoffeeOut_process = 0;                                        } else {                                            outputVacuum_ON();                                            console.log('outputVacuum_ON')                                            var time = new Date();                                            while ((new Date() - time) < testing_out_vacuum_in * 1000) { };                                            outputVacuum_OFF()                                            console.log('outputVacuum_OFF')                                            var time = new Date();                                            while ((new Date() - time) < testing_out_vacuum_out * 1000) { };                                            CoffeeOut_process = 0;                                        }                                      },                                    error:function(thrownError){                                        console.log("Error: " + thrownError)                                        CoffeeIn_Process = 0;                                    }                                })                            }                            tankDiskValve_OFF()                            console.log('tankDiskValve_OFF')                        } else if ( testing_tank_empty_height == 0){                            console.log('循環方式入豆')                                                        for (step = 1; step <= testing_out_vacuum_loop; step++) {                                console.log('循環第 ' + step + ' 次')                                outputVacuum_ON();                                console.log('outputVacuum_ON')                                var time = new Date();                                while ((new Date() - time) < testing_out_vacuum_in * 1000) { };                                if (step == 1) {                                    tankDiskValve_ON();                                    console.log('tankDiskValve_ON')                                    var time = new Date();                                    while ((new Date() - time) < testing_out_vacuum_in * 1000) { };                                }                                outputVacuum_OFF();                                console.log('outputVacuum_OFF')                                var time = new Date();                                while ((new Date() - time) < testing_out_vacuum_out * 1000) { };                            }                            tankDiskValve_OFF();                            console.log('tankDiskValve_OFF')                        };                    };                </script>            </td>        </tr>    </table>    <br>    <h4>攝影機畫面</h4>    <div class="container-fluid">        <div class="row" style="margin-top:5px;">            <div class="col flex">                <div class="col-md-12 row flex" style="text-align:center;margin-top:5px;">                    <div class="col-md-12 row flex">                        <img src="" id="two" width="80%" height="80%">                    </div>                </div>                <script>                    // M5 攝影機                    //const img = document.querySelector('#one');                    const img1 = document.querySelector('#two');                    const WS_URL1 = 'ws:///60.250.156.230:8089';                    const ws1 = new WebSocket(WS_URL1);                    let urlObject1;                    ws1.onopen = () => console.log(`Connected to ${WS_URL1}`);                    ws1.onmessage = message1 => {                        const arrayBuffer1 = message1.data;                        if (urlObject1) {                            URL.revokeObjectURL(urlObject1);                        }                        urlObject1 = URL.createObjectURL(new Blob([arrayBuffer1]));                        img1.src = urlObject1;                    }                </script>            </div>        </div>    </div>    <br>    <h4>水路排程測試</h4>    [保溫夾層] 水位高度:<span id="WaterLevel_t_status">{{WaterLevel}}</span>    <table style="font-size:18px; border:2px #cccccc solid;" cellpadding="5" border='1' width=100%>        <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_OFF()                        console.log('outerSolenoidWater_OFF')                        var time = new Date();                        while ((new Date() - time) < 1000) { };                        tankSolenoidWaterIn_ON()                        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_OFF()                        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_OFF()                        console.log('tankSolenoidWaterIn_OFF')                        var time = new Date();                        while ((new Date() - time) < 1000) { };                        outerSolenoidWater_ON()                        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_OFF()                        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_ON()                        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_OFF()                        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_ON()                        console.log('tankSolenoidWaterIn_ON')                        var time = new Date();                        while ((new Date() - time) < 2 * 1000) { };                        tankPumpSensor_ON()                        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_OFF()                        console.log('tankPumpSensor_OFF')                        var time = new Date();                        while ((new Date() - time) < 2 * 1000) { };                        tankSolenoidWaterIn_OFF()                        console.log('tankSolenoidWaterIn_OFF')                    }                </script>            </td>        </tr>    </table>    <br>    <!--    入料儲豆槽液位計高度 公分{{input_UltraSonic.UltraSonic}}    <div id="input_UltraSonic" d={{input_UltraSonic.UltraSonic}} style="display:none"></div>    <br>    溫溼度感測器 溫度 ℃{{tank_SHT11.SHT11_Temp}}    <div id="tank_Temp" d={{tank_SHT11.SHT11_Temp}} style="display:none"></div>    <br>    溫溼度感測器 濕度 %{{tank_SHT11.SHT11_Humidity}}    <div id="tank_EC" d={{tank_SHT11.SHT11_Humidity}} style="display:none"></div>    <br>    二氧化碳 CO2{{tank_CO2.CO2}}    <div id="tank_CO2" d={{tank_CO2.CO2}} style="display:none"></div>    <br>    酸鹼值 PH{{tank_PH.PH}}    <div id="tank_PH" d={{tank_PH.PH}} style="display:none"></div>    <br>    桶內壓力 PA{{tank_PA.PA}}    <div id="tank_PA" d={{tank_PA.PA}} style="display:none"></div>    <br>    發酵槽液位計高度 公分{{tank_UltraSonic.UltraSonic}}    <div id="tank_UltraSonic" d={{tank_UltraSonic.UltraSonic}} style="display:none"></div>    <br>    出料儲豆槽液位計高度 公分{{output_UltraSonic.UltraSonic}}    <div id="output_UltraSonic" d={{output_UltraSonic.UltraSonic}} style="display:none"></div>-->    <footer class="footer">        <div style="text-align: center; margin-top: 10px; font-size: 13px; margin-bottom: 10px;">            Copyright © 2021 Gold-in Tech. All Rights Reserved. 金子進科技股份有限公司 版權所有            <a href="mailto:service.gitc@gmail.com" target="_blank">service.gitc@gmail.com</a>        </div>    </footer>    </body></html>
 |