ferment_container_tank_0924.html 123 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625
  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="300" /><!-- <meta http-equiv="refresh" content="5" /> 每 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. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  18. <script language="JavaScript">
  19. // 指定 秒 刷新網頁一次
  20. var ftn = '{{tid}}';
  21. var status = '{{status}}';
  22. $(function(){
  23. $("#coffee_title").text('F' + ftn + ' 發酵槽操作介面');
  24. if (status == 2) {
  25. $('input').prop('disabled', true);
  26. $('button').prop('disabled', true);
  27. } else if ( (status == 0) || (status == 1) ) {
  28. $('input').prop('disabled', false);
  29. $('button').prop('disabled', false);
  30. }
  31. });
  32. WebUpdate_set = setInterval(function(){WebUpdate(ftn)} , 60 * 1000)
  33. </script>
  34. <style>
  35. .footer{
  36. position: absolute;
  37. width: 100%;
  38. background-color: #eee;
  39. text-align: center;
  40. }
  41. body {
  42. margin: 0;
  43. }
  44. input[type="button"] {
  45. padding: 4px 15px;
  46. background: #f3f3f3;
  47. border: 0 none;
  48. cursor: pointer;
  49. -webkit-border-radius: 5px;
  50. border-radius: 5px;
  51. }
  52. .navbar-dark .navbar-nav .nav-link {
  53. color: white;
  54. cursor: pointer;
  55. text-decoration: none;
  56. width: 110px;
  57. height: 46px;
  58. }
  59. .nav-top {
  60. line-height: 40px;
  61. background-color: #C4C4C4;
  62. }
  63. .website_title {
  64. font-family: Roboto;
  65. font-style: normal;
  66. font-weight: normal;
  67. font-size: 30px;
  68. color: #000000;
  69. }
  70. .navbar-nav>li {
  71. float: none;
  72. display: inline-block;
  73. width: 100px;
  74. margin: 0 auto;
  75. text-align: center;
  76. }
  77. .navbar-nav>li a {
  78. font-size: 20px;
  79. }
  80. .main-page {
  81. margin-top: 200px;
  82. }
  83. .page-title {
  84. font-family: Roboto;
  85. font-style: normal;
  86. font-weight: bold;
  87. font-size: 36px;
  88. }
  89. .flex {
  90. display: flex;
  91. flex-direction: row;
  92. flex-wrap: wrap;
  93. justify-content: center;
  94. }
  95. .set-link {
  96. display: inline-block;
  97. width: 350px;
  98. height: 100px;
  99. line-height: 100px;
  100. background: #008CBA;
  101. border: 1px solid #CFCFCF;
  102. box-sizing: border-box;
  103. color: #FFFFFF;
  104. border-radius: 10px;
  105. font-size: 36px;
  106. }
  107. .cmn-toggle {
  108. position: absolute;
  109. margin-left: 0px;
  110. visibility: hidden;
  111. }
  112. .cmn-toggle+label {
  113. display: block;
  114. position: relative;
  115. cursor: pointer;
  116. outline: none;
  117. user-select: none;
  118. }
  119. input.cmn-toggle-round-flat+label {
  120. padding: 2px;
  121. width: 60px;
  122. height: 30px;
  123. background-color: #C0C0C0;
  124. border-radius: 60px;
  125. transition: background 0.4s;
  126. }
  127. input.cmn-toggle-round-flat+label:before,
  128. input.cmn-toggle-round-flat+label:after {
  129. display: block;
  130. position: absolute;
  131. content: "";
  132. }
  133. input.cmn-toggle-round-flat+label:before {
  134. top: 2px;
  135. left: 2px;
  136. bottom: 2px;
  137. right: 2px;
  138. background-color: #fff;
  139. border-radius: 60px;
  140. transition: background 0.4s;
  141. }
  142. input.cmn-toggle-round-flat+label:after {
  143. top: 4px;
  144. left: 4px;
  145. bottom: 4px;
  146. width: 24px;
  147. background-color: #dddddd;
  148. border-radius: 52px;
  149. transition: margin 0.4s, background 0.4s;
  150. }
  151. input.cmn-toggle-round-flat:checked+label {
  152. background-color: #C0C0C0;
  153. }
  154. input.cmn-toggle-round-flat:checked+label:after {
  155. margin-left: 27px;
  156. background-color: #008CBA;
  157. }
  158. @media(max-width:373px) {
  159. .card {
  160. margin-right: 0px;
  161. }
  162. .set-link {
  163. width: 250px;
  164. }
  165. }
  166. @media(max-width:577px) {}
  167. @media(min-width:576px) {}
  168. @media(min-width:768px) {
  169. .navbar-nav>li {
  170. margin-left: 0px;
  171. }
  172. .navbar-nav .li-block {
  173. display: none;
  174. }
  175. }
  176. @media(min-width:991px) {
  177. .navbar-nav>li {
  178. margin-left: 20px;
  179. }
  180. .navbar-nav .li-block {
  181. display: none;
  182. }
  183. }
  184. @media(min-width:1200px) {
  185. .navbar-nav>li {
  186. margin-left: 50px;
  187. }
  188. .navbar-nav .li-block {
  189. display: inline-block;
  190. width: 100px;
  191. }
  192. }
  193. @media(min-width:1400px) {
  194. .navbar-nav .li-block {
  195. display: inline-block;
  196. width: 200px;
  197. }
  198. }
  199. @media(min-width:1689px) {
  200. .navbar-nav>li {
  201. margin-left: 50px;
  202. }
  203. .navbar-nav .li-block {
  204. display: inline-block;
  205. width: 500px;
  206. }
  207. }
  208. </style>
  209. <script>
  210. // 發酵槽_制動器控制
  211. var tank_num = '{{tid}}';
  212. function tankVacuum() {
  213. var status = "off";
  214. var check = $("input[name=tank_vacuum_status]:checked");
  215. console.log('check:', check);
  216. //大於0代表有被選中
  217. if (check.length > 0) {
  218. status = "on";
  219. $("#cmn-toggle-05").prop('checked', false);
  220. if (!confirm("你確定要開啟真空吸料機嗎?")) {
  221. return false;
  222. };
  223. } else {
  224. $("#cmn-toggle-05").prop('checked', true);
  225. if (!confirm("你確定要關閉真空吸料機嗎?")) {
  226. return false;
  227. };
  228. };
  229. var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": status };
  230. $.post('/mqtt/{{tid}}', data, function (res) {
  231. console.log('data:', data)
  232. if (res == 'on') {
  233. $("#cmn-toggle-05").prop('checked', true);
  234. setTimeout("alert('真空吸料機_開啟成功!')", 500);
  235. } else if (res == 'off') {
  236. $("#cmn-toggle-05").prop('checked', false);
  237. setTimeout("alert('真空吸料機_關閉成功!')", 500);
  238. } else {
  239. alert(res);
  240. };
  241. }, 'text')
  242. };
  243. function tankVacuum_ON() {
  244. var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": "on" };
  245. $.post('/mqtt/{{tid}}', data, function (res) {
  246. console.log('data:', data)
  247. if (res == 'on') {
  248. $("#cmn-toggle-05").prop('checked', true);
  249. } else if (res == 'off') {
  250. $("#cmn-toggle-05").prop('checked', false);
  251. } else {
  252. console.log(res)
  253. };
  254. }, 'text')
  255. }
  256. function tankVacuum_OFF() {
  257. var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": "off" };
  258. $.post('/mqtt/{{tid}}', data, function (res) {
  259. console.log('data:', data)
  260. if (res == 'on') {
  261. $("#cmn-toggle-05").prop('checked', true);
  262. } else if (res == 'off') {
  263. $("#cmn-toggle-05").prop('checked', false);
  264. } else {
  265. console.log(res)
  266. };
  267. }, 'text')
  268. }
  269. // Benson 真空吸料機 (END)
  270. function tankThreeWayValveInput() {
  271. //<!--setInterval(Relay,10000);-->
  272. var status = "off";
  273. var check = $("input[name=tank_threewayvalve_input_status]:checked");
  274. //大於0代表有被選中
  275. if (check.length > 0) {
  276. status = "on";
  277. $("#cmn-toggle-08").prop('checked', false);
  278. if (!confirm("你確定要開啟入料三通閥嗎?")) {
  279. return false;
  280. };
  281. } else {
  282. $("#cmn-toggle-08").prop('checked', true);
  283. if (!confirm("你確定要關閉入料三通閥嗎?")) {
  284. return false;
  285. };
  286. };
  287. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": status };
  288. $.post('/mqtt/{{tid}}', data, function (res) {
  289. console.log('data:', data)
  290. if (res == 'on') {
  291. $("#cmn-toggle-08").prop('checked', true);
  292. setTimeout("alert('入料三通閥入料_開啟成功!')", 500);
  293. } else if (res == 'off') {
  294. $("#cmn-toggle-08").prop('checked', false);
  295. setTimeout("alert('入料三通閥排氣_關閉成功!')", 500);
  296. } else {
  297. alert(res);
  298. };
  299. }, 'text')
  300. }
  301. function tankThreeWayValveInput_ON() {
  302. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": "on" };
  303. $.post('/mqtt/{{tid}}', data, function (res) {
  304. console.log('data:', data)
  305. if (res == 'on') {
  306. $("#cmn-toggle-08").prop('checked', true);
  307. } else if (res == 'off') {
  308. $("#cmn-toggle-08").prop('checked', false);
  309. } else {
  310. console.log(res)
  311. };
  312. }, 'text')
  313. };
  314. function tankThreeWayValveInput_OFF() {
  315. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": "off" };
  316. $.post('/mqtt/{{tid}}', data, function (res) {
  317. console.log('data:', data)
  318. if (res == 'on') {
  319. $("#cmn-toggle-08").prop('checked', true);
  320. } else if (res == 'off') {
  321. $("#cmn-toggle-08").prop('checked', false);
  322. } else {
  323. console.log(res)
  324. };
  325. }, 'text')
  326. };
  327. // Benson cargo2_actuator.html 控制蝴蝶閥函數 (START)
  328. function tankDiskValve() {
  329. //<!--setInterval(Relay,10000);-->
  330. var status = "off";
  331. var check = $("input[name=tank_diskvalve_status]:checked");
  332. //大於0代表有被選中
  333. if (check.length > 0) {
  334. status = "on";
  335. $("#cmn-toggle-11").prop('checked', false);
  336. if (!confirm("你確定要開啟蝴蝶閥嗎?")) {
  337. return false;
  338. };
  339. } else {
  340. $("#cmn-toggle-11").prop('checked', true);
  341. if (!confirm("你確定要關閉蝴蝶閥嗎?")) {
  342. return false;
  343. };
  344. };
  345. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": status };
  346. $.post('/mqtt/{{tid}}', data, function (res) {
  347. console.log('data:', data)
  348. if (res == 'on') {
  349. $("#cmn-toggle-11").prop('checked', true);
  350. setTimeout("alert('蝴蝶閥_開啟成功!')", 500);
  351. } else if (res == 'off') {
  352. $("#cmn-toggle-11").prop('checked', false);
  353. setTimeout("alert('蝴蝶閥_關閉成功!')", 500);
  354. } else {
  355. alert(res);
  356. };
  357. }, 'text')
  358. };
  359. function tankDiskValve_ON() {
  360. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "on" };
  361. $.post('/mqtt/{{tid}}', data, function (res) {
  362. console.log('data:', data)
  363. if (res == 'on') {
  364. $("#cmn-toggle-11").prop('checked', true);
  365. } else if (res == 'off') {
  366. $("#cmn-toggle-11").prop('checked', false);
  367. } else {
  368. console.log(res)
  369. };
  370. }, 'text')
  371. };
  372. function tankDiskValve_OFF() {
  373. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "off" };
  374. $.post('/mqtt/{{tid}}', data, function (res) {
  375. console.log('data:', data)
  376. if (res == 'on') {
  377. $("#cmn-toggle-11").prop('checked', true);
  378. } else if (res == 'off') {
  379. $("#cmn-toggle-11").prop('checked', false);
  380. } else {
  381. console.log(res)
  382. };
  383. }, 'text')
  384. };
  385. // Benson cargo2_actuator.html 閥 (START) 電磁閥 總進水
  386. function tankSolenoidWaterTotal() {
  387. var status = "off";
  388. var check = $("input[name=tank_solenoid_water_total_status]:checked");
  389. //大於0代表有被選中
  390. if (check.length > 0) {
  391. status = "on";
  392. $("#cmn-toggle-14").prop('checked', false);
  393. if (!confirm("你確定要開啟總進水電磁閥嗎?")) {
  394. return false;
  395. };
  396. } else {
  397. $("#cmn-toggle-14").prop('checked', true);
  398. if (!confirm("你確定要關閉總進水電磁閥嗎?")) {
  399. return false;
  400. };
  401. };
  402. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_total_status", "value": status };
  403. $.post('/mqtt/{{tid}}', data, function (res) {
  404. console.log('data:', data)
  405. if (res == 'on') {
  406. $("#cmn-toggle-14").prop('checked', true);
  407. setTimeout("alert('總進水電磁閥_開啟成功!')", 500);
  408. } else if (res == 'off') {
  409. $("#cmn-toggle-14").prop('checked', false);
  410. setTimeout("alert('總進水電磁閥_關閉成功!')", 500);
  411. } else {
  412. alert(res);
  413. };
  414. }, 'text')
  415. };
  416. function tankSolenoidWaterTotal_ON() {
  417. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_total_status", "value": "on" };
  418. $.post('/mqtt/{{tid}}', data, function (res) {
  419. console.log('data:', data)
  420. if (res == 'on') {
  421. $("#cmn-toggle-14").prop('checked', true);
  422. } else if (res == 'off') {
  423. $("#cmn-toggle-14").prop('checked', false);
  424. } else {
  425. console.log(res)
  426. };
  427. }, 'text')
  428. };
  429. function tankSolenoidWaterTotal_OFF() {
  430. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_total_status", "value": "off" };
  431. $.post('/mqtt/{{tid}}', data, function (res) {
  432. console.log('data:', data)
  433. if (res == 'on') {
  434. $("#cmn-toggle-14").prop('checked', true);
  435. } else if (res == 'off') {
  436. $("#cmn-toggle-14").prop('checked', false);
  437. } else {
  438. console.log(res)
  439. };
  440. }, 'text')
  441. };
  442. // Benson cargo2_actuator.html 閥 (START) 電磁閥消毒打菌
  443. function tankSolenoidDisinfect() {
  444. var status = "off";
  445. var check = $("input[name=tank_solenoid_disinfect_status]:checked");
  446. //大於0代表有被選中
  447. if (check.length > 0) {
  448. status = "on";
  449. $("#cmn-toggle-17").prop('checked', false);
  450. if (!confirm("你確定要開啟消毒電磁閥嗎?")) {
  451. return false;
  452. };
  453. } else {
  454. $("#cmn-toggle-17").prop('checked', true);
  455. if (!confirm("你確定要關閉消毒電磁閥嗎?")) {
  456. return false;
  457. };
  458. };
  459. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": status };
  460. $.post('/mqtt/{{tid}}', data, function (res) {
  461. console.log('data:', data)
  462. if (res == 'on') {
  463. $("#cmn-toggle-17").prop('checked', true);
  464. setTimeout("alert('消毒電磁閥_開啟成功!')", 500);
  465. } else if (res == 'off') {
  466. $("#cmn-toggle-17").prop('checked', false);
  467. setTimeout("alert('消毒電磁閥_關閉成功!')", 500);
  468. } else {
  469. alert(res);
  470. };
  471. }, 'text')
  472. };
  473. function tankSolenoidDisinfect_ON() {
  474. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": "on" };
  475. $.post('/mqtt/{{tid}}', data, function (res) {
  476. console.log('data:', data)
  477. if (res == 'on') {
  478. $("#cmn-toggle-17").prop('checked', true);
  479. } else if (res == 'off') {
  480. $("#cmn-toggle-17").prop('checked', false);
  481. } else {
  482. console.log(res)
  483. };
  484. }, 'text')
  485. };
  486. function tankSolenoidDisinfect_OFF() {
  487. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": "off" };
  488. $.post('/mqtt/{{tid}}', data, function (res) {
  489. console.log('data:', data)
  490. if (res == 'on') {
  491. $("#cmn-toggle-17").prop('checked', true);
  492. } else if (res == 'off') {
  493. $("#cmn-toggle-17").prop('checked', false);
  494. } else {
  495. console.log(res)
  496. };
  497. }, 'text')
  498. };
  499. // 電磁閥 保溫夾層加水
  500. function outerSolenoidWater() {
  501. var status = "off";
  502. var check = $("input[name=outer_solenoid_water_status]:checked");
  503. //大於0代表有被選中
  504. if (check.length > 0) {
  505. status = "on";
  506. $("#cmn-toggle-38").prop('checked', false);
  507. if (!confirm("你確定要開啟\"保溫夾層\"進水電磁閥嗎?")) {
  508. return false;
  509. };
  510. } else {
  511. $("#cmn-toggle-38").prop('checked', true);
  512. if (!confirm("你確定要關閉\"保溫夾層\"進水電磁閥嗎?")) {
  513. return false;
  514. };
  515. };
  516. var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": status };
  517. $.post('/mqtt/{{tid}}', data, function (res) {
  518. console.log('data:', data)
  519. if (res == 'on') {
  520. $("#cmn-toggle-38").prop('checked', true);
  521. setTimeout("alert('\"保溫夾層\"進水電磁閥_開啟成功!')", 500);
  522. } else if (res == 'off') {
  523. $("#cmn-toggle-38").prop('checked', false);
  524. setTimeout("alert('\"保溫夾層\"進水電磁閥_關閉成功!')", 500);
  525. } else {
  526. alert(res);
  527. };
  528. }, 'text')
  529. };
  530. function outerSolenoidWater_ON() {
  531. var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": "on" };
  532. $.post('/mqtt/{{tid}}', data, function (res) {
  533. console.log('data:', data)
  534. if (res == 'on') {
  535. $("#cmn-toggle-38").prop('checked', true);
  536. } else if (res == 'off') {
  537. $("#cmn-toggle-38").prop('checked', false);
  538. } else {
  539. console.log(res)
  540. };
  541. }, 'text')
  542. };
  543. function outerSolenoidWater_OFF() {
  544. var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": "off" };
  545. $.post('/mqtt/{{tid}}', data, function (res) {
  546. console.log('data:', data)
  547. if (res == 'on') {
  548. $("#cmn-toggle-38").prop('checked', true);
  549. } else if (res == 'off') {
  550. $("#cmn-toggle-38").prop('checked', false);
  551. } else {
  552. console.log(res)
  553. };
  554. }, 'text')
  555. };
  556. // 電磁閥 桶內加水
  557. function tankSolenoidWaterIn() {
  558. var status = "off";
  559. var check = $("input[name=tank_solenoid_water_in_status]:checked");
  560. //大於0代表有被選中
  561. if (check.length > 0) {
  562. status = "on";
  563. $("#cmn-toggle-50").prop('checked', false);
  564. if (!confirm("你確定要開啟\"桶內\"進水電磁閥嗎?")) {
  565. return false;
  566. };
  567. } else {
  568. $("#cmn-toggle-50").prop('checked', true);
  569. if (!confirm("你確定要關閉\"桶內\"進水電磁閥嗎?")) {
  570. return false;
  571. };
  572. };
  573. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": status };
  574. $.post('/mqtt/{{tid}}', data, function (res) {
  575. console.log('data:', data)
  576. if (res == 'on') {
  577. $("#cmn-toggle-50").prop('checked', true);
  578. setTimeout("alert('\"桶內\"進水電磁閥_開啟成功!')", 500);
  579. } else if (res == 'off') {
  580. $("#cmn-toggle-50").prop('checked', false);
  581. setTimeout("alert('\"桶內\"進水電磁閥_關閉成功!')", 500);
  582. } else {
  583. alert(res);
  584. };
  585. }, 'text')
  586. };
  587. function tankSolenoidWaterIn_ON() {
  588. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": "on" };
  589. $.post('/mqtt/{{tid}}', data, function (res) {
  590. console.log('data:', data)
  591. if (res == 'on') {
  592. $("#cmn-toggle-50").prop('checked', true);
  593. } else if (res == 'off') {
  594. $("#cmn-toggle-50").prop('checked', false);
  595. } else {
  596. console.log(res)
  597. };
  598. }, 'text')
  599. };
  600. function tankSolenoidWaterIn_OFF() {
  601. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": "off" };
  602. $.post('/mqtt/{{tid}}', data, function (res) {
  603. console.log('data:', data)
  604. if (res == 'on') {
  605. $("#cmn-toggle-50").prop('checked', true);
  606. } else if (res == 'off') {
  607. $("#cmn-toggle-50").prop('checked', false);
  608. } else {
  609. console.log(res)
  610. };
  611. }, 'text')
  612. };
  613. // 感測器用 pump 雙核隔膜泵
  614. function tankPumpSensor() {
  615. var status = "off";
  616. var check = $("input[name=tank_pump_sensor_status]:checked");
  617. //大於0代表有被選中
  618. if (check.length > 0) {
  619. status = "on";
  620. $("#cmn-toggle-41").prop('checked', false);
  621. if (!confirm("你確定要開啟感測器用 pump 雙核隔膜泵嗎?")) {
  622. return false;
  623. };
  624. } else {
  625. $("#cmn-toggle-41").prop('checked', true);
  626. if (!confirm("你確定要關閉感測器用 pump 雙核隔膜泵嗎?")) {
  627. return false;
  628. };
  629. };
  630. var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": status };
  631. $.post('/mqtt/{{tid}}', data, function (res) {
  632. console.log('data:', data)
  633. if (res == 'on') {
  634. $("#cmn-toggle-41").prop('checked', true);
  635. setTimeout("alert('感測器用 pump _開啟成功!')", 500);
  636. } else if (res == 'off') {
  637. $("#cmn-toggle-41").prop('checked', false);
  638. setTimeout("alert('感測器用 pump _關閉成功!')", 500);
  639. } else {
  640. alert(res);
  641. };
  642. }, 'text')
  643. };
  644. function tankPumpSensor_ON() {
  645. var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": "on" };
  646. $.post('/mqtt/{{tid}}', data, function (res) {
  647. console.log('data:', data)
  648. if (res == 'on') {
  649. $("#cmn-toggle-41").prop('checked', true);
  650. } else if (res == 'off') {
  651. $("#cmn-toggle-41").prop('checked', false);
  652. } else {
  653. console.log(res)
  654. };
  655. }, 'text')
  656. }
  657. function tankPumpSensor_OFF() {
  658. var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": "off" };
  659. $.post('/mqtt/{{tid}}', data, function (res) {
  660. console.log('data:', data)
  661. if (res == 'on') {
  662. $("#cmn-toggle-41").prop('checked', true);
  663. } else if (res == 'off') {
  664. $("#cmn-toggle-41").prop('checked', false);
  665. } else {
  666. console.log(res)
  667. };
  668. }, 'text')
  669. }
  670. // 感測模組下豆三通閥
  671. function tankThreeWayValveBean() {
  672. var status = "off";
  673. var check = $("input[name=tank_threewayvalve_bean_status]:checked");
  674. //大於0代表有被選中
  675. if (check.length > 0) {
  676. status = "on";
  677. $("#cmn-toggle-44").prop('checked', false);
  678. if (!confirm("你確定要開啟感測模組下豆三通閥嗎?")) {
  679. return false;
  680. };
  681. } else {
  682. $("#cmn-toggle-44").prop('checked', true);
  683. if (!confirm("你確定要關閉感測模組下豆三通閥嗎?")) {
  684. return false;
  685. };
  686. };
  687. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_bean_status", "value": status };
  688. $.post('/mqtt/{{tid}}', data, function (res) {
  689. console.log('data:', data)
  690. if (res == 'on') {
  691. $("#cmn-toggle-44").prop('checked', true);
  692. setTimeout("alert('感測模組下豆三通閥_開啟成功!')", 500);
  693. } else if (res == 'off') {
  694. $("#cmn-toggle-44").prop('checked', false);
  695. setTimeout("alert('感測模組下豆三通閥_關閉成功!')", 500);
  696. } else {
  697. alert(res);
  698. };
  699. }, 'text')
  700. };
  701. function tankThreeWayValveBean_ON() {
  702. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_bean_status", "value": "on" };
  703. $.post('/mqtt/{{tid}}', data, function (res) {
  704. console.log('data:', data)
  705. if (res == 'on') {
  706. $("#cmn-toggle-44").prop('checked', true);
  707. } else if (res == 'off') {
  708. $("#cmn-toggle-44").prop('checked', false);
  709. } else {
  710. console.log(res)
  711. };
  712. }, 'text')
  713. };
  714. function tankThreeWayValveBean_OFF() {
  715. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_bean_status", "value": "off" };
  716. $.post('/mqtt/{{tid}}', data, function (res) {
  717. console.log('data:', data)
  718. if (res == 'on') {
  719. $("#cmn-toggle-44").prop('checked', true);
  720. } else if (res == 'off') {
  721. $("#cmn-toggle-44").prop('checked', false);
  722. } else {
  723. console.log(res)
  724. };
  725. }, 'text')
  726. };
  727. // 外桶浮選三通閥
  728. function outerThreeWayValveFloat() {
  729. var status = "off";
  730. var check = $("input[name=outer_threewayvalve_float_status]:checked");
  731. //大於0代表有被選中
  732. if (check.length > 0) {
  733. status = "on";
  734. $("#cmn-toggle-47").prop('checked', false);
  735. if (!confirm("你確定要開啟外桶浮選三通閥嗎?")) {
  736. return false;
  737. };
  738. } else {
  739. $("#cmn-toggle-47").prop('checked', true);
  740. if (!confirm("你確定要關閉外桶浮選三通閥嗎?")) {
  741. return false;
  742. };
  743. };
  744. var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": status };
  745. $.post('/mqtt/{{tid}}', data, function (res) {
  746. console.log('data:', data)
  747. if (res == 'on') {
  748. $("#cmn-toggle-47").prop('checked', true);
  749. setTimeout("alert('外桶浮選三通閥_開啟成功!')", 500);
  750. } else if (res == 'off') {
  751. $("#cmn-toggle-47").prop('checked', false);
  752. setTimeout("alert('外桶浮選三通閥_關閉成功!')", 500);
  753. } else {
  754. alert(res);
  755. };
  756. }, 'text')
  757. };
  758. function outerThreeWayValveFloat_ON() {
  759. var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": "on" };
  760. $.post('/mqtt/{{tid}}', data, function (res) {
  761. console.log('data:', data)
  762. if (res == 'on') {
  763. $("#cmn-toggle-47").prop('checked', true);
  764. } else if (res == 'off') {
  765. $("#cmn-toggle-47").prop('checked', false);
  766. } else {
  767. console.log(res)
  768. };
  769. }, 'text')
  770. };
  771. function outerThreeWayValveFloat_OFF() {
  772. var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": "off" };
  773. $.post('/mqtt/{{tid}}', data, function (res) {
  774. console.log('data:', data)
  775. if (res == 'on') {
  776. $("#cmn-toggle-47").prop('checked', true);
  777. } else if (res == 'off') {
  778. $("#cmn-toggle-47").prop('checked', false);
  779. } else {
  780. console.log(res)
  781. };
  782. }, 'text')
  783. };
  784. // Benson cargo2_actuator.html 脫皮機馬達 (START) 馬達攪拌棒
  785. function tankMotor() {
  786. var motor_data = $("input[id=motor_rpm_data]").val();
  787. if (motor_data == '') {
  788. //$("#cmn-toggle-20").prop('checked', false);
  789. alert("請先輸入要運轉的值!");
  790. return false;
  791. } else if (motor_data == 0) {
  792. alert("轉速 0 為關閉馬達");
  793. } else if (Number(motor_data) < -50 || Number(motor_data) > 50 || !Number(motor_data)) {
  794. //
  795. //$("#cmn-toggle-20").prop('checked', false);
  796. alert("您輸入的值已超過範圍,請重新輸入!" + !Number(motor_data));
  797. return false;
  798. };
  799. var value = "off";
  800. //var check = $("input[name=peeling-machine-on]:checked");
  801. if (motor_data != 0) {
  802. value = motor_data;
  803. //$("#cmn-toggle-20").prop('checked', false);
  804. if (!confirm("你確定要開啟攪拌馬達,運轉速度為 " + motor_data + " RPM 嗎?")) {
  805. return false;
  806. };
  807. } else {
  808. //$("#cmn-toggle-20").prop('checked', true);
  809. if (!confirm("你確定要關閉攪拌馬達嗎?")) {
  810. return false;
  811. };
  812. };
  813. var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": motor_data };
  814. $.post('/mqtt/{{tid}}', data, function (res) {
  815. console.log('data:', data)
  816. if (res == 'on') {
  817. //$("#cmn-toggle-14").prop('checked', true); // prop 設置元素屬型與元素值, 設定 checked 屬性為 true
  818. setTimeout("alert('攪拌馬達_開啟成功!')", 500); // 設定時間執行函式 delay(500), 只執行一次
  819. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  820. } else if (res == 'off') {
  821. //$("#cmn-toggle-14").prop('checked', false);
  822. setTimeout("alert('攪拌馬達_關閉成功!')", 500);
  823. clearInterval(timer); // 取消 timer 的不斷執行
  824. $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
  825. } else {
  826. alert(res);
  827. };
  828. }, 'text')
  829. };
  830. function tankMotor_ON() {
  831. var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": "10" };
  832. $.post('/mqtt/{{tid}}', data, function (res) {
  833. console.log('data:', data)
  834. if (res == 'on') {
  835. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  836. } else if (res == 'off') {
  837. clearInterval(timer); // 取消 timer 的不斷執行
  838. $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
  839. } else {
  840. console.log(res)
  841. };
  842. }, 'text')
  843. };
  844. function tankMotor_OFF() {
  845. var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": "0" };
  846. $.post('/mqtt/{{tid}}', data, function (res) {
  847. console.log('data:', data)
  848. if (res == 'on') {
  849. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  850. } else if (res == 'off') {
  851. clearInterval(timer); // 取消 timer 的不斷執行
  852. $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
  853. } else {
  854. console.log(res)
  855. };
  856. }, 'text')
  857. };
  858. function Rotate() {
  859. $.get('/peeling', '', function (res) {
  860. //console.log(res.peeling);
  861. $("#motor_rpm_status-status").text(res.peeling + ' rpm(每1分鐘更新一次)');
  862. }, 'json');
  863. };
  864. // Benson cargo2_actuator.html 鼓風機 (START)
  865. //電熱管1函數
  866. function tankHeater1() {
  867. var status = "off";
  868. var check = $("input[name=tank_heater1_status]:checked");
  869. //大於0代表有被選中
  870. if (check.length > 0) {
  871. status = "on";
  872. $("#cmn-toggle-26").prop('checked', false);
  873. if (!confirm("你確定要開啟電熱管1嗎?")) {
  874. return false;
  875. };
  876. } else {
  877. $("#cmn-toggle-26").prop('checked', true);
  878. if (!confirm("你確定要關閉電熱管1嗎?")) {
  879. return false;
  880. };
  881. };
  882. var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": status };
  883. $.post('/mqtt/{{tid}}', data, function (res) {
  884. console.log('data:', data)
  885. if (res == 'on') {
  886. $("#cmn-toggle-26").prop('checked', true);
  887. setTimeout("alert('電熱管1_開啟成功!')", 500);
  888. } else if (res == 'off') {
  889. $("#cmn-toggle-26").prop('checked', false);
  890. setTimeout("alert('電熱管1_關閉成功!')", 500);
  891. } else {
  892. alert(res);
  893. };
  894. }, 'text')
  895. };
  896. function tankHeater1_ON() {
  897. var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": "on" };
  898. $.post('/mqtt/{{tid}}', data, function (res) {
  899. console.log('data:', data)
  900. if (res == 'on') {
  901. $("#cmn-toggle-26").prop('checked', true);
  902. } else if (res == 'off') {
  903. $("#cmn-toggle-26").prop('checked', false);
  904. } else {
  905. console.log(res)
  906. };
  907. }, 'text')
  908. };
  909. function tankHeater1_OFF() {
  910. var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": "off" };
  911. $.post('/mqtt/{{tid}}', data, function (res) {
  912. console.log('data:', data)
  913. if (res == 'on') {
  914. $("#cmn-toggle-26").prop('checked', true);
  915. } else if (res == 'off') {
  916. $("#cmn-toggle-26").prop('checked', false);
  917. } else {
  918. console.log(res)
  919. };
  920. }, 'text')
  921. };
  922. //電熱管2函數
  923. function tankHeater2() {
  924. var status = "off";
  925. var check = $("input[name=tank_heater2_status]:checked");
  926. //大於0代表有被選中
  927. if (check.length > 0) {
  928. status = "on";
  929. $("#cmn-toggle-29").prop('checked', false);
  930. if (!confirm("你確定要開啟電熱管2嗎?")) {
  931. return false;
  932. };
  933. } else {
  934. $("#cmn-toggle-29").prop('checked', true);
  935. if (!confirm("你確定要關閉電熱管2嗎?")) {
  936. return false;
  937. };
  938. };
  939. var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": status };
  940. $.post('/mqtt/{{tid}}', data, function (res) {
  941. console.log('data:', data)
  942. if (res == 'on') {
  943. $("#cmn-toggle-29").prop('checked', true);
  944. setTimeout("alert('電熱管2_開啟成功!')", 500);
  945. } else if (res == 'off') {
  946. $("#cmn-toggle-29").prop('checked', false);
  947. setTimeout("alert('電熱管2_關閉成功!')", 500);
  948. } else {
  949. alert(res);
  950. };
  951. }, 'text')
  952. };
  953. function tankHeater2_ON() {
  954. var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": "on" };
  955. $.post('/mqtt/{{tid}}', data, function (res) {
  956. console.log('data:', data)
  957. if (res == 'on') {
  958. $("#cmn-toggle-29").prop('checked', true);
  959. } else if (res == 'off') {
  960. $("#cmn-toggle-29").prop('checked', false);
  961. } else {
  962. console.log(res)
  963. };
  964. }, 'text')
  965. };
  966. function tankHeater2_OFF() {
  967. var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": "off" };
  968. $.post('/mqtt/{{tid}}', data, function (res) {
  969. console.log('data:', data)
  970. if (res == 'on') {
  971. $("#cmn-toggle-29").prop('checked', true);
  972. } else if (res == 'off') {
  973. $("#cmn-toggle-29").prop('checked', false);
  974. } else {
  975. console.log(res)
  976. };
  977. }, 'text')
  978. };
  979. // 溫度控制
  980. function tankTempEnable() {
  981. var status = "off";
  982. var check = $("input[name=tank_temp_enable_status]:checked");
  983. //大於0代表有被選中
  984. if (check.length > 0) {
  985. status = "on";
  986. $("#cmn-toggle-35").prop('checked', false);
  987. if (!confirm("你確定要開啟溫度控制嗎?")) {
  988. return false;
  989. };
  990. } else {
  991. $("#cmn-toggle-35").prop('checked', true);
  992. if (!confirm("你確定要關閉溫度控制嗎?")) {
  993. return false;
  994. };
  995. };
  996. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": status };
  997. $.post('/mqtt/{{tid}}', data, function (res) {
  998. console.log('data:', data)
  999. if (res == 'on') {
  1000. $("#cmn-toggle-35").prop('checked', true);
  1001. setTimeout("alert('溫度控制_開啟成功!')", 500);
  1002. } else if (res == 'off') {
  1003. $("#cmn-toggle-35").prop('checked', false);
  1004. setTimeout("alert('溫度控制_關閉成功!')", 500);
  1005. } else {
  1006. alert(res);
  1007. };
  1008. }, 'text')
  1009. };
  1010. function tankTempEnable_ON() {
  1011. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": "on" };
  1012. $.post('/mqtt/{{tid}}', data, function (res) {
  1013. console.log('data:', data)
  1014. if (res == 'on') {
  1015. $("#cmn-toggle-35").prop('checked', true);
  1016. } else if (res == 'off') {
  1017. $("#cmn-toggle-35").prop('checked', false);
  1018. } else {
  1019. console.log(res)
  1020. };
  1021. }, 'text')
  1022. };
  1023. function tankTempEnable_OFF() {
  1024. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": "off" };
  1025. $.post('/mqtt/{{tid}}', data, function (res) {
  1026. console.log('data:', data)
  1027. if (res == 'on') {
  1028. $("#cmn-toggle-35").prop('checked', true);
  1029. } else if (res == 'off') {
  1030. $("#cmn-toggle-35").prop('checked', false);
  1031. } else {
  1032. console.log(res)
  1033. };
  1034. }, 'text')
  1035. };
  1036. // 判斷是否整數
  1037. function isInteger(obj) {
  1038. return obj % 1 === 0
  1039. }
  1040. isInteger(3) // true
  1041. // 設定溫度
  1042. function tankTemp() {
  1043. var temp_data = $("input[id=tank_temp_data]").val();
  1044. if (temp_data == '') {
  1045. //$("#cmn-toggle-20").prop('checked', false);
  1046. alert("請先輸入設定溫度!");
  1047. return false;
  1048. } else if (!isInteger(temp_data)) {
  1049. //$("#cmn-toggle-20").prop('checked', false);
  1050. alert("溫度設定僅限整數,請重新輸入!" + !Number(temp_data));
  1051. return false;
  1052. };
  1053. var value = "0";
  1054. //var check = $("input[name=peeling-machine-on]:checked");
  1055. if ($("#cmn-toggle-35").prop('checked')) {
  1056. value = temp_data;
  1057. //$("#cmn-toggle-20").prop('checked', false);
  1058. if (!confirm("你確定要設定內桶溫度為 " + temp_data + " ℃ 嗎?")) {
  1059. return false;
  1060. };
  1061. } else {
  1062. //$("#cmn-toggle-20").prop('checked', true);
  1063. //你確定要停止桶內溫度設定嗎
  1064. if (!confirm("請先開啟溫控開關, 再設定桶內溫度")) {
  1065. return false;
  1066. };
  1067. };
  1068. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": temp_data };
  1069. $.post('/mqtt/{{tid}}', data, function (res) {
  1070. console.log('data:', data)
  1071. if (res == 'on') {
  1072. //$("#cmn-toggle-14").prop('checked', true); // prop 設置元素屬型與元素值, 設定 checked 屬性為 true
  1073. setTimeout("alert('溫度設定_開啟成功!')", 500); // 設定時間執行函式 delay(500), 只執行一次
  1074. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  1075. } else if (res == 'off') {
  1076. //$("#cmn-toggle-14").prop('checked', false);
  1077. setTimeout("alert('溫度設定_關閉成功!')", 500);
  1078. clearInterval(timer); // 取消 timer 的不斷執行
  1079. $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
  1080. } else {
  1081. alert(res);
  1082. };
  1083. }, 'text')
  1084. };
  1085. function tankTemp_ON() {
  1086. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": "40" };
  1087. $.post('/mqtt/{{tid}}', data, function (res) {
  1088. console.log('data:', data)
  1089. if (res == 'on') {
  1090. } else if (res == 'off') {
  1091. } else {
  1092. console.log(res)
  1093. };
  1094. }, 'text')
  1095. };
  1096. function tankTemp_OFF() {
  1097. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": "0" };
  1098. $.post('/mqtt/{{tid}}', data, function (res) {
  1099. console.log('data:', data)
  1100. if (res == 'on') {
  1101. } else if (res == 'off') {
  1102. } else {
  1103. console.log(res)
  1104. };
  1105. }, 'text')
  1106. };
  1107. // Benson 真空吸料機 (START) 出料儲豆槽
  1108. function outputVacuum() {
  1109. var status = "off";
  1110. var check = $("input[name=output_vacuum_status]:checked");
  1111. //大於0代表有被選中
  1112. if (check.length > 0) {
  1113. status = "on";
  1114. $("#cmn-toggle-32").prop('checked', false);
  1115. if (!confirm("你確定要開啟出料儲豆槽真空吸料機嗎?")) {
  1116. return false;
  1117. };
  1118. } else {
  1119. $("#cmn-toggle-32").prop('checked', true);
  1120. if (!confirm("你確定要關閉出料儲豆槽真空吸料機嗎?")) {
  1121. return false;
  1122. };
  1123. };
  1124. var data = { "tank_num": "F" + tank_num, "command": "output_vacuum_status", "value": status };
  1125. console.log('data:', data)
  1126. $.post('/mqtt/{{tid}}', data, function (res) {
  1127. if (res == 'on') {
  1128. $("#cmn-toggle-32").prop('checked', true);
  1129. setTimeout("alert('出料儲豆槽真空吸料機_開啟成功!')", 500);
  1130. } else if (res == 'off') {
  1131. $("#cmn-toggle-32").prop('checked', false);
  1132. setTimeout("alert('出料儲豆槽真空吸料機_關閉成功!')", 500);
  1133. } else {
  1134. alert(res);
  1135. };
  1136. }, 'text')
  1137. };
  1138. function outputVacuum_ON() {
  1139. var data = { "tank_num": "F" + tank_num, "command": "output_vacuum_status", "value": "on" };
  1140. console.log('data:', data)
  1141. $.post('/mqtt/{{tid}}', data, function (res) {
  1142. if (res == 'on') {
  1143. $("#cmn-toggle-32").prop('checked', true);
  1144. } else if (res == 'off') {
  1145. $("#cmn-toggle-32").prop('checked', false);
  1146. } else {
  1147. console.log(res)
  1148. };
  1149. }, 'text')
  1150. };
  1151. function outputVacuum_OFF() {
  1152. var data = { "tank_num": "F" + tank_num, "command": "output_vacuum_status", "value": "off" };
  1153. console.log('data:', data)
  1154. $.post('/mqtt/{{tid}}', data, function (res) {
  1155. if (res == 'on') {
  1156. $("#cmn-toggle-32").prop('checked', true);
  1157. } else if (res == 'off') {
  1158. $("#cmn-toggle-32").prop('checked', false);
  1159. } else {
  1160. console.log(res)
  1161. };
  1162. }, 'text')
  1163. };
  1164. </script>
  1165. </head>
  1166. <body>
  1167. <div id="wrapper">
  1168. <div id="coffee_header">
  1169. <!-- 匯入共同使用的 header.html 內容 -->
  1170. {% include 'header.html' %}
  1171. </div>
  1172. 狀態更新時間(秒)
  1173. <input name="webupdate_time" type="text" value="60" style="width:100px;">
  1174. <input type="button" value="設定更新時間" onclick="changeUpdate()">
  1175. <script language="JavaScript">
  1176. function changeUpdate() {
  1177. clearInterval(WebUpdate_set);
  1178. var webupdate_time = $("input[name=webupdate_time]").val()
  1179. console.log('webupdate_time' + webupdate_time)
  1180. WebUpdate_set = setInterval(function(){WebUpdate(ftn)} , webupdate_time * 1000);
  1181. }
  1182. // jQuery 更新感測器制動器狀態
  1183. function WebUpdate(ftn) {
  1184. $.get('/loading/F' + ftn, '', function (res) {
  1185. if (res.tank_vacuum == 0) {
  1186. $("#cmn-toggle-05").prop('checked', false);
  1187. } else if (res.tank_vacuum == 1) {
  1188. $("#cmn-toggle-05").prop('checked', true);}
  1189. if (res.tank_threewayvalve_input == 0) {
  1190. $("#cmn-toggle-08").prop('checked', false);
  1191. } else if (res.tank_threewayvalve_input == 1) {
  1192. $("#cmn-toggle-08").prop('checked', true);}
  1193. if (res.tank_diskvalve == 0) {
  1194. $("#cmn-toggle-11").prop('checked', false);
  1195. } else if (res.tank_diskvalve == 1) {
  1196. $("#cmn-toggle-11").prop('checked', true);}
  1197. if (res.tank_solenoid_water_total == 0) {
  1198. $("#cmn-toggle-14").prop('checked', false);
  1199. } else if (res.tank_solenoid_water_total == 1) {
  1200. $("#cmn-toggle-14").prop('checked', true);}
  1201. if (res.tank_solenoid_disinfect == 0) {
  1202. $("#cmn-toggle-17").prop('checked', false);
  1203. } else if (res.tank_solenoid_disinfect == 1) {
  1204. $("#cmn-toggle-17").prop('checked', true);}
  1205. if (res.outer_solenoid_water == 0) {
  1206. $("#cmn-toggle-38").prop('checked', false);
  1207. } else if (res.outer_solenoid_water == 1) {
  1208. $("#cmn-toggle-38").prop('checked', true);}
  1209. if (res.tank_solenoid_water_in == 0) {
  1210. $("#cmn-toggle-50").prop('checked', false);
  1211. } else if (res.tank_solenoid_water_in == 1) {
  1212. $("#cmn-toggle-50").prop('checked', true);}
  1213. if (res.tank_pump_sensor == 0) {
  1214. $("#cmn-toggle-41").prop('checked', false);
  1215. } else if (res.tank_pump_sensor == 1) {
  1216. $("#cmn-toggle-41").prop('checked', true);}
  1217. if (res.tank_threewayvalve_bean == 0) {
  1218. $("#cmn-toggle-44").prop('checked', false);
  1219. } else if (res.tank_threewayvalve_bean == 1) {
  1220. $("#cmn-toggle-44").prop('checked', true);}
  1221. if (res.outer_threewayvalve_float == 0) {
  1222. $("#cmn-toggle-47").prop('checked', false);
  1223. } else if (res.outer_threewayvalve_float == 1) {
  1224. $("#cmn-toggle-47").prop('checked', true);}
  1225. if (res.tank_heater1 == 0) {
  1226. $("#cmn-toggle-26").prop('checked', false);
  1227. } else if (res.tank_heater1 == 1) {
  1228. $("#cmn-toggle-26").prop('checked', true);}
  1229. if (res.tank_heater2 == 0) {
  1230. $("#cmn-toggle-29").prop('checked', false);
  1231. } else if (res.tank_heater2 == 1) {
  1232. $("#cmn-toggle-29").prop('checked', true);}
  1233. if (res.tank_temp_enable == 0) {
  1234. $("#cmn-toggle-35").prop('checked', false);
  1235. } else if (res.tank_temp_enable == 1) {
  1236. $("#cmn-toggle-35").prop('checked', true);}
  1237. $("#motor_rpm_data").attr("placeholder", res.tank_motor);
  1238. $("#tank_temp_data").attr("placeholder", res.tank_temp);
  1239. $("#SHT11_Temp_t_status").text(res.SHT11_Temp);
  1240. $("#SHT11_Humidity_t_status").text(res.SHT11_Humidity);
  1241. $("#CO2_t_status").text(res.CO2);
  1242. $("#PH_t_status").text(res.PH);
  1243. $("#ORP_t_status").text(res.ORP);
  1244. $("#DO_t_status").text(res.DO);
  1245. $("#EC_t_status").text(res.EC);
  1246. $("#PA_t_status").text(res.PA);
  1247. if (res.WaterLevel == '1') {
  1248. $("#WaterLevel_t_status").text('滿');
  1249. } else if (res.WaterLevel == '0') {
  1250. $("#WaterLevel_t_status").text('可注水');
  1251. } else {
  1252. $("#WaterLevel_t_status").text('ERROR');
  1253. }
  1254. $("[name = LiDAR_t_status]").text(res.LiDAR);
  1255. $("[name = PressureWaterLevel_t_status]").text(res.PressureWaterLevel);
  1256. if (res.WaterLevel == '1' && res.outer_solenoid_water == '1'){
  1257. outerSolenoidWater_OFF();
  1258. console.log('保溫夾層注水 OFF')
  1259. };
  1260. }, 'json');
  1261. }
  1262. </script>
  1263. <h4>制動器</h4>
  1264. <table border="1" style="font-size:18px; border:2px #cccccc solid; margin-left: 2px; margin-right: 2px;" width=98%>
  1265. <tr>
  1266. <td style="color:red;">Valve</td>
  1267. <td>桶內<br>真空吸料機</td>
  1268. <td>入料三通閥</td>
  1269. <td>總進水<br>電磁閥</td>
  1270. <td>桶內消毒<br>電磁閥</td>
  1271. <td>保溫夾層進水<br>電磁閥</td>
  1272. <td>桶內進水<br>電磁閥</td>
  1273. <td>感測器<br>雙核隔膜泵</td>
  1274. <td>感測模組<br>下豆三通閥</td>
  1275. <td>外桶浮選<br>三通閥</td>
  1276. <td>馬達</td>
  1277. <td>加熱器 1</td>
  1278. <td>加熱器 2</td>
  1279. <td>溫控開關</td>
  1280. <td>溫度設定</td>
  1281. <td>蝴蝶閥</td>
  1282. </tr>
  1283. <tr>
  1284. <td>
  1285. <span style="color:#C0C0C0;">off</span>
  1286. <span style="color:#008CBA;">on</span>
  1287. </td>
  1288. <td>
  1289. <div class="switch_div">
  1290. <div class="switch">
  1291. <input id="cmn-toggle-04" class="cmn-toggle cmn-toggle-round" type="checkbox">
  1292. <label for="cmn-toggle-04"></label>
  1293. </div>
  1294. <div class="switch text-center">
  1295. {% if tank_vacuum=='ON' %}
  1296. <input id="cmn-toggle-05" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  1297. name="tank_vacuum_status" value="ON" onclick="tankVacuum()">
  1298. {% else %}
  1299. <input id="cmn-toggle-05" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1300. name="tank_vacuum_status" value="OFF" onclick="tankVacuum()">
  1301. {% endif %}
  1302. <label for="cmn-toggle-05"></label>
  1303. </div>
  1304. <div class="switch">
  1305. <input id="cmn-toggle-06" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  1306. <label for="cmn-toggle-06" data-on="Yes" data-off="No"></label>
  1307. </div>
  1308. </div>
  1309. </td>
  1310. <td>
  1311. <div class="switch_div">
  1312. <div class="switch">
  1313. <input id="cmn-toggle-07" class="cmn-toggle cmn-toggle-round" type="checkbox">
  1314. <label for="cmn-toggle-07"></label>
  1315. </div>
  1316. <div class="switch text-center">
  1317. {% if tank_threewayvalve_input=='ON' %}
  1318. <input id="cmn-toggle-08" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  1319. name="tank_threewayvalve_input_status" value="ON" onclick="tankThreeWayValveInput()">
  1320. {% else %}
  1321. <input id="cmn-toggle-08" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1322. name="tank_threewayvalve_input_status" value="OFF" onclick="tankThreeWayValveInput()">
  1323. {% endif %}
  1324. <label for="cmn-toggle-08"></label>
  1325. </div>
  1326. <div class="switch">
  1327. <input id="cmn-toggle-09" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  1328. <label for="cmn-toggle-09" data-on="Yes" data-off="No"></label>
  1329. </div>
  1330. </div>
  1331. </td>
  1332. <td>
  1333. <div class="switch_div">
  1334. <div class="switch">
  1335. <input id="cmn-toggle-13" class="cmn-toggle cmn-toggle-round" type="checkbox">
  1336. <label for="cmn-toggle-13"></label>
  1337. </div>
  1338. <div class="switch text-center">
  1339. {% if tank_solenoid_water_total=='ON' %}
  1340. <input id="cmn-toggle-14" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  1341. name="tank_solenoid_water_total_status" value="ON" onclick="tankSolenoidWaterTotal()">
  1342. {% else %}
  1343. <input id="cmn-toggle-14" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1344. name="tank_solenoid_water_total_status" value="OFF" onclick="tankSolenoidWaterTotal()">
  1345. {% endif %}
  1346. <label for="cmn-toggle-14"></label>
  1347. </div>
  1348. <div class="switch">
  1349. <input id="cmn-toggle-15" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  1350. <label for="cmn-toggle-15" data-on="Yes" data-off="No"></label>
  1351. </div>
  1352. </div>
  1353. </td>
  1354. <td>
  1355. <div class="switch_div">
  1356. <div class="switch">
  1357. <input id="cmn-toggle-16" class="cmn-toggle cmn-toggle-round" type="checkbox">
  1358. <label for="cmn-toggle-16"></label>
  1359. </div>
  1360. <div class="switch text-center">
  1361. {% if tank_solenoid_disinfect=='ON' %}
  1362. <input id="cmn-toggle-17" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox"
  1363. name="tank_solenoid_disinfect_status" value="ON" onclick="tankSolenoidDisinfect()">
  1364. {% else %}
  1365. <input id="cmn-toggle-17" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1366. name="tank_solenoid_disinfect_status" value="OFF" onclick="tankSolenoidDisinfect()">
  1367. {% endif %}
  1368. <label for="cmn-toggle-17"></label>
  1369. </div>
  1370. <div class="switch">
  1371. <input id="cmn-toggle-18" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  1372. <label for="cmn-toggle-18" data-on="Yes" data-off="No"></label>
  1373. </div>
  1374. </div>
  1375. </td>
  1376. <td>
  1377. <div class="switch_div">
  1378. <div class="switch">
  1379. <input id="cmn-toggle-37" class="cmn-toggle cmn-toggle-round" type="checkbox">
  1380. <label for="cmn-toggle-37"></label>
  1381. </div>
  1382. <div class="switch text-center">
  1383. {% if outer_solenoid_water=='ON' %}
  1384. <input id="cmn-toggle-38" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox"
  1385. name="outer_solenoid_water_status" value="ON" onclick="outerSolenoidWater()">
  1386. {% else %}
  1387. <input id="cmn-toggle-38" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1388. name="outer_solenoid_water_status" value="OFF" onclick="outerSolenoidWater()">
  1389. {% endif %}
  1390. <label for="cmn-toggle-38"></label>
  1391. </div>
  1392. <div class="switch">
  1393. <input id="cmn-toggle-39" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  1394. <label for="cmn-toggle-39" data-on="Yes" data-off="No"></label>
  1395. </div>
  1396. </div>
  1397. </td>
  1398. <td>
  1399. <div class="switch_div">
  1400. <div class="switch">
  1401. <input id="cmn-toggle-49" class="cmn-toggle cmn-toggle-round" type="checkbox">
  1402. <label for="cmn-toggle-49"></label>
  1403. </div>
  1404. <div class="switch text-center">
  1405. {% if tank_solenoid_water_in=='ON' %}
  1406. <input id="cmn-toggle-50" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox"
  1407. name="tank_solenoid_water_in_status" value="ON" onclick="tankSolenoidWaterIn()">
  1408. {% else %}
  1409. <input id="cmn-toggle-50" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1410. name="tank_solenoid_water_in_status" value="OFF" onclick="tankSolenoidWaterIn()">
  1411. {% endif %}
  1412. <label for="cmn-toggle-50"></label>
  1413. </div>
  1414. <div class="switch">
  1415. <input id="cmn-toggle-51" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  1416. <label for="cmn-toggle-51" data-on="Yes" data-off="No"></label>
  1417. </div>
  1418. </div>
  1419. </td>
  1420. <td>
  1421. <div class="switch_div">
  1422. <div class="switch">
  1423. <input id="cmn-toggle-40" class="cmn-toggle cmn-toggle-round" type="checkbox">
  1424. <label for="cmn-toggle-40"></label>
  1425. </div>
  1426. <div class="switch text-center">
  1427. {% if tank_pump_sensor=='ON' %}
  1428. <input id="cmn-toggle-41" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox"
  1429. name="tank_pump_sensor_status" value="ON" onclick="tankPumpSensor()">
  1430. {% else %}
  1431. <input id="cmn-toggle-41" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1432. name="tank_pump_sensor_status" value="OFF" onclick="tankPumpSensor()">
  1433. {% endif %}
  1434. <label for="cmn-toggle-41"></label>
  1435. </div>
  1436. <div class="switch">
  1437. <input id="cmn-toggle-42" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  1438. <label for="cmn-toggle-42" data-on="Yes" data-off="No"></label>
  1439. </div>
  1440. </div>
  1441. </td>
  1442. <td>
  1443. <div class="switch_div">
  1444. <div class="switch">
  1445. <input id="cmn-toggle-43" class="cmn-toggle cmn-toggle-round" type="checkbox">
  1446. <label for="cmn-toggle-43"></label>
  1447. </div>
  1448. <div class="switch text-center">
  1449. {% if tank_threewayvalve_bean=='ON' %}
  1450. <input id="cmn-toggle-44" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox"
  1451. name="tank_threewayvalve_bean_status" value="ON" onclick="tankThreeWayValveBean()">
  1452. {% else %}
  1453. <input id="cmn-toggle-44" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1454. name="tank_threewayvalve_bean_status" value="OFF" onclick="tankThreeWayValveBean()">
  1455. {% endif %}
  1456. <label for="cmn-toggle-44"></label>
  1457. </div>
  1458. <div class="switch">
  1459. <input id="cmn-toggle-45" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  1460. <label for="cmn-toggle-45" data-on="Yes" data-off="No"></label>
  1461. </div>
  1462. </div>
  1463. </td>
  1464. <td>
  1465. <div class="switch_div">
  1466. <div class="switch">
  1467. <input id="cmn-toggle-46" class="cmn-toggle cmn-toggle-round" type="checkbox">
  1468. <label for="cmn-toggle-46"></label>
  1469. </div>
  1470. <div class="switch text-center">
  1471. {% if outer_threewayvalve_float=='ON' %}
  1472. <input id="cmn-toggle-47" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox"
  1473. name="outer_threewayvalve_float_status" value="ON" onclick="outerThreeWayValveFloat()">
  1474. {% else %}
  1475. <input id="cmn-toggle-47" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1476. name="outer_threewayvalve_float_status" value="OFF" onclick="outerThreeWayValveFloat()">
  1477. {% endif %}
  1478. <label for="cmn-toggle-47"></label>
  1479. </div>
  1480. <div class="switch">
  1481. <input id="cmn-toggle-48" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  1482. <label for="cmn-toggle-48" data-on="Yes" data-off="No"></label>
  1483. </div>
  1484. </div>
  1485. </td>
  1486. <td>
  1487. <input id="motor_rpm_data" type="text" placeholder="{{tank_motor}}" value="" style="width:50px;">RPM
  1488. <br>
  1489. <span id="motor_rpm_status" style="color:red;"></span>
  1490. <input type="button" value="送出" name="tank_motor_status" onclick="tankMotor()">
  1491. </td>
  1492. <td>
  1493. <div class="switch_div">
  1494. <div class="switch">
  1495. <input id="cmn-toggle-25" class="cmn-toggle cmn-toggle-round" type="checkbox">
  1496. <label for="cmn-toggle-25"></label>
  1497. </div>
  1498. <div class="switch text-center">
  1499. {% if tank_heater1=='ON' %}
  1500. <input id="cmn-toggle-26" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  1501. name="tank_heater1_status" value="ON" onclick="tankHeater1()">
  1502. {% else %}
  1503. <input id="cmn-toggle-26" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1504. name="tank_heater1_status" value="OFF" onclick="tankHeater1()">
  1505. {% endif %}
  1506. <label for="cmn-toggle-26"></label>
  1507. </div>
  1508. <div class="switch">
  1509. <input id="cmn-toggle-27" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  1510. <label for="cmn-toggle-27" data-on="Yes" data-off="No"></label>
  1511. </div>
  1512. </div>
  1513. </td>
  1514. <td>
  1515. <div class="switch_div">
  1516. <div class="switch">
  1517. <input id="cmn-toggle-28" class="cmn-toggle cmn-toggle-round" type="checkbox">
  1518. <label for="cmn-toggle-28"></label>
  1519. </div>
  1520. <div class="switch text-center">
  1521. {% if tank_heater2=='ON' %}
  1522. <input id="cmn-toggle-29" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  1523. name="tank_heater2_status" value="ON" onclick="tankHeater2()">
  1524. {% else %}
  1525. <input id="cmn-toggle-29" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1526. name="tank_heater2_status" value="OFF" onclick="tankHeater2()">
  1527. {% endif %}
  1528. <label for="cmn-toggle-29"></label>
  1529. </div>
  1530. <div class="switch">
  1531. <input id="cmn-toggle-30" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  1532. <label for="cmn-toggle-30" data-on="Yes" data-off="No"></label>
  1533. </div>
  1534. </div>
  1535. </td>
  1536. <td>
  1537. <div class="switch_div">
  1538. <div class="switch">
  1539. <input id="cmn-toggle-34" class="cmn-toggle cmn-toggle-round" type="checkbox">
  1540. <label for="cmn-toggle-34"></label>
  1541. </div>
  1542. <div class="switch text-center">
  1543. {% if tank_temp_enable=='ON' %}
  1544. <input id="cmn-toggle-35" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  1545. name="tank_temp_enable_status" value="ON" onclick="tankTempEnable()">
  1546. {% else %}
  1547. <input id="cmn-toggle-35" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1548. name="tank_temp_enable_status" value="OFF" onclick="tankTempEnable()">
  1549. {% endif %}
  1550. <label for="cmn-toggle-35"></label>
  1551. </div>
  1552. <div class="switch">
  1553. <input id="cmn-toggle-36" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  1554. <label for="cmn-toggle-36" data-on="Yes" data-off="No"></label>
  1555. </div>
  1556. </div>
  1557. </td>
  1558. <td>
  1559. <input id="tank_temp_data" type="text" placeholder="{{tank_temp}}" value="" style="width:50px;">℃
  1560. <span id="tank_temp_status" style="color:red;"></span>
  1561. <br>
  1562. <input type="button" value="送出" name="tank_temp_status" onclick="tankTemp()">
  1563. </td>
  1564. <td>
  1565. <div class="switch_div">
  1566. <div class="switch">
  1567. <input id="cmn-toggle-10" class="cmn-toggle cmn-toggle-round" type="checkbox">
  1568. <label for="cmn-toggle-10"></label>
  1569. </div>
  1570. <div class="switch text-center">
  1571. {% if tank_diskvalve=='ON' %}
  1572. <input id="cmn-toggle-11" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  1573. name="tank_diskvalve_status" value="ON" onclick="tankDiskValve()">
  1574. {% else %}
  1575. <input id="cmn-toggle-11" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1576. name="tank_diskvalve_status" value="OFF" onclick="tankDiskValve()">
  1577. {% endif %}
  1578. <label for="cmn-toggle-11"></label>
  1579. </div>
  1580. <div class="switch">
  1581. <input id="cmn-toggle-12" class="cmn-toggle cmn-toggle-on-off" type="checkbox">
  1582. <label for="cmn-toggle-12" data-on="Yes" data-off="No"></label>
  1583. </div>
  1584. </div>
  1585. </td>
  1586. </tr>
  1587. <tr>
  1588. <td><span style="color:#008CBA;"><b>ON</b></span></td>
  1589. <td><input type="button" value="ON" name="tank_vacuum_ON" onclick="tankVacuum_ON()"></td>
  1590. <td><input type="button" value="ON" name="tank_threewayvalve_input_ON"
  1591. onclick="tankThreeWayValveInput_ON()"></td>
  1592. <td><input type="button" value="ON" name="tank_solenoid_water_in_ON" onclick="tankSolenoidWaterTotal_ON()">
  1593. </td>
  1594. <td><input type="button" value="ON" name="tank_solenoid_disinfect_ON" onclick="tankSolenoidDisinfect_ON()">
  1595. </td>
  1596. <td><input type="button" value="ON" name="outer_solenoid_water_ON" onclick="outerSolenoidWater_ON()">
  1597. </td>
  1598. <td><input type="button" value="ON" name="tank_solenoid_water_in_ON" onclick="tankSolenoidWaterIn_ON()">
  1599. </td>
  1600. <td><input type="button" value="ON" name="tank_pump_sensor_ON" onclick="tankPumpSensor_ON()">
  1601. </td>
  1602. <td><input type="button" value="ON" name="tank_threewayvalve_bean_ON" onclick="tankThreeWayValveBean_ON()">
  1603. </td>
  1604. <td><input type="button" value="ON" name="outer_threewayvalve_float_ON"
  1605. onclick="outerThreeWayValveFloat_ON()">
  1606. </td>
  1607. <td><input type="button" value="ON" name="tank_motor_ON" onclick="tankMotor_ON()"></td>
  1608. <td><input type="button" value="ON" name="tank_heater1_ON" onclick="tankHeater1_ON()"></td>
  1609. <td><input type="button" value="ON" name="tank_heater2_ON" onclick="tankHeater2_ON()"></td>
  1610. <td><input type="button" value="ON" name="tank_temp_enable_ON" onclick="tankTempEnable_ON()"></td>
  1611. <td><input type="button" value="ON" name="tank_temp_ON" onclick="tankTemp_ON()"></td>
  1612. <td><input type="button" value="ON" name="tank_diskvalve_ON" onclick="tankDiskValve_ON()"></td>
  1613. </tr>
  1614. <tr>
  1615. <td><span style="color:#C0C0C0;"><b>OFF</b></span></td>
  1616. <td><input type="button" value="OFF" name="tank_vacuum_OFF" onclick="tankVacuum_OFF()"></td>
  1617. <td><input type="button" value="OFF" name="tank_threewayvalve_input_OFF"
  1618. onclick="tankThreeWayValveInput_OFF()"></td>
  1619. <td><input type="button" value="OFF" name="tank_solenoid_water_in_OFF"
  1620. onclick="tankSolenoidWaterTotal_OFF()">
  1621. </td>
  1622. <td><input type="button" value="OFF" name="tank_solenoid_disinfect_OFF"
  1623. onclick="tankSolenoidDisinfect_OFF()"></td>
  1624. <td><input type="button" value="OFF" name="outer_solenoid_water_OFF" onclick="outerSolenoidWater_OFF()">
  1625. </td>
  1626. <td><input type="button" value="OFF" name="tank_solenoid_water_in_OFF" onclick="tankSolenoidWaterIn_OFF()">
  1627. </td>
  1628. <td><input type="button" value="OFF" name="tank_pump_sensor_OFF" onclick="tankPumpSensor_OFF()"></td>
  1629. <td><input type="button" value="OFF" name="tank_threewayvalve_bean_OFF"
  1630. onclick="tankThreeWayValveBean_OFF()">
  1631. </td>
  1632. <td><input type="button" value="OFF" name="outer_threewayvalve_float_OFF"
  1633. onclick="outerThreeWayValveFloat_OFF()">
  1634. </td>
  1635. <td><input type="button" value="OFF" name="tank_motor_OFF" onclick="tankMotor_OFF()"></td>
  1636. <td><input type="button" value="OFF" name="tank_heater1_OFF" onclick="tankHeater1_OFF()"></td>
  1637. <td><input type="button" value="OFF" name="tank_heater2_OFF" onclick="tankHeater2_OFF()"></td>
  1638. <td><input type="button" value="OFF" name="tank_temp_enable_OFF" onclick="tankTempEnable_OFF()"></td>
  1639. <td><input type="button" value="OFF" name="tank_temp_OFF" onclick="tankTemp_OFF()"></td>
  1640. <td><input type="button" value="OFF" name="tank_diskvalve_OFF" onclick="tankDiskValve_OFF()"></td>
  1641. </tr>
  1642. </table>
  1643. <br>
  1644. <h4>感測器</h4>
  1645. <table border="1" style="font-size:18px; border:2px #cccccc solid; margin-left: 2px; margin-right: 2px;" cellpadding="10" width=98%>
  1646. <tr>
  1647. <td colspan="4">[桶內] 生豆高度:<span name="LiDAR_t_status">{{tank_LiDAR.LiDAR}}</span> 公分</td>
  1648. <td colspan="4">[桶內] 水位高度:<span name="PressureWaterLevel_t_status">{{PressureWaterLevel}}</span> 公分</td>
  1649. </tr>
  1650. <tr>
  1651. <td style="background-color:#f3f3f3">溫度</td>
  1652. <td><span id="SHT11_Temp_t_status">{{tank_SHT11.SHT11_Temp}}</span> ℃</td>
  1653. <td style="background-color:#f3f3f3">濕度</td>
  1654. <td><span id="SHT11_Humidity_t_status">{{tank_SHT11.SHT11_Humidity}}</span> %</td>
  1655. <td style="background-color:#f3f3f3">二氧化碳</td>
  1656. <td><span id="CO2_t_status">{{tank_CO2.CO2}}</span> ppm</td>
  1657. <td style="background-color:#f3f3f3">氣壓</td>
  1658. <td><span id="PA_t_status">{{tank_PA.PA}}</span> Pa</td>
  1659. </tr>
  1660. <tr>
  1661. <td style="background-color:#f3f3f3">pH</td>
  1662. <td><span id="PH_t_status">{{tank_PH.PH}}</span></td>
  1663. <td style="background-color:#f3f3f3">ORP</td>
  1664. <td><span id="ORP_t_status">{{tank_ORP.ORP}}</span> mV</td>
  1665. <td style="background-color:#f3f3f3">DO</td>
  1666. <td><span id="DO_t_status">{{tank_DO.DO}}</span> mg/L</td>
  1667. <td style="background-color:#f3f3f3">EC</td>
  1668. <td><span id="EC_t_status">{{tank_EC.EC}}</span> μS/cm</td>
  1669. </tr>
  1670. <tr>
  1671. <td colspan="8">[保溫夾層] 水位高度:<span id="WaterLevel_t_status">{{WaterLevel}}</span></td>
  1672. </tr>
  1673. </table>
  1674. <br>
  1675. <h4>排程測試</h4>
  1676. <table style="font-size:18px; border:2px #cccccc solid;" cellpadding="5" border='1' width=100%>
  1677. <tr>
  1678. <td>發酵</td>
  1679. <td>入水</td>
  1680. <td>入豆</td>
  1681. <td>水質測量 (攪拌、加熱)</td>
  1682. </tr>
  1683. <tr>
  1684. <td>
  1685. -- 入水 --<br>
  1686. 保溫夾層加滿水<br>
  1687. 指定桶內水位高度
  1688. <input name="testing_tank_water_height_F" value="100" type="text" style="width: 40px;">公分<br>
  1689. -- 入豆 --<br>
  1690. 指定桶內生豆高度
  1691. <input name="testing_tank_bean_height_F" value="20" type="text" style="width: 40px;">公分<br>
  1692. -- 發酵 --<br>
  1693. 指定溫度
  1694. <input name="testing_tank_temp_F" value="21" type="text" style="width: 40px;">℃<br>
  1695. 指定時間
  1696. <input name="testing_tank_time_F" value="10" type="text" style="width: 40px;">秒<br>
  1697. -- 出料 --<br>
  1698. 設定空桶高度
  1699. <input name="testing_tank_empty_height_F" value="10" type="text" style="width: 40px;">公分<br>
  1700. <!--
  1701. 入料吸料時間(秒)
  1702. <input name="testing_tank_vacuum_in_F" value="1" type="text" style="width: 40px;">
  1703. <br>
  1704. 入料放料時間(>10秒)
  1705. <input name="testing_tank_vacuum_out_F" value="10" type="text" style="width: 40px;">
  1706. <br>
  1707. 入料循環次數
  1708. <input name="testing_tank_vacuum_loop_F" value="4" type="text" style="width: 40px;">
  1709. <br>
  1710. 保溫夾層注水
  1711. <br>
  1712. 保溫夾層滿水時加熱
  1713. <br>
  1714. 溫度達設定溫度時, 停止加熱
  1715. <br>
  1716. 馬達 rpm
  1717. <input name="testing_motor_rpm_F" value="20" type="text" style="width:100px;">
  1718. <br>
  1719. 出料吸料時間(秒)
  1720. <input name="testing_out_vacuum_in_F" value="1" type="text"
  1721. style="width: 40px;">
  1722. <br>
  1723. 出料放料時間(>10秒)
  1724. <input name="testing_out_vacuum_out_F" value="10" type="text"
  1725. style="width: 40px;">
  1726. <br>
  1727. 出料循環次數
  1728. <input name="testing_out_vacuum_loop_F" value="4" type="text"
  1729. style="width: 40px;">
  1730. -->
  1731. </td>
  1732. <td>
  1733. [桶內] 水位高度&nbsp;<span name="PressureWaterLevel_t_status">{{PressureWaterLevel}}</span>&nbsp;公分<br>
  1734. 指定水量高度
  1735. <input name="testing_tank_water_height" id="testing_tank_water_height" type="text" value="100" style="width: 40px;">公分
  1736. </td>
  1737. <td>
  1738. [桶內] 生豆高度&nbsp;<span name="LiDAR_t_status">{{tank_LiDAR.LiDAR}}</span>&nbsp;公分<br>
  1739. 指定咖啡豆高度
  1740. <input name="testing_tank_coffee_height" id="testing_tank_coffee_height" type="text" value="0"
  1741. style="width: 40px;">公分<br>
  1742. 入料吸料時間
  1743. <input name="testing_tank_vacuum_in" id="testing_tank_vacuum_in" type="text" value="1" style="width: 40px;">秒<br>
  1744. 入料放料時間(>10)
  1745. <input name="testing_tank_vacuum_out" id="testing_tank_vacuum_out" type="text" value="10" style="width: 40px;">秒<br>
  1746. 入料循環次數
  1747. <input name="testing_tank_vacuum_loop" id="testing_tank_vacuum_loop" type="text" value="3" style="width: 40px;">次
  1748. </td>
  1749. <td>
  1750. 馬達
  1751. <input name="testing_motor_rpm" id="testing_motor_rpm" value="0" type="text" style="width: 40px;">rpm<br>
  1752. <!--
  1753. 發酵時間(秒)
  1754. <input name="testing_tank_dry_time" id="testing_tank_dry_time" type="text" style="width: 40px;">
  1755. <br>
  1756. 溫度控制(℃)
  1757. <input name="AAA" id="AAA" type="text" style="width: 40px;">
  1758. -->
  1759. 加熱器 1、2 ON
  1760. <br>
  1761. pump 開啟時間
  1762. <input name="testing_tank_pump_on" id="testing_tank_pump_on" value="10" type="text" style="width: 40px;">秒<br>
  1763. pump 關閉時間
  1764. <input name="testing_tank_pump_off" id="testing_tank_pump_off" value="10" type="text" style="width: 40px;">秒<br>
  1765. pump 循環次數
  1766. <input name="testing_tank_pump_loop" id="testing_tank_pump_loop" value="3" type="text" style="width: 40px;">次<br>
  1767. </td>
  1768. </tr>
  1769. <tr>
  1770. <td>
  1771. <button type="submit" class="btn btn-primary" onclick="testing_F()">發酵測試</button>
  1772. <script>
  1773. // 入水狀態
  1774. var WaterIn_F_Process = 0;
  1775. // 入豆狀態
  1776. var BeanIn_F_Process = 0;
  1777. // 發酵狀態
  1778. var Fermenting_F_Process = 0;
  1779. // 出料狀態
  1780. var WaterBeanOut_F_Process = 0;
  1781. // 發酵
  1782. function testing_F() {
  1783. clearInterval(WebUpdate);
  1784. var testing_tank_water_height_F = $("input[name=testing_tank_water_height_F]").val();
  1785. console.log("指定水高: " + testing_tank_water_height_F)
  1786. // -- 入水 --
  1787. // 若桶內水還沒滿, 開啟桶內入水
  1788. $.get('/ferment_PressureWaterLevel_' + tank_num, '', function (res) {
  1789. if ( res.PressureWaterLevel < testing_tank_water_height_F ){
  1790. console.log('桶內開始入水')
  1791. tankSolenoidWaterIn_ON();
  1792. console.log('tankSolenoidWaterIn_ON')
  1793. console.log('請開啟水龍頭進水')
  1794. };
  1795. }, 'json');
  1796. // 若夾層水還沒滿, 開啟夾層入水
  1797. $.get('/ferment_WaterLevel_' + tank_num, '', function (res) {
  1798. if ( res.WaterLevel != 1 ){
  1799. console.log('夾層開始入水')
  1800. outerSolenoidWater_ON();
  1801. console.log('tankSolenoidWaterIn_ON')
  1802. console.log('請開啟水龍頭進水')
  1803. };
  1804. }, 'json');
  1805. // 入水每五秒判斷
  1806. var WaterIn_F_interval = setInterval(WaterIn_F, 5000);
  1807. var BeanIn_F_interval
  1808. function WaterIn_F(){
  1809. if(WaterIn_F_Process == 1){
  1810. return; // 若還在處理就取消, 函式立即停止
  1811. }
  1812. // 取得桶內目前水位、取得夾層是否達水位計
  1813. WaterIn_F_Process = 1;
  1814. $.ajax({
  1815. async:false,
  1816. type:"GET",
  1817. url:"/ferment_WaterIn_" + tank_num,
  1818. dataType:"JSON",
  1819. success:function(response){
  1820. var present_tank_water_height = response.PressureWaterLevel
  1821. var present_WaterLevel = response.WaterLevel
  1822. if (present_WaterLevel == 1) {
  1823. outerSolenoidWater_OFF()
  1824. console.log("outerSolenoidWater_OFF")
  1825. console.log("保溫夾層入水完成, 桶內加水中")
  1826. }
  1827. if (present_tank_water_height > testing_tank_water_height_F) {
  1828. tankSolenoidWaterIn_OFF()
  1829. console.log("tankSolenoidWaterIn_OFF")
  1830. console.log("桶內入水完成, 保溫夾層加水中")
  1831. }
  1832. if (present_WaterLevel == 1 &&
  1833. present_tank_water_height > testing_tank_water_height_F) {
  1834. clearInterval(WaterIn_F_interval);
  1835. console.log("入水完成!")
  1836. // -- 入豆 --
  1837. BeanIn_F_interval = setInterval(BeanIn_F, 5000);
  1838. }
  1839. WaterIn_F_Process = 0;
  1840. },
  1841. error:function(thrownError){
  1842. console.log("Error: " + thrownError)
  1843. WaterIn_F_Process = 0;
  1844. }
  1845. });
  1846. }
  1847. // 發酵排程
  1848. var Fermenting_F_interval
  1849. function BeanIn_F(){
  1850. if (BeanIn_F_Process == 1) {
  1851. return; // 若還在處理就取消, 函式立即停止
  1852. }
  1853. // 取得桶內生豆高度
  1854. BeanIn_F_Process = 1;
  1855. $.ajax({
  1856. async:false,
  1857. type:"GET",
  1858. url:"/ferment_LiDAR_" + tank_num,
  1859. dataType:'json',
  1860. success:function(response){
  1861. var present_Bean_height = response.LiDAR
  1862. console.log("目前豆高: " + present_Bean_height)
  1863. var testing_tank_bean_height_F = $("input[name=testing_tank_bean_height_F]").val();
  1864. console.log("指定豆高: " + testing_tank_bean_height_F)
  1865. if (present_Bean_height > testing_tank_bean_height_F) {
  1866. clearInterval(BeanIn_F_interval);
  1867. console.log("已達生豆高度!")
  1868. var testing_tank_temp_F = $("input[name=testing_tank_temp_F]").val();
  1869. var testing_tank_time_F = $("input[name=testing_tank_time_F]").val();
  1870. console.log("指定溫度: " + testing_tank_temp_F)
  1871. console.log("指定時間: " + testing_tank_time_F)
  1872. tankMotor_ON()
  1873. console.log("tankMotor_ON")
  1874. // 取得桶內溫度, 若低於指定溫度則開啟加熱器
  1875. $.get('/ferment_SHT11_' + tank_num, '', function(res){
  1876. if (res.SHT11_Temp < testing_tank_temp_F){
  1877. tankHeater1_ON()
  1878. console.log("tankHeater1_ON")
  1879. tankHeater2_ON()
  1880. console.log("tankHeater2_ON")
  1881. }
  1882. });
  1883. Fermenting_F_interval = setInterval(Fermenting_F, 5000);
  1884. } else {
  1885. tankVacuum_ON()
  1886. console.log("tankVacuum_ON")
  1887. var time = new Date();
  1888. while ((new Date() - time) < 2 * 1000) { };
  1889. tankVacuum_OFF()
  1890. console.log("tankVacuum_OFF")
  1891. }
  1892. BeanIn_F_Process = 0;
  1893. },
  1894. error:function(thrownError){
  1895. console.log("Error: " + thrownError)
  1896. BeanIn_F_Process = 0;
  1897. }
  1898. });
  1899. };
  1900. // 出水排豆排程
  1901. var WaterBeanOut_F_interval
  1902. function Fermenting_F(){
  1903. var testing_tank_temp_F = $("input[name=testing_tank_temp_F]").val();
  1904. var testing_tank_time_F = $("input[name=testing_tank_time_F]").val();
  1905. if (Fermenting_F_Process == 1) {
  1906. return;
  1907. }
  1908. // 取得現在溫度
  1909. Fermenting_F_Process = 1;
  1910. $.ajax({
  1911. async:false,
  1912. type:"GET",
  1913. url:"/ferment_SHT11_" + tank_num,
  1914. dataType:"json",
  1915. success:function(response){
  1916. var present_Temp = response.SHT11_Temp
  1917. console.log("現在溫度: " + present_Temp)
  1918. if (present_Temp > testing_tank_temp_F) {
  1919. clearInterval(Fermenting_F_interval)
  1920. console.log("已達指定溫度!")
  1921. tankHeater1_OFF()
  1922. console.log("tankHeater1_OFF")
  1923. tankHeater2_OFF()
  1924. console.log("tankHeater2_OFF")
  1925. console.log("發酵 " + testing_tank_time_F + " 秒")
  1926. var time = new Date();
  1927. while ((new Date() - time) < testing_tank_time_F * 1000) { };
  1928. tankMotor_OFF()
  1929. console.log("tankMotor_OFF")
  1930. WaterBeanOut_F_interval = setInterval(WaterBeanOut_F, 5000);
  1931. }
  1932. Fermenting_F_Process = 0;
  1933. },
  1934. error:function(thrownError){
  1935. console.log("Error: " + thrownError)
  1936. Fermenting_F_Process = 0;
  1937. }
  1938. });
  1939. };
  1940. function WaterBeanOut_F(){
  1941. // -- 出料 --
  1942. // 設定空桶高度
  1943. var testing_tank_empty_height_F = $("input[name=testing_tank_empty_height_F]").val();
  1944. console.log("設定空桶高度: " + testing_tank_empty_height_F)
  1945. if (WaterBeanOut_F_Process == 1){
  1946. return;
  1947. }
  1948. // 取得桶內生豆高度
  1949. WaterBeanOut_F_Process = 1;
  1950. $.ajax({
  1951. async:false,
  1952. type:"GET",
  1953. url:"/ferment_LiDAR_" + tank_num,
  1954. dataType:"json",
  1955. success:function(response){
  1956. var present_Bean_height = response.LiDAR
  1957. console.log("目前發酵豆高: " + present_Bean_height)
  1958. if (present_Bean_height > testing_tank_empty_height_F) {
  1959. outputVacuum_ON()
  1960. console.log("outputVacuum_ON")
  1961. var time = new Date();
  1962. while ((new Date() - time) < 2 * 1000) { };
  1963. outputVacuum_OFF()
  1964. console.log("outputVacuum_OFF")
  1965. } else {
  1966. clearInterval(WaterBeanOut_F_interval);
  1967. console.log("發酵完成!槽內已無生豆")
  1968. }
  1969. WaterBeanOut_F_Process = 0;
  1970. },
  1971. error:function(thrownError){
  1972. console.log("Error: " + thrownError)
  1973. WaterBeanOut_F_Process = 0;
  1974. }
  1975. })
  1976. };
  1977. }
  1978. </script>
  1979. </td>
  1980. <td>
  1981. <button type="submit" class="btn btn-primary" onclick="WaterIn_testing()">入水測試</button>
  1982. <script>
  1983. var WaterIn_Process = 0; // 發酵槽入水狀態
  1984. function WaterIn_testing() {
  1985. var testing_tank_water_height = $("input[name=testing_tank_water_height]").val();
  1986. console.log('testing_tank_water_height: ' + testing_tank_water_height)
  1987. $.get('/ferment_PressureWaterLevel_' + tank_num, '', function (res) {
  1988. if ( res.PressureWaterLevel < testing_tank_water_height ){
  1989. console.log('開始入水')
  1990. tankSolenoidWaterIn_ON();
  1991. console.log('tankSolenoidWaterIn_ON')
  1992. console.log('請開啟水龍頭進水')
  1993. var time = new Date();
  1994. while ((new Date() - time) < 1000) { };
  1995. };
  1996. }, 'json');
  1997. var WaterIn_interval = setInterval(tankWaterIn, 5000);
  1998. function tankWaterIn(){
  1999. if(WaterIn_Process == 1){
  2000. return;
  2001. }
  2002. WaterIn_Process = 1;
  2003. $.ajax({
  2004. type:"GET",
  2005. url:'/ferment_PressureWaterLevel_' + tank_num,
  2006. dataType:'json',
  2007. success:function(response){
  2008. var present_water_height = response.PressureWaterLevel
  2009. console.log('目前水位高度: ' + present_water_height)
  2010. if( parseInt(present_water_height) >= parseInt(testing_tank_water_height) ){
  2011. clearInterval(WaterIn_interval);
  2012. console.log('達到目標水位!')
  2013. console.log('請關閉水龍頭')
  2014. var time = new Date();
  2015. while ((new Date() - time) < 1000) { };
  2016. tankSolenoidWaterIn_OFF();
  2017. console.log('tankSolenoidWaterIn_OFF')
  2018. }
  2019. WaterIn_Process = 0;
  2020. },
  2021. error:function(thrownError){
  2022. console.log("Error: " + thrownError)
  2023. WaterIn_Process = 0;
  2024. }
  2025. });
  2026. WaterIn_Process = 0;
  2027. }
  2028. };
  2029. </script>
  2030. </td>
  2031. <td>
  2032. <button type="submit" class="btn btn-primary" onclick="CoffeeIn_testing()">入豆測試</button>
  2033. <script>
  2034. CoffeeIn_Process = 0; // 生豆入豆狀態
  2035. function CoffeeIn_testing() {
  2036. var testing_tank_coffee_height = $("input[name=testing_tank_coffee_height]").val();
  2037. console.log('目標入料高度' + testing_tank_coffee_height)
  2038. var testing_tank_vacuum_in = $("input[name=testing_tank_vacuum_in]").val();
  2039. var testing_tank_vacuum_out = $("input[name=testing_tank_vacuum_out]").val();
  2040. var testing_tank_vacuum_loop = $("input[name=testing_tank_vacuum_loop]").val();
  2041. if (testing_tank_coffee_height != 0) {
  2042. console.log('以目標高度入豆')
  2043. var Coffee_interval = setInterval(tankCoffeeHeight, 5000);
  2044. function tankCoffeeHeight(){
  2045. if (CoffeeIn_Process == 1){
  2046. return;
  2047. }
  2048. CoffeeIn_Process = 1;
  2049. $.ajax({
  2050. async:false,
  2051. type:'GET',
  2052. url:'/ferment_LiDAR_' + tank_num,
  2053. dataType:'JSON',
  2054. success:function(response){
  2055. var present_Coffee_height = response.LiDAR
  2056. console.log("目前生豆高度: ", present_Coffee_height)
  2057. if( present_Coffee_height >= testing_tank_coffee_height){
  2058. clearInterval(Coffee_interval);
  2059. console.log("生豆已達目標高度!")
  2060. CoffeeIn_Process = 0;
  2061. } else {
  2062. tankVacuum_ON()
  2063. console.log('tankVacuum_ON')
  2064. var time = new Date();
  2065. while ((new Date() - time) < testing_tank_vacuum_in * 1000) { };
  2066. tankVacuum_OFF()
  2067. console.log('tankVacuum_OFF')
  2068. var time = new Date();
  2069. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  2070. CoffeeIn_Process = 0;
  2071. }
  2072. },
  2073. error:function(thrownError){
  2074. console.log("Error: " + thrownError)
  2075. CoffeeIn_Process = 0;
  2076. }
  2077. });
  2078. CoffeeIn_Process = 0;
  2079. };
  2080. } else if (testing_tank_coffee_height == 0){
  2081. console.log('開始循環入豆')
  2082. for (step = 1; step <= testing_tank_vacuum_loop; step++) {
  2083. console.log('-- 循環第 ' + step + ' 次 --');
  2084. tankVacuum_ON()
  2085. console.log('tankVacuum_ON')
  2086. var time = new Date();
  2087. while ((new Date() - time) < testing_tank_vacuum_in * 1000) { };
  2088. tankVacuum_OFF()
  2089. console.log('tankVacuum_OFF')
  2090. var time = new Date();
  2091. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  2092. }
  2093. console.log('-- 循環入豆結束 --')
  2094. }
  2095. }
  2096. </script>
  2097. </td>
  2098. <td>
  2099. <button type="submit" class="btn btn-primary" onclick="WATER_testing()">水質測量(攪拌、加熱)</button>
  2100. <script>
  2101. function WATER_testing() {
  2102. var set_motor_rpm = $("input[name=testing_motor_rpm]").val();
  2103. var data = { "tank_num": "C" + tank_num, "command": "tank_motor_status", "value": set_motor_rpm };
  2104. $.post('/mqtt/{{tid}}', data, function (res) {
  2105. console.log('data:', data)
  2106. if (res == 'on') {
  2107. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  2108. } else if (res == 'off') {
  2109. clearInterval(timer); // 取消 timer 的不斷執行
  2110. } else {
  2111. };
  2112. }, 'text')
  2113. // setTimeout(function () { location.reload(); }, 500);
  2114. console.log('motor rpm:' + set_motor_rpm)
  2115. var time = new Date();
  2116. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  2117. tankHeater1_ON()
  2118. console.log('tankHeater1_ON')
  2119. var time = new Date();
  2120. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  2121. tankHeater2_ON()
  2122. console.log('tankHeater2_ON')
  2123. console.log('暫停 5 秒鐘')
  2124. var time = new Date();
  2125. while ((new Date() - time) < 5 * 1000) { };
  2126. var testing_tank_pump_on = $("input[name=testing_tank_pump_on]").val();
  2127. var testing_tank_pump_off = $("input[name=testing_tank_pump_off]").val();
  2128. var testing_tank_pump_loop = $("input[name=testing_tank_pump_loop]").val();
  2129. for (step = 1; step <= testing_tank_pump_loop; step++) {
  2130. console.log('-- pump 循環第 ' + step + ' 次 --')
  2131. tankPumpSensor_ON()
  2132. console.log('tankPumpSensor_ON')
  2133. var time = new Date();
  2134. while ((new Date() - time) < testing_tank_pump_on * 1000) { };
  2135. tankPumpSensor_OFF()
  2136. console.log('tankPumpSensor_OFF')
  2137. var time = new Date();
  2138. while ((new Date() - time) < testing_tank_pump_off * 1000) { };
  2139. }
  2140. console.log('暫停 5 秒鐘')
  2141. var time = new Date();
  2142. while ((new Date() - time) < 5 * 1000) { };
  2143. tankMotor_OFF()
  2144. console.log('tankMotor_OFF')
  2145. var time = new Date();
  2146. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  2147. tankHeater1_OFF()
  2148. console.log('tankHeater1_OFF')
  2149. var time = new Date();
  2150. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  2151. tankHeater2_OFF()
  2152. console.log('tankHeater2_OFF')
  2153. };
  2154. </script>
  2155. </td>
  2156. </tr>
  2157. </table>
  2158. <br>
  2159. <h4>攝影機畫面</h4>
  2160. <div class="container-fluid">
  2161. <div class="row" style="margin-top:5px;">
  2162. <div class="col flex">
  2163. <div class="col-md-12 row flex" style="text-align:center;margin-top:5px;">
  2164. <div class="col-md-12 row flex">
  2165. <img src="" id="two" width="80%" height="80%">
  2166. </div>
  2167. </div>
  2168. <script>
  2169. // M5 攝影機
  2170. //const img = document.querySelector('#one');
  2171. const img1 = document.querySelector('#two');
  2172. const WS_URL1 = 'ws:///60.250.156.230:8089';
  2173. const ws1 = new WebSocket(WS_URL1);
  2174. let urlObject1;
  2175. ws1.onopen = () => console.log(`Connected to ${WS_URL1}`);
  2176. ws1.onmessage = message1 => {
  2177. const arrayBuffer1 = message1.data;
  2178. if (urlObject1) {
  2179. URL.revokeObjectURL(urlObject1);
  2180. }
  2181. urlObject1 = URL.createObjectURL(new Blob([arrayBuffer1]));
  2182. img1.src = urlObject1;
  2183. }
  2184. </script>
  2185. </div>
  2186. </div>
  2187. </div>
  2188. <br>
  2189. <h4>水路排程測試</h4>
  2190. [保溫夾層] 水位高度:<span id="WaterLevel_t_status">{{WaterLevel}}</span>
  2191. <table style="font-size:18px; border:2px #cccccc solid;" cellpadding="5" border='1' width=100%>
  2192. <tr>
  2193. <td colspan="2">桶內進水</td>
  2194. <td colspan="2">保溫夾層進水</td>
  2195. <td colspan="2">消毒/打菌</td>
  2196. <td colspan="2">感測器 pump 進水</td>
  2197. </tr>
  2198. <tr>
  2199. <td>桶內進水 ON</td>
  2200. <td>桶內進水 OFF</td>
  2201. <td>保溫夾層進水 ON</td>
  2202. <td>保溫夾層進水 OFF</td>
  2203. <td>消毒/打菌 ON</td>
  2204. <td>消毒/打菌 OFF</td>
  2205. <td>感測器 pump 進水 ON</td>
  2206. <td>感測器 pump 進水 OFF</td>
  2207. </tr>
  2208. <tr>
  2209. <td>保溫夾層電磁閥 OFF<br>桶內電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font></td>
  2210. <td><font color="#FF0000">水龍頭 OFF</font><br>桶內電磁閥 OFF</td>
  2211. <td>桶內電磁閥 OFF<br>保溫夾層電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font></td>
  2212. <td><font color="#FF0000">水龍頭 OFF</font><br>保溫夾層電磁閥 OFF</td>
  2213. <td>消毒電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font></td>
  2214. <td><font color="#FF0000">水龍頭 OFF</font><br>消毒電磁閥 OFF</td>
  2215. <td>桶內電磁閥 ON<br>pump ON</td>
  2216. <td>pump OFF<br>桶內電磁閥 OFF</td>
  2217. </tr>
  2218. <tr>
  2219. <td>
  2220. <button type="submit" class="btn btn-primary" onclick="tank_WaterIn_ON_testing()">桶內進水 ON</button>
  2221. <script>
  2222. // 保溫夾層電磁閥 OFF<br>桶內電磁閥 ON<br>總進水電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font>
  2223. function tank_WaterIn_ON_testing(){
  2224. outerSolenoidWater_OFF()
  2225. console.log('outerSolenoidWater_OFF')
  2226. var time = new Date();
  2227. while ((new Date() - time) < 1000) { };
  2228. tankSolenoidWaterIn_ON()
  2229. console.log('tankSolenoidWaterIn_ON')
  2230. console.log('請開啟水龍頭進水')
  2231. }
  2232. </script>
  2233. </td>
  2234. <td>
  2235. <button type="submit" class="btn btn-primary" onclick="tank_WaterIn_OFF_testing()">桶內進水 OFF</button>
  2236. <script>
  2237. // <font color="#FF0000">水龍頭 OFF</font><br>總進水電磁閥 OFF<br>桶內電磁閥 OFF
  2238. function tank_WaterIn_OFF_testing(){
  2239. console.log('請關閉水龍頭進水')
  2240. var time = new Date();
  2241. while ((new Date() - time) < 1000) { };
  2242. tankSolenoidWaterIn_OFF()
  2243. console.log('tankSolenoidWaterIn_OFF')
  2244. }
  2245. </script>
  2246. </td>
  2247. <td>
  2248. <button type="submit" class="btn btn-primary" onclick="outer_WaterIn_ON_testing()">保溫夾層進水 ON</button>
  2249. <script>
  2250. // 桶內電磁閥 OFF<br>保溫夾層電磁閥 ON<br>總進水電磁閥 ON<br><font color="#FF0000">水龍頭 ON
  2251. function outer_WaterIn_ON_testing(){
  2252. tankSolenoidWaterIn_OFF()
  2253. console.log('tankSolenoidWaterIn_OFF')
  2254. var time = new Date();
  2255. while ((new Date() - time) < 1000) { };
  2256. outerSolenoidWater_ON()
  2257. console.log('outerSolenoidWater_ON')
  2258. var time = new Date();
  2259. while ((new Date() - time) < 1000) { };
  2260. console.log('請開啟水龍頭進水')
  2261. }
  2262. </script>
  2263. </td>
  2264. <td>
  2265. <button type="submit" class="btn btn-primary" onclick="outer_WaterIn_OFF_testing()">保溫夾層進水 OFF</button>
  2266. <script>
  2267. // <font color="#FF0000">水龍頭 OFF</font><br>總進水電磁閥 OFF<br>保溫夾層電磁閥 OFF
  2268. function outer_WaterIn_OFF_testing(){
  2269. console.log('請關閉水龍頭進水')
  2270. var time = new Date();
  2271. while ((new Date() - time) < 1000) { };
  2272. outerSolenoidWater_OFF()
  2273. console.log('outerSolenoidWater_OFF')
  2274. }
  2275. </script>
  2276. </td>
  2277. <td>
  2278. <button type="submit" class="btn btn-primary" onclick="tank_Disinfect_ON_testing()">消毒/打菌 ON</button>
  2279. <script>
  2280. // 消毒電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font>
  2281. function tank_Disinfect_ON_testing(){
  2282. tankSolenoidDisinfect_ON()
  2283. console.log('tankSolenoidDisinfect_ON')
  2284. var time = new Date();
  2285. while ((new Date() - time) < 1000) { };
  2286. console.log('請開啟水龍頭進水')
  2287. }
  2288. </script>
  2289. </td>
  2290. <td>
  2291. <button type="submit" class="btn btn-primary" onclick="tank_Disinfect_OFF_testing()">消毒/打菌 OFF</button>
  2292. <script>
  2293. // <font color="#FF0000">水龍頭 OFF</font><br>消毒電磁閥 OFF
  2294. function tank_Disinfect_OFF_testing(){
  2295. console.log('請關閉水龍頭進水')
  2296. var time = new Date();
  2297. while ((new Date() - time) < 1000) { };
  2298. tankSolenoidDisinfect_OFF()
  2299. console.log('tankSolenoidDisinfect_OFF')
  2300. }
  2301. </script>
  2302. </td>
  2303. <td>
  2304. <button type="submit" class="btn btn-primary" onclick="tank_SensorPump_ON_testing()">感測器 pump 進水 ON</button>
  2305. <script>
  2306. // 桶內電磁閥 ON<br>pump ON
  2307. function tank_SensorPump_ON_testing(){
  2308. tankSolenoidWaterIn_ON()
  2309. console.log('tankSolenoidWaterIn_ON')
  2310. var time = new Date();
  2311. while ((new Date() - time) < 2 * 1000) { };
  2312. tankPumpSensor_ON()
  2313. console.log('tankPumpSensor_ON')
  2314. }
  2315. </script>
  2316. </td>
  2317. <td>
  2318. <button type="submit" class="btn btn-primary" onclick="tank_SensorPump_OFF_testing()">感測器 pump 進水 OFF</button>
  2319. <script>
  2320. // pump OFF<br>桶內電磁閥 OFF
  2321. function tank_SensorPump_OFF_testing(){
  2322. tankPumpSensor_OFF()
  2323. console.log('tankPumpSensor_OFF')
  2324. var time = new Date();
  2325. while ((new Date() - time) < 2 * 1000) { };
  2326. tankSolenoidWaterIn_OFF()
  2327. console.log('tankSolenoidWaterIn_OFF')
  2328. }
  2329. </script>
  2330. </td>
  2331. </tr>
  2332. </table>
  2333. <br>
  2334. <br>
  2335. <!--
  2336. <footer class="footer">
  2337. <div style="text-align: center; margin-top: 10px; font-size: 13px; margin-bottom: 10px;">
  2338. Copyright © 2021 Gold-in Tech. All Rights Reserved. 金子進科技股份有限公司 版權所有
  2339. <a href="mailto:service.gitc@gmail.com" target="_blank">service.gitc@gmail.com</a>
  2340. </div>
  2341. </footer>
  2342. -->
  2343. <div id="coffee_footer">
  2344. <!-- 匯入共同使用的 footer.html 內容 -->
  2345. {% include 'footer.html' %}
  2346. </div>
  2347. </div>
  2348. </body>
  2349. </html>