| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740 | <!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}}')            peel_output_status = ['{{PO1}}']            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('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 {                    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 {                    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 {                    console.log('pass')                }            }                        loading_F()            // css             // height: 185px; 取代成 height: 210px;            // FI2 FO2  top: 620px; 取代成 top: 645px;        });        $(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>        })        function loading_F(){            $.get('/loading/FI1', '', function (res) {                $("#actuator_00").text(res.input_vacuum);                $("#sensor_00").text(res.input_UltraSonic);            }, 'json');            $.get('/loading/FO1', '', function (res) {                $("#actuator_99").text(res.output_vacuum);                $("#sensor_99").text(res.output_UltraSonic);            }, 'json');            $.get('/loading/F1', '', function (res) {                $("#actuator_1").text(res.tank_vacuum);                $("#actuator_2").text(res.tank_threewayvalve_input);                $("#actuator_3").text(res.tank_diskvalve);                $("#actuator_4").text(res.solenoid_tank_pump);                $("#actuator_5").text(res.tank_solenoid_disinfect);                $("#actuator_6").text(res.outer_solenoid_water);                $("#actuator_7").text(res.tank_solenoid_water_in);                $("#actuator_8").text(res.tank_solenoid_water_out);                $("#actuator_9").text(res.tank_pump_sensor);                $("#actuator_10").text(res.outer_threewayvalve_float);                $("#actuator_11").text(res.tank_motor);                $("#actuator_12").text(res.tank_heater1);                $("#actuator_13").text(res.tank_heater2);                $("#actuator_14").text(res.tank_temp_enable);                $("#actuator_15").text(res.tank_temp);                $("#sensor_1").text(res.UltraSonic);                $("#sensor_2").text(res.SHT11_Temp);                $("#sensor_3").text(res.SHT11_Humidity);                $("#sensor_4").text(res.CO2);                $("#sensor_5").text(res.PA);                $("#sensor_6").text(res.PH);                $("#sensor_7").text(res.ORP);                $("#sensor_8").text(res.DO);                $("#sensor_9").text(res.EC);                $("#sensor_10").text(res.WaterLevel);                           }, 'json');        }    </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        // WebUpdate_set = setInterval(function(){WebUpdate()} , 60 * 1000)        function WebUpdate(){            console.log("-- 狀態更新 start --")            /*            $.get('/loading_container_status/F', '', function (res) {            }, 'json');            */            console.log("-- 狀態更新 end --")        };    </script></head><body>    <div id="wrapper">        <div id="coffee_header">            <!-- 匯入共同使用的 header.html 內容 -->            {% include 'header.html' %}        </div>        <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>                </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>                </tr>                <tr>                    <td>PO2</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>                </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">00</span>                        </td>                        <td>                            <span id="sensor_1">00</span>                        </td>                        <td>                            <span id="sensor_2">00</span>                        </td>                        <td>                            <span id="sensor_3">00</span>                        </td>                        <td>                            <span id="sensor_4">00</span>                        </td>                        <td>                            <span id="sensor_5">00</span>                        </td>                        <td>                            <span id="sensor_6">00</span>                        </td>                        <td>                            <span id="sensor_7">00</span>                        </td>                        <td>                            <span id="sensor_8">00</span>                        </td>                        <td>                            <span id="sensor_9">00</span>                        </td>                        <td>                            <span id="sensor_10">00</span>                        </td>                        <td>                            <span id="sensor_99">00</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 id="coffee_footer">            <!-- 匯入共同使用的 footer.html 內容 -->            {% include 'footer.html' %}        </div>    </div></body></html>
 |