| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987 | <!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="600" /><!-- <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>        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)        WebUpdate_set = setInterval(function(){WebUpdate(ftid)} , 10 * 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>    指定水位高度:    <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="10" style="width:100px;">    <input type="button" value="設定更新時間" onclick="changeUpdate()">    設定溫度    <input name="testing_tank_dry_temp_F" value="30" type="text" style="width:100px;">    <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);                $("#WaterLevel_t_status").text(res.WaterLevel);                $("[name = LiDAR_t_status]").text(res.LiDAR);                $("[name = PressureWaterLevel_t_status]").text(res.PressureWaterLevel);                var testing_motor_rpm = $("input[name=testing_motor_rpm_F]").val();                var testing_tank_dry_temp_F = $("input[name=testing_tank_dry_temp_F]").val();                var testing_out_vacuum_in_F = $("input[name=testing_out_vacuum_in_F]").val();                var testing_out_vacuum_out = $("input[name=testing_out_vacuum_out_F]").val();                var testing_out_vacuum_loop = $("input[name=testing_out_vacuum_loop_F]").val();                if (res.WaterLevel == '1' && res.outer_solenoid_water == '1'){                    outerSolenoidWater_OFF();                    console.log('保溫夾層注水 OFF')/*                    var time = new Date();                    while ((new Date() - time) < 1000) { }                    tankHeater1_ON()                    console.log('加熱棒 1 ON')                    var time = new Date();                    while ((new Date() - time) < 1000) { }                    tankHeater2_ON()                    console.log('加熱棒 2 ON')                    var time = new Date();                        while ((new Date() - time) < 1000) { }                    var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": testing_motor_rpm };                    $.post('/mqtt/{{tid}}', data, function (res) {                        console.log('data:', data)                        if (res == 'on') {                            var timer = setInterval(Rotate, 60000);                        } else if (res == 'off') {                            clearInterval(timer);                            $("#motor_rpm_status").text('');                        } else {                        };                    }, 'text')                    console.log('馬達 ' + testing_motor_rpm + ' rpm')                    var time = new Date();                    while ((new Date() - time) < 1000) { }                    console.log('發酵 ' + testing_tank_dry_time + ' 秒')                    var time = new Date();                    while ((new Date() - time) < testing_tank_dry_time * 1000) { }                    tankTempEnable_ON()                    var data = { "tank_num": "F" + tank_num, "command": "temp1", "value": testing_tank_dry_temp_F };                    $.post('/mqtt/{{tid}}', data, function (res) {                        console.log('data:', data)                    }, 'text')                    console.log('指定發酵保溫夾層溫度 ' + testing_tank_dry_temp_F + ' 開始加熱')*/                };                                if (res.SHT11_Temp > testing_tank_dry_temp_F && res.tank_heater1 == 1 && res.tank_heater2 == 1 ){                    tankMotor_OFF()                    console.log('馬達停止')                                        var time = new Date();                    while ((new Date() - time) < 1000) { }                    tankHeater1_OFF()                    console.log('加熱棒 1 OFF')                    var time = new Date();                    while ((new Date() - time) < 1000) { }                    tankHeater2_OFF()                    console.log('加熱棒 2 OFF')/*                    for (step = 1; step <= testing_out_vacuum_loop; step++) {                        console.log('循環第 ' + step + ' 次');                        outputVacuum_ON()                        console.log('出料真空吸料機 ON')                        var time = new Date();                        while ((new Date() - time) < testing_out_vacuum_in_F * 1000) { }                        if (step == 1) {                            tankDiskValve_ON()                            console.log('蝴蝶閥 ON')                            var time = new Date();                            while ((new Date() - time) < testing_out_vacuum_in_F * 1000) { }                        }                        outputVacuum_OFF()                        console.log('出料真空吸料機 OFF')                        var time = new Date();                        while ((new Date() - time) < testing_out_vacuum_out * 1000) { }                    }                    tankDiskValve_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="10" 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">{{tank_PressureWaterLevel.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></td>            <td style="background-color:#f3f3f3">氣壓</td>            <td><span id="PA_t_status">{{tank_PA.PA}}</span></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></td>            <td style="background-color:#f3f3f3">DO</td>            <td><span id="DO_t_status">{{tank_DO.DO}}</span></td>            <td style="background-color:#f3f3f3">EC</td>            <td><span id="EC_t_status">{{tank_EC.EC}}</span></td>        </tr>        <tr>            <td colspan="8">[保溫夾層] 水位高度:<span id="WaterLevel_t_status">{{tank_WaterLevel.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="10" 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:70px;"><br>                -- 入豆 --<br>                指定桶內生豆高度:                <input name="testing_tank_bean_height_F" value="20" type="text" style="width:70px;"><br>                -- 發酵 --<br>                指定溫度:                <input name="testing_tank_temp_F" value="21" type="text" style="width:70px;"><br>                指定時間(s):                <input name="testing_tank_time_F" value="10" type="text" style="width:70px;"><br>                -- 出料 --<br>                設定空桶高度:                <input name="testing_tank_empty_height_F" value="10" type="text" style="width:70px;"><br>                <!--                入料吸料時間(秒):                <input name="testing_tank_vacuum_in_F" value="1" type="text" style="width:70px;">                <br>                入料放料時間(>10秒):                <input name="testing_tank_vacuum_out_F" value="10" type="text" style="width:70px;">                <br>                入料循環次數:                <input name="testing_tank_vacuum_loop_F" value="4" type="text" style="width:70px;">                <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:70px;">                <br>                出料放料時間(>10秒)                <input name="testing_out_vacuum_out_F" value="10" type="text"                    style="width:70px;">                <br>                出料循環次數                <input name="testing_out_vacuum_loop_F" value="4" type="text"                    style="width:70px;">                -->            </td>            <td>                [桶內] 水位高度:<span name="PressureWaterLevel_t_status">{{tank_PressureWaterLevel.PressureWaterLevel}}</span>                <br>                指定水量高度(cm):                <input name="testing_tank_water_height" id="testing_tank_water_height" type="text" value="100" style="width:70px;">            </td>            <td>                [桶內] 生豆高度:<span name="LiDAR_t_status">{{tank_LiDAR.LiDAR}}</span>                <br>                指定咖啡豆高度(cm):                <input name="testing_tank_coffee_height" id="testing_tank_coffee_height" type="text" value="0"                    style="width:70px;">                <br>                入料吸料時間(秒):                <input name="testing_tank_vacuum_in" id="testing_tank_vacuum_in" type="text" value="1" style="width:70px;">                <br>                入料放料時間(>10秒):                <input name="testing_tank_vacuum_out" id="testing_tank_vacuum_out" type="text" value="10" style="width:70px;">                <br>                入料循環次數:                <input name="testing_tank_vacuum_loop" id="testing_tank_vacuum_loop" type="text" value="3" style="width:70px;">            </td>            <td>                馬達(rpm):                <input name="testing_motor_rpm" id="testing_motor_rpm" value="0" type="text" style="width:70px;">                <br>                <!--                發酵時間(秒):                <input name="testing_tank_dry_time" id="testing_tank_dry_time" type="text" style="width:70px;">                <br>                溫度控制(℃):                <input name="AAA" id="AAA" type="text" style="width:70px;">-->                加熱棒 1、2 ON                <br>                pump 開啟時間(秒):                <input name="testing_tank_pump_on" id="testing_tank_pump_on" value="10" type="text" style="width:70px;">                <br>                pump 關閉時間(秒):                <input name="testing_tank_pump_off" id="testing_tank_pump_off" value="10" type="text" style="width:70px;">                <br>                pump 循環次數:                <input name="testing_tank_pump_loop" id="testing_tank_pump_loop" value="3" type="text" style="width:70px;">                <br>            </td>            <td>                蝴蝶閥 ON                <br>                出料吸料時間(秒):                <input name="testing_out_vacuum_in" id="testing_out_vacuum_in" value="1" type="text" style="width:70px;">                <br>                出料放料時間(>10秒):                <input name="testing_out_vacuum_out" id="testing_out_vacuum_out" value="10" type="text" style="width:70px;">                <br>                出料循環次數:                <input name="testing_out_vacuum_loop" id="testing_out_vacuum_loop" value="3" type="text" style="width:70px;">            </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('桶內開始入水')                                // aaa tankSolenoidWaterIn_ON();                                console.log('tankSolenoidWaterIn_ON')                                console.log('請開啟水龍頭進水')                            };                        }, 'json');                        $.get('/ferment_WaterLevel_' + tank_num, '', function (res) {                            if ( res.WaterLevel != 1 ){                                console.log('夾層開始入水')                                // aaa outerSolenoidWater_ON();                                console.log('tankSolenoidWaterIn_ON')                                console.log('請開啟水龍頭進水')                            };                        }, 'json');                        // 保溫夾層加滿水                        // 指定桶內水位高度                        var WaterIn_F_interval = setInterval(WaterIn_F, 5000);                        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) {                                        // aaa outerSolenoidWater_OFF()                                        console.log("outerSolenoidWater_OFF")                                    }                                    if (present_tank_water_height > testing_tank_water_height_F) {                                        // aaa tankSolenoidWaterIn_OFF()                                        console.log("tankSolenoidWaterIn_OFF")                                    }                                    if (present_WaterLevel == 1 &&                                     present_tank_water_height > testing_tank_water_height_F) {                                        clearInterval(WaterIn_F_interval);                                        console.log("入水完成!")                                    }                                    WaterIn_F_Process = 0;                                },                                error:function(thrownError){                                    console.log("Error: " + thrownError)                                    WaterIn_F_Process = 0;                                }                            });                           }                        // -- 入豆 --                        // 指定桶內生豆高度                        var testing_tank_bean_height_F = $("input[name=testing_tank_bean_height_F]").val();                        console.log("指定豆高: " + testing_tank_bean_height_F)                        var BeanIn_F_interval = setInterval(BeanIn_F, 5000);                        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)                                    if (present_Bean_height > testing_tank_bean_height_F) {                                        clearInterval(BeanIn_F_interval);                                        console.log("已達生豆高度!")                                    } else {                                        // aaa tankVacuum_ON()                                        console.log("tankVacuum_ON")                                        var time = new Date();                                        while ((new Date() - time) < 2 * 1000) { };                                        // aaa tankVacuum_OFF()                                        console.log("tankVacuum_OFF")                                    }                                    BeanIn_F_Process = 0;                                },                                error:function(thrownError){                                    console.log("Error: " + thrownError)                                    BeanIn_F_Process = 0;                                }                            });                        };                                                // -- 發酵 --                        // 指定溫度                        // 指定時間(s)                        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)                        $.get('/ferment_SHT11_' + tank_num, '', function(res){                            if (res.SHT11_Temp < testing_tank_temp_F){                                // aaa tankHeater1_ON()                                console.log("tankHeater1_ON")                                // aaa tankHeater2_ON()                                console.log("tankHeater2_ON")                                // aaa tankMotor_ON()                                console.log("tankMotor_ON")                            }                        });                        var Fermenting_F_interval = setInterval(Fermenting_F, 5000);                        function Fermenting_F(){                            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("已達指定溫度!")                                        console.log("發酵 " + testing_tank_time_F + " 秒")                                        var time = new Date();                                        while ((new Date() - time) < testing_tank_time_F * 1000) { };                                        // aaa tankHeater1_OFF()                                        console.log("tankHeater1_OFF")                                        // aaa tankHeater2_OFF()                                        console.log("tankHeater2_OFF")                                        // aaa tankMotor_OFF()                                        console.log("tankMotor_OFF")                                    }                                    Fermenting_F_Process = 0;                                },                                error:function(thrownError){                                    console.log("Error: " + thrownError)                                    Fermenting_F_Process = 0;                                }                            });                        };                                                // -- 出料 --                        // 設定空桶高度                        var testing_tank_empty_height_F = $("input[name=testing_tank_empty_height_F]").val();                        console.log("設定空桶高度: " + testing_tank_empty_height_F)                        var WaterBeanOut_F_interval = setInterval(WaterBeanOut_F, 5000);                        function WaterBeanOut_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) {                                        // aaa tankVacuum_ON()                                        console.log("tankVacuum_ON")                                        var time = new Date();                                        while ((new Date() - time) < 2 * 1000) { };                                        // aaa tankVacuum_OFF()                                        console.log("tankVacuum_OFF")                                    } else {                                        clearInterval(BeanIn_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);/*                        alert("setp 1");                         $.ajax({                              url: "admin/PfmOptionRuleItem.do",                              async: false,                              success: function(data){                                   alert("hello ajax"); //①                              }                         });                                                 alert("setp 2"); //②*/                        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: ' + 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({                                    type:'GET',                                    url:'/ferment_LiDAR_' + tank_num,                                    dataType:'JSON',                                    success:function(response){                                        var present_Coffee_height = response.LiDAR                                        console.log("present_Coffee_height: ", 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) { };                                        }                                    },                                    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('-- 循環入豆結束 --')                            }                        } else  {                            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>                    function CoffeeOut_testing() {                        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();                        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>    [保溫夾層] 水位高度:<span id="WaterLevel_t_status">{{tank_WaterLevel.WaterLevel}}</span>    <table style="font-size:18px; border:2px #cccccc solid;" cellpadding="10" 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>    <h4>攝影機畫面</h4>    <div class="container-fluid">        <div class="row" style="margin-top:100px;">            <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="70%" height="70%">                    </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>    <!--    入料儲豆槽液位計高度 公分:{{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>--></body></html>
 |