| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781 | <!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="10" />每 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>    <!--    <script src="../static/js/sign_in.js"></script>    <link rel="stylesheet" href="../static/css/sign_in.css">    -->    <!-- Rita 發酵貨櫃 - 入料、桶槽、出料致動器 function-->    <script type="text/javascript" src="../static/js/ferment_function.js"></script>    <script>        var tank_num = '1';        $(document).ready(function(){            $("#coffee_title").text('發酵自動化');            // 脫皮出料顯示            console.log('PO1: ' + '{{PO1}}')            console.log('PO2: ' + '{{PO2}}')            peel_output_status = ['{{PO1}}','{{PO2}}']            for (let i=0; i<peel_output_status.length; i++) {                if (peel_output_status[i] == 'PO_InputtingBean') {                    console.log('[動作] 脫皮出料 PO' + parseInt(i+1) + ' 入豆中')                    $("#PO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#PO"+parseInt(i+1)+"_status").text("PO" + parseInt(i+1) + " 入豆中")                } else if (peel_output_status[i] == 'PO_Waiting') {                    console.log('[動作] 脫皮出料 PO' + parseInt(i+1) + ' 空桶等待')                    $("#PO"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")                    $("#PO"+parseInt(i+1)+"_status").text("PO" + parseInt(i+1) + " 空桶等待")                } else if (peel_output_status[i] == 'PO_OutputtingBean') {                    console.log('[動作] 脫皮出料 PO' + parseInt(i+1) + ' 可出豆')                    $("#PO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#PO"+parseInt(i+1)+"_status").text("PO" + parseInt(i+1) + " 可出豆")                } else if (peel_output_status[i] == 'PO_Stand_by') {                    $("#PO"+parseInt(i+1)+"_status_dot").css("background-color", "HotPink")                    $("#PO"+parseInt(i+1)+"_status").text("PO" + parseInt(i+1) + " 待命")                } else {                    console.log('pass')                }            }                 // 乾燥入料顯示            console.log('DO1: ' + '{{DI1}}')            console.log('DO2: ' + '{{DI2}}')            dry_input_status = ['{{DI1}}','{{DI2}}']            for (let i=0; i<dry_input_status.length; i++) {                if (dry_input_status[i] == 'DI_InputtingBean') {                    console.log('[動作] 乾燥入料 DO' + parseInt(i+1) + ' 入豆中')                    $("#DI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#DI"+parseInt(i+1)+"_status").text("DI" + parseInt(i+1) + " 入豆中")                } else if (dry_input_status[i] == 'DI_Waiting') {                    console.log('[動作] 乾燥入料 DI' + parseInt(i+1) + ' 空桶等待')                    $("#DI"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")                    $("#DI"+parseInt(i+1)+"_status").text("DI" + parseInt(i+1) + " 空桶等待")                } else if (dry_input_status[i] == 'DI_OutputtingBean') {                    console.log('[動作] 乾燥入料 DI' + parseInt(i+1) + ' 可出豆')                    $("#DI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#DI"+parseInt(i+1)+"_status").text("DI" + parseInt(i+1) + " 可出豆")                } else if (dry_input_status[i] == 'DI_Stand_by') {                    $("#DI"+parseInt(i+1)+"_status_dot").css("background-color", "HotPink")                    $("#DI"+parseInt(i+1)+"_status").text("DI" + parseInt(i+1) + " 待命")                } else {                    console.log('pass')                }            }            // 桶槽入料顯示            ferment_input_status_N = ['{{FI1}}', '{{FI2}}']            // console.log('ferment_input_status_N: ' + ferment_input_status_N)            for (let i=0; i<ferment_input_status_N.length; i++) {                // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態                // console.log(i+1 + ' : '+ ferment_output_status[i])                // 1 : F_InputtingBean                // 2 : F_Waiting                if (ferment_input_status_N[i] == 'FI_InputtingBean') {                    $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 入豆中")                } else if (ferment_input_status_N[i] == 'FI_Waiting') {                    $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")                    $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 空桶等待")                } else if (ferment_input_status_N[i] == 'FI_OutputtingBean') {                    $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 可出豆")                } else if (ferment_input_status_N[i] == 'FI_Stand_by') {                    $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "HotPink")                    $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 待命")                } else {                    console.log('pass')                }            }            // 桶槽狀態顯示            ferment_tank_status_N = ['{{F1}}', '{{F2}}', '{{F3}}', '{{F4}}', '{{F5}}', '{{F6}}',                                    '{{F7}}', '{{F8}}', '{{F9}}', '{{F10}}', '{{F11}}', '{{F12}}']            // console.log('ferment_tank_status_N: ' + ferment_tank_status_N)            for (let i=0; i<ferment_tank_status_N.length; i++) {                // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態                // console.log(i+1 + ' : '+ ferment_tank_status[i])                // 1 : F_InputtingBean                // 2 : F_Waiting                if (ferment_tank_status_N[i] == 'F_InputtingBean') {                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  入豆中")                } else if (ferment_tank_status_N[i] == 'F_InputtingBean_Pause') {                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  入豆暫停")                } else if (ferment_tank_status_N[i] == 'F_InputtingBean_Finish') {                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  入豆完成")                } else if (ferment_tank_status_N[i] == 'F_InputtingWater') {                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  入水中")                } else if (ferment_tank_status_N[i] == 'F_Waiting') {                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  空桶等待")                } else if (ferment_tank_status_N[i] == 'F_Cleaning') {                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "plum")                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  清洗中")                } else if (ferment_tank_status_N[i] == 'F_Fermenting') {                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  發酵中")                } else if (ferment_tank_status_N[i] == 'F_OutputtingBean') {                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  可出豆")                } else if (ferment_tank_status_N[i] == 'F_Warning') {                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "crimson")                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  發生錯誤")                    $("#F"+parseInt(i+1)+"_status").css("color", "crimson")                } else if (ferment_tank_status_N[i] == 'F_Stand_by') {                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "HotPink")                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 待命中")                } else {                    console.log('pass')                }            }            // 桶槽出料顯示            ferment_output_status_N = ['{{FO1}}', '{{FO2}}']            // console.log('ferment_output_status_N: ' + ferment_output_status_N)            for (let i=0; i<ferment_output_status_N.length; i++) {                // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態                // console.log(i+1 + ' : '+ ferment_output_status[i])                // 1 : F_InputtingBean                // 2 : F_Waiting                if (ferment_output_status_N[i] == 'FO_InputtingBean') {                    $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 入豆中")                } else if (ferment_output_status_N[i] == 'FO_Waiting') {                    $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")                    $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 空桶等待")                } else if (ferment_output_status_N[i] == 'FO_OutputtingBean') {                    $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                    $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 可出豆")                } else if (ferment_output_status_N[i] == 'FO_Stand_by') {                    $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "HotPink")                    $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 待命")                } else {                    console.log('pass')                }            }        });        $(function(){            $('#cb_cleaning').on('change', function () {                if ($('#cb_cleaning').prop('checked')) {                    $("input[name='Ferment_auto_cleaning_Ftimes']").attr('disabled', false);                    $("input[name='Ferment_auto_cleaning_Ftimes']").attr('value', '1');                } else {                    $("input[name='Ferment_auto_cleaning_Ftimes']").attr('disabled', true);                }            })            $('#cb_calibratingEC').on('change', function () {                if ($('#cb_calibratingEC').prop('checked')) {                    $("input[name='Ferment_auto_calibratingEC_Ftimes']").attr('disabled', false);                    $("input[name='Ferment_auto_calibratingEC_Ftimes']").attr('value', '1');                } else {                    $("input[name='Ferment_auto_calibratingEC_Ftimes']").attr('disabled', true);                }            })            $('#cb_calibratingSTIR').on('change', function () {                if ($('#cb_calibratingSTIR').prop('checked')) {                    $("input[name='Ferment_auto_calibratingSTIR_Ftimes']").attr('disabled', false);                    $("input[name='Ferment_auto_calibratingSTIR_Ftimes']").attr('value', '1');                } else {                    $("input[name='Ferment_auto_calibratingSTIR_Ftimes']").attr('disabled', true);                }            })            // <label><input type="checkbox" id="cb_cleaning">清洗:發酵            //     <input name="Ferment_auto_cleaning_Ftimes" class="input-text" type="text">次執行            // </label><br>            // <label><input type="checkbox" id="cb_calibratingEC">校正 EC            //     <input name="Ferment_auto_calibratingEC_Ftimes" class="input-text" type="text">次執行            // </label><br>            // <label><input type="checkbox" id="cb_calibratingSTIR">校正攪拌棒            //     <input name="Ferment_auto_calibratingSTIR_Ftimes" class="input-text" type="text">次執行            // </label>        })    </script>    <style>        .F_status_css {            font-weight: bold;            text-align: center;        }        .FermentContainer_position {            position: absolute;            top: 95px;            left: 53px;        }        .F1_position {            width: 110px;        }        .F2_position {            width: 110px;        }        .F3_position {            width: 110px;        }        .F4_position {            width: 110px;        }        .F5_position {            width: 110px;        }        .F6_position {            width: 110px;        }        .F7_position {            width: 110px;        }        .F8_position {            width: 110px;        }        .F9_position {            width: 110px;        }        .F10_position {            width: 110px;        }        .F11_position {            width: 110px;        }        .F12_position {            width: 110px;        }        .FI1_position {            width: 110px;        }        .FI2_position {            width: 110px;        }        .FO1_position {            width: 110px;        }        .FO2_position {            width: 110px;        }        .footer{            position: absolute;            bottom: 0px;            width: 100%;            background-color: #eee;            text-align: center;        }        .input-text {            height: 25px;            width: 40px;            text-align: center;            margin-left: 2px;            margin-right: 5px;        }    </style>    <script language="JavaScript">        // 指定 10秒 刷新網頁一次        //var WebUpdate_set = setInterval(function(){WebUpdate()} , 60 * 1000) ;        function WebUpdate(){            console.log("-- 狀態更新 start --")            /*            $.get('/ferment_auto', '', function (res) {            }, 'json');            */            console.log("-- 狀態更新 end --")        };    </script>    <script language="JavaScript">        function myrefresh()        {        window.location.reload();        }        setTimeout('myrefresh()',10000); //指定1秒刷新一次    </script></head><body>    <div id="wrapper">        <div>            <!-- 發酵貨櫃 測試按鈕-->            <div style="text-align: center;">                <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="ferment_auto_status_stop()">                    <u>狀態判斷_停止</u></button>                <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="ferment_auto_status_testing()">                    <u>[測試] 發酵自動化_狀態判斷</u></button>                <script>                    var ferment_status_interval  // 每 5 秒更新桶槽狀態、致動器狀態、感測器數值, 放全域                    var loadingF                    var ferment_status_process = 0;                    function ferment_auto_status_testing(){                        console.log("------- 狀態判斷 開始 -------")                        loadingF = setInterval(loading_F, 10*1000)                        var Ferment_Input_bean_height = $("input[name=Ferment_Input_bean_height]").val();                        var Ferment_Input_vacuumON_time = $("input[name=Ferment_Input_vacuumON_time]").val();                        var Ferment_Input_vacuumOFF_time = $("input[name=Ferment_Input_vacuumOFF_time]").val();                        var Ferment_Tank_bean_height = $("input[name=Ferment_Tank_bean_height]").val();                        var Ferment_Tank_vacuumON_time = $("input[name=Ferment_Tank_vacuumON_time]").val();                        var Ferment_Tank_vacuumOFF_time = $("input[name=Ferment_Tank_vacuumOFF_time]").val();                        var Ferment_Tank_water_height = $("input[name=Ferment_Tank_water_height]").val();                        var Ferment_Tank_fermenting_temp = $("input[name=Ferment_Tank_fermenting_temp]").val();                        var Ferment_Tank_fermenting_time = $("input[name=Ferment_Tank_fermenting_time]").val();                        var Ferment_Tank_fermenting_pH = $("input[name=Ferment_Tank_fermenting_pH]").val();                        var Ferment_Tank_fermenting_DO = $("input[name=Ferment_Tank_fermenting_DO]").val();                        var Ferment_Tank_fermenting_ORP = $("input[name=Ferment_Tank_fermenting_ORP]").val();                        var Ferment_Tank_fermenting_EC = $("input[name=Ferment_Tank_fermenting_EC]").val();                        var Ferment_Tank_motor_rpm = $("input[name=Ferment_Tank_motor_rpm]").val();                        var Ferment_Tank_motor_time = $("input[name=Ferment_Tank_motor_time]").val();                        var Ferment_Tank_WaterOut_time = $("input[name=Ferment_Tank_WaterOut_time]").val();                        var Ferment_Tank_Disinfect_time = $("input[name=Ferment_Tank_Disinfect_time]").val();                        var Ferment_Output_bean_height = $("input[name=Ferment_Output_bean_height]").val();                        var Ferment_Output_vacuumON_time = $("input[name=Ferment_Output_vacuumON_time]").val();                        var Ferment_Output_vacuumOFF_time = $("input[name=Ferment_Output_vacuumOFF_time]").val();                        var FermentAuto_fermenting = $('#cb_fermenting').prop('checked') // true false                        var FermentAuto_cleaning = $('#cb_cleaning').prop('checked')                        var FermentAuto_calibratingEC = $('#cb_calibratingEC').prop('checked')                        var FermentAuto_calibratingSTIR = $('#cb_calibratingSTIR').prop('checked')                        var Ferment_auto_cleaning_Ftimes = $("input[name=Ferment_auto_cleaning_Ftimes]").val();                        var Ferment_auto_calibratingEC_Ftimes = $("input[name=Ferment_auto_calibratingEC_Ftimes]").val();                        var Ferment_auto_calibratingSTIR_Ftimes = $("input[name=Ferment_auto_calibratingSTIR_Ftimes]").val();                        var Ferment_cb_vacuum = $('#Ferment_cb_vacuum').prop('checked') // true false                        var Ferment_cb_vacuum_time = $("input[name=Ferment_cb_vacuum_time]").val();                        if ( (!(/(^[1-9]\d*$)/.test(Ferment_auto_cleaning_Ftimes)) && FermentAuto_cleaning) ||                                    (!(/(^[1-9]\d*$)/.test(Ferment_auto_calibratingEC_Ftimes)) && FermentAuto_calibratingEC) ||                                    (!(/(^[1-9]\d*$)/.test(Ferment_auto_calibratingSTIR_Ftimes)) && FermentAuto_calibratingSTIR) ) {                            alert('[發酵貨櫃] 次數只接受正整數, 請重新輸入')                            return                        } else {                            // 若發酵排程被勾選則為 1, 否則為 0 (預設發酵排程會不斷執行)                            if (FermentAuto_fermenting == true) { FermentAuto_fermenting = 1                            } else { FermentAuto_fermenting = 0 }                            // 若清洗排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)                            if (FermentAuto_cleaning == true) { FermentAuto_cleaning = Ferment_auto_cleaning_Ftimes                            } else { FermentAuto_cleaning = 0 }                            // 若校正 EC 排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)                            if (FermentAuto_calibratingEC == true) { FermentAuto_calibratingEC = Ferment_auto_calibratingEC_Ftimes                            } else { FermentAuto_calibratingEC = 0 }                            // 若校正攪拌棒排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)                            if (FermentAuto_calibratingSTIR == true) { FermentAuto_calibratingSTIR = Ferment_auto_calibratingSTIR_Ftimes                            } else { FermentAuto_calibratingSTIR = 0 }                        }                        var data = { 'command': 'Ferment_auto_parameter',                                     'FermentAuto_fermenting': FermentAuto_fermenting,                                     'FermentAuto_cleaning': FermentAuto_cleaning,                                     'FermentAuto_calibratingEC': FermentAuto_calibratingEC,                                     'FermentAuto_calibratingSTIR': FermentAuto_calibratingSTIR,                                     'Ferment_cb_vacuum': Ferment_cb_vacuum,                                     'Ferment_cb_vacuum_time': Ferment_cb_vacuum_time,                                     'Ferment_Tank_fermenting_pH': Ferment_Tank_fermenting_pH,                                     'Ferment_Input_bean_height':Ferment_Input_bean_height,                                     'Ferment_Input_vacuumON_time': Ferment_Input_vacuumON_time,                                     'Ferment_Input_vacuumOFF_time': Ferment_Input_vacuumOFF_time,                                     'Ferment_Tank_bean_height': Ferment_Tank_bean_height,                                     'Ferment_Tank_vacuumON_time': Ferment_Tank_vacuumON_time,                                     'Ferment_Tank_vacuumOFF_time': Ferment_Tank_vacuumOFF_time,                                     'Ferment_Tank_water_height': Ferment_Tank_water_height,                                     'Ferment_Tank_fermenting_temp': Ferment_Tank_fermenting_temp,                                     'Ferment_Tank_fermenting_time': Ferment_Tank_fermenting_time,                                     'Ferment_Tank_fermenting_pH': Ferment_Tank_fermenting_pH,                                     'Ferment_Tank_fermenting_DO': Ferment_Tank_fermenting_DO,                                     'Ferment_Tank_fermenting_ORP': Ferment_Tank_fermenting_ORP,                                     'Ferment_Tank_fermenting_EC': Ferment_Tank_fermenting_EC,                                     'Ferment_Tank_motor_rpm': Ferment_Tank_motor_rpm,                                     'Ferment_Tank_motor_time': Ferment_Tank_motor_time,                                     'Ferment_Tank_WaterOut_time': Ferment_Tank_WaterOut_time,                                     'Ferment_Tank_Disinfect_time': Ferment_Tank_Disinfect_time,                                     'Ferment_Output_bean_height': Ferment_Output_bean_height,                                     'Ferment_Output_vacuumON_time': Ferment_Output_vacuumON_time,                                     'Ferment_Output_vacuumOFF_time': Ferment_Output_vacuumOFF_time };                        ferment_status_interval = setInterval(ferment_auto_status, 5*1000);                        function ferment_auto_status(){                            if (ferment_status_process == 1) { return };                            ferment_status_process = 1;                            $.get('/ferment_auto_status', data, function (res) {                                FI1 = res.Ferment_Input_1                                F1 = res.Ferment_Tank_1                                F2 = res.Ferment_Tank_2                                F3 = res.Ferment_Tank_3                                F4 = res.Ferment_Tank_4                                F5 = res.Ferment_Tank_5                                F6 = res.Ferment_Tank_6                                FO1 = res.Ferment_Output_1                                console.log('FI1: ' + FI1)                                console.log('F1: ' + F1)                                console.log('F2: ' + F2)                                console.log('F3: ' + F3)                                console.log('F4: ' + F4)                                console.log('F5: ' + F5)                                console.log('F6: ' + F6)                                console.log('FO1: ' + FO1)                                // ----- 脫皮出料 PO1 狀態 --------------------------------------------------------------                                peel_output_status = [res.Peel_Output_1]                                for (let i=0; i<peel_output_status.length; i++) {                                    if (peel_output_status[i] == 'PO_InputtingBean') {                                        console.log('[動作] 脫皮出料 PO' + parseInt(i+1) + ' 入豆中')                                        $("#PO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                        $("#PO"+parseInt(i+1)+"_status").text("PO" + parseInt(i+1) + " 入豆中")                                    } else if (peel_output_status[i] == 'PO_Waiting') {                                        console.log('[動作] 脫皮出料 PO' + parseInt(i+1) + ' 空桶等待')                                        $("#PO"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")                                        $("#PO"+parseInt(i+1)+"_status").text("PO" + parseInt(i+1) + " 空桶等待")                                    } else if (peel_output_status[i] == 'PO_OutputtingBean') {                                        console.log('[動作] 脫皮出料 PO' + parseInt(i+1) + ' 可出豆')                                        $("#PO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                        $("#PO"+parseInt(i+1)+"_status").text("PO" + parseInt(i+1) + " 可出豆")                                    } else {                                        console.log('PO pass')                                    }                                }                                // ----- 發酵出料 FO1 狀態 --------------------------------------------------------------                                ferment_input_status = [res.Ferment_Input_1]                                for (let i=0; i<ferment_input_status.length; i++) {                                    // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態                                    // console.log(i+1 + ' : '+ ferment_output_status[i])                                    // 1 : F_InputtingBean                                    // 2 : F_Waiting                                    if (ferment_input_status[i] == 'FI_InputtingBean') {                                        console.log('[動作] 發酵入料 FI' + parseInt(i+1) + ' 入豆中')                                        $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                        $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 入豆中")                                    } else if (ferment_input_status[i] == 'FI_Waiting') {                                        console.log('[動作] 發酵入料 FI' + parseInt(i+1) + ' 空桶等待')                                        $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")                                        $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 空桶等待")                                    } else if (ferment_input_status[i] == 'FI_OutputtingBean') {                                        console.log('[動作] 發酵入料 FI' + parseInt(i+1) + ' 可出豆')                                        $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                        $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 可出豆")                                    } else {                                        console.log('pass')                                    }                                }                                // ----- 發酵桶槽 F1~F6 狀態 --------------------------------------------------------------                                ferment_tank_status = [res.Ferment_Tank_1, res.Ferment_Tank_2, res.Ferment_Tank_3,                                                        res.Ferment_Tank_4, res.Ferment_Tank_5, res.Ferment_Tank_6]                                for (let i=0; i<ferment_tank_status.length; i++) {                                    // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態                                    // console.log(i+1 + ' : '+ ferment_tank_status[i])                                    // 1 : F_InputtingBean                                    // 2 : F_Waiting                                    if (ferment_tank_status[i] == 'F_InputtingBean') {                                        console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入豆中')                                        $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                        $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  入豆中")                                    } else if (ferment_tank_status[i] == 'F_InputtingBean_Pause') {                                        console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入豆暫停')                                        $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                        $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  入豆暫停")                                    } else if (ferment_tank_status[i] == 'F_InputtingBean_Finish') {                                        console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入豆完成')                                        $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                        $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  入豆完成")                                    } else if (ferment_tank_status[i] == 'F_InputtingWater') {                                        console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入水中')                                        $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                        $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  入水中")                                    } else if (ferment_tank_status[i] == 'F_Waiting') {                                        console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 空桶等待')                                        $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")                                        $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  空桶等待")                                    } else if (ferment_tank_status[i] == 'F_Fermenting') {                                        console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 發酵中')                                        $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                        $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  發酵中")                                    } else if (ferment_tank_status_N[i] == 'F_Cleaning') {                                        console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 清洗中')                                        $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "plum")                                        $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  清洗中")                                    } else if (ferment_tank_status[i] == 'F_OutputtingBean') {                                        console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 可出豆')                                        $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                        $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  可出豆")                                    } else if (ferment_tank_status[i] == 'F_Warning') {                                        console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 發生錯誤')                                        $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "crimson")                                        $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  發生錯誤")                                        $("#F"+parseInt(i+1)+"_status").css("color", "crimson")                                    } else {                                        console.log('pass')                                    }                                }                                // ----- 發酵出料 FO1 狀態 --------------------------------------------------------------                                ferment_output_status = [res.Ferment_Output_1]                                for (let i=0; i<ferment_output_status.length; i++) {                                    // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態                                    // console.log(i+1 + ' : '+ ferment_output_status[i])                                    // 1 : F_InputtingBean                                    // 2 : F_Waiting                                    if (ferment_output_status[i] == 'FO_InputtingBean') {                                        console.log('[動作] 發酵出料 FO' + parseInt(i+1) + ' 入豆中')                                        $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                        $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 入豆中")                                    } else if (ferment_output_status[i] == 'FO_Waiting') {                                        console.log('[動作] 發酵出料 FO' + parseInt(i+1) + ' 空桶等待')                                        $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")                                        $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 空桶等待")                                    } else if (ferment_output_status[i] == 'FO_OutputtingBean') {                                        console.log('[動作] 發酵出料 FO' + parseInt(i+1) + ' 可出豆')                                        $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                        $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 可出豆")                                    } else {                                        console.log('pass')                                    }                                }                                ferment_status_process = 0;                            }, 'json');                        };                    };                    function ferment_auto_status_stop(){                        clearInterval(ferment_status_interval);                        clearInterval(loadingF);                        console.log("------- 狀態自動化判斷 停止 -------")                    };                </script>            </div>            <!-- 發酵貨櫃 狀態表格-->            <table style="border: 3px lightsteelblue solid; margin-right: auto; margin-left: auto; text-align: center; margin-top: 5px;" cellpadding="5" border="1">                <tr>                    <td>                        <!-- 脫皮機出料儲豆槽 PO11 -->                        <div id="PO1" tabindex="0" class="PO1_position" role="button" style="text-align: center;">                            <span id="PO1_status" class="F_status_css">PO1 status</span>                            <div id="PO1_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                        </div>                    </td>                    <td style="border: lightsteelblue 1px solid;">                        <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">                            <tr>                                <td>                                    <!-- 發酵槽入料儲豆槽 FI1 -->                                    <div id="FI1" tabindex="0" class="FI1_position" role="button" style="text-align: center;">                                        <span id="FI1_status" class="F_status_css">FI1 status</span>                                        <div id="FI1_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                            </tr>                        </table>                    </td>                    <td style="border: lightsteelblue 1px solid;">                        <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">                            <tr>                                <td>                                    <!-- 發酵槽 F1 -->                                    <div id="F1" tabindex="0" class="F1_position" role="button">                                        <span id="F1_status" class="F_status_css">F1 status</span>                                        <!-- F1 狀態點點-->                                        <div id="F1_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                                <td>                                    <!-- 發酵槽 F2 -->                                    <div id="F2" tabindex="0" class="F2_position" role="button">                                        <span id="F2_status" class="F_status_css">F2 status</span>                                        <div id="F2_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                                <td>                                    <!-- 發酵槽 F3 -->                                    <div id="F3" tabindex="0" class="F3_position" role="button">                                        <span id="F3_status" class="F_status_css">F3 status</span>                                        <div id="F3_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                                <td>                                    <!-- 發酵槽 F4 -->                                    <div id="F4" tabindex="0" class="F4_position" role="button">                                        <span id="F4_status" class="F_status_css">F4 status</span>                                        <div id="F4_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                                <td>                                    <!-- 發酵槽 F5 -->                                    <div id="F5" tabindex="0" class="F5_position" role="button">                                        <span id="F5_status" class="F_status_css">F5 status</span>                                        <div id="F5_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                                <td>                                    <!-- 發酵槽 F6 -->                                    <div id="F6" tabindex="0" class="F6_position" role="button">                                        <span id="F6_status" class="F_status_css">F6 status</span>                                        <div id="F6_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                            </tr>                        </table>                    </td>                    <td style="border: lightsteelblue 1px solid;">                         <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">                            <tr>                                <td>                                    <!-- 發酵槽出料儲豆槽 FO1 -->                                    <div id="FO1" tabindex="0" class="FO1_position" role="button">                                        <span id="FO1_status" class="F_status_css">FO1 status</span>                                        <div id="FO1_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                            </tr>                        </table>                    </td>                    <td style="border: lightsteelblue 1px solid;">                         <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">                            <tr>                                <td>                                    <!-- 發酵槽出料儲豆槽 FO1 -->                                    <div id="DI1" tabindex="0" class="DI1_position" role="button">                                        <span id="DI1_status" class="F_status_css">DI1 status</span>                                        <div id="DI1_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                            </tr>                        </table>                    </td>                </tr>                <tr>                    <td>脫皮機儲豆槽</td>                    <td style="border: lightsteelblue 1px solid;">                        發酵入料儲豆槽                    </td>                    <td style="border: lightsteelblue 1px solid;">                        發酵桶槽                    </td>                    <td style="border: lightsteelblue 1px solid;">                        發酵出料儲豆槽                    </td>                    <td style="border: lightsteelblue 1px solid;">                        乾燥入料儲豆槽                    </td>                </tr>                <tr>                    <td>                        <!-- 脫皮機出料儲豆槽 PO2 -->                        <div id="PO2" tabindex="0" class="PO2_position" role="button" style="text-align: center;">                            <span id="PO2_status" class="F_status_css">PO2 status</span>                            <div id="PO2_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                        </div>                    </td>                    <td style="border: lightsteelblue 1px solid;">                        <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">                            <tr>                                <td>                                    <!-- 發酵槽入料儲豆槽 FI2 -->                                    <div id="FI2" tabindex="0" class="FI2_position" role="button">                                        <span id="FI2_status" class="F_status_css">FI2 status</span>                                        <div id="FI2_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                            </tr>                        </table>                    </td>                    <td style="border: lightsteelblue 1px solid;">                        <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">                            <tr>                                <td>                                    <!-- 發酵槽 F7 -->                                    <div id="F7" tabindex="0" class="F7_position" role="button" style="vertical-align: bottom;">                                        <span id="F7_status" class="F_status_css">F7 status</span>                                        <div id="F7_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                                <td>                                    <!-- 發酵槽 F8 -->                                    <div id="F8" tabindex="0" class="F8_position" role="button">                                        <span id="F8_status" class="F_status_css">F8 status</span>                                        <div id="F8_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                                <td>                                    <!-- 發酵槽 F9 -->                                    <div id="F9" tabindex="0" class="F9_position" role="button">                                        <span id="F9_status" class="F_status_css">F9 status</span>                                        <div id="F9_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                                <td>                                    <!-- 發酵槽 F10 -->                                    <div id="F10" tabindex="0" class="F10_position" role="button">                                        <span id="F10_status" class="F_status_css">F10 status</span>                                        <div id="F10_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                                <td>                                    <!-- 發酵槽 F11 -->                                    <div id="F11" tabindex="0" class="F11_position" role="button">                                        <span id="F11_status" class="F_status_css">F11 status</span>                                        <div id="F11_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                                <td>                                    <!-- 發酵槽 F12 -->                                    <div id="F12" tabindex="0" class="F12_position" role="button">                                        <span id="F12_status" class="F_status_css">F12 status</span>                                        <div id="F12_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                            </tr>                        </table>                    </td>                    <td style="border: lightsteelblue 1px solid;">                        <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">                            <tr>                                <td>                                    <!-- 發酵槽出料儲豆槽 FO2 -->                                    <div id="FO2" tabindex="0" class="FO2_position" role="button">                                        <span id="FO2_status" class="F_status_css">FO2 status</span>                                        <div id="FO2_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                            </tr>                        </table>                    </td>                    <td style="border: lightsteelblue 1px solid;">                        <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">                            <tr>                                <td>                                    <!-- 乾燥入料儲豆槽 DO2 -->                                    <div id="DI2" tabindex="0" class="DI2_position" role="button">                                        <span id="DI2_status" class="F_status_css">DI2 status</span>                                        <div id="DI2_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>                                    </div>                                </td>                            </tr>                        </table>                    </td>                </tr>            </table>            <!-- 發酵貨櫃 致動器狀態 感測器數值 -->            <div style="text-align: center;">                <table style="border: 3px lightsteelblue solid; margin-right: auto; margin-left: auto; text-align: center; margin-top: 5px;" cellpadding="5" border="1">                    <tr>                        <td>                            入料<br>Vacuum                        </td>                        <td>                            桶槽<br>                            Vacuum                        </td>                        <td>                            入料<br>三通閥                        </td>                        <td>                            蝴蝶閥                        </td>                        <td>                            逆洗 pump<br>電磁閥                        </td>                        <td>                            消毒<br>電磁閥                        </td>                        <td>                            夾層入水<br>電磁閥                        </td>                        <td>                            桶內入水<br>電磁閥                        </td>                        <td>                            桶內排水<br>電磁閥                        </td>                        <td>                            水質<br>pump                        </td>                        <td>                            夾層浮選<br>三通閥                        </td>                        <td>                            馬達                        </td>                        <td>                            加熱器<br>1                        </td>                        <td>                            加熱器<br>2                        </td>                        <td>                            溫控開關                        </td>                        <td>                            設定溫度                        </td>                        <td>                            出料<br>Vacuum                        </td>                    </tr>                    <tr>                        <td>                            <span id="actuator_00">x</span>                        </td>                        <td>                            <span id="actuator_1">x</span>                        </td>                        <td>                            <span id="actuator_2">x</span>                        </td>                        <td>                            <span id="actuator_3">x</span>                        </td>                        <td>                            <span id="actuator_4">x</span>                        </td>                        <td>                            <span id="actuator_5">x</span>                        </td>                        <td>                            <span id="actuator_6">x</span>                        </td>                        <td>                            <span id="actuator_7">x</span>                        </td>                        <td>                            <span id="actuator_8">x</span>                        </td>                        <td>                            <span id="actuator_9">x</span>                        </td>                        <td>                            <span id="actuator_10">x</span>                        </td>                        <td>                            <span id="actuator_11">x</span>                        </td>                        <td>                            <span id="actuator_12">x</span>                        </td>                        <td>                            <span id="actuator_13">x</span>                        </td>                        <td>                            <span id="actuator_14">x</span>                        </td>                        <td>                            <span id="actuator_15">x</span>                        </td>                        <td>                            <span id="actuator_99">x</span>                        </td>                    </tr>                </table>                <table style="border: 3px lightsteelblue solid; margin-right: auto; margin-left: auto; text-align: center; margin-top: 5px;" cellpadding="5" border="1">                    <tr>                        <td>                            入料<br>高度                        </td>                        <td>                            高度                        </td>                        <td>                            溫度                        </td>                        <td>                            濕度                        </td>                        <td>                            二氧化碳                        </td>                        <td>                            大氣壓力                        </td>                        <td>                            pH                        </td>                        <td>                            ORP                        </td>                        <td>                            DO                        </td>                        <td>                            EC                        </td>                        <td>                            水位計                        </td>                        <td>                            出料<br>高度                        </td>                    </tr>                    <tr>                        <td>                            <span id="sensor_00">{{UltraSonic_input}}</span>                        </td>                        <td>                            <span id="sensor_1">{{UltraSonic_tank}}</span>                        </td>                        <td>                            <span id="sensor_2">{{SHT11_Temp}}</span>                        </td>                        <td>                            <span id="sensor_3">{{SHT11_Humidity}}</span>                        </td>                        <td>                            <span id="sensor_4">{{CO2}}</span>                        </td>                        <td>                            <span id="sensor_5">{{PA}}</span>                        </td>                        <td>                            <span id="sensor_6">{{PH}}</span>                        </td>                        <td>                            <span id="sensor_7">{{ORP}}</span>                        </td>                        <td>                            <span id="sensor_8">{{DO}}</span>                        </td>                        <td>                            <span id="sensor_9">{{EC}}</span>                        </td>                        <td>                            <span id="sensor_10">{{WaterLevel}}</span>                        </td>                        <td>                            <span id="sensor_99">{{UltraSonic_output}}</span>                        </td>                    </tr>                </table>            </div>            <!-- 發酵貨櫃 參數設定-->            <table style="border: 3px lightsteelblue solid; margin-right: auto; margin-left: auto; text-align: center; margin-top: 5px; line-height: 28px;" cellpadding="5" border="1">                <tr>                    <td>                        發酵自動化<br>                        排程                    </td>                    <td>                        入料儲豆槽<br>                        參數設定                    </td>                    <td>                        桶槽<br>                        參數設定                    </td>                    <td>                        出料儲豆槽<br>                        參數設定                    </td>                </tr>                <tr>                    <td style="padding: 10px; text-align: left; vertical-align: text-top;">                        <label><input type="checkbox" id="cb_fermenting" checked>發酵</label><br>                        <label><input type="checkbox" id="cb_cleaning">清洗:發酵                            <input name="Ferment_auto_cleaning_Ftimes" class="input-text" type="text">次執行                        </label><br>                        <label><input type="checkbox" id="cb_calibratingEC">校正 EC:發酵                            <input name="Ferment_auto_calibratingEC_Ftimes" class="input-text" type="text">次執行                        </label><br>                        <label><input type="checkbox" id="cb_calibratingSTIR">校正攪拌棒:發酵                            <input name="Ferment_auto_calibratingSTIR_Ftimes" class="input-text" type="text">次執行                        </label>                    </td>                    <td style="padding: 10px; text-align: left; vertical-align: text-top;">                        生豆高度                        <input name="Ferment_Input_bean_height" class="input-text" type="text" value="5">公分<br>                        吸料時間                        <input name="Ferment_Input_vacuumON_time" class="input-text" type="text" value="5">秒<br>                        放料時間                        <input name="Ferment_Input_vacuumOFF_time" class="input-text" type="text" value="10">秒<br>                    </td>                    <td style="padding: 10px; text-align: left; vertical-align: text-top;">                        生豆高度                        <input name="Ferment_Tank_bean_height" class="input-text" type="text" value="5">公分<br>                        吸料時間                        <input name="Ferment_Tank_vacuumON_time" class="input-text" type="text" value="5">秒<br>                        放料時間                        <input name="Ferment_Tank_vacuumOFF_time" class="input-text" type="text" value="10">秒<br>                        水位高度                        <input name="Ferment_Tank_water_height" class="input-text" type="text" value="8">公分<br>                        馬達轉速                        <input name="Ferment_Tank_motor_rpm" class="input-text" type="text" value="15">rpm,                        攪拌時間                        <input name="Ferment_Tank_motor_time" class="input-text" type="text" value="30">秒<br>                        <label><input type="checkbox" id="Ferment_cb_vacuum" class="input-checkbox">發酵時桶內抽真空?抽氣                            <input name="Ferment_cb_vacuum_time" class="input-text" type="text" value="30">秒</label><br>                        發酵溫度                        <input name="Ferment_Tank_fermenting_temp" class="input-text" type="text" value="30">℃                        , 且持溫時間                        <input name="Ferment_Tank_fermenting_time" class="input-text" type="text" value="60">秒<br>                        指定 pH                        <input name="Ferment_Tank_fermenting_pH" class="input-text" type="text" value="5">/                        <del>指定 DO                        <input name="Ferment_Tank_fermenting_DO" class="input-text" type="text" value="43">/                        指定 ORP                        <input name="Ferment_Tank_fermenting_ORP" class="input-text" type="text" value="-0.5">/                        指定 EC                        <input name="Ferment_Tank_fermenting_EC" class="input-text" type="text" value="300"><br></del>                        廢水排放                        <input name="Ferment_Tank_WaterOut_time" class="input-text" type="text" value="60">秒, 消毒開啟                        <input name="Ferment_Tank_Disinfect_time" class="input-text" type="text" value="10">秒<br>                    </td>                    <td style="padding: 10px; text-align: left; vertical-align: text-top;">                        生豆高度                        <input name="Ferment_Output_bean_height" class="input-text" type="text" value="5">公分<br>                        吸料時間                        <input name="Ferment_Output_vacuumON_time" class="input-text" type="text" value="5">秒<br>                        放料時間                        <input name="Ferment_Output_vacuumOFF_time" class="input-text" type="text" value="10">秒<br>                    </td>                </tr>            </table>            <!-- 發酵貨櫃 測試按鈕-->            <div style="text-align: center;">                <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="ferment_auto_testing()">                    [測試] 發酵自動化_網頁控制</button>                <script>                    // 入料儲豆槽 入豆狀態                    var BeanIn_FI_Process = 0;                    // 入豆狀態                    var BeanIn_F_Process = 0;                    // 入水狀態                    var WaterIn_F_Process = 0;                    // 發酵狀態                    var Fermenting_F_Process = 0;                    // 出料狀態                    var WaterBeanOut_F_Process = 0;                    // 出料儲豆槽 入豆狀態                    var BeanIn_FO_Process = 0;                    function ferment_auto_testing(){                        var Ferment_Input_bean_height = parseFloat($("input[name=Ferment_Input_bean_height]").val());                        var Ferment_Input_vacuumON_time = parseFloat($("input[name=Ferment_Input_vacuumON_time]").val());                        var Ferment_Input_vacuumOFF_time = parseFloat($("input[name=Ferment_Input_vacuumOFF_time]").val());                        var Ferment_Tank_bean_height = parseFloat($("input[name=Ferment_Tank_bean_height]").val());                        var Ferment_Tank_vacuumON_time = parseFloat($("input[name=Ferment_Tank_vacuumON_time]").val());                        var Ferment_Tank_vacuumOFF_time = parseFloat($("input[name=Ferment_Tank_vacuumOFF_time]").val());                        var Ferment_Tank_water_height = parseFloat($("input[name=Ferment_Tank_water_height]").val());                        var Ferment_Tank_fermenting_temp = parseFloat($("input[name=Ferment_Tank_fermenting_temp]").val());                        var Ferment_Tank_fermenting_time = parseFloat($("input[name=Ferment_Tank_fermenting_time]").val());                        var Ferment_Tank_fermenting_pH = parseFloat($("input[name=Ferment_Tank_fermenting_pH]").val());                        var Ferment_Tank_fermenting_DO = parseFloat($("input[name=Ferment_Tank_fermenting_DO]").val());                        var Ferment_Tank_fermenting_ORP = parseFloat($("input[name=Ferment_Tank_fermenting_ORP]").val());                        var Ferment_Tank_fermenting_EC = parseFloat($("input[name=Ferment_Tank_fermenting_EC]").val());                        var Ferment_Tank_motor_rpm = parseFloat($("input[name=Ferment_Tank_motor_rpm]").val());                        var Ferment_Tank_motor_time = parseFloat($("input[name=Ferment_Tank_motor_time]").val());                        var Ferment_Output_bean_height = parseFloat($("input[name=Ferment_Output_bean_height]").val());                        var Ferment_Output_vacuumON_time = parseFloat($("input[name=Ferment_Output_vacuumON_time]").val());                        var Ferment_Output_vacuumOFF_time = parseFloat($("input[name=Ferment_Output_vacuumOFF_time]").val());                        var BeanIn_FI_interval = setInterval(BeanIn_FI, 5000);                        function BeanIn_FI(){                            if (BeanIn_FI_Process == 1) {                                return; // 若還在處理就取消, 函式立即停止                            }                            // 取得桶內生豆高度, 若未達生豆高度則入豆                            BeanIn_FI_Process = 1;                            $.ajax({                                async:false,                                type:"GET",                                url:"/ferment_input_UltraSonic_1",                                dataType:'json',                                success:function(response){                                    var present_FIBean_height = parseFloat(response.UltraSonic)                                    console.log("目前入料儲豆槽豆高: " + present_FIBean_height)                                    console.log("指定入料儲豆槽豆高: " + Ferment_Input_bean_height)                                    if ( present_FIBean_height >= Ferment_Input_bean_height ) {                                        clearInterval(BeanIn_FI_interval);                                        console.log("入料儲豆槽已達生豆高度!")                                        BeanIn_F_interval = setInterval(BeanIn_F, 5000);                                    } else {                                        // aaa inputVacuum_ON()                                        console.log("inputVacuum_ON")                                        var time = new Date();                                        while ((new Date() - time) < Ferment_Input_vacuumON_time * 1000) { };                                        // aaa inputVacuum_OFF()                                        console.log("inputVacuum_OFF")                                        var time = new Date();                                        while ((new Date() - time) < Ferment_Input_vacuumOFF_time * 1000) { };                                    }                                    BeanIn_FI_Process = 0;                                },                                error:function(thrownError){                                    console.log("Error: " + thrownError)                                    BeanIn_FI_Process = 0;                                }                            });                        };                        var BeanIn_F_interval;                        function BeanIn_F(){                            if (BeanIn_F_Process == 1) {                                return; // 若還在處理就取消, 函式立即停止                            }                            // 取得桶內生豆高度, 若未達生豆高度則入豆                            BeanIn_F_Process = 1;                            $.ajax({                                async:false,                                type:"GET",                                url:"/ferment_UltraSonic_1",                                dataType:'json',                                success:function(response){                                    var present_FBean_height = parseFloat(response.UltraSonic)                                    console.log("目前桶槽豆高: " + present_FBean_height)                                    console.log("指定桶槽豆高: " + Ferment_Tank_bean_height)                                    if ( present_FBean_height >= Ferment_Tank_bean_height ) {                                        clearInterval(BeanIn_F_interval);                                        console.log("桶槽豆高已達指定高度!")                                        console.log("指定水高: " + Ferment_Tank_water_height)                                        // 若桶內水還沒滿, 開啟桶內入水                                        $.get('/ferment_UltraSonic_1', '', function (res) {                                            if ( res.UltraSonic < Ferment_Tank_water_height ){                                                console.log('桶內開始入水')                                                // aaa tankSolenoidWaterIn_ON();                                                console.log('tankSolenoidWaterIn_ON')                                                console.log('請開啟水龍頭進水')                                            };                                        }, 'json');                                        // 若夾層水還沒滿, 開啟夾層入水                                        $.get('/ferment_WaterLevel_1', '', function (res) {                                            if ( res.WaterLevel != 1 ){                                                console.log('夾層開始入水')                                                // aaa outerSolenoidWater_ON();                                                console.log('tankSolenoidWaterIn_ON')                                                console.log('請開啟水龍頭進水')                                            };                                        }, 'json');                                        // 入水每五秒判斷                                        WaterIn_F_interval = setInterval(WaterIn_F, 5000);                                    } else {                                        // aaa tankVacuum_ON()                                        console.log("tankVacuum_ON")                                        var time = new Date();                                        while ((new Date() - time) < Ferment_Input_vacuumON_time * 1000) { };                                        // aaa tankVacuum_OFF()                                        console.log("tankVacuum_OFF")                                        var time = new Date();                                        while ((new Date() - time) < Ferment_Input_vacuumOFF_time * 1000) { };                                    }                                    BeanIn_F_Process = 0;                                },                                error:function(thrownError){                                    console.log("Error: " + thrownError)                                    BeanIn_F_Process = 0;                                }                            });                        };                        // 入豆排程                        var Fermenting_F_interval                        function WaterIn_F(){                            if(WaterIn_F_Process == 1){                                return;     // 若還在處理就取消, 函式立即停止                            }                            // 取得桶內目前水位、取得夾層是否達水位計                            WaterIn_F_Process = 1;                            $.ajax({                                async:false,                                type:"GET",                                url:"/ferment_WaterIn_" + tank_num,                                dataType:"JSON",                                success:function(response){                                    console.log("指定入水高度: " + Ferment_Tank_water_height)                                    var present_tank_water_height = parseInt(response.UltraSonic)                                    console.log("目前水位高度: " + present_tank_water_height)                                    var present_WaterLevel = response.WaterLevel                                    console.log("目前夾層水位計高度: " + present_WaterLevel)                                    if (present_WaterLevel == 1 && present_tank_water_height >= Ferment_Tank_water_height) {                                        clearInterval(WaterIn_F_interval);                                        console.log("入水完成!")                                        console.log("指定溫度: " + Ferment_Tank_fermenting_temp)                                        console.log("指定時間: " + Ferment_Tank_fermenting_time)                                        // aaa tankMotor_ON()                                        console.log("tankMotor_ON")                                        // 取得桶內溫度, 若低於指定溫度則開啟加熱器                                        $.get('/ferment_SHT11_' + tank_num, '', function(res){                                            if (res.SHT11_Temp < Ferment_Tank_fermenting_temp){                                                // aaa setTemp(Ferment_Tank_fermenting_temp, Ferment_Tank_fermenting_time)                                                console.log("setTemp(" + Ferment_Tank_fermenting_temp + ", " + Ferment_Tank_fermenting_time + ")")                                            }                                        });                                        // -- 發酵 --                                        console.log("進入發酵流程")                                        Fermenting_F_interval = setInterval(Fermenting_F, 5000);                                    }                                    else if (present_WaterLevel == 1) {                                        // aaa outerSolenoidWater_OFF()                                        console.log("outerSolenoidWater_OFF")                                        console.log("保溫夾層入水完成, 桶內加水中")                                    }                                    else if (present_tank_water_height > Ferment_Tank_water_height) {                                        // aaa tankSolenoidWaterIn_OFF()                                        console.log("tankSolenoidWaterIn_OFF")                                        console.log("桶內入水完成, 保溫夾層加水中")                                    }                                    WaterIn_F_Process = 0;                                },                                error:function(thrownError){                                    console.log("Error: " + thrownError)                                    WaterIn_F_Process = 0;                                }                            });                        };                        // 出水排豆排程                        var WaterBeanOut_F_interval                        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 >= Ferment_Tank_fermenting_temp) {                                        clearInterval(Fermenting_F_interval)                                        console.log("已達指定溫度!")                                        console.log("發酵 " + Ferment_Tank_fermenting_time + " 秒")                                        var time = new Date();                                        while ((new Date() - time) < Ferment_Tank_fermenting_time * 1000) { };                                        console.log("發酵完成, 準備出豆")                                        // aaa tankTempEnable_OFF()                                        console.log("tankTempEnable_OFF")                                        // aaa tankMotor_OFF()                                        console.log("tankMotor_OFF")                                        // aaa tankSolenoidWaterOut_ON()                                        console.log("tankSolenoidWaterOut_ON")                                        console.log("暫停 1 分鐘排放廢水")                                        var time = new Date();                                        while ((new Date() - time) < 60 * 1000) { };                                        // aaa tankSolenoidWaterOut_OFF()                                        console.log("tankSolenoidWaterOut_OFF")                                        WaterBeanOut_F_interval = setInterval(WaterBeanOut_F, 5000);                                    }                                    Fermenting_F_Process = 0;                                },                                error:function(thrownError){                                    console.log("Error: " + thrownError)                                    Fermenting_F_Process = 0;                                }                            });                        };                        function WaterBeanOut_F(){                            // -- 出料 --                            // 設定空桶高度                            var testing_tank_empty_height_F = 3.0;                            console.log("設定空桶高度: " + testing_tank_empty_height_F)                            if (WaterBeanOut_F_Process == 1){                                return;                            }                            // 取得桶內生豆高度                            WaterBeanOut_F_Process = 1;                            $.ajax({                                async:false,                                type:"GET",                                url:"/ferment_UltraSonic_" + tank_num,                                dataType:"json",                                success:function(response){                                    var present_Bean_height = parseFloat(response.UltraSonic);                                    console.log("目前發酵豆高/水位: " + present_Bean_height)                                    if (present_Bean_height > testing_tank_empty_height_F) {                                        // aaa outputVacuum_ON()                                        console.log("outputVacuum_ON")                                        var time = new Date();                                        while ((new Date() - time) < Ferment_Output_vacuumON_time * 1000) { };                                        // aaa outputVacuum_OFF()                                        console.log("outputVacuum_OFF")                                        var time = new Date();                                        while ((new Date() - time) < Ferment_Output_vacuumOFF_time * 1000) { };                                    } else {                                        clearInterval(WaterBeanOut_F_interval);                                        console.log("發酵完成!槽內已無生豆")                                    }                                    WaterBeanOut_F_Process = 0;                                },                                error:function(thrownError){                                    console.log("Error: " + thrownError)                                    WaterBeanOut_F_Process = 0;                                }                            })                        };                    }                </script>                <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="ferment_auto()">                    [測試] MQTT + 每 60 秒更新貨櫃狀態</button>                <script>                    function ferment_auto(){                        var Ferment_Input_bean_height = $("input[name=Ferment_Input_bean_height]").val();                        var Ferment_Input_vacuumON_time = $("input[name=Ferment_Input_vacuumON_time]").val();                        var Ferment_Input_vacuumOFF_time = $("input[name=Ferment_Input_vacuumOFF_time]").val();                        var Ferment_Tank_bean_height = $("input[name=Ferment_Tank_bean_height]").val();                        var Ferment_Tank_vacuumON_time = $("input[name=Ferment_Tank_vacuumON_time]").val();                        var Ferment_Tank_vacuumOFF_time = $("input[name=Ferment_Tank_vacuumOFF_time]").val();                        var Ferment_Tank_water_height = $("input[name=Ferment_Tank_water_height]").val();                        var Ferment_Tank_fermenting_temp = $("input[name=Ferment_Tank_fermenting_temp]").val();                        var Ferment_Tank_fermenting_time = $("input[name=Ferment_Tank_fermenting_time]").val();                        var Ferment_Tank_fermenting_pH = $("input[name=Ferment_Tank_fermenting_pH]").val();                        var Ferment_Tank_fermenting_DO = $("input[name=Ferment_Tank_fermenting_DO]").val();                        var Ferment_Tank_fermenting_ORP = $("input[name=Ferment_Tank_fermenting_ORP]").val();                        var Ferment_Tank_fermenting_EC = $("input[name=Ferment_Tank_fermenting_EC]").val();                        var Ferment_Tank_motor_rpm = $("input[name=Ferment_Tank_motor_rpm]").val();                        var Ferment_Tank_motor_time = $("input[name=Ferment_Tank_motor_time]").val();                        var Ferment_Tank_Disinfect_time = $("input[name=Ferment_Tank_Disinfect_time]").val();                        var Ferment_Output_bean_height = $("input[name=Ferment_Output_bean_height]").val();                        var Ferment_Output_vacuumON_time = $("input[name=Ferment_Output_vacuumON_time]").val();                        var Ferment_Output_vacuumOFF_time = $("input[name=Ferment_Output_vacuumOFF_time]").val();                        var FermentAuto_fermenting = $('#cb_fermenting').prop('checked') // true false                        var FermentAuto_cleaning = $('#cb_cleaning').prop('checked')                        var FermentAuto_calibratingEC = $('#cb_calibratingEC').prop('checked')                        var FermentAuto_calibratingSTIR = $('#cb_calibratingSTIR').prop('checked')                        var Ferment_auto_cleaning_Ftimes = $("input[name=Ferment_auto_cleaning_Ftimes]").val();                        var Ferment_auto_calibratingEC_Ftimes = $("input[name=Ferment_auto_calibratingEC_Ftimes]").val();                        var Ferment_auto_calibratingSTIR_Ftimes = $("input[name=Ferment_auto_calibratingSTIR_Ftimes]").val();                        if ( (!(/(^[1-9]\d*$)/.test(Ferment_auto_cleaning_Ftimes)) && FermentAuto_cleaning) ||                                    (!(/(^[1-9]\d*$)/.test(Ferment_auto_calibratingEC_Ftimes)) && FermentAuto_calibratingEC) ||                                    (!(/(^[1-9]\d*$)/.test(Ferment_auto_calibratingSTIR_Ftimes)) && FermentAuto_calibratingSTIR) ) {                            alert('[發酵貨櫃] 次數只接受正整數, 請重新輸入')                            return                        } else {                            // 若發酵排程被勾選則為 1, 否則為 0 (預設發酵排程會不斷執行)                            if (FermentAuto_fermenting == true) { FermentAuto_fermenting = 1                            } else { FermentAuto_fermenting = 0 }                            // 若清洗排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)                            if (FermentAuto_cleaning == true) { FermentAuto_cleaning = Ferment_auto_cleaning_Ftimes                            } else { FermentAuto_cleaning = 0 }                            // 若校正 EC 排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)                            if (FermentAuto_calibratingEC == true) { FermentAuto_calibratingEC = Ferment_auto_calibratingEC_Ftimes                            } else { FermentAuto_calibratingEC = 0 }                            // 若校正攪拌棒排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)                            if (FermentAuto_calibratingSTIR == true) { FermentAuto_calibratingSTIR = Ferment_auto_calibratingSTIR_Ftimes                            } else { FermentAuto_calibratingSTIR = 0 }                        }                        var data = { 'command': 'Ferment_auto_parameter',                                    'FermentAuto_fermenting': FermentAuto_fermenting,                                    'FermentAuto_cleaning': FermentAuto_cleaning,                                    'FermentAuto_calibratingEC': FermentAuto_calibratingEC,                                    'FermentAuto_calibratingSTIR': FermentAuto_calibratingSTIR,                                    'Ferment_Input_bean_height':Ferment_Input_bean_height,                                    'Ferment_Input_vacuumON_time': Ferment_Input_vacuumON_time,                                    'Ferment_Input_vacuumOFF_time': Ferment_Input_vacuumOFF_time,                                    'Ferment_Tank_bean_height': Ferment_Tank_bean_height,                                    'Ferment_Tank_vacuumON_time': Ferment_Tank_vacuumON_time,                                    'Ferment_Tank_vacuumOFF_time': Ferment_Tank_vacuumOFF_time,                                    'Ferment_Tank_water_height': Ferment_Tank_water_height,                                    'Ferment_Tank_fermenting_temp': Ferment_Tank_fermenting_temp,                                    'Ferment_Tank_fermenting_time': Ferment_Tank_fermenting_time,                                    'Ferment_Tank_fermenting_pH': Ferment_Tank_fermenting_pH,                                    'Ferment_Tank_fermenting_DO': Ferment_Tank_fermenting_DO,                                    'Ferment_Tank_fermenting_ORP': Ferment_Tank_fermenting_ORP,                                    'Ferment_Tank_fermenting_EC': Ferment_Tank_fermenting_EC,                                    'Ferment_Tank_motor_rpm': Ferment_Tank_motor_rpm,                                    'Ferment_Tank_motor_time': Ferment_Tank_motor_time,                                    'Ferment_Output_bean_height': Ferment_Output_bean_height,                                    'Ferment_Output_vacuumON_time': Ferment_Output_vacuumON_time,                                    'Ferment_Output_vacuumOFF_time': Ferment_Output_vacuumOFF_time };                        $.post('/mqtt/101', data, function (res) {                            console.log('data: ', data)                            console.log('res: ', res)                        }, 'text')                        var ferment_interval = setInterval(testing_F_auto, 30*1000)                    }                </script>                <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="testing_F_auto()">                    [測試] 發酵貨櫃狀態</button>                <script>                    function test(){                        var FermentAuto_fermenting = $('#cb_fermenting').prop('checked') // true false                        var FermentAuto_cleaning = $('#cb_cleaning').prop('checked')                        var FermentAuto_calibratingEC = $('#cb_calibratingEC').prop('checked')                        var FermentAuto_calibratingSTIR = $('#cb_calibratingSTIR').prop('checked')                        /*                        if ($('#cb_fermenting').prop('checked')) {                            console.log("發酵自動化:加入發酵排程");                        }                        if ($('#cb_cleaning').prop('checked')) {                            console.log("發酵自動化:加入清洗排程");                        }                        if ($('#cb_calibratingEC').prop('checked')) {                            console.log("發酵自動化:加入校正 EC 排程");                        }                        if ($('#cb_calibratingSTIR').prop('checked')) {                            console.log("發酵自動化:加入校正攪拌棒排程");                        }                        */                        Ferment_auto_cleaning_Ftimes = $("input[name=Ferment_auto_cleaning_Ftimes]").val();                        console.log('Ferment_auto_cleaning_Ftimes: ' + Ferment_auto_cleaning_Ftimes)                        if ( !(/(^[1-9]\d*$)/.test(Ferment_auto_cleaning_Ftimes)) ){                            console.log('不可為小數')                        }                        console.log(FermentAuto_fermenting)                        console.log(FermentAuto_cleaning)                        console.log(FermentAuto_calibratingEC)                        console.log(FermentAuto_calibratingSTIR)                    };                    function testing_F_auto(){                        var FermentAuto_fermenting = $('#cb_fermenting').prop('checked') // true false                        var FermentAuto_cleaning = $('#cb_cleaning').prop('checked')                        var FermentAuto_calibratingEC = $('#cb_calibratingEC').prop('checked')                        var FermentAuto_calibratingSTIR = $('#cb_calibratingSTIR').prop('checked')                        var Ferment_auto_cleaning_Ftimes = $("input[name=Ferment_auto_cleaning_Ftimes]").val();                        var Ferment_auto_calibratingEC_Ftimes = $("input[name=Ferment_auto_calibratingEC_Ftimes]").val();                        var Ferment_auto_calibratingSTIR_Ftimes = $("input[name=Ferment_auto_calibratingSTIR_Ftimes]").val();                        if ((!FermentAuto_fermenting) && (!FermentAuto_cleaning) && !FermentAuto_calibratingEC && !FermentAuto_calibratingSTIR) {                            alert('[發酵貨櫃] 未勾選任何排程, 自動化結束')                            return                        } else if ( (!(/(^[1-9]\d*$)/.test(Ferment_auto_cleaning_Ftimes)) && FermentAuto_cleaning) ||                                    (!(/(^[1-9]\d*$)/.test(Ferment_auto_calibratingEC_Ftimes)) && FermentAuto_calibratingEC) ||                                    (!(/(^[1-9]\d*$)/.test(Ferment_auto_calibratingSTIR_Ftimes)) && FermentAuto_calibratingSTIR) ) {                            alert('[發酵貨櫃] 次數只接受正整數, 請重新輸入')                            return                        } else {                            // 若發酵排程被勾選則為 1, 否則為 0 (預設發酵排程會不斷執行)                            if (FermentAuto_fermenting == true) { FermentAuto_fermenting = 1                            } else { FermentAuto_fermenting = 0 }                            // 若清洗排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)                            if (FermentAuto_cleaning == true) { FermentAuto_cleaning = Ferment_auto_cleaning_Ftimes                            } else { FermentAuto_cleaning = 0 }                            // 若校正 EC 排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)                            if (FermentAuto_calibratingEC == true) { FermentAuto_calibratingEC = Ferment_auto_calibratingEC_Ftimes                            } else { FermentAuto_calibratingEC = 0 }                            // 若校正攪拌棒排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)                            if (FermentAuto_calibratingSTIR == true) { FermentAuto_calibratingSTIR = Ferment_auto_calibratingSTIR_Ftimes                            } else { FermentAuto_calibratingSTIR = 0 }                        }                        var Ferment_Input_vacuumON_time = $("input[name=Ferment_Input_vacuumON_time]").val();                        var Ferment_Input_vacuumOFF_time = $("input[name=Ferment_Input_vacuumOFF_time]").val();                        var Ferment_Tank_bean_height = $("input[name=Ferment_Tank_bean_height]").val();                        var Ferment_Tank_vacuumON_time = $("input[name=Ferment_Tank_vacuumON_time]").val();                        var Ferment_Tank_vacuumOFF_time = $("input[name=Ferment_Tank_vacuumOFF_time]").val();                        var Ferment_Tank_water_height = $("input[name=Ferment_Tank_water_height]").val();                        var Ferment_Tank_fermenting_temp = $("input[name=Ferment_Tank_fermenting_temp]").val();                        var Ferment_Tank_fermenting_time = $("input[name=Ferment_Tank_fermenting_time]").val();                        var Ferment_Tank_fermenting_pH = $("input[name=Ferment_Tank_fermenting_pH]").val();                        var Ferment_Tank_fermenting_DO = $("input[name=Ferment_Tank_fermenting_DO]").val();                        var Ferment_Tank_fermenting_ORP = $("input[name=Ferment_Tank_fermenting_ORP]").val();                        var Ferment_Tank_fermenting_EC = $("input[name=Ferment_Tank_fermenting_EC]").val();                        var Ferment_Tank_motor_rpm = $("input[name=Ferment_Tank_motor_rpm]").val();                        var Ferment_Tank_Disinfect_time = $("input[name=Ferment_Tank_Disinfect_time]").val();                        var Ferment_Output_vacuumON_time = $("input[name=Ferment_Output_vacuumON_time]").val();                        var Ferment_Output_vacuumOFF_time = $("input[name=Ferment_Output_vacuumOFF_time]").val();                        var data = { 'command': 'Ferment_auto_parameter',                                    'FermentAuto_fermenting': FermentAuto_fermenting,                                    'FermentAuto_cleaning': FermentAuto_cleaning,                                    'FermentAuto_calibratingEC': FermentAuto_calibratingEC,                                    'FermentAuto_calibratingSTIR': FermentAuto_calibratingSTIR,                                    'Ferment_Input_vacuumON_time': Ferment_Input_vacuumON_time,                                    'Ferment_Input_vacuumOFF_time': Ferment_Input_vacuumOFF_time,                                    'Ferment_Tank_bean_height': Ferment_Tank_bean_height,                                    'Ferment_Tank_vacuumON_time': Ferment_Tank_vacuumON_time,                                    'Ferment_Tank_vacuumOFF_time': Ferment_Tank_vacuumOFF_time,                                    'Ferment_Tank_water_height': Ferment_Tank_water_height,                                    'Ferment_Tank_fermenting_temp': Ferment_Tank_fermenting_temp,                                    'Ferment_Tank_fermenting_time': Ferment_Tank_fermenting_time,                                    'Ferment_Tank_fermenting_pH': Ferment_Tank_fermenting_pH,                                    'Ferment_Tank_fermenting_DO': Ferment_Tank_fermenting_DO,                                    'Ferment_Tank_fermenting_ORP': Ferment_Tank_fermenting_ORP,                                    'Ferment_Tank_fermenting_EC': Ferment_Tank_fermenting_EC,                                    'Ferment_Tank_motor_rpm': Ferment_Tank_motor_rpm,                                    'Ferment_Output_vacuumON_time': Ferment_Output_vacuumON_time,                                    'Ferment_Output_vacuumOFF_time': Ferment_Output_vacuumOFF_time };                        $.get('/ferment_auto_status', data, function (res) {                            console.log('FI1: ' + res.Ferment_Input_1)                            console.log('F1: ' + res.Ferment_Tank_1)                            console.log('F2: ' + res.Ferment_Tank_2)                            console.log('F3: ' + res.Ferment_Tank_3)                            console.log('F4: ' + res.Ferment_Tank_4)                            console.log('F5: ' + res.Ferment_Tank_5)                            console.log('F6: ' + res.Ferment_Tank_6)                            console.log('FO1: ' + res.Ferment_Output_1)                            // ----- 發酵出料 FO1 狀態 --------------------------------------------------------------                            ferment_input_status = [res.Ferment_Input_1]                            for (let i=0; i<ferment_input_status.length; i++) {                                // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態                                // console.log(i+1 + ' : '+ ferment_output_status[i])                                // 1 : F_InputtingBean                                // 2 : F_Waiting                                if (ferment_input_status[i] == 'FI_InputtingBean') {                                    console.log('[動作] 發酵入料 FI' + parseInt(i+1) + ' 入豆中')                                    $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                    $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 入豆中")                                } else if (ferment_input_status[i] == 'FI_Waiting') {                                    console.log('[動作] 發酵入料 FI' + parseInt(i+1) + ' 空桶等待')                                    $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")                                    $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 空桶等待")                                } else if (ferment_input_status[i] == 'FI_OutputtingBean') {                                    console.log('[動作] 發酵入料 FI' + parseInt(i+1) + ' 可出豆')                                    $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                    $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 可出豆")                                } else {                                    console.log('pass')                                }                            }                            // ----- 發酵桶槽 F1~F6 狀態 --------------------------------------------------------------                            ferment_tank_status = [res.Ferment_Tank_1, res.Ferment_Tank_2, res.Ferment_Tank_3,                                                    res.Ferment_Tank_4, res.Ferment_Tank_5, res.Ferment_Tank_6]                            for (let i=0; i<ferment_tank_status.length; i++) {                                // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態                                // console.log(i+1 + ' : '+ ferment_tank_status[i])                                // 1 : F_InputtingBean                                // 2 : F_Waiting                                if (ferment_tank_status[i] == 'F_InputtingBean') {                                    console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入豆中')                                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  入豆中")                                } else if (ferment_tank_status[i] == 'F_InputtingBean_Pause') {                                    console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入豆暫停')                                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  入豆暫停")                                } else if (ferment_tank_status[i] == 'F_InputtingBean_Finish') {                                    console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入豆完成')                                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  入豆完成")                                } else if (ferment_tank_status[i] == 'F_InputtingWater') {                                    console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入水中')                                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  入水中")                                } else if (ferment_tank_status[i] == 'F_Waiting') {                                    console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 空桶等待')                                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")                                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  空桶等待")                                } else if (ferment_tank_status[i] == 'F_Fermenting') {                                    console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 發酵中')                                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  發酵中")                                } else if (ferment_tank_status_N[i] == 'F_Cleaning') {                                    console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 清洗中')                                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "plum")                                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  清洗中")                                } else if (ferment_tank_status[i] == 'F_OutputtingBean') {                                    console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 可出豆')                                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  可出豆")                                } else if (ferment_tank_status[i] == 'F_Warning') {                                    console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 發生錯誤')                                    $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "crimson")                                    $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + "  發生錯誤")                                    $("#F"+parseInt(i+1)+"_status").css("color", "crimson")                                } else {                                    console.log('pass')                                }                            }                            // ----- 發酵出料 FO1 狀態 --------------------------------------------------------------                            ferment_output_status = [res.Ferment_Output_1]                            for (let i=0; i<ferment_output_status.length; i++) {                                // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態                                // console.log(i+1 + ' : '+ ferment_output_status[i])                                // 1 : F_InputtingBean                                // 2 : F_Waiting                                if (ferment_output_status[i] == 'FO_InputtingBean') {                                    console.log('[動作] 發酵出料 FO' + parseInt(i+1) + ' 入豆中')                                    $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                    $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 入豆中")                                } else if (ferment_output_status[i] == 'FO_Waiting') {                                    console.log('[動作] 發酵出料 FO' + parseInt(i+1) + ' 空桶等待')                                    $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")                                    $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 空桶等待")                                } else if (ferment_output_status[i] == 'FO_OutputtingBean') {                                    console.log('[動作] 發酵出料 FO' + parseInt(i+1) + ' 可出豆')                                    $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")                                    $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 可出豆")                                } else {                                    console.log('pass')                                }                            }                            /*                            console.log(res.Ferment_Input_2)                            console.log(res.Ferment_Tank_7)                            console.log(res.Ferment_Tank_8)                            console.log(res.Ferment_Tank_9)                            console.log(res.Ferment_Tank_10)                            console.log(res.Ferment_Tank_11)                            console.log(res.Ferment_Tank_12)                            console.log(res.Ferment_Output_1)                            console.log(res.Ferment_Output_2)                            */                        }, 'json');                        // console.log("-- 自動化程式 end --")                    }                </script>            </div>            <br>            <br>        </div>    </div></body></html>
 |