1
0

ferment_auto.html 104 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>{{ title }}</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7. <!-- <meta http-equiv="refresh" content="10" />每 content 秒網頁自動更新-->
  8. <!-- 新 Bootstrap4 核心 CSS 文件 -->
  9. <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
  10. <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
  11. <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  12. <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
  13. <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
  14. <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
  15. <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  16. <!--
  17. <script src="../static/js/sign_in.js"></script>
  18. <link rel="stylesheet" href="../static/css/sign_in.css">
  19. -->
  20. <!-- Rita 發酵貨櫃 - 入料、桶槽、出料致動器 function-->
  21. <script type="text/javascript" src="../static/js/ferment_function.js"></script>
  22. <script>
  23. var tank_num = '1';
  24. $(document).ready(function(){
  25. $("#coffee_title").text('發酵自動化');
  26. // 脫皮出料顯示
  27. console.log('PO1: ' + '{{PO1}}')
  28. peel_output_status = ['{{PO1}}']
  29. for (let i=0; i<peel_output_status.length; i++) {
  30. if (peel_output_status[i] == 'PO_InputtingBean') {
  31. console.log('[動作] 脫皮出料 PO' + parseInt(i+1) + ' 入豆中')
  32. $("#PO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  33. $("#PO"+parseInt(i+1)+"_status").text("PO" + parseInt(i+1) + " 入豆中")
  34. } else if (peel_output_status[i] == 'PO_Waiting') {
  35. console.log('[動作] 脫皮出料 PO' + parseInt(i+1) + ' 空桶等待')
  36. $("#PO"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  37. $("#PO"+parseInt(i+1)+"_status").text("PO" + parseInt(i+1) + " 空桶等待")
  38. } else if (peel_output_status[i] == 'PO_OutputtingBean') {
  39. console.log('[動作] 脫皮出料 PO' + parseInt(i+1) + ' 可出豆')
  40. $("#PO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  41. $("#PO"+parseInt(i+1)+"_status").text("PO" + parseInt(i+1) + " 可出豆")
  42. } else {
  43. console.log('pass')
  44. }
  45. }
  46. // 桶槽入料顯示
  47. ferment_input_status_N = ['{{FI1}}', '{{FI2}}']
  48. // console.log('ferment_input_status_N: ' + ferment_input_status_N)
  49. for (let i=0; i<ferment_input_status_N.length; i++) {
  50. // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態
  51. // console.log(i+1 + ' : '+ ferment_output_status[i])
  52. // 1 : F_InputtingBean
  53. // 2 : F_Waiting
  54. if (ferment_input_status_N[i] == 'FI_InputtingBean') {
  55. $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  56. $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 入豆中")
  57. } else if (ferment_input_status_N[i] == 'FI_Waiting') {
  58. $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  59. $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 空桶等待")
  60. } else if (ferment_input_status_N[i] == 'FI_OutputtingBean') {
  61. $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  62. $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 可出豆")
  63. } else {
  64. console.log('pass')
  65. }
  66. }
  67. // 桶槽狀態顯示
  68. ferment_tank_status_N = ['{{F1}}', '{{F2}}', '{{F3}}', '{{F4}}', '{{F5}}', '{{F6}}',
  69. '{{F7}}', '{{F8}}', '{{F9}}', '{{F10}}', '{{F11}}', '{{F12}}']
  70. // console.log('ferment_tank_status_N: ' + ferment_tank_status_N)
  71. for (let i=0; i<ferment_tank_status_N.length; i++) {
  72. // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態
  73. // console.log(i+1 + ' : '+ ferment_tank_status[i])
  74. // 1 : F_InputtingBean
  75. // 2 : F_Waiting
  76. if (ferment_tank_status_N[i] == 'F_InputtingBean') {
  77. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  78. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 入豆中")
  79. } else if (ferment_tank_status_N[i] == 'F_InputtingBean_Pause') {
  80. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  81. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 入豆暫停")
  82. } else if (ferment_tank_status_N[i] == 'F_InputtingBean_Finish') {
  83. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  84. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 入豆完成")
  85. } else if (ferment_tank_status_N[i] == 'F_InputtingWater') {
  86. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  87. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 入水中")
  88. } else if (ferment_tank_status_N[i] == 'F_Waiting') {
  89. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  90. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 空桶等待")
  91. } else if (ferment_tank_status_N[i] == 'F_Cleaning') {
  92. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "plum")
  93. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 清洗中")
  94. } else if (ferment_tank_status_N[i] == 'F_Fermenting') {
  95. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  96. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 發酵中")
  97. } else if (ferment_tank_status_N[i] == 'F_OutputtingBean') {
  98. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  99. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 可出豆")
  100. } else if (ferment_tank_status_N[i] == 'F_Warning') {
  101. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "crimson")
  102. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 發生錯誤")
  103. $("#F"+parseInt(i+1)+"_status").css("color", "crimson")
  104. } else {
  105. console.log('pass')
  106. }
  107. }
  108. // 桶槽出料顯示
  109. ferment_output_status_N = ['{{FO1}}', '{{FO2}}']
  110. // console.log('ferment_output_status_N: ' + ferment_output_status_N)
  111. for (let i=0; i<ferment_output_status_N.length; i++) {
  112. // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態
  113. // console.log(i+1 + ' : '+ ferment_output_status[i])
  114. // 1 : F_InputtingBean
  115. // 2 : F_Waiting
  116. if (ferment_output_status_N[i] == 'FO_InputtingBean') {
  117. $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  118. $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 入豆中")
  119. } else if (ferment_output_status_N[i] == 'FO_Waiting') {
  120. $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  121. $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 空桶等待")
  122. } else if (ferment_output_status_N[i] == 'FO_OutputtingBean') {
  123. $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  124. $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 可出豆")
  125. } else {
  126. console.log('pass')
  127. }
  128. }
  129. loading_F()
  130. // css
  131. // height: 185px; 取代成 height: 210px;
  132. // FI2 FO2 top: 620px; 取代成 top: 645px;
  133. });
  134. $(function(){
  135. $('#cb_cleaning').on('change', function () {
  136. if ($('#cb_cleaning').prop('checked')) {
  137. $("input[name='Ferment_auto_cleaning_Ftimes']").attr('disabled', false);
  138. $("input[name='Ferment_auto_cleaning_Ftimes']").attr('value', '1');
  139. } else {
  140. $("input[name='Ferment_auto_cleaning_Ftimes']").attr('disabled', true);
  141. }
  142. })
  143. $('#cb_calibratingEC').on('change', function () {
  144. if ($('#cb_calibratingEC').prop('checked')) {
  145. $("input[name='Ferment_auto_calibratingEC_Ftimes']").attr('disabled', false);
  146. $("input[name='Ferment_auto_calibratingEC_Ftimes']").attr('value', '1');
  147. } else {
  148. $("input[name='Ferment_auto_calibratingEC_Ftimes']").attr('disabled', true);
  149. }
  150. })
  151. $('#cb_calibratingSTIR').on('change', function () {
  152. if ($('#cb_calibratingSTIR').prop('checked')) {
  153. $("input[name='Ferment_auto_calibratingSTIR_Ftimes']").attr('disabled', false);
  154. $("input[name='Ferment_auto_calibratingSTIR_Ftimes']").attr('value', '1');
  155. } else {
  156. $("input[name='Ferment_auto_calibratingSTIR_Ftimes']").attr('disabled', true);
  157. }
  158. })
  159. // <label><input type="checkbox" id="cb_cleaning">清洗:發酵
  160. // <input name="Ferment_auto_cleaning_Ftimes" class="input-text" type="text">次執行
  161. // </label><br>
  162. // <label><input type="checkbox" id="cb_calibratingEC">校正 EC
  163. // <input name="Ferment_auto_calibratingEC_Ftimes" class="input-text" type="text">次執行
  164. // </label><br>
  165. // <label><input type="checkbox" id="cb_calibratingSTIR">校正攪拌棒
  166. // <input name="Ferment_auto_calibratingSTIR_Ftimes" class="input-text" type="text">次執行
  167. // </label>
  168. })
  169. function loading_F(){
  170. $.get('/loading/FI1', '', function (res) {
  171. $("#actuator_00").text(res.input_vacuum);
  172. $("#sensor_00").text(res.input_UltraSonic);
  173. }, 'json');
  174. $.get('/loading/FO1', '', function (res) {
  175. $("#actuator_99").text(res.output_vacuum);
  176. $("#sensor_99").text(res.output_UltraSonic);
  177. }, 'json');
  178. $.get('/loading/F1', '', function (res) {
  179. $("#actuator_1").text(res.tank_vacuum);
  180. $("#actuator_2").text(res.tank_threewayvalve_input);
  181. $("#actuator_3").text(res.tank_diskvalve);
  182. $("#actuator_4").text(res.solenoid_tank_pump);
  183. $("#actuator_5").text(res.tank_solenoid_disinfect);
  184. $("#actuator_6").text(res.outer_solenoid_water);
  185. $("#actuator_7").text(res.tank_solenoid_water_in);
  186. $("#actuator_8").text(res.tank_solenoid_water_out);
  187. $("#actuator_9").text(res.tank_pump_sensor);
  188. $("#actuator_10").text(res.outer_threewayvalve_float);
  189. $("#actuator_11").text(res.tank_motor);
  190. $("#actuator_12").text(res.tank_heater1);
  191. $("#actuator_13").text(res.tank_heater2);
  192. $("#actuator_14").text(res.tank_temp_enable);
  193. $("#actuator_15").text(res.tank_temp);
  194. $("#sensor_1").text(res.UltraSonic);
  195. $("#sensor_2").text(res.SHT11_Temp);
  196. $("#sensor_3").text(res.SHT11_Humidity);
  197. $("#sensor_4").text(res.CO2);
  198. $("#sensor_5").text(res.PA);
  199. $("#sensor_6").text(res.PH);
  200. $("#sensor_7").text(res.ORP);
  201. $("#sensor_8").text(res.DO);
  202. $("#sensor_9").text(res.EC);
  203. $("#sensor_10").text(res.WaterLevel);
  204. }, 'json');
  205. }
  206. </script>
  207. <style>
  208. .F_status_css {
  209. font-weight: bold;
  210. text-align: center;
  211. }
  212. .FermentContainer_position {
  213. position: absolute;
  214. top: 95px;
  215. left: 53px;
  216. }
  217. .F1_position {
  218. width: 110px;
  219. }
  220. .F2_position {
  221. width: 110px;
  222. }
  223. .F3_position {
  224. width: 110px;
  225. }
  226. .F4_position {
  227. width: 110px;
  228. }
  229. .F5_position {
  230. width: 110px;
  231. }
  232. .F6_position {
  233. width: 110px;
  234. }
  235. .F7_position {
  236. width: 110px;
  237. }
  238. .F8_position {
  239. width: 110px;
  240. }
  241. .F9_position {
  242. width: 110px;
  243. }
  244. .F10_position {
  245. width: 110px;
  246. }
  247. .F11_position {
  248. width: 110px;
  249. }
  250. .F12_position {
  251. width: 110px;
  252. }
  253. .FI1_position {
  254. width: 110px;
  255. }
  256. .FI2_position {
  257. width: 110px;
  258. }
  259. .FO1_position {
  260. width: 110px;
  261. }
  262. .FO2_position {
  263. width: 110px;
  264. }
  265. .footer{
  266. position: absolute;
  267. bottom: 0px;
  268. width: 100%;
  269. background-color: #eee;
  270. text-align: center;
  271. }
  272. .input-text {
  273. height: 25px;
  274. width: 40px;
  275. text-align: center;
  276. margin-left: 2px;
  277. margin-right: 5px;
  278. }
  279. </style>
  280. <script language="JavaScript">
  281. // 指定 10秒 刷新網頁一次
  282. var WebUpdate_set
  283. // WebUpdate_set = setInterval(function(){WebUpdate()} , 60 * 1000)
  284. function WebUpdate(){
  285. console.log("-- 狀態更新 start --")
  286. /*
  287. $.get('/loading_container_status/F', '', function (res) {
  288. }, 'json');
  289. */
  290. console.log("-- 狀態更新 end --")
  291. };
  292. </script>
  293. </head>
  294. <body>
  295. <div id="wrapper">
  296. <div id="coffee_header">
  297. <!-- 匯入共同使用的 header.html 內容 -->
  298. {% include 'header.html' %}
  299. </div>
  300. <div>
  301. <!-- 發酵貨櫃 測試按鈕-->
  302. <div style="text-align: center;">
  303. <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="ferment_auto_status_stop()">
  304. <u>狀態判斷_停止</u></button>
  305. <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="ferment_auto_status_testing()">
  306. <u>[測試] 發酵自動化_狀態判斷</u></button>
  307. <script>
  308. var ferment_status_interval // 每 5 秒更新桶槽狀態、致動器狀態、感測器數值, 放全域
  309. var loadingF
  310. var ferment_status_process = 0;
  311. function ferment_auto_status_testing(){
  312. console.log("------- 狀態判斷 開始 -------")
  313. loadingF = setInterval(loading_F, 10*1000)
  314. var Ferment_Input_bean_height = $("input[name=Ferment_Input_bean_height]").val();
  315. var Ferment_Input_vacuumON_time = $("input[name=Ferment_Input_vacuumON_time]").val();
  316. var Ferment_Input_vacuumOFF_time = $("input[name=Ferment_Input_vacuumOFF_time]").val();
  317. var Ferment_Tank_bean_height = $("input[name=Ferment_Tank_bean_height]").val();
  318. var Ferment_Tank_vacuumON_time = $("input[name=Ferment_Tank_vacuumON_time]").val();
  319. var Ferment_Tank_vacuumOFF_time = $("input[name=Ferment_Tank_vacuumOFF_time]").val();
  320. var Ferment_Tank_water_height = $("input[name=Ferment_Tank_water_height]").val();
  321. var Ferment_Tank_fermenting_temp = $("input[name=Ferment_Tank_fermenting_temp]").val();
  322. var Ferment_Tank_fermenting_time = $("input[name=Ferment_Tank_fermenting_time]").val();
  323. var Ferment_Tank_fermenting_pH = $("input[name=Ferment_Tank_fermenting_pH]").val();
  324. var Ferment_Tank_fermenting_DO = $("input[name=Ferment_Tank_fermenting_DO]").val();
  325. var Ferment_Tank_fermenting_ORP = $("input[name=Ferment_Tank_fermenting_ORP]").val();
  326. var Ferment_Tank_fermenting_EC = $("input[name=Ferment_Tank_fermenting_EC]").val();
  327. var Ferment_Tank_motor_rpm = $("input[name=Ferment_Tank_motor_rpm]").val();
  328. var Ferment_Tank_motor_time = $("input[name=Ferment_Tank_motor_time]").val();
  329. var Ferment_Tank_WaterOut_time = $("input[name=Ferment_Tank_WaterOut_time]").val();
  330. var Ferment_Tank_Disinfect_time = $("input[name=Ferment_Tank_Disinfect_time]").val();
  331. var Ferment_Output_bean_height = $("input[name=Ferment_Output_bean_height]").val();
  332. var Ferment_Output_vacuumON_time = $("input[name=Ferment_Output_vacuumON_time]").val();
  333. var Ferment_Output_vacuumOFF_time = $("input[name=Ferment_Output_vacuumOFF_time]").val();
  334. var FermentAuto_fermenting = $('#cb_fermenting').prop('checked') // true false
  335. var FermentAuto_cleaning = $('#cb_cleaning').prop('checked')
  336. var FermentAuto_calibratingEC = $('#cb_calibratingEC').prop('checked')
  337. var FermentAuto_calibratingSTIR = $('#cb_calibratingSTIR').prop('checked')
  338. var Ferment_auto_cleaning_Ftimes = $("input[name=Ferment_auto_cleaning_Ftimes]").val();
  339. var Ferment_auto_calibratingEC_Ftimes = $("input[name=Ferment_auto_calibratingEC_Ftimes]").val();
  340. var Ferment_auto_calibratingSTIR_Ftimes = $("input[name=Ferment_auto_calibratingSTIR_Ftimes]").val();
  341. var Ferment_cb_vacuum = $('#Ferment_cb_vacuum').prop('checked') // true false
  342. var Ferment_cb_vacuum_time = $("input[name=Ferment_cb_vacuum_time]").val();
  343. if ( (!(/(^[1-9]\d*$)/.test(Ferment_auto_cleaning_Ftimes)) && FermentAuto_cleaning) ||
  344. (!(/(^[1-9]\d*$)/.test(Ferment_auto_calibratingEC_Ftimes)) && FermentAuto_calibratingEC) ||
  345. (!(/(^[1-9]\d*$)/.test(Ferment_auto_calibratingSTIR_Ftimes)) && FermentAuto_calibratingSTIR) ) {
  346. alert('[發酵貨櫃] 次數只接受正整數, 請重新輸入')
  347. return
  348. } else {
  349. // 若發酵排程被勾選則為 1, 否則為 0 (預設發酵排程會不斷執行)
  350. if (FermentAuto_fermenting == true) { FermentAuto_fermenting = 1
  351. } else { FermentAuto_fermenting = 0 }
  352. // 若清洗排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)
  353. if (FermentAuto_cleaning == true) { FermentAuto_cleaning = Ferment_auto_cleaning_Ftimes
  354. } else { FermentAuto_cleaning = 0 }
  355. // 若校正 EC 排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)
  356. if (FermentAuto_calibratingEC == true) { FermentAuto_calibratingEC = Ferment_auto_calibratingEC_Ftimes
  357. } else { FermentAuto_calibratingEC = 0 }
  358. // 若校正攪拌棒排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)
  359. if (FermentAuto_calibratingSTIR == true) { FermentAuto_calibratingSTIR = Ferment_auto_calibratingSTIR_Ftimes
  360. } else { FermentAuto_calibratingSTIR = 0 }
  361. }
  362. var data = { 'command': 'Ferment_auto_parameter',
  363. 'FermentAuto_fermenting': FermentAuto_fermenting,
  364. 'FermentAuto_cleaning': FermentAuto_cleaning,
  365. 'FermentAuto_calibratingEC': FermentAuto_calibratingEC,
  366. 'FermentAuto_calibratingSTIR': FermentAuto_calibratingSTIR,
  367. 'Ferment_cb_vacuum': Ferment_cb_vacuum,
  368. 'Ferment_cb_vacuum_time': Ferment_cb_vacuum_time,
  369. 'Ferment_Tank_fermenting_pH': Ferment_Tank_fermenting_pH,
  370. 'Ferment_Input_bean_height':Ferment_Input_bean_height,
  371. 'Ferment_Input_vacuumON_time': Ferment_Input_vacuumON_time,
  372. 'Ferment_Input_vacuumOFF_time': Ferment_Input_vacuumOFF_time,
  373. 'Ferment_Tank_bean_height': Ferment_Tank_bean_height,
  374. 'Ferment_Tank_vacuumON_time': Ferment_Tank_vacuumON_time,
  375. 'Ferment_Tank_vacuumOFF_time': Ferment_Tank_vacuumOFF_time,
  376. 'Ferment_Tank_water_height': Ferment_Tank_water_height,
  377. 'Ferment_Tank_fermenting_temp': Ferment_Tank_fermenting_temp,
  378. 'Ferment_Tank_fermenting_time': Ferment_Tank_fermenting_time,
  379. 'Ferment_Tank_fermenting_pH': Ferment_Tank_fermenting_pH,
  380. 'Ferment_Tank_fermenting_DO': Ferment_Tank_fermenting_DO,
  381. 'Ferment_Tank_fermenting_ORP': Ferment_Tank_fermenting_ORP,
  382. 'Ferment_Tank_fermenting_EC': Ferment_Tank_fermenting_EC,
  383. 'Ferment_Tank_motor_rpm': Ferment_Tank_motor_rpm,
  384. 'Ferment_Tank_motor_time': Ferment_Tank_motor_time,
  385. 'Ferment_Tank_WaterOut_time': Ferment_Tank_WaterOut_time,
  386. 'Ferment_Tank_Disinfect_time': Ferment_Tank_Disinfect_time,
  387. 'Ferment_Output_bean_height': Ferment_Output_bean_height,
  388. 'Ferment_Output_vacuumON_time': Ferment_Output_vacuumON_time,
  389. 'Ferment_Output_vacuumOFF_time': Ferment_Output_vacuumOFF_time };
  390. ferment_status_interval = setInterval(ferment_auto_status, 5*1000);
  391. function ferment_auto_status(){
  392. if (ferment_status_process == 1) { return };
  393. ferment_status_process = 1;
  394. $.get('/ferment_auto_status', data, function (res) {
  395. FI1 = res.Ferment_Input_1
  396. F1 = res.Ferment_Tank_1
  397. F2 = res.Ferment_Tank_2
  398. F3 = res.Ferment_Tank_3
  399. F4 = res.Ferment_Tank_4
  400. F5 = res.Ferment_Tank_5
  401. F6 = res.Ferment_Tank_6
  402. FO1 = res.Ferment_Output_1
  403. console.log('FI1: ' + FI1)
  404. console.log('F1: ' + F1)
  405. console.log('F2: ' + F2)
  406. console.log('F3: ' + F3)
  407. console.log('F4: ' + F4)
  408. console.log('F5: ' + F5)
  409. console.log('F6: ' + F6)
  410. console.log('FO1: ' + FO1)
  411. // ----- 脫皮出料 PO1 狀態 --------------------------------------------------------------
  412. peel_output_status = [res.Peel_Output_1]
  413. for (let i=0; i<peel_output_status.length; i++) {
  414. if (peel_output_status[i] == 'PO_InputtingBean') {
  415. console.log('[動作] 脫皮出料 PO' + parseInt(i+1) + ' 入豆中')
  416. $("#PO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  417. $("#PO"+parseInt(i+1)+"_status").text("PO" + parseInt(i+1) + " 入豆中")
  418. } else if (peel_output_status[i] == 'PO_Waiting') {
  419. console.log('[動作] 脫皮出料 PO' + parseInt(i+1) + ' 空桶等待')
  420. $("#PO"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  421. $("#PO"+parseInt(i+1)+"_status").text("PO" + parseInt(i+1) + " 空桶等待")
  422. } else if (peel_output_status[i] == 'PO_OutputtingBean') {
  423. console.log('[動作] 脫皮出料 PO' + parseInt(i+1) + ' 可出豆')
  424. $("#PO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  425. $("#PO"+parseInt(i+1)+"_status").text("PO" + parseInt(i+1) + " 可出豆")
  426. } else {
  427. console.log('PO pass')
  428. }
  429. }
  430. // ----- 發酵出料 FO1 狀態 --------------------------------------------------------------
  431. ferment_input_status = [res.Ferment_Input_1]
  432. for (let i=0; i<ferment_input_status.length; i++) {
  433. // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態
  434. // console.log(i+1 + ' : '+ ferment_output_status[i])
  435. // 1 : F_InputtingBean
  436. // 2 : F_Waiting
  437. if (ferment_input_status[i] == 'FI_InputtingBean') {
  438. console.log('[動作] 發酵入料 FI' + parseInt(i+1) + ' 入豆中')
  439. $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  440. $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 入豆中")
  441. } else if (ferment_input_status[i] == 'FI_Waiting') {
  442. console.log('[動作] 發酵入料 FI' + parseInt(i+1) + ' 空桶等待')
  443. $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  444. $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 空桶等待")
  445. } else if (ferment_input_status[i] == 'FI_OutputtingBean') {
  446. console.log('[動作] 發酵入料 FI' + parseInt(i+1) + ' 可出豆')
  447. $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  448. $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 可出豆")
  449. } else {
  450. console.log('pass')
  451. }
  452. }
  453. // ----- 發酵桶槽 F1~F6 狀態 --------------------------------------------------------------
  454. ferment_tank_status = [res.Ferment_Tank_1, res.Ferment_Tank_2, res.Ferment_Tank_3,
  455. res.Ferment_Tank_4, res.Ferment_Tank_5, res.Ferment_Tank_6]
  456. for (let i=0; i<ferment_tank_status.length; i++) {
  457. // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態
  458. // console.log(i+1 + ' : '+ ferment_tank_status[i])
  459. // 1 : F_InputtingBean
  460. // 2 : F_Waiting
  461. if (ferment_tank_status[i] == 'F_InputtingBean') {
  462. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入豆中')
  463. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  464. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 入豆中")
  465. } else if (ferment_tank_status[i] == 'F_InputtingBean_Pause') {
  466. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入豆暫停')
  467. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  468. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 入豆暫停")
  469. } else if (ferment_tank_status[i] == 'F_InputtingBean_Finish') {
  470. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入豆完成')
  471. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  472. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 入豆完成")
  473. } else if (ferment_tank_status[i] == 'F_InputtingWater') {
  474. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入水中')
  475. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  476. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 入水中")
  477. } else if (ferment_tank_status[i] == 'F_Waiting') {
  478. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 空桶等待')
  479. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  480. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 空桶等待")
  481. } else if (ferment_tank_status[i] == 'F_Fermenting') {
  482. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 發酵中')
  483. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  484. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 發酵中")
  485. } else if (ferment_tank_status_N[i] == 'F_Cleaning') {
  486. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 清洗中')
  487. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "plum")
  488. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 清洗中")
  489. } else if (ferment_tank_status[i] == 'F_OutputtingBean') {
  490. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 可出豆')
  491. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  492. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 可出豆")
  493. } else if (ferment_tank_status[i] == 'F_Warning') {
  494. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 發生錯誤')
  495. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "crimson")
  496. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 發生錯誤")
  497. $("#F"+parseInt(i+1)+"_status").css("color", "crimson")
  498. } else {
  499. console.log('pass')
  500. }
  501. }
  502. // ----- 發酵出料 FO1 狀態 --------------------------------------------------------------
  503. ferment_output_status = [res.Ferment_Output_1]
  504. for (let i=0; i<ferment_output_status.length; i++) {
  505. // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態
  506. // console.log(i+1 + ' : '+ ferment_output_status[i])
  507. // 1 : F_InputtingBean
  508. // 2 : F_Waiting
  509. if (ferment_output_status[i] == 'FO_InputtingBean') {
  510. console.log('[動作] 發酵出料 FO' + parseInt(i+1) + ' 入豆中')
  511. $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  512. $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 入豆中")
  513. } else if (ferment_output_status[i] == 'FO_Waiting') {
  514. console.log('[動作] 發酵出料 FO' + parseInt(i+1) + ' 空桶等待')
  515. $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  516. $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 空桶等待")
  517. } else if (ferment_output_status[i] == 'FO_OutputtingBean') {
  518. console.log('[動作] 發酵出料 FO' + parseInt(i+1) + ' 可出豆')
  519. $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  520. $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 可出豆")
  521. } else {
  522. console.log('pass')
  523. }
  524. }
  525. ferment_status_process = 0;
  526. }, 'json');
  527. };
  528. };
  529. function ferment_auto_status_stop(){
  530. clearInterval(ferment_status_interval);
  531. clearInterval(loadingF);
  532. console.log("------- 狀態自動化判斷 停止 -------")
  533. };
  534. </script>
  535. </div>
  536. <!-- 發酵貨櫃 狀態表格-->
  537. <table style="border: 3px lightsteelblue solid; margin-right: auto; margin-left: auto; text-align: center; margin-top: 5px;" cellpadding="5" border="1">
  538. <tr>
  539. <td>
  540. <!-- 脫皮機出料儲豆槽 PO11 -->
  541. <div id="PO1" tabindex="0" class="PO1_position" role="button" style="text-align: center;">
  542. <span id="PO1_status" class="F_status_css">PO1 status</span>
  543. <div id="PO1_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  544. </div>
  545. </td>
  546. <td style="border: lightsteelblue 1px solid;">
  547. <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">
  548. <tr>
  549. <td>
  550. <!-- 發酵槽入料儲豆槽 FI1 -->
  551. <div id="FI1" tabindex="0" class="FI1_position" role="button" style="text-align: center;">
  552. <span id="FI1_status" class="F_status_css">FI1 status</span>
  553. <div id="FI1_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  554. </div>
  555. </td>
  556. </tr>
  557. </table>
  558. </td>
  559. <td style="border: lightsteelblue 1px solid;">
  560. <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">
  561. <tr>
  562. <td>
  563. <!-- 發酵槽 F1 -->
  564. <div id="F1" tabindex="0" class="F1_position" role="button">
  565. <span id="F1_status" class="F_status_css">F1 status</span>
  566. <!-- F1 狀態點點-->
  567. <div id="F1_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  568. </div>
  569. </td>
  570. <td>
  571. <!-- 發酵槽 F2 -->
  572. <div id="F2" tabindex="0" class="F2_position" role="button">
  573. <span id="F2_status" class="F_status_css">F2 status</span>
  574. <div id="F2_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  575. </div>
  576. </td>
  577. <td>
  578. <!-- 發酵槽 F3 -->
  579. <div id="F3" tabindex="0" class="F3_position" role="button">
  580. <span id="F3_status" class="F_status_css">F3 status</span>
  581. <div id="F3_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  582. </div>
  583. </td>
  584. <td>
  585. <!-- 發酵槽 F4 -->
  586. <div id="F4" tabindex="0" class="F4_position" role="button">
  587. <span id="F4_status" class="F_status_css">F4 status</span>
  588. <div id="F4_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  589. </div>
  590. </td>
  591. <td>
  592. <!-- 發酵槽 F5 -->
  593. <div id="F5" tabindex="0" class="F5_position" role="button">
  594. <span id="F5_status" class="F_status_css">F5 status</span>
  595. <div id="F5_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  596. </div>
  597. </td>
  598. <td>
  599. <!-- 發酵槽 F6 -->
  600. <div id="F6" tabindex="0" class="F6_position" role="button">
  601. <span id="F6_status" class="F_status_css">F6 status</span>
  602. <div id="F6_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  603. </div>
  604. </td>
  605. </tr>
  606. </table>
  607. </td>
  608. <td style="border: lightsteelblue 1px solid;">
  609. <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">
  610. <tr>
  611. <td>
  612. <!-- 發酵槽出料儲豆槽 FO1 -->
  613. <div id="FO1" tabindex="0" class="FO1_position" role="button">
  614. <span id="FO1_status" class="F_status_css">FO1 status</span>
  615. <div id="FO1_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  616. </div>
  617. </td>
  618. </tr>
  619. </table>
  620. </td>
  621. </tr>
  622. <tr>
  623. <td>脫皮機儲豆槽</td>
  624. <td style="border: lightsteelblue 1px solid;">
  625. 入料儲豆槽
  626. </td>
  627. <td style="border: lightsteelblue 1px solid;">
  628. 發酵桶槽
  629. </td>
  630. <td style="border: lightsteelblue 1px solid;">
  631. 出料儲豆槽
  632. </td>
  633. </tr>
  634. <tr>
  635. <td>PO2</td>
  636. <td style="border: lightsteelblue 1px solid;">
  637. <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">
  638. <tr>
  639. <td>
  640. <!-- 發酵槽入料儲豆槽 FI2 -->
  641. <div id="FI2" tabindex="0" class="FI2_position" role="button">
  642. <span id="FI2_status" class="F_status_css">FI2 status</span>
  643. <div id="FI2_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  644. </div>
  645. </td>
  646. </tr>
  647. </table>
  648. </td>
  649. <td style="border: lightsteelblue 1px solid;">
  650. <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">
  651. <tr>
  652. <td>
  653. <!-- 發酵槽 F7 -->
  654. <div id="F7" tabindex="0" class="F7_position" role="button" style="vertical-align: bottom;">
  655. <span id="F7_status" class="F_status_css">F7 status</span>
  656. <div id="F7_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  657. </div>
  658. </td>
  659. <td>
  660. <!-- 發酵槽 F8 -->
  661. <div id="F8" tabindex="0" class="F8_position" role="button">
  662. <span id="F8_status" class="F_status_css">F8 status</span>
  663. <div id="F8_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  664. </div>
  665. </td>
  666. <td>
  667. <!-- 發酵槽 F9 -->
  668. <div id="F9" tabindex="0" class="F9_position" role="button">
  669. <span id="F9_status" class="F_status_css">F9 status</span>
  670. <div id="F9_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  671. </div>
  672. </td>
  673. <td>
  674. <!-- 發酵槽 F10 -->
  675. <div id="F10" tabindex="0" class="F10_position" role="button">
  676. <span id="F10_status" class="F_status_css">F10 status</span>
  677. <div id="F10_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  678. </div>
  679. </td>
  680. <td>
  681. <!-- 發酵槽 F11 -->
  682. <div id="F11" tabindex="0" class="F11_position" role="button">
  683. <span id="F11_status" class="F_status_css">F11 status</span>
  684. <div id="F11_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  685. </div>
  686. </td>
  687. <td>
  688. <!-- 發酵槽 F12 -->
  689. <div id="F12" tabindex="0" class="F12_position" role="button">
  690. <span id="F12_status" class="F_status_css">F12 status</span>
  691. <div id="F12_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  692. </div>
  693. </td>
  694. </tr>
  695. </table>
  696. </td>
  697. <td style="border: lightsteelblue 1px solid;">
  698. <table style="border: 0px plum solid; margin-right: auto; margin-left: auto; text-align: center;" cellpadding="5">
  699. <tr>
  700. <td>
  701. <!-- 發酵槽出料儲豆槽 FO2 -->
  702. <div id="FO2" tabindex="0" class="FO2_position" role="button">
  703. <span id="FO2_status" class="F_status_css">FO2 status</span>
  704. <div id="FO2_status_dot" style="width: 110px; height: 20px; background-color: black;"></div>
  705. </div>
  706. </td>
  707. </tr>
  708. </table>
  709. </td>
  710. </tr>
  711. </table>
  712. <!-- 發酵貨櫃 致動器狀態 感測器數值 -->
  713. <div style="text-align: center;">
  714. <table style="border: 3px lightsteelblue solid; margin-right: auto; margin-left: auto; text-align: center; margin-top: 5px;" cellpadding="5" border="1">
  715. <tr>
  716. <td>
  717. 入料<br>Vacuum
  718. </td>
  719. <td>
  720. 桶槽<br>
  721. Vacuum
  722. </td>
  723. <td>
  724. 入料<br>三通閥
  725. </td>
  726. <td>
  727. 蝴蝶閥
  728. </td>
  729. <td>
  730. 逆洗 pump<br>電磁閥
  731. </td>
  732. <td>
  733. 消毒<br>電磁閥
  734. </td>
  735. <td>
  736. 夾層入水<br>電磁閥
  737. </td>
  738. <td>
  739. 桶內入水<br>電磁閥
  740. </td>
  741. <td>
  742. 桶內排水<br>電磁閥
  743. </td>
  744. <td>
  745. 水質<br>pump
  746. </td>
  747. <td>
  748. 夾層浮選<br>三通閥
  749. </td>
  750. <td>
  751. 馬達
  752. </td>
  753. <td>
  754. 加熱器<br>1
  755. </td>
  756. <td>
  757. 加熱器<br>2
  758. </td>
  759. <td>
  760. 溫控開關
  761. </td>
  762. <td>
  763. 設定溫度
  764. </td>
  765. <td>
  766. 出料<br>Vacuum
  767. </td>
  768. </tr>
  769. <tr>
  770. <td>
  771. <span id="actuator_00">x</span>
  772. </td>
  773. <td>
  774. <span id="actuator_1">x</span>
  775. </td>
  776. <td>
  777. <span id="actuator_2">x</span>
  778. </td>
  779. <td>
  780. <span id="actuator_3">x</span>
  781. </td>
  782. <td>
  783. <span id="actuator_4">x</span>
  784. </td>
  785. <td>
  786. <span id="actuator_5">x</span>
  787. </td>
  788. <td>
  789. <span id="actuator_6">x</span>
  790. </td>
  791. <td>
  792. <span id="actuator_7">x</span>
  793. </td>
  794. <td>
  795. <span id="actuator_8">x</span>
  796. </td>
  797. <td>
  798. <span id="actuator_9">x</span>
  799. </td>
  800. <td>
  801. <span id="actuator_10">x</span>
  802. </td>
  803. <td>
  804. <span id="actuator_11">x</span>
  805. </td>
  806. <td>
  807. <span id="actuator_12">x</span>
  808. </td>
  809. <td>
  810. <span id="actuator_13">x</span>
  811. </td>
  812. <td>
  813. <span id="actuator_14">x</span>
  814. </td>
  815. <td>
  816. <span id="actuator_15">x</span>
  817. </td>
  818. <td>
  819. <span id="actuator_99">x</span>
  820. </td>
  821. </tr>
  822. </table>
  823. <table style="border: 3px lightsteelblue solid; margin-right: auto; margin-left: auto; text-align: center; margin-top: 5px;" cellpadding="5" border="1">
  824. <tr>
  825. <td>
  826. 入料<br>高度
  827. </td>
  828. <td>
  829. 高度
  830. </td>
  831. <td>
  832. 溫度
  833. </td>
  834. <td>
  835. 濕度
  836. </td>
  837. <td>
  838. 二氧化碳
  839. </td>
  840. <td>
  841. 大氣壓力
  842. </td>
  843. <td>
  844. pH
  845. </td>
  846. <td>
  847. ORP
  848. </td>
  849. <td>
  850. DO
  851. </td>
  852. <td>
  853. EC
  854. </td>
  855. <td>
  856. 水位計
  857. </td>
  858. <td>
  859. 出料<br>高度
  860. </td>
  861. </tr>
  862. <tr>
  863. <td>
  864. <span id="sensor_00">00</span>
  865. </td>
  866. <td>
  867. <span id="sensor_1">00</span>
  868. </td>
  869. <td>
  870. <span id="sensor_2">00</span>
  871. </td>
  872. <td>
  873. <span id="sensor_3">00</span>
  874. </td>
  875. <td>
  876. <span id="sensor_4">00</span>
  877. </td>
  878. <td>
  879. <span id="sensor_5">00</span>
  880. </td>
  881. <td>
  882. <span id="sensor_6">00</span>
  883. </td>
  884. <td>
  885. <span id="sensor_7">00</span>
  886. </td>
  887. <td>
  888. <span id="sensor_8">00</span>
  889. </td>
  890. <td>
  891. <span id="sensor_9">00</span>
  892. </td>
  893. <td>
  894. <span id="sensor_10">00</span>
  895. </td>
  896. <td>
  897. <span id="sensor_99">00</span>
  898. </td>
  899. </tr>
  900. </table>
  901. </div>
  902. <!-- 發酵貨櫃 參數設定-->
  903. <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">
  904. <tr>
  905. <td>
  906. 發酵自動化<br>
  907. 排程
  908. </td>
  909. <td>
  910. 入料儲豆槽<br>
  911. 參數設定
  912. </td>
  913. <td>
  914. 桶槽<br>
  915. 參數設定
  916. </td>
  917. <td>
  918. 出料儲豆槽<br>
  919. 參數設定
  920. </td>
  921. </tr>
  922. <tr>
  923. <td style="padding: 10px; text-align: left; vertical-align: text-top;">
  924. <label><input type="checkbox" id="cb_fermenting" checked>發酵</label><br>
  925. <label><input type="checkbox" id="cb_cleaning">清洗:發酵
  926. <input name="Ferment_auto_cleaning_Ftimes" class="input-text" type="text">次執行
  927. </label><br>
  928. <label><input type="checkbox" id="cb_calibratingEC">校正 EC:發酵
  929. <input name="Ferment_auto_calibratingEC_Ftimes" class="input-text" type="text">次執行
  930. </label><br>
  931. <label><input type="checkbox" id="cb_calibratingSTIR">校正攪拌棒:發酵
  932. <input name="Ferment_auto_calibratingSTIR_Ftimes" class="input-text" type="text">次執行
  933. </label>
  934. </td>
  935. <td style="padding: 10px; text-align: left; vertical-align: text-top;">
  936. 生豆高度
  937. <input name="Ferment_Input_bean_height" class="input-text" type="text" value="5">公分<br>
  938. 吸料時間
  939. <input name="Ferment_Input_vacuumON_time" class="input-text" type="text" value="5">秒<br>
  940. 放料時間
  941. <input name="Ferment_Input_vacuumOFF_time" class="input-text" type="text" value="10">秒<br>
  942. </td>
  943. <td style="padding: 10px; text-align: left; vertical-align: text-top;">
  944. 生豆高度
  945. <input name="Ferment_Tank_bean_height" class="input-text" type="text" value="5">公分<br>
  946. 吸料時間
  947. <input name="Ferment_Tank_vacuumON_time" class="input-text" type="text" value="5">秒<br>
  948. 放料時間
  949. <input name="Ferment_Tank_vacuumOFF_time" class="input-text" type="text" value="10">秒<br>
  950. 水位高度
  951. <input name="Ferment_Tank_water_height" class="input-text" type="text" value="8">公分<br>
  952. 馬達轉速
  953. <input name="Ferment_Tank_motor_rpm" class="input-text" type="text" value="15">rpm,
  954. 攪拌時間
  955. <input name="Ferment_Tank_motor_time" class="input-text" type="text" value="30">秒<br>
  956. <label><input type="checkbox" id="Ferment_cb_vacuum" class="input-checkbox">發酵時桶內抽真空?抽氣
  957. <input name="Ferment_cb_vacuum_time" class="input-text" type="text" value="30">秒</label><br>
  958. 發酵溫度
  959. <input name="Ferment_Tank_fermenting_temp" class="input-text" type="text" value="30">℃
  960. , 且持溫時間
  961. <input name="Ferment_Tank_fermenting_time" class="input-text" type="text" value="60">秒<br>
  962. 指定 pH
  963. <input name="Ferment_Tank_fermenting_pH" class="input-text" type="text" value="5">/
  964. <del>指定 DO
  965. <input name="Ferment_Tank_fermenting_DO" class="input-text" type="text" value="43">/
  966. 指定 ORP
  967. <input name="Ferment_Tank_fermenting_ORP" class="input-text" type="text" value="-0.5">/
  968. 指定 EC
  969. <input name="Ferment_Tank_fermenting_EC" class="input-text" type="text" value="300"><br></del>
  970. 廢水排放
  971. <input name="Ferment_Tank_WaterOut_time" class="input-text" type="text" value="60">秒, 消毒開啟
  972. <input name="Ferment_Tank_Disinfect_time" class="input-text" type="text" value="10">秒<br>
  973. </td>
  974. <td style="padding: 10px; text-align: left; vertical-align: text-top;">
  975. 生豆高度
  976. <input name="Ferment_Output_bean_height" class="input-text" type="text" value="5">公分<br>
  977. 吸料時間
  978. <input name="Ferment_Output_vacuumON_time" class="input-text" type="text" value="5">秒<br>
  979. 放料時間
  980. <input name="Ferment_Output_vacuumOFF_time" class="input-text" type="text" value="10">秒<br>
  981. </td>
  982. </tr>
  983. </table>
  984. <!-- 發酵貨櫃 測試按鈕-->
  985. <div style="text-align: center;">
  986. <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="ferment_auto_testing()">
  987. [測試] 發酵自動化_網頁控制</button>
  988. <script>
  989. // 入料儲豆槽 入豆狀態
  990. var BeanIn_FI_Process = 0;
  991. // 入豆狀態
  992. var BeanIn_F_Process = 0;
  993. // 入水狀態
  994. var WaterIn_F_Process = 0;
  995. // 發酵狀態
  996. var Fermenting_F_Process = 0;
  997. // 出料狀態
  998. var WaterBeanOut_F_Process = 0;
  999. // 出料儲豆槽 入豆狀態
  1000. var BeanIn_FO_Process = 0;
  1001. function ferment_auto_testing(){
  1002. var Ferment_Input_bean_height = parseFloat($("input[name=Ferment_Input_bean_height]").val());
  1003. var Ferment_Input_vacuumON_time = parseFloat($("input[name=Ferment_Input_vacuumON_time]").val());
  1004. var Ferment_Input_vacuumOFF_time = parseFloat($("input[name=Ferment_Input_vacuumOFF_time]").val());
  1005. var Ferment_Tank_bean_height = parseFloat($("input[name=Ferment_Tank_bean_height]").val());
  1006. var Ferment_Tank_vacuumON_time = parseFloat($("input[name=Ferment_Tank_vacuumON_time]").val());
  1007. var Ferment_Tank_vacuumOFF_time = parseFloat($("input[name=Ferment_Tank_vacuumOFF_time]").val());
  1008. var Ferment_Tank_water_height = parseFloat($("input[name=Ferment_Tank_water_height]").val());
  1009. var Ferment_Tank_fermenting_temp = parseFloat($("input[name=Ferment_Tank_fermenting_temp]").val());
  1010. var Ferment_Tank_fermenting_time = parseFloat($("input[name=Ferment_Tank_fermenting_time]").val());
  1011. var Ferment_Tank_fermenting_pH = parseFloat($("input[name=Ferment_Tank_fermenting_pH]").val());
  1012. var Ferment_Tank_fermenting_DO = parseFloat($("input[name=Ferment_Tank_fermenting_DO]").val());
  1013. var Ferment_Tank_fermenting_ORP = parseFloat($("input[name=Ferment_Tank_fermenting_ORP]").val());
  1014. var Ferment_Tank_fermenting_EC = parseFloat($("input[name=Ferment_Tank_fermenting_EC]").val());
  1015. var Ferment_Tank_motor_rpm = parseFloat($("input[name=Ferment_Tank_motor_rpm]").val());
  1016. var Ferment_Tank_motor_time = parseFloat($("input[name=Ferment_Tank_motor_time]").val());
  1017. var Ferment_Output_bean_height = parseFloat($("input[name=Ferment_Output_bean_height]").val());
  1018. var Ferment_Output_vacuumON_time = parseFloat($("input[name=Ferment_Output_vacuumON_time]").val());
  1019. var Ferment_Output_vacuumOFF_time = parseFloat($("input[name=Ferment_Output_vacuumOFF_time]").val());
  1020. var BeanIn_FI_interval = setInterval(BeanIn_FI, 5000);
  1021. function BeanIn_FI(){
  1022. if (BeanIn_FI_Process == 1) {
  1023. return; // 若還在處理就取消, 函式立即停止
  1024. }
  1025. // 取得桶內生豆高度, 若未達生豆高度則入豆
  1026. BeanIn_FI_Process = 1;
  1027. $.ajax({
  1028. async:false,
  1029. type:"GET",
  1030. url:"/ferment_input_UltraSonic_1",
  1031. dataType:'json',
  1032. success:function(response){
  1033. var present_FIBean_height = parseFloat(response.UltraSonic)
  1034. console.log("目前入料儲豆槽豆高: " + present_FIBean_height)
  1035. console.log("指定入料儲豆槽豆高: " + Ferment_Input_bean_height)
  1036. if ( present_FIBean_height >= Ferment_Input_bean_height ) {
  1037. clearInterval(BeanIn_FI_interval);
  1038. console.log("入料儲豆槽已達生豆高度!")
  1039. BeanIn_F_interval = setInterval(BeanIn_F, 5000);
  1040. } else {
  1041. // aaa inputVacuum_ON()
  1042. console.log("inputVacuum_ON")
  1043. var time = new Date();
  1044. while ((new Date() - time) < Ferment_Input_vacuumON_time * 1000) { };
  1045. // aaa inputVacuum_OFF()
  1046. console.log("inputVacuum_OFF")
  1047. var time = new Date();
  1048. while ((new Date() - time) < Ferment_Input_vacuumOFF_time * 1000) { };
  1049. }
  1050. BeanIn_FI_Process = 0;
  1051. },
  1052. error:function(thrownError){
  1053. console.log("Error: " + thrownError)
  1054. BeanIn_FI_Process = 0;
  1055. }
  1056. });
  1057. };
  1058. var BeanIn_F_interval;
  1059. function BeanIn_F(){
  1060. if (BeanIn_F_Process == 1) {
  1061. return; // 若還在處理就取消, 函式立即停止
  1062. }
  1063. // 取得桶內生豆高度, 若未達生豆高度則入豆
  1064. BeanIn_F_Process = 1;
  1065. $.ajax({
  1066. async:false,
  1067. type:"GET",
  1068. url:"/ferment_UltraSonic_1",
  1069. dataType:'json',
  1070. success:function(response){
  1071. var present_FBean_height = parseFloat(response.UltraSonic)
  1072. console.log("目前桶槽豆高: " + present_FBean_height)
  1073. console.log("指定桶槽豆高: " + Ferment_Tank_bean_height)
  1074. if ( present_FBean_height >= Ferment_Tank_bean_height ) {
  1075. clearInterval(BeanIn_F_interval);
  1076. console.log("桶槽豆高已達指定高度!")
  1077. console.log("指定水高: " + Ferment_Tank_water_height)
  1078. // 若桶內水還沒滿, 開啟桶內入水
  1079. $.get('/ferment_UltraSonic_1', '', function (res) {
  1080. if ( res.UltraSonic < Ferment_Tank_water_height ){
  1081. console.log('桶內開始入水')
  1082. // aaa tankSolenoidWaterIn_ON();
  1083. console.log('tankSolenoidWaterIn_ON')
  1084. console.log('請開啟水龍頭進水')
  1085. };
  1086. }, 'json');
  1087. // 若夾層水還沒滿, 開啟夾層入水
  1088. $.get('/ferment_WaterLevel_1', '', function (res) {
  1089. if ( res.WaterLevel != 1 ){
  1090. console.log('夾層開始入水')
  1091. // aaa outerSolenoidWater_ON();
  1092. console.log('tankSolenoidWaterIn_ON')
  1093. console.log('請開啟水龍頭進水')
  1094. };
  1095. }, 'json');
  1096. // 入水每五秒判斷
  1097. WaterIn_F_interval = setInterval(WaterIn_F, 5000);
  1098. } else {
  1099. // aaa tankVacuum_ON()
  1100. console.log("tankVacuum_ON")
  1101. var time = new Date();
  1102. while ((new Date() - time) < Ferment_Input_vacuumON_time * 1000) { };
  1103. // aaa tankVacuum_OFF()
  1104. console.log("tankVacuum_OFF")
  1105. var time = new Date();
  1106. while ((new Date() - time) < Ferment_Input_vacuumOFF_time * 1000) { };
  1107. }
  1108. BeanIn_F_Process = 0;
  1109. },
  1110. error:function(thrownError){
  1111. console.log("Error: " + thrownError)
  1112. BeanIn_F_Process = 0;
  1113. }
  1114. });
  1115. };
  1116. // 入豆排程
  1117. var Fermenting_F_interval
  1118. function WaterIn_F(){
  1119. if(WaterIn_F_Process == 1){
  1120. return; // 若還在處理就取消, 函式立即停止
  1121. }
  1122. // 取得桶內目前水位、取得夾層是否達水位計
  1123. WaterIn_F_Process = 1;
  1124. $.ajax({
  1125. async:false,
  1126. type:"GET",
  1127. url:"/ferment_WaterIn_" + tank_num,
  1128. dataType:"JSON",
  1129. success:function(response){
  1130. console.log("指定入水高度: " + Ferment_Tank_water_height)
  1131. var present_tank_water_height = parseInt(response.UltraSonic)
  1132. console.log("目前水位高度: " + present_tank_water_height)
  1133. var present_WaterLevel = response.WaterLevel
  1134. console.log("目前夾層水位計高度: " + present_WaterLevel)
  1135. if (present_WaterLevel == 1 && present_tank_water_height >= Ferment_Tank_water_height) {
  1136. clearInterval(WaterIn_F_interval);
  1137. console.log("入水完成!")
  1138. console.log("指定溫度: " + Ferment_Tank_fermenting_temp)
  1139. console.log("指定時間: " + Ferment_Tank_fermenting_time)
  1140. // aaa tankMotor_ON()
  1141. console.log("tankMotor_ON")
  1142. // 取得桶內溫度, 若低於指定溫度則開啟加熱器
  1143. $.get('/ferment_SHT11_' + tank_num, '', function(res){
  1144. if (res.SHT11_Temp < Ferment_Tank_fermenting_temp){
  1145. // aaa setTemp(Ferment_Tank_fermenting_temp, Ferment_Tank_fermenting_time)
  1146. console.log("setTemp(" + Ferment_Tank_fermenting_temp + ", " + Ferment_Tank_fermenting_time + ")")
  1147. }
  1148. });
  1149. // -- 發酵 --
  1150. console.log("進入發酵流程")
  1151. Fermenting_F_interval = setInterval(Fermenting_F, 5000);
  1152. }
  1153. else if (present_WaterLevel == 1) {
  1154. // aaa outerSolenoidWater_OFF()
  1155. console.log("outerSolenoidWater_OFF")
  1156. console.log("保溫夾層入水完成, 桶內加水中")
  1157. }
  1158. else if (present_tank_water_height > Ferment_Tank_water_height) {
  1159. // aaa tankSolenoidWaterIn_OFF()
  1160. console.log("tankSolenoidWaterIn_OFF")
  1161. console.log("桶內入水完成, 保溫夾層加水中")
  1162. }
  1163. WaterIn_F_Process = 0;
  1164. },
  1165. error:function(thrownError){
  1166. console.log("Error: " + thrownError)
  1167. WaterIn_F_Process = 0;
  1168. }
  1169. });
  1170. };
  1171. // 出水排豆排程
  1172. var WaterBeanOut_F_interval
  1173. function Fermenting_F(){
  1174. if (Fermenting_F_Process == 1) {
  1175. return;
  1176. }
  1177. // 取得現在溫度
  1178. Fermenting_F_Process = 1;
  1179. $.ajax({
  1180. async:false,
  1181. type:"GET",
  1182. url:"/ferment_SHT11_" + tank_num,
  1183. dataType:"json",
  1184. success:function(response){
  1185. var present_Temp = response.SHT11_Temp
  1186. console.log("現在溫度: " + present_Temp)
  1187. if (present_Temp >= Ferment_Tank_fermenting_temp) {
  1188. clearInterval(Fermenting_F_interval)
  1189. console.log("已達指定溫度!")
  1190. console.log("發酵 " + Ferment_Tank_fermenting_time + " 秒")
  1191. var time = new Date();
  1192. while ((new Date() - time) < Ferment_Tank_fermenting_time * 1000) { };
  1193. console.log("發酵完成, 準備出豆")
  1194. // aaa tankTempEnable_OFF()
  1195. console.log("tankTempEnable_OFF")
  1196. // aaa tankMotor_OFF()
  1197. console.log("tankMotor_OFF")
  1198. // aaa tankSolenoidWaterOut_ON()
  1199. console.log("tankSolenoidWaterOut_ON")
  1200. console.log("暫停 1 分鐘排放廢水")
  1201. var time = new Date();
  1202. while ((new Date() - time) < 60 * 1000) { };
  1203. // aaa tankSolenoidWaterOut_OFF()
  1204. console.log("tankSolenoidWaterOut_OFF")
  1205. WaterBeanOut_F_interval = setInterval(WaterBeanOut_F, 5000);
  1206. }
  1207. Fermenting_F_Process = 0;
  1208. },
  1209. error:function(thrownError){
  1210. console.log("Error: " + thrownError)
  1211. Fermenting_F_Process = 0;
  1212. }
  1213. });
  1214. };
  1215. function WaterBeanOut_F(){
  1216. // -- 出料 --
  1217. // 設定空桶高度
  1218. var testing_tank_empty_height_F = 3.0;
  1219. console.log("設定空桶高度: " + testing_tank_empty_height_F)
  1220. if (WaterBeanOut_F_Process == 1){
  1221. return;
  1222. }
  1223. // 取得桶內生豆高度
  1224. WaterBeanOut_F_Process = 1;
  1225. $.ajax({
  1226. async:false,
  1227. type:"GET",
  1228. url:"/ferment_UltraSonic_" + tank_num,
  1229. dataType:"json",
  1230. success:function(response){
  1231. var present_Bean_height = parseFloat(response.UltraSonic);
  1232. console.log("目前發酵豆高/水位: " + present_Bean_height)
  1233. if (present_Bean_height > testing_tank_empty_height_F) {
  1234. // aaa outputVacuum_ON()
  1235. console.log("outputVacuum_ON")
  1236. var time = new Date();
  1237. while ((new Date() - time) < Ferment_Output_vacuumON_time * 1000) { };
  1238. // aaa outputVacuum_OFF()
  1239. console.log("outputVacuum_OFF")
  1240. var time = new Date();
  1241. while ((new Date() - time) < Ferment_Output_vacuumOFF_time * 1000) { };
  1242. } else {
  1243. clearInterval(WaterBeanOut_F_interval);
  1244. console.log("發酵完成!槽內已無生豆")
  1245. }
  1246. WaterBeanOut_F_Process = 0;
  1247. },
  1248. error:function(thrownError){
  1249. console.log("Error: " + thrownError)
  1250. WaterBeanOut_F_Process = 0;
  1251. }
  1252. })
  1253. };
  1254. }
  1255. </script>
  1256. <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="ferment_auto()">
  1257. [測試] MQTT + 每 60 秒更新貨櫃狀態</button>
  1258. <script>
  1259. function ferment_auto(){
  1260. var Ferment_Input_bean_height = $("input[name=Ferment_Input_bean_height]").val();
  1261. var Ferment_Input_vacuumON_time = $("input[name=Ferment_Input_vacuumON_time]").val();
  1262. var Ferment_Input_vacuumOFF_time = $("input[name=Ferment_Input_vacuumOFF_time]").val();
  1263. var Ferment_Tank_bean_height = $("input[name=Ferment_Tank_bean_height]").val();
  1264. var Ferment_Tank_vacuumON_time = $("input[name=Ferment_Tank_vacuumON_time]").val();
  1265. var Ferment_Tank_vacuumOFF_time = $("input[name=Ferment_Tank_vacuumOFF_time]").val();
  1266. var Ferment_Tank_water_height = $("input[name=Ferment_Tank_water_height]").val();
  1267. var Ferment_Tank_fermenting_temp = $("input[name=Ferment_Tank_fermenting_temp]").val();
  1268. var Ferment_Tank_fermenting_time = $("input[name=Ferment_Tank_fermenting_time]").val();
  1269. var Ferment_Tank_fermenting_pH = $("input[name=Ferment_Tank_fermenting_pH]").val();
  1270. var Ferment_Tank_fermenting_DO = $("input[name=Ferment_Tank_fermenting_DO]").val();
  1271. var Ferment_Tank_fermenting_ORP = $("input[name=Ferment_Tank_fermenting_ORP]").val();
  1272. var Ferment_Tank_fermenting_EC = $("input[name=Ferment_Tank_fermenting_EC]").val();
  1273. var Ferment_Tank_motor_rpm = $("input[name=Ferment_Tank_motor_rpm]").val();
  1274. var Ferment_Tank_motor_time = $("input[name=Ferment_Tank_motor_time]").val();
  1275. var Ferment_Tank_Disinfect_time = $("input[name=Ferment_Tank_Disinfect_time]").val();
  1276. var Ferment_Output_bean_height = $("input[name=Ferment_Output_bean_height]").val();
  1277. var Ferment_Output_vacuumON_time = $("input[name=Ferment_Output_vacuumON_time]").val();
  1278. var Ferment_Output_vacuumOFF_time = $("input[name=Ferment_Output_vacuumOFF_time]").val();
  1279. var FermentAuto_fermenting = $('#cb_fermenting').prop('checked') // true false
  1280. var FermentAuto_cleaning = $('#cb_cleaning').prop('checked')
  1281. var FermentAuto_calibratingEC = $('#cb_calibratingEC').prop('checked')
  1282. var FermentAuto_calibratingSTIR = $('#cb_calibratingSTIR').prop('checked')
  1283. var Ferment_auto_cleaning_Ftimes = $("input[name=Ferment_auto_cleaning_Ftimes]").val();
  1284. var Ferment_auto_calibratingEC_Ftimes = $("input[name=Ferment_auto_calibratingEC_Ftimes]").val();
  1285. var Ferment_auto_calibratingSTIR_Ftimes = $("input[name=Ferment_auto_calibratingSTIR_Ftimes]").val();
  1286. if ( (!(/(^[1-9]\d*$)/.test(Ferment_auto_cleaning_Ftimes)) && FermentAuto_cleaning) ||
  1287. (!(/(^[1-9]\d*$)/.test(Ferment_auto_calibratingEC_Ftimes)) && FermentAuto_calibratingEC) ||
  1288. (!(/(^[1-9]\d*$)/.test(Ferment_auto_calibratingSTIR_Ftimes)) && FermentAuto_calibratingSTIR) ) {
  1289. alert('[發酵貨櫃] 次數只接受正整數, 請重新輸入')
  1290. return
  1291. } else {
  1292. // 若發酵排程被勾選則為 1, 否則為 0 (預設發酵排程會不斷執行)
  1293. if (FermentAuto_fermenting == true) { FermentAuto_fermenting = 1
  1294. } else { FermentAuto_fermenting = 0 }
  1295. // 若清洗排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)
  1296. if (FermentAuto_cleaning == true) { FermentAuto_cleaning = Ferment_auto_cleaning_Ftimes
  1297. } else { FermentAuto_cleaning = 0 }
  1298. // 若校正 EC 排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)
  1299. if (FermentAuto_calibratingEC == true) { FermentAuto_calibratingEC = Ferment_auto_calibratingEC_Ftimes
  1300. } else { FermentAuto_calibratingEC = 0 }
  1301. // 若校正攪拌棒排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)
  1302. if (FermentAuto_calibratingSTIR == true) { FermentAuto_calibratingSTIR = Ferment_auto_calibratingSTIR_Ftimes
  1303. } else { FermentAuto_calibratingSTIR = 0 }
  1304. }
  1305. var data = { 'command': 'Ferment_auto_parameter',
  1306. 'FermentAuto_fermenting': FermentAuto_fermenting,
  1307. 'FermentAuto_cleaning': FermentAuto_cleaning,
  1308. 'FermentAuto_calibratingEC': FermentAuto_calibratingEC,
  1309. 'FermentAuto_calibratingSTIR': FermentAuto_calibratingSTIR,
  1310. 'Ferment_Input_bean_height':Ferment_Input_bean_height,
  1311. 'Ferment_Input_vacuumON_time': Ferment_Input_vacuumON_time,
  1312. 'Ferment_Input_vacuumOFF_time': Ferment_Input_vacuumOFF_time,
  1313. 'Ferment_Tank_bean_height': Ferment_Tank_bean_height,
  1314. 'Ferment_Tank_vacuumON_time': Ferment_Tank_vacuumON_time,
  1315. 'Ferment_Tank_vacuumOFF_time': Ferment_Tank_vacuumOFF_time,
  1316. 'Ferment_Tank_water_height': Ferment_Tank_water_height,
  1317. 'Ferment_Tank_fermenting_temp': Ferment_Tank_fermenting_temp,
  1318. 'Ferment_Tank_fermenting_time': Ferment_Tank_fermenting_time,
  1319. 'Ferment_Tank_fermenting_pH': Ferment_Tank_fermenting_pH,
  1320. 'Ferment_Tank_fermenting_DO': Ferment_Tank_fermenting_DO,
  1321. 'Ferment_Tank_fermenting_ORP': Ferment_Tank_fermenting_ORP,
  1322. 'Ferment_Tank_fermenting_EC': Ferment_Tank_fermenting_EC,
  1323. 'Ferment_Tank_motor_rpm': Ferment_Tank_motor_rpm,
  1324. 'Ferment_Tank_motor_time': Ferment_Tank_motor_time,
  1325. 'Ferment_Output_bean_height': Ferment_Output_bean_height,
  1326. 'Ferment_Output_vacuumON_time': Ferment_Output_vacuumON_time,
  1327. 'Ferment_Output_vacuumOFF_time': Ferment_Output_vacuumOFF_time };
  1328. $.post('/mqtt/101', data, function (res) {
  1329. console.log('data: ', data)
  1330. console.log('res: ', res)
  1331. }, 'text')
  1332. var ferment_interval = setInterval(testing_F_auto, 30*1000)
  1333. }
  1334. </script>
  1335. <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="testing_F_auto()">
  1336. [測試] 發酵貨櫃狀態</button>
  1337. <script>
  1338. function test(){
  1339. var FermentAuto_fermenting = $('#cb_fermenting').prop('checked') // true false
  1340. var FermentAuto_cleaning = $('#cb_cleaning').prop('checked')
  1341. var FermentAuto_calibratingEC = $('#cb_calibratingEC').prop('checked')
  1342. var FermentAuto_calibratingSTIR = $('#cb_calibratingSTIR').prop('checked')
  1343. /*
  1344. if ($('#cb_fermenting').prop('checked')) {
  1345. console.log("發酵自動化:加入發酵排程");
  1346. }
  1347. if ($('#cb_cleaning').prop('checked')) {
  1348. console.log("發酵自動化:加入清洗排程");
  1349. }
  1350. if ($('#cb_calibratingEC').prop('checked')) {
  1351. console.log("發酵自動化:加入校正 EC 排程");
  1352. }
  1353. if ($('#cb_calibratingSTIR').prop('checked')) {
  1354. console.log("發酵自動化:加入校正攪拌棒排程");
  1355. }
  1356. */
  1357. Ferment_auto_cleaning_Ftimes = $("input[name=Ferment_auto_cleaning_Ftimes]").val();
  1358. console.log('Ferment_auto_cleaning_Ftimes: ' + Ferment_auto_cleaning_Ftimes)
  1359. if ( !(/(^[1-9]\d*$)/.test(Ferment_auto_cleaning_Ftimes)) ){
  1360. console.log('不可為小數')
  1361. }
  1362. console.log(FermentAuto_fermenting)
  1363. console.log(FermentAuto_cleaning)
  1364. console.log(FermentAuto_calibratingEC)
  1365. console.log(FermentAuto_calibratingSTIR)
  1366. };
  1367. function testing_F_auto(){
  1368. var FermentAuto_fermenting = $('#cb_fermenting').prop('checked') // true false
  1369. var FermentAuto_cleaning = $('#cb_cleaning').prop('checked')
  1370. var FermentAuto_calibratingEC = $('#cb_calibratingEC').prop('checked')
  1371. var FermentAuto_calibratingSTIR = $('#cb_calibratingSTIR').prop('checked')
  1372. var Ferment_auto_cleaning_Ftimes = $("input[name=Ferment_auto_cleaning_Ftimes]").val();
  1373. var Ferment_auto_calibratingEC_Ftimes = $("input[name=Ferment_auto_calibratingEC_Ftimes]").val();
  1374. var Ferment_auto_calibratingSTIR_Ftimes = $("input[name=Ferment_auto_calibratingSTIR_Ftimes]").val();
  1375. if ((!FermentAuto_fermenting) && (!FermentAuto_cleaning) && !FermentAuto_calibratingEC && !FermentAuto_calibratingSTIR) {
  1376. alert('[發酵貨櫃] 未勾選任何排程, 自動化結束')
  1377. return
  1378. } else if ( (!(/(^[1-9]\d*$)/.test(Ferment_auto_cleaning_Ftimes)) && FermentAuto_cleaning) ||
  1379. (!(/(^[1-9]\d*$)/.test(Ferment_auto_calibratingEC_Ftimes)) && FermentAuto_calibratingEC) ||
  1380. (!(/(^[1-9]\d*$)/.test(Ferment_auto_calibratingSTIR_Ftimes)) && FermentAuto_calibratingSTIR) ) {
  1381. alert('[發酵貨櫃] 次數只接受正整數, 請重新輸入')
  1382. return
  1383. } else {
  1384. // 若發酵排程被勾選則為 1, 否則為 0 (預設發酵排程會不斷執行)
  1385. if (FermentAuto_fermenting == true) { FermentAuto_fermenting = 1
  1386. } else { FermentAuto_fermenting = 0 }
  1387. // 若清洗排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)
  1388. if (FermentAuto_cleaning == true) { FermentAuto_cleaning = Ferment_auto_cleaning_Ftimes
  1389. } else { FermentAuto_cleaning = 0 }
  1390. // 若校正 EC 排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)
  1391. if (FermentAuto_calibratingEC == true) { FermentAuto_calibratingEC = Ferment_auto_calibratingEC_Ftimes
  1392. } else { FermentAuto_calibratingEC = 0 }
  1393. // 若校正攪拌棒排程被勾選則取得輸入框次數, 否則為 0 (勾選預設為 1)
  1394. if (FermentAuto_calibratingSTIR == true) { FermentAuto_calibratingSTIR = Ferment_auto_calibratingSTIR_Ftimes
  1395. } else { FermentAuto_calibratingSTIR = 0 }
  1396. }
  1397. var Ferment_Input_vacuumON_time = $("input[name=Ferment_Input_vacuumON_time]").val();
  1398. var Ferment_Input_vacuumOFF_time = $("input[name=Ferment_Input_vacuumOFF_time]").val();
  1399. var Ferment_Tank_bean_height = $("input[name=Ferment_Tank_bean_height]").val();
  1400. var Ferment_Tank_vacuumON_time = $("input[name=Ferment_Tank_vacuumON_time]").val();
  1401. var Ferment_Tank_vacuumOFF_time = $("input[name=Ferment_Tank_vacuumOFF_time]").val();
  1402. var Ferment_Tank_water_height = $("input[name=Ferment_Tank_water_height]").val();
  1403. var Ferment_Tank_fermenting_temp = $("input[name=Ferment_Tank_fermenting_temp]").val();
  1404. var Ferment_Tank_fermenting_time = $("input[name=Ferment_Tank_fermenting_time]").val();
  1405. var Ferment_Tank_fermenting_pH = $("input[name=Ferment_Tank_fermenting_pH]").val();
  1406. var Ferment_Tank_fermenting_DO = $("input[name=Ferment_Tank_fermenting_DO]").val();
  1407. var Ferment_Tank_fermenting_ORP = $("input[name=Ferment_Tank_fermenting_ORP]").val();
  1408. var Ferment_Tank_fermenting_EC = $("input[name=Ferment_Tank_fermenting_EC]").val();
  1409. var Ferment_Tank_motor_rpm = $("input[name=Ferment_Tank_motor_rpm]").val();
  1410. var Ferment_Tank_Disinfect_time = $("input[name=Ferment_Tank_Disinfect_time]").val();
  1411. var Ferment_Output_vacuumON_time = $("input[name=Ferment_Output_vacuumON_time]").val();
  1412. var Ferment_Output_vacuumOFF_time = $("input[name=Ferment_Output_vacuumOFF_time]").val();
  1413. var data = { 'command': 'Ferment_auto_parameter',
  1414. 'FermentAuto_fermenting': FermentAuto_fermenting,
  1415. 'FermentAuto_cleaning': FermentAuto_cleaning,
  1416. 'FermentAuto_calibratingEC': FermentAuto_calibratingEC,
  1417. 'FermentAuto_calibratingSTIR': FermentAuto_calibratingSTIR,
  1418. 'Ferment_Input_vacuumON_time': Ferment_Input_vacuumON_time,
  1419. 'Ferment_Input_vacuumOFF_time': Ferment_Input_vacuumOFF_time,
  1420. 'Ferment_Tank_bean_height': Ferment_Tank_bean_height,
  1421. 'Ferment_Tank_vacuumON_time': Ferment_Tank_vacuumON_time,
  1422. 'Ferment_Tank_vacuumOFF_time': Ferment_Tank_vacuumOFF_time,
  1423. 'Ferment_Tank_water_height': Ferment_Tank_water_height,
  1424. 'Ferment_Tank_fermenting_temp': Ferment_Tank_fermenting_temp,
  1425. 'Ferment_Tank_fermenting_time': Ferment_Tank_fermenting_time,
  1426. 'Ferment_Tank_fermenting_pH': Ferment_Tank_fermenting_pH,
  1427. 'Ferment_Tank_fermenting_DO': Ferment_Tank_fermenting_DO,
  1428. 'Ferment_Tank_fermenting_ORP': Ferment_Tank_fermenting_ORP,
  1429. 'Ferment_Tank_fermenting_EC': Ferment_Tank_fermenting_EC,
  1430. 'Ferment_Tank_motor_rpm': Ferment_Tank_motor_rpm,
  1431. 'Ferment_Output_vacuumON_time': Ferment_Output_vacuumON_time,
  1432. 'Ferment_Output_vacuumOFF_time': Ferment_Output_vacuumOFF_time };
  1433. $.get('/ferment_auto_status', data, function (res) {
  1434. console.log('FI1: ' + res.Ferment_Input_1)
  1435. console.log('F1: ' + res.Ferment_Tank_1)
  1436. console.log('F2: ' + res.Ferment_Tank_2)
  1437. console.log('F3: ' + res.Ferment_Tank_3)
  1438. console.log('F4: ' + res.Ferment_Tank_4)
  1439. console.log('F5: ' + res.Ferment_Tank_5)
  1440. console.log('F6: ' + res.Ferment_Tank_6)
  1441. console.log('FO1: ' + res.Ferment_Output_1)
  1442. // ----- 發酵出料 FO1 狀態 --------------------------------------------------------------
  1443. ferment_input_status = [res.Ferment_Input_1]
  1444. for (let i=0; i<ferment_input_status.length; i++) {
  1445. // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態
  1446. // console.log(i+1 + ' : '+ ferment_output_status[i])
  1447. // 1 : F_InputtingBean
  1448. // 2 : F_Waiting
  1449. if (ferment_input_status[i] == 'FI_InputtingBean') {
  1450. console.log('[動作] 發酵入料 FI' + parseInt(i+1) + ' 入豆中')
  1451. $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  1452. $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 入豆中")
  1453. } else if (ferment_input_status[i] == 'FI_Waiting') {
  1454. console.log('[動作] 發酵入料 FI' + parseInt(i+1) + ' 空桶等待')
  1455. $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  1456. $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 空桶等待")
  1457. } else if (ferment_input_status[i] == 'FI_OutputtingBean') {
  1458. console.log('[動作] 發酵入料 FI' + parseInt(i+1) + ' 可出豆')
  1459. $("#FI"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  1460. $("#FI"+parseInt(i+1)+"_status").text("FI" + parseInt(i+1) + " 可出豆")
  1461. } else {
  1462. console.log('pass')
  1463. }
  1464. }
  1465. // ----- 發酵桶槽 F1~F6 狀態 --------------------------------------------------------------
  1466. ferment_tank_status = [res.Ferment_Tank_1, res.Ferment_Tank_2, res.Ferment_Tank_3,
  1467. res.Ferment_Tank_4, res.Ferment_Tank_5, res.Ferment_Tank_6]
  1468. for (let i=0; i<ferment_tank_status.length; i++) {
  1469. // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態
  1470. // console.log(i+1 + ' : '+ ferment_tank_status[i])
  1471. // 1 : F_InputtingBean
  1472. // 2 : F_Waiting
  1473. if (ferment_tank_status[i] == 'F_InputtingBean') {
  1474. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入豆中')
  1475. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  1476. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 入豆中")
  1477. } else if (ferment_tank_status[i] == 'F_InputtingBean_Pause') {
  1478. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入豆暫停')
  1479. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  1480. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 入豆暫停")
  1481. } else if (ferment_tank_status[i] == 'F_InputtingBean_Finish') {
  1482. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入豆完成')
  1483. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  1484. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 入豆完成")
  1485. } else if (ferment_tank_status[i] == 'F_InputtingWater') {
  1486. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 入水中')
  1487. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  1488. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 入水中")
  1489. } else if (ferment_tank_status[i] == 'F_Waiting') {
  1490. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 空桶等待')
  1491. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  1492. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 空桶等待")
  1493. } else if (ferment_tank_status[i] == 'F_Fermenting') {
  1494. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 發酵中')
  1495. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  1496. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 發酵中")
  1497. } else if (ferment_tank_status_N[i] == 'F_Cleaning') {
  1498. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 清洗中')
  1499. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "plum")
  1500. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 清洗中")
  1501. } else if (ferment_tank_status[i] == 'F_OutputtingBean') {
  1502. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 可出豆')
  1503. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  1504. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 可出豆")
  1505. } else if (ferment_tank_status[i] == 'F_Warning') {
  1506. console.log('[動作] 發酵桶槽 F' + parseInt(i+1) + ' 發生錯誤')
  1507. $("#F"+parseInt(i+1)+"_status_dot").css("background-color", "crimson")
  1508. $("#F"+parseInt(i+1)+"_status").text("F" + parseInt(i+1) + " 發生錯誤")
  1509. $("#F"+parseInt(i+1)+"_status").css("color", "crimson")
  1510. } else {
  1511. console.log('pass')
  1512. }
  1513. }
  1514. // ----- 發酵出料 FO1 狀態 --------------------------------------------------------------
  1515. ferment_output_status = [res.Ferment_Output_1]
  1516. for (let i=0; i<ferment_output_status.length; i++) {
  1517. // 顯示對應發酵桶槽號碼 F1~F6 和目前狀態
  1518. // console.log(i+1 + ' : '+ ferment_output_status[i])
  1519. // 1 : F_InputtingBean
  1520. // 2 : F_Waiting
  1521. if (ferment_output_status[i] == 'FO_InputtingBean') {
  1522. console.log('[動作] 發酵出料 FO' + parseInt(i+1) + ' 入豆中')
  1523. $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  1524. $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 入豆中")
  1525. } else if (ferment_output_status[i] == 'FO_Waiting') {
  1526. console.log('[動作] 發酵出料 FO' + parseInt(i+1) + ' 空桶等待')
  1527. $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "lightgray")
  1528. $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 空桶等待")
  1529. } else if (ferment_output_status[i] == 'FO_OutputtingBean') {
  1530. console.log('[動作] 發酵出料 FO' + parseInt(i+1) + ' 可出豆')
  1531. $("#FO"+parseInt(i+1)+"_status_dot").css("background-color", "MediumSeaGreen")
  1532. $("#FO"+parseInt(i+1)+"_status").text("FO" + parseInt(i+1) + " 可出豆")
  1533. } else {
  1534. console.log('pass')
  1535. }
  1536. }
  1537. /*
  1538. console.log(res.Ferment_Input_2)
  1539. console.log(res.Ferment_Tank_7)
  1540. console.log(res.Ferment_Tank_8)
  1541. console.log(res.Ferment_Tank_9)
  1542. console.log(res.Ferment_Tank_10)
  1543. console.log(res.Ferment_Tank_11)
  1544. console.log(res.Ferment_Tank_12)
  1545. console.log(res.Ferment_Output_1)
  1546. console.log(res.Ferment_Output_2)
  1547. */
  1548. }, 'json');
  1549. // console.log("-- 自動化程式 end --")
  1550. }
  1551. </script>
  1552. </div>
  1553. <br>
  1554. <br>
  1555. </div>
  1556. <div id="coffee_footer">
  1557. <!-- 匯入共同使用的 footer.html 內容 -->
  1558. {% include 'footer.html' %}
  1559. </div>
  1560. </div>
  1561. </body>
  1562. </html>