ferment_container_tank.html 101 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963
  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="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_pc").text('F' + ftn + ' 發酵槽操作介面');
  24. $("#coffee_title_phone").text('F' + ftn + ' 發酵槽操作介面');
  25. if (status == 2) {
  26. $('input').prop('disabled', true);
  27. $('button').prop('disabled', true);
  28. } else if ( (status == 0) || (status == 1) ) {
  29. $('input').prop('disabled', false);
  30. $('button').prop('disabled', false);
  31. }
  32. });
  33. WebUpdate_set = setInterval(function(){WebUpdate(ftn)} , 10 * 1000)
  34. </script>
  35. <script>
  36. // 發酵槽_致動器控制
  37. var tank_num = '{{tid}}';
  38. function tankVacuum(params) {
  39. if (params == '1') {
  40. var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": "on" };
  41. } else if (params == '0') {
  42. var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": "off" };
  43. } else {
  44. var status = "off";
  45. var check = $("input[name=tank_vacuum_status]:checked");
  46. console.log('check:', check);
  47. //大於0代表有被選中
  48. if (check.length > 0) {
  49. status = "on";
  50. $("#cmn-toggle-05").prop('checked', false);
  51. if (!confirm("你確定要開啟真空吸料機嗎?")) {
  52. return false;
  53. };
  54. } else {
  55. $("#cmn-toggle-05").prop('checked', true);
  56. if (!confirm("你確定要關閉真空吸料機嗎?")) {
  57. return false;
  58. };
  59. };
  60. var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": status };
  61. }
  62. $.post('/mqtt/{{tid}}', data, function (res) {
  63. console.log('data:', data)
  64. if (res == 'on') {
  65. $("#cmn-toggle-05").prop('checked', true);
  66. } else if (res == 'off') {
  67. $("#cmn-toggle-05").prop('checked', false);
  68. } else {
  69. console.log(res)
  70. };
  71. }, 'text')
  72. }
  73. function tankThreeWayValveInput(params) {
  74. if (params == '1') {
  75. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": "on" };
  76. } else if (params == '0') {
  77. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": "off" };
  78. } else {
  79. var status = "off";
  80. var check = $("input[name=tank_threewayvalve_input_status]:checked");
  81. if (check.length > 0) {
  82. status = "on";
  83. $("#cmn-toggle-08").prop('checked', false);
  84. if (!confirm("你確定要開啟入料三通閥嗎?")) {
  85. return false;
  86. };
  87. } else {
  88. $("#cmn-toggle-08").prop('checked', true);
  89. if (!confirm("你確定要關閉入料三通閥嗎?")) {
  90. return false;
  91. };
  92. };
  93. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": status };
  94. }
  95. $.post('/mqtt/{{tid}}', data, function (res) {
  96. console.log('data:', data)
  97. if (res == 'on') {
  98. $("#cmn-toggle-08").prop('checked', true);
  99. } else if (res == 'off') {
  100. $("#cmn-toggle-08").prop('checked', false);
  101. } else {
  102. console.log(res)
  103. };
  104. }, 'text')
  105. }
  106. function tankDiskValve(params) {
  107. if (params == '1') {
  108. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "on" };
  109. } else if (params == '0') {
  110. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "off" };
  111. } else {
  112. var status = "off";
  113. var check = $("input[name=tank_diskvalve_status]:checked");
  114. if (check.length > 0) {
  115. status = "on";
  116. $("#cmn-toggle-11").prop('checked', false);
  117. if (!confirm("你確定要開啟蝴蝶閥嗎?")) {
  118. return false;
  119. };
  120. } else {
  121. $("#cmn-toggle-11").prop('checked', true);
  122. if (!confirm("你確定要關閉蝴蝶閥嗎?")) {
  123. return false;
  124. };
  125. };
  126. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": status };
  127. }
  128. $.post('/mqtt/{{tid}}', data, function (res) {
  129. console.log('data:', data)
  130. if (res == 'on') {
  131. $("#cmn-toggle-11").prop('checked', true);
  132. } else if (res == 'off') {
  133. $("#cmn-toggle-11").prop('checked', false);
  134. } else {
  135. console.log(res)
  136. };
  137. }, 'text')
  138. }
  139. function tankSolenoidPump(params) {
  140. if (params == '1') {
  141. var data = { "tank_num": "F" + tank_num, "command": "solenoid_tank_pump_status", "value": "on" };
  142. } else if (params == '0') {
  143. var data = { "tank_num": "F" + tank_num, "command": "solenoid_tank_pump_status", "value": "off" };
  144. } else {
  145. var status = "off";
  146. var check = $("input[name=solenoid_tank_pump_status]:checked");
  147. //大於0代表有被選中
  148. if (check.length > 0) {
  149. status = "on";
  150. $("#cmn-toggle-14").prop('checked', false);
  151. if (!confirm("你確定要開啟水泵逆洗電磁閥嗎?")) {
  152. return false;
  153. };
  154. } else {
  155. $("#cmn-toggle-14").prop('checked', true);
  156. if (!confirm("你確定要關閉水泵逆洗電磁閥嗎?")) {
  157. return false;
  158. };
  159. };
  160. var data = { "tank_num": "F" + tank_num, "command": "solenoid_tank_pump_status", "value": status };
  161. }
  162. $.post('/mqtt/{{tid}}', data, function (res) {
  163. console.log('data:', data)
  164. if (res == 'on') {
  165. $("#cmn-toggle-14").prop('checked', true);
  166. } else if (res == 'off') {
  167. $("#cmn-toggle-14").prop('checked', false);
  168. } else {
  169. console.log(res)
  170. };
  171. }, 'text')
  172. }
  173. function tankSolenoidDisinfect(params) {
  174. if (params == '1') {
  175. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": "on" };
  176. } else if (params == '0') {
  177. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": "off" };
  178. } else {
  179. var status = "off";
  180. var check = $("input[name=tank_solenoid_disinfect_status]:checked");
  181. //大於0代表有被選中
  182. if (check.length > 0) {
  183. status = "on";
  184. $("#cmn-toggle-17").prop('checked', false);
  185. if (!confirm("你確定要開啟消毒電磁閥嗎?")) {
  186. return false;
  187. };
  188. } else {
  189. $("#cmn-toggle-17").prop('checked', true);
  190. if (!confirm("你確定要關閉消毒電磁閥嗎?")) {
  191. return false;
  192. };
  193. };
  194. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": status };
  195. }
  196. $.post('/mqtt/{{tid}}', data, function (res) {
  197. console.log('data:', data)
  198. if (res == 'on') {
  199. $("#cmn-toggle-17").prop('checked', true);
  200. } else if (res == 'off') {
  201. $("#cmn-toggle-17").prop('checked', false);
  202. } else {
  203. console.log(res)
  204. };
  205. }, 'text')
  206. }
  207. function outerSolenoidWater(params) {
  208. if (params == '1') {
  209. var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": "on" };
  210. } else if (params == '0') {
  211. var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": "off" };
  212. } else {
  213. var status = "off";
  214. var check = $("input[name=outer_solenoid_water_status]:checked");
  215. //大於0代表有被選中
  216. if (check.length > 0) {
  217. status = "on";
  218. $("#cmn-toggle-38").prop('checked', false);
  219. if (!confirm("你確定要開啟\"桶外\"進水電磁閥嗎?")) {
  220. return false;
  221. };
  222. } else {
  223. $("#cmn-toggle-38").prop('checked', true);
  224. if (!confirm("你確定要關閉\"桶外\"進水電磁閥嗎?")) {
  225. return false;
  226. };
  227. };
  228. var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": status };
  229. }
  230. $.post('/mqtt/{{tid}}', data, function (res) {
  231. console.log('data:', data)
  232. if (res == 'on') {
  233. $("#cmn-toggle-38").prop('checked', true);
  234. } else if (res == 'off') {
  235. $("#cmn-toggle-38").prop('checked', false);
  236. } else {
  237. console.log(res)
  238. };
  239. }, 'text')
  240. }
  241. function tankSolenoidWaterIn(params) {
  242. if (params == '1') {
  243. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": "on" };
  244. } else if (params == '0') {
  245. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": "off" };
  246. } else {
  247. var status = "off";
  248. var check = $("input[name=tank_solenoid_water_in_status]:checked");
  249. //大於0代表有被選中
  250. if (check.length > 0) {
  251. status = "on";
  252. $("#cmn-toggle-50").prop('checked', false);
  253. if (!confirm("你確定要開啟\"桶內\"進水電磁閥嗎?")) {
  254. return false;
  255. };
  256. } else {
  257. $("#cmn-toggle-50").prop('checked', true);
  258. if (!confirm("你確定要關閉\"桶內\"進水電磁閥嗎?")) {
  259. return false;
  260. };
  261. };
  262. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": status };
  263. }
  264. $.post('/mqtt/{{tid}}', data, function (res) {
  265. console.log('data:', data)
  266. if (res == 'on') {
  267. $("#cmn-toggle-50").prop('checked', true);
  268. } else if (res == 'off') {
  269. $("#cmn-toggle-50").prop('checked', false);
  270. } else {
  271. console.log(res)
  272. };
  273. }, 'text')
  274. }
  275. function tankSolenoidWaterOut(params) {
  276. if (params == '1') {
  277. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_out_status", "value": "on" };
  278. } else if (params == '0') {
  279. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_out_status", "value": "off" };
  280. } else {
  281. var status = "off";
  282. var check = $("input[name=tank_solenoid_water_out_status]:checked");
  283. //大於0代表有被選中
  284. if (check.length > 0) {
  285. status = "on";
  286. $("#cmn-toggle-53").prop('checked', false);
  287. if (!confirm("你確定要開啟\"桶內排水\"電磁閥嗎?")) {
  288. return false;
  289. };
  290. } else {
  291. $("#cmn-toggle-53").prop('checked', true);
  292. if (!confirm("你確定要關閉\"桶內排水\"電磁閥嗎?")) {
  293. return false;
  294. };
  295. };
  296. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_out_status", "value": status };
  297. }
  298. $.post('/mqtt/{{tid}}', data, function (res) {
  299. console.log('data:', data)
  300. if (res == 'on') {
  301. $("#cmn-toggle-53").prop('checked', true);
  302. } else if (res == 'off') {
  303. $("#cmn-toggle-53").prop('checked', false);
  304. } else {
  305. console.log(res)
  306. };
  307. }, 'text')
  308. }
  309. function tankPumpSensor(params) {
  310. if (params == '1') {
  311. var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": "on" };
  312. } else if (params == '0') {
  313. var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": "off" };
  314. } else {
  315. var status = "off";
  316. var check = $("input[name=tank_pump_sensor_status]:checked");
  317. //大於0代表有被選中
  318. if (check.length > 0) {
  319. status = "on";
  320. $("#cmn-toggle-41").prop('checked', false);
  321. if (!confirm("你確定要開啟感測器用 pump 雙核隔膜泵嗎?")) {
  322. return false;
  323. };
  324. } else {
  325. $("#cmn-toggle-41").prop('checked', true);
  326. if (!confirm("你確定要關閉感測器用 pump 雙核隔膜泵嗎?")) {
  327. return false;
  328. };
  329. };
  330. var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": status };
  331. }
  332. $.post('/mqtt/{{tid}}', data, function (res) {
  333. console.log('data:', data)
  334. if (res == 'on') {
  335. $("#cmn-toggle-41").prop('checked', true);
  336. } else if (res == 'off') {
  337. $("#cmn-toggle-41").prop('checked', false);
  338. } else {
  339. console.log(res)
  340. };
  341. }, 'text')
  342. }
  343. function outerThreeWayValveFloat(params) {
  344. if (params == '1') {
  345. var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": "on" };
  346. } else if (params == '0') {
  347. var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": "off" };
  348. } else {
  349. var status = "off";
  350. var check = $("input[name=outer_threewayvalve_float_status]:checked");
  351. //大於0代表有被選中
  352. if (check.length > 0) {
  353. status = "on";
  354. $("#cmn-toggle-47").prop('checked', false);
  355. if (!confirm("你確定要開啟外桶浮選三通閥嗎?")) {
  356. return false;
  357. };
  358. } else {
  359. $("#cmn-toggle-47").prop('checked', true);
  360. if (!confirm("你確定要關閉外桶浮選三通閥嗎?")) {
  361. return false;
  362. };
  363. };
  364. var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": status };
  365. }
  366. $.post('/mqtt/{{tid}}', data, function (res) {
  367. console.log('data:', data)
  368. if (res == 'on') {
  369. $("#cmn-toggle-47").prop('checked', true);
  370. } else if (res == 'off') {
  371. $("#cmn-toggle-47").prop('checked', false);
  372. } else {
  373. console.log(res)
  374. };
  375. }, 'text')
  376. }
  377. function tankMotor_set() {
  378. var motor_data = $("input[id=motor_rpm_data]").val();
  379. if (motor_data == '') {
  380. //$("#cmn-toggle-20").prop('checked', false);
  381. alert("請先輸入要運轉的值!");
  382. return false;
  383. } else if (motor_data == 0) {
  384. alert("轉速 0 為關閉馬達");
  385. } else if (Number(motor_data) < -50 || Number(motor_data) > 50 || !Number(motor_data)) {
  386. //$("#cmn-toggle-20").prop('checked', false);
  387. alert("您輸入的值已超過範圍,請重新輸入!" + !Number(motor_data));
  388. return false;
  389. };
  390. var value = "off";
  391. if (motor_data != 0) {
  392. value = motor_data;
  393. if (!confirm("你確定要開啟攪拌馬達,運轉速度為 " + motor_data + " RPM 嗎?")) {
  394. return false;
  395. };
  396. } else {
  397. if (!confirm("你確定要關閉攪拌馬達嗎?")) {
  398. return false;
  399. };
  400. };
  401. var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": motor_data };
  402. $.post('/mqtt/{{tid}}', data, function (res) {
  403. console.log('data:', data)
  404. if (res == 'on') {
  405. //$("#cmn-toggle-14").prop('checked', true); // prop 設置元素屬型與元素值, 設定 checked 屬性為 true
  406. setTimeout("alert('攪拌馬達_開啟成功!')", 500); // 設定時間執行函式 delay(500), 只執行一次
  407. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  408. } else if (res == 'off') {
  409. //$("#cmn-toggle-14").prop('checked', false);
  410. setTimeout("alert('攪拌馬達_關閉成功!')", 500);
  411. clearInterval(timer); // 取消 timer 的不斷執行
  412. $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
  413. } else {
  414. alert(res);
  415. };
  416. }, 'text')
  417. };
  418. function tankMotor(params) {
  419. var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": params };
  420. $.post('/mqtt/{{tid}}', data, function (res) {
  421. console.log('data:', data)
  422. if (res == 'on') {
  423. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  424. } else if (res == 'off') {
  425. clearInterval(timer); // 取消 timer 的不斷執行
  426. $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
  427. } else {
  428. console.log(res)
  429. };
  430. }, 'text')
  431. }
  432. function Rotate() {
  433. $.get('/peel', '', function (res) {
  434. //console.log(res.peeling);
  435. $("#motor_rpm_status-status").text(res.peeling + ' rpm(每1分鐘更新一次)');
  436. }, 'json');
  437. };
  438. function tankHeater1(params) {
  439. if (params == '1') {
  440. var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": "on" };
  441. } else if (params == '0') {
  442. var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": "off" };
  443. } else {
  444. var status = "off";
  445. var check = $("input[name=tank_heater1_status]:checked");
  446. //大於0代表有被選中
  447. if (check.length > 0) {
  448. status = "on";
  449. $("#cmn-toggle-26").prop('checked', false);
  450. if (!confirm("你確定要開啟電熱管1嗎?")) {
  451. return false;
  452. };
  453. } else {
  454. $("#cmn-toggle-26").prop('checked', true);
  455. if (!confirm("你確定要關閉電熱管1嗎?")) {
  456. return false;
  457. };
  458. };
  459. var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": status };
  460. }
  461. $.post('/mqtt/{{tid}}', data, function (res) {
  462. console.log('data:', data)
  463. if (res == 'on') {
  464. $("#cmn-toggle-26").prop('checked', true);
  465. } else if (res == 'off') {
  466. $("#cmn-toggle-26").prop('checked', false);
  467. } else {
  468. console.log(res)
  469. };
  470. }, 'text')
  471. }
  472. function tankHeater2(params) {
  473. if (params == '1') {
  474. var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": "on" };
  475. } else if (params == '0') {
  476. var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": "off" };
  477. } else {
  478. var status = "off";
  479. var check = $("input[name=tank_heater2_status]:checked");
  480. //大於0代表有被選中
  481. if (check.length > 0) {
  482. status = "on";
  483. $("#cmn-toggle-29").prop('checked', false);
  484. if (!confirm("你確定要開啟電熱管2嗎?")) {
  485. return false;
  486. };
  487. } else {
  488. $("#cmn-toggle-29").prop('checked', true);
  489. if (!confirm("你確定要關閉電熱管2嗎?")) {
  490. return false;
  491. };
  492. };
  493. var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": status };
  494. }
  495. $.post('/mqtt/{{tid}}', data, function (res) {
  496. console.log('data:', data)
  497. if (res == 'on') {
  498. $("#cmn-toggle-29").prop('checked', true);
  499. } else if (res == 'off') {
  500. $("#cmn-toggle-29").prop('checked', false);
  501. } else {
  502. console.log(res)
  503. };
  504. }, 'text')
  505. }
  506. function tankTempEnable(params) {
  507. if (params == '1') {
  508. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": "on" };
  509. } else if (params == '0') {
  510. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": "off" };
  511. } else {
  512. var status = "off";
  513. var check = $("input[name=tank_temp_enable_status]:checked");
  514. //大於0代表有被選中
  515. if (check.length > 0) {
  516. status = "on";
  517. $("#cmn-toggle-35").prop('checked', false);
  518. if (!confirm("你確定要開啟溫度控制嗎?")) {
  519. return false;
  520. };
  521. } else {
  522. $("#cmn-toggle-35").prop('checked', true);
  523. if (!confirm("你確定要關閉溫度控制嗎?")) {
  524. return false;
  525. };
  526. };
  527. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": status };
  528. }
  529. $.post('/mqtt/{{tid}}', data, function (res) {
  530. console.log('data:', data)
  531. if (res == 'on') {
  532. $("#cmn-toggle-35").prop('checked', true);
  533. } else if (res == 'off') {
  534. $("#cmn-toggle-35").prop('checked', false);
  535. } else {
  536. console.log(res)
  537. };
  538. }, 'text')
  539. }
  540. // 判斷是否整數
  541. function isInteger(obj) {
  542. return obj % 1 === 0
  543. }
  544. isInteger(3) // true
  545. // 設定溫度
  546. function tankTemp_set() {
  547. var temp_data = $("input[id=tank_temp_data]").val();
  548. if (temp_data == '') {
  549. //$("#cmn-toggle-20").prop('checked', false);
  550. alert("請先輸入設定溫度!");
  551. return false;
  552. } else if (!isInteger(temp_data)) {
  553. //$("#cmn-toggle-20").prop('checked', false);
  554. alert("溫度設定僅限整數,請重新輸入!" + !Number(temp_data));
  555. return false;
  556. };
  557. var value = "0";
  558. //var check = $("input[name=peeling-machine-on]:checked");
  559. if ($("#cmn-toggle-35").prop('checked')) {
  560. value = temp_data;
  561. //$("#cmn-toggle-20").prop('checked', false);
  562. if (!confirm("你確定要設定內桶溫度為 " + temp_data + " ℃ 嗎?")) {
  563. return false;
  564. };
  565. } else {
  566. //$("#cmn-toggle-20").prop('checked', true);
  567. //你確定要停止桶內溫度設定嗎
  568. if (!confirm("請先開啟溫控開關, 再設定桶內溫度")) {
  569. return false;
  570. };
  571. };
  572. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": temp_data };
  573. $.post('/mqtt/{{tid}}', data, function (res) {
  574. console.log('data:', data)
  575. if (res == 'on') {
  576. //$("#cmn-toggle-14").prop('checked', true); // prop 設置元素屬型與元素值, 設定 checked 屬性為 true
  577. setTimeout("alert('溫度設定_開啟成功!')", 500); // 設定時間執行函式 delay(500), 只執行一次
  578. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  579. } else if (res == 'off') {
  580. //$("#cmn-toggle-14").prop('checked', false);
  581. setTimeout("alert('溫度設定_關閉成功!')", 500);
  582. clearInterval(timer); // 取消 timer 的不斷執行
  583. $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
  584. } else {
  585. alert(res);
  586. };
  587. }, 'text')
  588. };
  589. function tankTemp(params) {
  590. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": params };
  591. $.post('/mqtt/{{tid}}', data, function (res) {
  592. console.log('data:', data)
  593. if (res == 'on') {
  594. } else if (res == 'off') {
  595. } else {
  596. console.log(res)
  597. };
  598. }, 'text')
  599. }
  600. function outputVacuum(params) {
  601. if (params == '1') {
  602. var data = { "tank_num": "F" + tank_num, "command": "output_vacuum_status", "value": "on" };
  603. } else if (params == '0') {
  604. var data = { "tank_num": "F" + tank_num, "command": "output_vacuum_status", "value": "off" };
  605. } else {
  606. var status = "off";
  607. var check = $("input[name=output_vacuum_status]:checked");
  608. //大於0代表有被選中
  609. if (check.length > 0) {
  610. status = "on";
  611. $("#cmn-toggle-32").prop('checked', false);
  612. if (!confirm("你確定要開啟出料儲豆槽真空吸料機嗎?")) {
  613. return false;
  614. };
  615. } else {
  616. $("#cmn-toggle-32").prop('checked', true);
  617. if (!confirm("你確定要關閉出料儲豆槽真空吸料機嗎?")) {
  618. return false;
  619. };
  620. };
  621. var data = { "tank_num": "F" + tank_num, "command": "output_vacuum_status", "value": status };
  622. }
  623. $.post('/mqtt/{{tid}}', data, function (res) {
  624. if (res == 'on') {
  625. $("#cmn-toggle-32").prop('checked', true);
  626. } else if (res == 'off') {
  627. $("#cmn-toggle-32").prop('checked', false);
  628. } else {
  629. console.log(res)
  630. };
  631. }, 'text')
  632. }
  633. </script>
  634. <script language="JavaScript">
  635. function changeUpdate() {
  636. // aaa clearInterval(WebUpdate_set);
  637. var webupdate_time = $("input[name=webupdate_time]").val()
  638. console.log('webupdate_time' + webupdate_time)
  639. WebUpdate_set = setInterval(function(){WebUpdate(ftn)} , webupdate_time * 1000);
  640. }
  641. // jQuery 更新感測器致動器狀態
  642. function WebUpdate(ftn) {
  643. $.get('/loading/F' + ftn, '', function (res) {
  644. if (res.tank_vacuum == 0) {
  645. $("#cmn-toggle-05").prop('checked', false);
  646. } else if (res.tank_vacuum == 1) {
  647. $("#cmn-toggle-05").prop('checked', true);}
  648. if (res.tank_threewayvalve_input == 0) {
  649. $("#cmn-toggle-08").prop('checked', false);
  650. } else if (res.tank_threewayvalve_input == 1) {
  651. $("#cmn-toggle-08").prop('checked', true);}
  652. if (res.tank_diskvalve == 0) {
  653. $("#cmn-toggle-11").prop('checked', false);
  654. } else if (res.tank_diskvalve == 1) {
  655. $("#cmn-toggle-11").prop('checked', true);}
  656. if (res.solenoid_tank_pump == 0) {
  657. $("#cmn-toggle-14").prop('checked', false);
  658. } else if (res.solenoid_tank_pump == 1) {
  659. $("#cmn-toggle-14").prop('checked', true);}
  660. if (res.tank_solenoid_disinfect == 0) {
  661. $("#cmn-toggle-17").prop('checked', false);
  662. } else if (res.tank_solenoid_disinfect == 1) {
  663. $("#cmn-toggle-17").prop('checked', true);}
  664. if (res.outer_solenoid_water == 0) {
  665. $("#cmn-toggle-38").prop('checked', false);
  666. } else if (res.outer_solenoid_water == 1) {
  667. $("#cmn-toggle-38").prop('checked', true);}
  668. if (res.tank_solenoid_water_in == 0) {
  669. $("#cmn-toggle-50").prop('checked', false);
  670. } else if (res.tank_solenoid_water_in == 1) {
  671. $("#cmn-toggle-50").prop('checked', true);}
  672. if (res.tank_solenoid_water_out == 0) {
  673. $("#cmn-toggle-53").prop('checked', false);
  674. } else if (res.tank_solenoid_water_out == 1) {
  675. $("#cmn-toggle-53").prop('checked', true);}
  676. if (res.tank_pump_sensor == 0) {
  677. $("#cmn-toggle-41").prop('checked', false);
  678. } else if (res.tank_pump_sensor == 1) {
  679. $("#cmn-toggle-41").prop('checked', true);}
  680. if (res.outer_threewayvalve_float == 0) {
  681. $("#cmn-toggle-47").prop('checked', false);
  682. } else if (res.outer_threewayvalve_float == 1) {
  683. $("#cmn-toggle-47").prop('checked', true);}
  684. if (res.tank_heater1 == 0) {
  685. $("#cmn-toggle-26").prop('checked', false);
  686. } else if (res.tank_heater1 == 1) {
  687. $("#cmn-toggle-26").prop('checked', true);}
  688. if (res.tank_heater2 == 0) {
  689. $("#cmn-toggle-29").prop('checked', false);
  690. } else if (res.tank_heater2 == 1) {
  691. $("#cmn-toggle-29").prop('checked', true);}
  692. if (res.tank_temp_enable == 0) {
  693. $("#cmn-toggle-35").prop('checked', false);
  694. } else if (res.tank_temp_enable == 1) {
  695. $("#cmn-toggle-35").prop('checked', true);}
  696. $("#motor_rpm_data").attr("placeholder", res.tank_motor);
  697. $("#tank_temp_data").attr("placeholder", res.tank_temp);
  698. $("#SHT11_Temp_t_status").text(res.SHT11_Temp);
  699. $("#SHT11_Humidity_t_status").text(res.SHT11_Humidity);
  700. $("#CO2_t_status").text(res.CO2);
  701. $("#PH_t_status").text(res.PH);
  702. $("#ORP_t_status").text(res.ORP);
  703. $("#DO_t_status").text(res.DO);
  704. $("#EC_t_status").text(res.EC);
  705. $("#PA_t_status").text(res.PA);
  706. if (res.WaterLevel == '1') {
  707. $("#WaterLevel_t_status").text('滿');
  708. } else if (res.WaterLevel == '0') {
  709. $("#WaterLevel_t_status").text('可注水');
  710. } else {
  711. $("#WaterLevel_t_status").text('ERROR');
  712. }
  713. $("[name = UltraSonic_t_status]").text(res.UltraSonic);
  714. $("[name = PressureWaterLevel_t_status]").text(res.PressureWaterLevel);
  715. if (res.WaterLevel == '1' && res.outer_solenoid_water == '1'){
  716. outerSolenoidWater('0');
  717. console.log('桶外注水 OFF')
  718. };
  719. $("#motorEncoder_t_status").text(res.motorEncoder);
  720. }, 'json');
  721. }
  722. </script>
  723. </head>
  724. <body>
  725. <div id="wrapper">
  726. <div id="coffee_header">
  727. <!-- 匯入共同使用的 header.html 內容 -->
  728. {% include 'header.html' %}
  729. </div>
  730. <!-- <div style="width: 500px; margin: 0px auto; background-color: lightgreen;">
  731. test
  732. <table>
  733. <tr>
  734. <td style="color:red;">Valve</td>
  735. <td>桶內<br>真空吸料機</td>
  736. <td>入料三通閥</td>
  737. <td>水泵逆洗<br>電磁閥</td>
  738. <td>桶內消毒<br>電磁閥</td>
  739. <td>桶外進水<br>電磁閥</td>
  740. <td>桶內進水<br>電磁閥</td>
  741. <td>桶內排水<br>電磁閥</td>
  742. <td>感測器<br>雙核隔膜泵</td>
  743. <td>外桶浮選<br>三通閥</td>
  744. <td>馬達</td>
  745. <td>加熱器 1</td>
  746. <td>加熱器 2</td>
  747. <td>溫控開關</td>
  748. <td>溫度設定</td>
  749. <td>蝴蝶閥</td>
  750. </tr>
  751. </table>
  752. </div> -->
  753. <h4>致動器</h4>
  754. <table border="1" class="table-all" cellpadding="3" style="text-align: center;">
  755. <tr>
  756. <td style="color:red;">Valve</td>
  757. <td>真空吸料機</td>
  758. <td>入料三通閥</td>
  759. <td>桶外進水<br>電磁閥</td>
  760. <td>桶內進水<br>電磁閥</td>
  761. <td>感測器<br>雙核隔膜泵</td>
  762. <td>外桶浮選<br>三通閥</td>
  763. <td>馬達</td>
  764. <td>加熱器 1</td>
  765. <td>加熱器 2</td>
  766. <td>溫控開關</td>
  767. <td>溫度設定</td>
  768. <td>水泵逆洗<br>電磁閥</td>
  769. <td>桶內排水<br>電磁閥</td>
  770. <td>桶內消毒<br>電磁閥</td>
  771. <td>蝴蝶閥</td>
  772. </tr>
  773. <tr>
  774. <td>
  775. <span style="color:#C0C0C0;">off</span>
  776. <span style="color:#008CBA;">on</span>
  777. </td>
  778. <td>
  779. <div class="switch_div">
  780. <div class="switch">
  781. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-04">
  782. </div>
  783. <div class="switch text-center">
  784. {% if tank_vacuum=='ON' %}
  785. <input id="cmn-toggle-05" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  786. name="tank_vacuum_status" value="ON" onclick="tankVacuum()">
  787. {% else %}
  788. <input id="cmn-toggle-05" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  789. name="tank_vacuum_status" value="OFF" onclick="tankVacuum()">
  790. {% endif %}
  791. <label class="label_ActuatorStatus" for="cmn-toggle-05"></label>
  792. </div>
  793. <div class="switch">
  794. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-06">
  795. </div>
  796. </div>
  797. </td>
  798. <td>
  799. <div class="switch_div">
  800. <div class="switch">
  801. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-07">
  802. </div>
  803. <div class="switch text-center">
  804. {% if tank_threewayvalve_input=='ON' %}
  805. <input id="cmn-toggle-08" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  806. name="tank_threewayvalve_input_status" value="ON" onclick="tankThreeWayValveInput()">
  807. {% else %}
  808. <input id="cmn-toggle-08" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  809. name="tank_threewayvalve_input_status" value="OFF" onclick="tankThreeWayValveInput()">
  810. {% endif %}
  811. <label class="label_ActuatorStatus" for="cmn-toggle-08"></label>
  812. </div>
  813. <div class="switch">
  814. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-09">
  815. </div>
  816. </div>
  817. </td>
  818. <td>
  819. <div class="switch_div">
  820. <div class="switch">
  821. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-37">
  822. </div>
  823. <div class="switch text-center">
  824. {% if outer_solenoid_water=='ON' %}
  825. <input id="cmn-toggle-38" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox"
  826. name="outer_solenoid_water_status" value="ON" onclick="outerSolenoidWater()">
  827. {% else %}
  828. <input id="cmn-toggle-38" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  829. name="outer_solenoid_water_status" value="OFF" onclick="outerSolenoidWater()">
  830. {% endif %}
  831. <label class="label_ActuatorStatus" for="cmn-toggle-38"></label>
  832. </div>
  833. <div class="switch">
  834. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-39">
  835. </div>
  836. </div>
  837. </td>
  838. <td>
  839. <div class="switch_div">
  840. <div class="switch">
  841. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-49">
  842. </div>
  843. <div class="switch text-center">
  844. {% if tank_solenoid_water_in=='ON' %}
  845. <input id="cmn-toggle-50" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox"
  846. name="tank_solenoid_water_in_status" value="ON" onclick="tankSolenoidWaterIn()">
  847. {% else %}
  848. <input id="cmn-toggle-50" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  849. name="tank_solenoid_water_in_status" value="OFF" onclick="tankSolenoidWaterIn()">
  850. {% endif %}
  851. <label class="label_ActuatorStatus" for="cmn-toggle-50"></label>
  852. </div>
  853. <div class="switch">
  854. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-51">
  855. </div>
  856. </div>
  857. </td>
  858. <td>
  859. <div class="switch_div">
  860. <div class="switch">
  861. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-40">
  862. </div>
  863. <div class="switch text-center">
  864. {% if tank_pump_sensor=='ON' %}
  865. <input id="cmn-toggle-41" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox"
  866. name="tank_pump_sensor_status" value="ON" onclick="tankPumpSensor()">
  867. {% else %}
  868. <input id="cmn-toggle-41" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  869. name="tank_pump_sensor_status" value="OFF" onclick="tankPumpSensor()">
  870. {% endif %}
  871. <label class="label_ActuatorStatus" for="cmn-toggle-41"></label>
  872. </div>
  873. <div class="switch">
  874. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-42">
  875. </div>
  876. </div>
  877. </td>
  878. <td>
  879. <div class="switch_div">
  880. <div class="switch">
  881. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-46">
  882. </div>
  883. <div class="switch text-center">
  884. {% if outer_threewayvalve_float=='ON' %}
  885. <input id="cmn-toggle-47" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox"
  886. name="outer_threewayvalve_float_status" value="ON" onclick="outerThreeWayValveFloat()">
  887. {% else %}
  888. <input id="cmn-toggle-47" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  889. name="outer_threewayvalve_float_status" value="OFF" onclick="outerThreeWayValveFloat()">
  890. {% endif %}
  891. <label class="label_ActuatorStatus" for="cmn-toggle-47"></label>
  892. </div>
  893. <div class="switch">
  894. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-48">
  895. </div>
  896. </div>
  897. </td>
  898. <td>
  899. <input type="text" class="input-text" id="motor_rpm_data" placeholder="{{tank_motor}}" value="">RPM<br>
  900. <input type="button" class="input-button" value="Confirm" onclick="tankMotor_set()">
  901. </td>
  902. <td>
  903. <div class="switch_div">
  904. <div class="switch">
  905. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-25">
  906. </div>
  907. <div class="switch text-center">
  908. {% if tank_heater1=='ON' %}
  909. <input id="cmn-toggle-26" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  910. name="tank_heater1_status" value="ON" onclick="tankHeater1()">
  911. {% else %}
  912. <input id="cmn-toggle-26" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  913. name="tank_heater1_status" value="OFF" onclick="tankHeater1()">
  914. {% endif %}
  915. <label class="label_ActuatorStatus" for="cmn-toggle-26"></label>
  916. </div>
  917. <div class="switch">
  918. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-27">
  919. </div>
  920. </div>
  921. </td>
  922. <td>
  923. <div class="switch_div">
  924. <div class="switch">
  925. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-28">
  926. </div>
  927. <div class="switch text-center">
  928. {% if tank_heater2=='ON' %}
  929. <input id="cmn-toggle-29" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  930. name="tank_heater2_status" value="ON" onclick="tankHeater2()">
  931. {% else %}
  932. <input id="cmn-toggle-29" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  933. name="tank_heater2_status" value="OFF" onclick="tankHeater2()">
  934. {% endif %}
  935. <label class="label_ActuatorStatus" for="cmn-toggle-29"></label>
  936. </div>
  937. <div class="switch">
  938. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-30">
  939. </div>
  940. </div>
  941. </td>
  942. <td>
  943. <div class="switch_div">
  944. <div class="switch">
  945. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-34">
  946. </div>
  947. <div class="switch text-center">
  948. {% if tank_temp_enable=='ON' %}
  949. <input id="cmn-toggle-35" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  950. name="tank_temp_enable_status" value="ON" onclick="tankTempEnable()">
  951. {% else %}
  952. <input id="cmn-toggle-35" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  953. name="tank_temp_enable_status" value="OFF" onclick="tankTempEnable()">
  954. {% endif %}
  955. <label class="label_ActuatorStatus" for="cmn-toggle-35"></label>
  956. </div>
  957. <div class="switch">
  958. <input id="cmn-toggle-36" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
  959. <label class="label_ActuatorStatus" for="cmn-toggle-36" data-on="Yes" data-off="No"></label>
  960. </div>
  961. </div>
  962. </td>
  963. <td>
  964. <input type="text" class="input-text" id="tank_temp_data" placeholder="{{tank_temp}}" value="">℃<br>
  965. <input type="button" class="input-button" value="Confirm" onclick="tankTemp_set()">
  966. </td>
  967. <td>
  968. <div class="switch_div">
  969. <div class="switch">
  970. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-13">
  971. </div>
  972. <div class="switch text-center">
  973. {% if solenoid_tank_pump =='ON' %}
  974. <input id="cmn-toggle-14" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  975. name="solenoid_tank_pump_status" value="ON" onclick="tankSolenoidPump()">
  976. {% else %}
  977. <input id="cmn-toggle-14" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  978. name="solenoid_tank_pump_status" value="OFF" onclick="tankSolenoidPump()">
  979. {% endif %}
  980. <label class="label_ActuatorStatus" for="cmn-toggle-14"></label>
  981. </div>
  982. <div class="switch">
  983. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-15">
  984. </div>
  985. </div>
  986. </td>
  987. <td>
  988. <div class="switch_div">
  989. <div class="switch">
  990. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-52">
  991. </div>
  992. <div class="switch text-center">
  993. {% if tank_solenoid_water_out =='ON' %}
  994. <input id="cmn-toggle-53" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox"
  995. name="tank_solenoid_water_out_status" value="ON" onclick="tankSolenoidWaterOut()">
  996. {% else %}
  997. <input id="cmn-toggle-53" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  998. name="tank_solenoid_water_in_status" value="OFF" onclick="tankSolenoidWaterOut()">
  999. {% endif %}
  1000. <label class="label_ActuatorStatus" for="cmn-toggle-53"></label>
  1001. </div>
  1002. <div class="switch">
  1003. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-54">
  1004. </div>
  1005. </div>
  1006. </td>
  1007. <td>
  1008. <div class="switch_div">
  1009. <div class="switch">
  1010. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-16">
  1011. </div>
  1012. <div class="switch text-center">
  1013. {% if tank_solenoid_disinfect=='ON' %}
  1014. <input id="cmn-toggle-17" class="cmn-toggle cmn-toggle-round-flat" checked type="checkbox"
  1015. name="tank_solenoid_disinfect_status" value="ON" onclick="tankSolenoidDisinfect()">
  1016. {% else %}
  1017. <input id="cmn-toggle-17" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1018. name="tank_solenoid_disinfect_status" value="OFF" onclick="tankSolenoidDisinfect()">
  1019. {% endif %}
  1020. <label class="label_ActuatorStatus" for="cmn-toggle-17"></label>
  1021. </div>
  1022. <div class="switch">
  1023. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-18">
  1024. </div>
  1025. </div>
  1026. </td>
  1027. <td>
  1028. <div class="switch_div">
  1029. <div class="switch">
  1030. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-10">
  1031. </div>
  1032. <div class="switch text-center">
  1033. {% if tank_diskvalve=='ON' %}
  1034. <input id="cmn-toggle-11" class="cmn-toggle cmn-toggle-round-flat" type="checkbox" checked
  1035. name="tank_diskvalve_status" value="ON" onclick="tankDiskValve()">
  1036. {% else %}
  1037. <input id="cmn-toggle-11" class="cmn-toggle cmn-toggle-round-flat" type="checkbox"
  1038. name="tank_diskvalve_status" value="OFF" onclick="tankDiskValve()">
  1039. {% endif %}
  1040. <label class="label_ActuatorStatus" for="cmn-toggle-11"></label>
  1041. </div>
  1042. <div class="switch">
  1043. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-12">
  1044. </div>
  1045. </div>
  1046. </td>
  1047. </tr>
  1048. <tr>
  1049. <td><span style="color:#008CBA;"><b>ON</b></span></td>
  1050. <td><input type="button" class="input-button-on" value="ON" name="tank_vacuum_ON" onclick="tankVacuum('1')"></td>
  1051. <td><input type="button" class="input-button-on" value="ON" name="tank_threewayvalve_input_ON"
  1052. onclick="tankThreeWayValveInput('1')"></td>
  1053. <td><input type="button" class="input-button-on" value="ON" name="outer_solenoid_water_ON" onclick="outerSolenoidWater('1')">
  1054. </td>
  1055. <td><input type="button" class="input-button-on" value="ON" name="tank_solenoid_water_in_ON" onclick="tankSolenoidWaterIn('1')">
  1056. </td>
  1057. <td><input type="button" class="input-button-on" value="ON" name="tank_pump_sensor_ON" onclick="tankPumpSensor('1')">
  1058. </td>
  1059. <td><input type="button" class="input-button-on" value="ON" name="outer_threewayvalve_float_ON"
  1060. onclick="outerThreeWayValveFloat('1')">
  1061. </td>
  1062. <td><input type="button" class="input-button-on" value="20" name="tank_motor_ON" onclick="tankMotor('20')"></td>
  1063. <td><input type="button" class="input-button-on" value="ON" name="tank_heater1_ON" onclick="tankHeater1('1')"></td>
  1064. <td><input type="button" class="input-button-on" value="ON" name="tank_heater2_ON" onclick="tankHeater2('1')"></td>
  1065. <td><input type="button" class="input-button-on" value="ON" name="tank_temp_enable_ON" onclick="tankTempEnable('1')"></td>
  1066. <td><input type="button" class="input-button-on" value="30" name="tank_temp_ON" onclick="tankTemp('30')"></td>
  1067. <td><input type="button" class="input-button-on" value="ON" name="tank_solenoid_water_in_ON" onclick="tankSolenoidPump('1')">
  1068. </td>
  1069. <td><input type="button" class="input-button-on" value="ON" name="tank_solenoid_water_out_ON" onclick="tankSolenoidWaterOut('1')">
  1070. </td>
  1071. <td><input type="button" class="input-button-on" value="ON" name="tank_solenoid_disinfect_ON" onclick="tankSolenoidDisinfect('1')">
  1072. </td>
  1073. <td><input type="button" class="input-button-on" value="ON" name="tank_diskvalve_ON" onclick="tankDiskValve('1')"></td>
  1074. </tr>
  1075. <tr>
  1076. <td><span style="color:#C0C0C0;"><b>OFF</b></span></td>
  1077. <td><input type="button" class="input-button-off" value="OFF" name="tank_vacuum_OFF" onclick="tankVacuum('0')"></td>
  1078. <td><input type="button" class="input-button-off" value="OFF" name="tank_threewayvalve_input_OFF"
  1079. onclick="tankThreeWayValveInput('0')"></td>
  1080. <td><input type="button" class="input-button-off" value="OFF" name="outer_solenoid_water_OFF" onclick="outerSolenoidWater('0')">
  1081. </td>
  1082. <td><input type="button" class="input-button-off" value="OFF" name="tank_solenoid_water_in_OFF" onclick="tankSolenoidWaterIn('0')">
  1083. </td>
  1084. <td><input type="button" class="input-button-off" value="OFF" name="tank_pump_sensor_OFF" onclick="tankPumpSensor('0')"></td>
  1085. <td><input type="button" class="input-button-off" value="OFF" name="outer_threewayvalve_float_OFF"
  1086. onclick="outerThreeWayValveFloat('0')"></td>
  1087. <td><input type="button" class="input-button-off" value="0" name="tank_motor_OFF" onclick="tankMotor('0')"></td>
  1088. <td><input type="button" class="input-button-off" value="OFF" name="tank_heater1_OFF" onclick="tankHeater1('0')"></td>
  1089. <td><input type="button" class="input-button-off" value="OFF" name="tank_heater2_OFF" onclick="tankHeater2('0')"></td>
  1090. <td><input type="button" class="input-button-off" value="OFF" name="tank_temp_enable_OFF" onclick="tankTempEnable('0')"></td>
  1091. <td><input type="button" class="input-button-off" value="0" name="tank_temp_OFF" onclick="tankTemp('0.0')"></td>
  1092. <td><input type="button" class="input-button-off" value="OFF" name="tank_solenoid_water_in_OFF"
  1093. onclick="tankSolenoidPump('0')"></td>
  1094. <td><input type="button" class="input-button-off" value="OFF" name="tank_solenoid_water_out_OFF" onclick="tankSolenoidWaterOut('0')">
  1095. </td>
  1096. <td><input type="button" class="input-button-off" value="OFF" name="tank_solenoid_disinfect_OFF"
  1097. onclick="tankSolenoidDisinfect('0')"></td>
  1098. <td><input type="button" class="input-button-off" value="OFF" name="tank_diskvalve_OFF" onclick="tankDiskValve('0')"></td>
  1099. </tr>
  1100. </table>
  1101. <br>
  1102. <h4>感測器</h4>
  1103. <table border="1" class="table-all" cellpadding="3">
  1104. <tr>
  1105. <td style="background-color:#f3f3f3">[桶內] 生豆/水位高度</td>
  1106. <td><span name="UltraSonic_t_status">{{tank_UltraSonic.UltraSonic}}</span> 公分</td>
  1107. <td style="background-color:#f3f3f3">[桶外] 水位高度</td>
  1108. <td><span id="WaterLevel_t_status">{{WaterLevel}}</span></td>
  1109. <td style="background-color:#f3f3f3">馬達編碼器</td>
  1110. <td><span id="motorEncoder_t_status">{{tank_motorEncoder.motorEncoder}}</span> RPM</td>
  1111. </tr>
  1112. <tr>
  1113. <td style="background-color:#f3f3f3">溫度</td>
  1114. <td><span id="SHT11_Temp_t_status">{{tank_SHT11.SHT11_Temp}}</span> ℃</td>
  1115. <td style="background-color:#f3f3f3">濕度</td>
  1116. <td><span id="SHT11_Humidity_t_status">{{tank_SHT11.SHT11_Humidity}}</span> %</td>
  1117. <td style="background-color:#f3f3f3">二氧化碳</td>
  1118. <td><span id="CO2_t_status">{{tank_CO2.CO2}}</span> ppm</td>
  1119. <td style="background-color:#f3f3f3">氣壓</td>
  1120. <td><span id="PA_t_status">{{tank_PA.PA}}</span> Pa</td>
  1121. </tr>
  1122. <tr>
  1123. <td style="background-color:#f3f3f3">pH</td>
  1124. <td><span id="PH_t_status">{{tank_PH.PH}}</span></td>
  1125. <td style="background-color:#f3f3f3">ORP</td>
  1126. <td><span id="ORP_t_status">{{tank_ORP.ORP}}</span> mV</td>
  1127. <td style="background-color:#f3f3f3">DO</td>
  1128. <td><span id="DO_t_status">{{tank_DO.DO}}</span> mg/L</td>
  1129. <td style="background-color:#f3f3f3">EC</td>
  1130. <td><span id="EC_t_status">{{tank_EC.EC}}</span> μS/cm</td>
  1131. </tr>
  1132. </table>
  1133. <br>
  1134. <h4>排程測試</h4>
  1135. <table border="1" class="table-all" cellpadding="3">
  1136. <tr>
  1137. <td>發酵</td>
  1138. <td>入豆</td>
  1139. <td>入水</td>
  1140. <td>水質測量 (攪拌、加熱)</td>
  1141. </tr>
  1142. <tr>
  1143. <td>
  1144. -- 入豆 --<br>
  1145. 指定桶內生豆高度
  1146. <input type="text" class="input-text" name="testing_tank_bean_height_F" value="10">公分<br>
  1147. -- 入水 --<br>
  1148. 桶外加滿水<br>
  1149. 指定桶內水位高度
  1150. <input type="text" class="input-text" name="testing_tank_water_height_F" value="20">公分<br>
  1151. -- 發酵 --<br>
  1152. 指定溫度
  1153. <input type="text" class="input-text" name="testing_tank_temp_F" value="21">℃<br>
  1154. 指定時間
  1155. <input type="text" class="input-text" name="testing_tank_time_F" value="10">秒<br>
  1156. -- 出料 --<br>
  1157. 設定空桶高度
  1158. <input type="text" class="input-text" name="testing_tank_empty_height_F" value="1">公分<br>
  1159. <!--
  1160. 入料吸料時間(秒)
  1161. <input type="text" class="input-text" name="testing_tank_vacuum_in_F" value="1">
  1162. <br>
  1163. 入料放料時間(>10秒)
  1164. <input type="text" class="input-text" name="testing_tank_vacuum_out_F" value="10">
  1165. <br>
  1166. 入料循環次數
  1167. <input type="text" class="input-text" name="testing_tank_vacuum_loop_F" value="4">
  1168. <br>
  1169. 桶外注水
  1170. <br>
  1171. 桶外滿水時加熱
  1172. <br>
  1173. 溫度達設定溫度時, 停止加熱
  1174. <br>
  1175. 馬達 rpm
  1176. <input type="text" class="input-text" name="testing_motor_rpm_F" value="20" style="width:100px;">
  1177. <br>
  1178. 出料吸料時間(秒)
  1179. <input type="text" class="input-text" name="testing_out_vacuum_in_F" value="1"
  1180. style="width: 40px;">
  1181. <br>
  1182. 出料放料時間(>10秒)
  1183. <input type="text" class="input-text" name="testing_out_vacuum_out_F" value="10"
  1184. style="width: 40px;">
  1185. <br>
  1186. 出料循環次數
  1187. <input type="text" class="input-text" name="testing_out_vacuum_loop_F" value="4"
  1188. style="width: 40px;">
  1189. -->
  1190. </td>
  1191. <td>
  1192. [桶內] 生豆/水位高度:<span name="UltraSonic_t_status">{{tank_UltraSonic.UltraSonic}}</span> 公分<br>
  1193. 指定咖啡豆高度
  1194. <input type="text" class="input-text" name="testing_tank_coffee_height" id="testing_tank_coffee_height" value="0"
  1195. style="width: 40px;">公分<br>
  1196. 入料吸料時間
  1197. <input type="text" class="input-text" name="testing_tank_vacuum_in" id="testing_tank_vacuum_in" value="1" style="width: 40px;">秒<br>
  1198. 入料放料時間(>10)
  1199. <input type="text" class="input-text" name="testing_tank_vacuum_out" id="testing_tank_vacuum_out" value="10" style="width: 40px;">秒<br>
  1200. 入料循環次數
  1201. <input type="text" class="input-text" name="testing_tank_vacuum_loop" id="testing_tank_vacuum_loop" value="3" style="width: 40px;">次
  1202. </td>
  1203. <td>
  1204. [桶內] 生豆/水位高度:<span name="UltraSonic_t_status">{{tank_UltraSonic.UltraSonic}}</span>&nbsp;公分<br>
  1205. 指定水量高度
  1206. <input type="text" class="input-text" name="testing_tank_water_height" id="testing_tank_water_height" value="100" style="width: 40px;">公分
  1207. </td>
  1208. <td>
  1209. 馬達
  1210. <input type="text" class="input-text" name="testing_motor_rpm" id="testing_motor_rpm" value="0">rpm<br>
  1211. <!--
  1212. 發酵時間(秒)
  1213. <input type="text" class="input-text" name="testing_tank_dry_time" id="testing_tank_dry_time">
  1214. <br>
  1215. 溫度控制(℃)
  1216. <input type="text" class="input-text" name="AAA" id="AAA">
  1217. -->
  1218. 加熱器 1、2 ON
  1219. <br>
  1220. pump 開啟時間
  1221. <input type="text" class="input-text" name="testing_tank_pump_on" id="testing_tank_pump_on" value="10">秒<br>
  1222. pump 關閉時間
  1223. <input type="text" class="input-text" name="testing_tank_pump_off" id="testing_tank_pump_off" value="10">秒<br>
  1224. pump 循環次數
  1225. <input type="text" class="input-text" name="testing_tank_pump_loop" id="testing_tank_pump_loop" value="3">次<br>
  1226. </td>
  1227. </tr>
  1228. <tr>
  1229. <td>
  1230. <button type="submit" class="btn btn-primary" onclick="testing_F()">發酵測試</button>
  1231. <script>
  1232. // 入水狀態
  1233. var WaterIn_F_Process = 0;
  1234. // 入豆狀態
  1235. var BeanIn_F_Process = 0;
  1236. // 發酵狀態
  1237. var Fermenting_F_Process = 0;
  1238. // 出料狀態
  1239. var WaterBeanOut_F_Process = 0;
  1240. // 發酵
  1241. function testing_F() {
  1242. // aaa clearInterval(WebUpdate_set);
  1243. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1244. // -- 入豆 --
  1245. var testing_tank_bean_height_F = $("input[name=testing_tank_bean_height_F]").val();
  1246. var BeanIn_F_interval = setInterval(BeanIn_F, 5000);
  1247. // -- 入水 --
  1248. var WaterIn_F_interval
  1249. function BeanIn_F(){
  1250. if (BeanIn_F_Process == 1) {
  1251. return; // 若還在處理就取消, 函式立即停止
  1252. }
  1253. var testing_tank_water_height_F = $("input[name=testing_tank_water_height_F]").val();
  1254. // 取得桶內生豆高度
  1255. BeanIn_F_Process = 1;
  1256. $.ajax({
  1257. async:false,
  1258. type:"GET",
  1259. url:"/ferment_UltraSonic_" + tank_num,
  1260. dataType:'json',
  1261. success:function(response){
  1262. var present_Bean_height = response.UltraSonic
  1263. console.log("目前豆高: " + present_Bean_height)
  1264. console.log("指定豆高: " + testing_tank_bean_height_F)
  1265. if ( parseInt(present_Bean_height) >= parseInt(testing_tank_bean_height_F) ) {
  1266. clearInterval(BeanIn_F_interval);
  1267. console.log("已達生豆高度!")
  1268. // 讀取指定水高
  1269. var testing_tank_water_height_F = $("input[name=testing_tank_water_height_F]").val();
  1270. console.log("指定水高: " + testing_tank_water_height_F)
  1271. // 若桶內水還沒滿, 開啟桶內入水
  1272. $.get('/ferment_UltraSonic_' + tank_num, '', function (res) {
  1273. if ( res.UltraSonic < testing_tank_water_height_F ){
  1274. console.log('桶內開始入水')
  1275. tankSolenoidWaterIn('1');
  1276. console.log('tankSolenoidWaterIn_ON')
  1277. console.log('請開啟水龍頭進水')
  1278. };
  1279. }, 'json');
  1280. // 若桶外水還沒滿, 開啟桶外入水
  1281. $.get('/ferment_WaterLevel_' + tank_num, '', function (res) {
  1282. if ( res.WaterLevel != 1 ){
  1283. console.log('桶外開始入水')
  1284. outerSolenoidWater('1');
  1285. console.log('tankSolenoidWaterIn_ON')
  1286. console.log('請開啟水龍頭進水')
  1287. };
  1288. }, 'json');
  1289. // 入水每五秒判斷
  1290. WaterIn_F_interval = setInterval(WaterIn_F, 5000);
  1291. } else {
  1292. tankVacuum('1')
  1293. console.log("tankVacuum_ON")
  1294. var time = new Date();
  1295. while ((new Date() - time) < 2 * 1000) { };
  1296. tankVacuum('0')
  1297. console.log("tankVacuum_OFF")
  1298. }
  1299. BeanIn_F_Process = 0;
  1300. },
  1301. error:function(thrownError){
  1302. console.log("Error: " + thrownError)
  1303. BeanIn_F_Process = 0;
  1304. }
  1305. });
  1306. };
  1307. // 入豆排程
  1308. var Fermenting_F_interval
  1309. function WaterIn_F(){
  1310. if(WaterIn_F_Process == 1){
  1311. return; // 若還在處理就取消, 函式立即停止
  1312. }
  1313. // 取得桶內目前水位、取得桶外是否達水位計
  1314. WaterIn_F_Process = 1;
  1315. $.ajax({
  1316. async:false,
  1317. type:"GET",
  1318. url:"/ferment_WaterIn_" + tank_num,
  1319. dataType:"JSON",
  1320. success:function(response){
  1321. var testing_tank_water_height_F = parseInt($("input[name=testing_tank_water_height_F]").val());
  1322. var present_tank_water_height = parseInt(response.UltraSonic)
  1323. var present_WaterLevel = response.WaterLevel
  1324. if (present_WaterLevel == 1 && present_tank_water_height >= testing_tank_water_height_F) {
  1325. clearInterval(WaterIn_F_interval);
  1326. console.log("入水完成!")
  1327. var testing_tank_temp_F = $("input[name=testing_tank_temp_F]").val();
  1328. var testing_tank_time_F = $("input[name=testing_tank_time_F]").val();
  1329. console.log("指定溫度: " + testing_tank_temp_F)
  1330. console.log("指定時間: " + testing_tank_time_F)
  1331. tankMotor('20')
  1332. console.log("tankMotor_ON")
  1333. // 取得桶內溫度, 若低於指定溫度則開啟加熱器
  1334. $.get('/ferment_SHT11_' + tank_num, '', function(res){
  1335. if (res.SHT11_Temp < testing_tank_temp_F){
  1336. tankHeater1('1')
  1337. console.log("tankHeater1_ON")
  1338. tankHeater2('1')
  1339. console.log("tankHeater2_ON")
  1340. }
  1341. });
  1342. // -- 發酵 --
  1343. console.log("進入發酵流程")
  1344. Fermenting_F_interval = setInterval(Fermenting_F, 5000);
  1345. }
  1346. else if (present_WaterLevel == 1) {
  1347. outerSolenoidWater('0')
  1348. console.log("outerSolenoidWater_OFF")
  1349. console.log("桶外入水完成, 桶內加水中")
  1350. }
  1351. else if (present_tank_water_height > testing_tank_water_height_F) {
  1352. tankSolenoidWaterIn('0')
  1353. console.log("tankSolenoidWaterIn_OFF")
  1354. console.log("桶內入水完成, 桶外加水中")
  1355. }
  1356. WaterIn_F_Process = 0;
  1357. },
  1358. error:function(thrownError){
  1359. console.log("Error: " + thrownError)
  1360. WaterIn_F_Process = 0;
  1361. }
  1362. });
  1363. WaterIn_F_Process = 0;
  1364. }
  1365. // 出水排豆排程
  1366. var WaterBeanOut_F_interval
  1367. function Fermenting_F(){
  1368. var testing_tank_temp_F = $("input[name=testing_tank_temp_F]").val();
  1369. var testing_tank_time_F = $("input[name=testing_tank_time_F]").val();
  1370. if (Fermenting_F_Process == 1) {
  1371. return;
  1372. }
  1373. // 取得現在溫度
  1374. Fermenting_F_Process = 1;
  1375. $.ajax({
  1376. async:false,
  1377. type:"GET",
  1378. url:"/ferment_SHT11_" + tank_num,
  1379. dataType:"json",
  1380. success:function(response){
  1381. var present_Temp = response.SHT11_Temp
  1382. console.log("現在溫度: " + present_Temp)
  1383. if (present_Temp >= testing_tank_temp_F) {
  1384. clearInterval(Fermenting_F_interval)
  1385. console.log("已達指定溫度!")
  1386. tankHeater1('0')
  1387. console.log("tankHeater1_OFF")
  1388. tankHeater2('0')
  1389. console.log("tankHeater2_OFF")
  1390. console.log("發酵 " + testing_tank_time_F + " 秒")
  1391. var time = new Date();
  1392. while ((new Date() - time) < testing_tank_time_F * 1000) { };
  1393. tankMotor('0')
  1394. console.log("tankMotor_OFF")
  1395. WaterBeanOut_F_interval = setInterval(WaterBeanOut_F, 5000);
  1396. }
  1397. Fermenting_F_Process = 0;
  1398. },
  1399. error:function(thrownError){
  1400. console.log("Error: " + thrownError)
  1401. Fermenting_F_Process = 0;
  1402. }
  1403. });
  1404. };
  1405. function WaterBeanOut_F(){
  1406. // -- 出料 --
  1407. // 設定空桶高度
  1408. var testing_tank_empty_height_F = $("input[name=testing_tank_empty_height_F]").val();
  1409. console.log("設定空桶高度: " + testing_tank_empty_height_F)
  1410. if (WaterBeanOut_F_Process == 1){
  1411. return;
  1412. }
  1413. // 取得桶內生豆高度
  1414. WaterBeanOut_F_Process = 1;
  1415. $.ajax({
  1416. async:false,
  1417. type:"GET",
  1418. url:"/ferment_UltraSonic_" + tank_num,
  1419. dataType:"json",
  1420. success:function(response){
  1421. var present_Bean_height = response.UltraSonic
  1422. console.log("目前發酵豆高/水位: " + present_Bean_height)
  1423. if (present_Bean_height > testing_tank_empty_height_F) {
  1424. outputVacuum('1')
  1425. console.log("outputVacuum_ON")
  1426. var time = new Date();
  1427. while ((new Date() - time) < 2 * 1000) { };
  1428. outputVacuum('0')
  1429. console.log("outputVacuum_OFF")
  1430. } else {
  1431. clearInterval(WaterBeanOut_F_interval);
  1432. console.log("發酵完成!槽內已無生豆")
  1433. }
  1434. WaterBeanOut_F_Process = 0;
  1435. },
  1436. error:function(thrownError){
  1437. console.log("Error: " + thrownError)
  1438. WaterBeanOut_F_Process = 0;
  1439. }
  1440. })
  1441. };
  1442. }
  1443. </script>
  1444. </td>
  1445. <td>
  1446. <button type="submit" class="btn btn-primary" onclick="CoffeeIn_testing()">入豆測試</button>
  1447. <script>
  1448. // 入豆狀態
  1449. CoffeeIn_Process = 0;
  1450. function CoffeeIn_testing() {
  1451. var testing_tank_coffee_height = $("input[name=testing_tank_coffee_height]").val();
  1452. console.log('目標入料高度' + testing_tank_coffee_height)
  1453. var testing_tank_vacuum_in = $("input[name=testing_tank_vacuum_in]").val();
  1454. var testing_tank_vacuum_out = $("input[name=testing_tank_vacuum_out]").val();
  1455. var testing_tank_vacuum_loop = $("input[name=testing_tank_vacuum_loop]").val();
  1456. if (testing_tank_coffee_height != 0) {
  1457. console.log('以目標高度入豆')
  1458. var Coffee_interval = setInterval(tankCoffeeHeight, 5000);
  1459. function tankCoffeeHeight(){
  1460. if (CoffeeIn_Process == 1){
  1461. return;
  1462. }
  1463. CoffeeIn_Process = 1;
  1464. $.ajax({
  1465. async:false,
  1466. type:'GET',
  1467. url:'/ferment_UltraSonic_' + tank_num,
  1468. dataType:'JSON',
  1469. success:function(response){
  1470. var present_Coffee_height = response.UltraSonic
  1471. console.log("目前生豆高度: ", present_Coffee_height)
  1472. if( present_Coffee_height >= testing_tank_coffee_height){
  1473. clearInterval(Coffee_interval);
  1474. console.log("生豆已達目標高度!")
  1475. } else {
  1476. tankVacuum('1')
  1477. console.log('tankVacuum_ON')
  1478. var time = new Date();
  1479. while ((new Date() - time) < testing_tank_vacuum_in * 1000) { };
  1480. tankVacuum('0')
  1481. console.log('tankVacuum_OFF')
  1482. var time = new Date();
  1483. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  1484. }
  1485. CoffeeIn_Process = 0;
  1486. },
  1487. error:function(thrownError){
  1488. console.log("Error: " + thrownError)
  1489. CoffeeIn_Process = 0;
  1490. }
  1491. });
  1492. };
  1493. } else if (testing_tank_coffee_height == 0){
  1494. console.log('開始循環入豆')
  1495. for (step = 1; step <= testing_tank_vacuum_loop; step++) {
  1496. console.log('-- 循環第 ' + step + ' 次 --');
  1497. tankVacuum('1')
  1498. console.log('tankVacuum_ON')
  1499. var time = new Date();
  1500. while ((new Date() - time) < testing_tank_vacuum_in * 1000) { };
  1501. tankVacuum('0')
  1502. console.log('tankVacuum_OFF')
  1503. var time = new Date();
  1504. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  1505. }
  1506. console.log('-- 循環入豆結束 --')
  1507. }
  1508. }
  1509. </script>
  1510. </td>
  1511. <td>
  1512. <button type="submit" class="btn btn-primary" onclick="WaterIn_testing()">入水測試</button>
  1513. <script>
  1514. var WaterIn_Process = 0; // 發酵槽入水狀態
  1515. function WaterIn_testing() {
  1516. var testing_tank_water_height = $("input[name=testing_tank_water_height]").val();
  1517. console.log('testing_tank_water_height: ' + testing_tank_water_height)
  1518. $.get('/ferment_UltraSonic_' + tank_num, '', function (res) {
  1519. if ( res.UltraSonic < testing_tank_water_height ){
  1520. console.log('開始入水')
  1521. tankSolenoidWaterIn('1');
  1522. console.log('tankSolenoidWaterIn_ON')
  1523. console.log('請開啟水龍頭進水')
  1524. var time = new Date();
  1525. while ((new Date() - time) < 1000) { };
  1526. };
  1527. }, 'json');
  1528. var WaterIn_interval = setInterval(tankWaterIn, 5000);
  1529. function tankWaterIn(){
  1530. if(WaterIn_Process == 1){
  1531. return;
  1532. }
  1533. WaterIn_Process = 1;
  1534. $.ajax({
  1535. type:"GET",
  1536. url:'/ferment_UltraSonic_' + tank_num,
  1537. dataType:'json',
  1538. success:function(response){
  1539. var present_water_height = response.UltraSonic
  1540. console.log('目前水位高度: ' + present_water_height)
  1541. if( parseInt(present_water_height) >= parseInt(testing_tank_water_height) ){
  1542. clearInterval(WaterIn_interval);
  1543. console.log('達到目標水位!')
  1544. console.log('請關閉水龍頭')
  1545. var time = new Date();
  1546. while ((new Date() - time) < 1000) { };
  1547. tankSolenoidWaterIn('0');
  1548. console.log('tankSolenoidWaterIn_OFF')
  1549. }
  1550. WaterIn_Process = 0;
  1551. },
  1552. error:function(thrownError){
  1553. console.log("Error: " + thrownError)
  1554. WaterIn_Process = 0;
  1555. }
  1556. });
  1557. WaterIn_Process = 0;
  1558. }
  1559. };
  1560. </script>
  1561. </td>
  1562. <td>
  1563. <button type="submit" class="btn btn-primary" onclick="WATER_testing()">水質測量(攪拌、加熱)</button>
  1564. <script>
  1565. function WATER_testing() {
  1566. var set_motor_rpm = $("input[name=testing_motor_rpm]").val();
  1567. var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": set_motor_rpm };
  1568. $.post('/mqtt/{{tid}}', data, function (res) {
  1569. console.log('data:', data)
  1570. if (res == 'on') {
  1571. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  1572. } else if (res == 'off') {
  1573. clearInterval(timer); // 取消 timer 的不斷執行
  1574. } else {
  1575. };
  1576. }, 'text')
  1577. // setTimeout(function () { location.reload(); }, 500);
  1578. console.log('motor rpm:' + set_motor_rpm)
  1579. var time = new Date();
  1580. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  1581. tankHeater1('1')
  1582. console.log('tankHeater1_ON')
  1583. var time = new Date();
  1584. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  1585. tankHeater2('1')
  1586. console.log('tankHeater2_ON')
  1587. console.log('暫停 5 秒鐘')
  1588. var time = new Date();
  1589. while ((new Date() - time) < 5 * 1000) { };
  1590. var testing_tank_pump_on = $("input[name=testing_tank_pump_on]").val();
  1591. var testing_tank_pump_off = $("input[name=testing_tank_pump_off]").val();
  1592. var testing_tank_pump_loop = $("input[name=testing_tank_pump_loop]").val();
  1593. for (step = 1; step <= testing_tank_pump_loop; step++) {
  1594. console.log('-- pump 循環第 ' + step + ' 次 --')
  1595. tankPumpSensor('1')
  1596. console.log('tankPumpSensor_ON')
  1597. var time = new Date();
  1598. while ((new Date() - time) < testing_tank_pump_on * 1000) { };
  1599. tankPumpSensor('0')
  1600. console.log('tankPumpSensor_OFF')
  1601. var time = new Date();
  1602. while ((new Date() - time) < testing_tank_pump_off * 1000) { };
  1603. }
  1604. console.log('暫停 5 秒鐘')
  1605. var time = new Date();
  1606. while ((new Date() - time) < 5 * 1000) { };
  1607. tankMotor('0')
  1608. console.log('tankMotor_OFF')
  1609. var time = new Date();
  1610. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  1611. tankHeater1('0')
  1612. console.log('tankHeater1_OFF')
  1613. var time = new Date();
  1614. while ((new Date() - time) < testing_tank_vacuum_out * 1000) { };
  1615. tankHeater2('0')
  1616. console.log('tankHeater2_OFF')
  1617. };
  1618. </script>
  1619. </td>
  1620. </tr>
  1621. </table>
  1622. <br>
  1623. <h4>水路排程測試</h4>
  1624. [桶外] 水位高度:<span id="WaterLevel_t_status">{{WaterLevel}}</span>
  1625. <table border="1" class="table-all" cellpadding="3">
  1626. <tr>
  1627. <td colspan="2">桶內進水</td>
  1628. <td colspan="2">桶外進水</td>
  1629. <td colspan="2">消毒/打菌</td>
  1630. <td colspan="2">感測器 pump 進水</td>
  1631. </tr>
  1632. <tr>
  1633. <td>桶內進水 ON</td>
  1634. <td>桶內進水 OFF</td>
  1635. <td>桶外進水 ON</td>
  1636. <td>桶外進水 OFF</td>
  1637. <td>消毒/打菌 ON</td>
  1638. <td>消毒/打菌 OFF</td>
  1639. <td>感測器 pump 進水 ON</td>
  1640. <td>感測器 pump 進水 OFF</td>
  1641. </tr>
  1642. <tr>
  1643. <td>桶外電磁閥 OFF<br>桶內電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font></td>
  1644. <td><font color="#FF0000">水龍頭 OFF</font><br>桶內電磁閥 OFF</td>
  1645. <td>桶內電磁閥 OFF<br>桶外電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font></td>
  1646. <td><font color="#FF0000">水龍頭 OFF</font><br>桶外電磁閥 OFF</td>
  1647. <td>消毒電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font></td>
  1648. <td><font color="#FF0000">水龍頭 OFF</font><br>消毒電磁閥 OFF</td>
  1649. <td>桶內電磁閥 ON<br>pump ON</td>
  1650. <td>pump OFF<br>桶內電磁閥 OFF</td>
  1651. </tr>
  1652. <tr>
  1653. <td>
  1654. <button type="submit" class="btn btn-primary" onclick="tank_WaterIn_ON_testing()">桶內進水 ON</button>
  1655. <script>
  1656. // 桶外電磁閥 OFF<br>桶內電磁閥 ON<br>水泵逆洗電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font>
  1657. function tank_WaterIn_ON_testing(){
  1658. outerSolenoidWater('0')
  1659. console.log('outerSolenoidWater_OFF')
  1660. var time = new Date();
  1661. while ((new Date() - time) < 1000) { };
  1662. tankSolenoidWaterIn('1')
  1663. console.log('tankSolenoidWaterIn_ON')
  1664. console.log('請開啟水龍頭進水')
  1665. }
  1666. </script>
  1667. </td>
  1668. <td>
  1669. <button type="submit" class="btn btn-primary" onclick="tank_WaterIn_OFF_testing()">桶內進水 OFF</button>
  1670. <script>
  1671. // <font color="#FF0000">水龍頭 OFF</font><br>水泵逆洗電磁閥 OFF<br>桶內電磁閥 OFF
  1672. function tank_WaterIn_OFF_testing(){
  1673. console.log('請關閉水龍頭進水')
  1674. var time = new Date();
  1675. while ((new Date() - time) < 1000) { };
  1676. tankSolenoidWaterIn('0')
  1677. console.log('tankSolenoidWaterIn_OFF')
  1678. }
  1679. </script>
  1680. </td>
  1681. <td>
  1682. <button type="submit" class="btn btn-primary" onclick="outer_WaterIn_ON_testing()">桶外進水 ON</button>
  1683. <script>
  1684. // 桶內電磁閥 OFF<br>桶外電磁閥 ON<br>水泵逆洗電磁閥 ON<br><font color="#FF0000">水龍頭 ON
  1685. function outer_WaterIn_ON_testing(){
  1686. tankSolenoidWaterIn('0')
  1687. console.log('tankSolenoidWaterIn_OFF')
  1688. var time = new Date();
  1689. while ((new Date() - time) < 1000) { };
  1690. outerSolenoidWater('1')
  1691. console.log('outerSolenoidWater_ON')
  1692. var time = new Date();
  1693. while ((new Date() - time) < 1000) { };
  1694. console.log('請開啟水龍頭進水')
  1695. }
  1696. </script>
  1697. </td>
  1698. <td>
  1699. <button type="submit" class="btn btn-primary" onclick="outer_WaterIn_OFF_testing()">桶外進水 OFF</button>
  1700. <script>
  1701. // <font color="#FF0000">水龍頭 OFF</font><br>水泵逆洗電磁閥 OFF<br>桶外電磁閥 OFF
  1702. function outer_WaterIn_OFF_testing(){
  1703. console.log('請關閉水龍頭進水')
  1704. var time = new Date();
  1705. while ((new Date() - time) < 1000) { };
  1706. outerSolenoidWater('0')
  1707. console.log('outerSolenoidWater_OFF')
  1708. }
  1709. </script>
  1710. </td>
  1711. <td>
  1712. <button type="submit" class="btn btn-primary" onclick="tank_Disinfect_ON_testing()">消毒/打菌 ON</button>
  1713. <script>
  1714. // 消毒電磁閥 ON<br><font color="#FF0000">水龍頭 ON</font>
  1715. function tank_Disinfect_ON_testing(){
  1716. tankSolenoidDisinfect('1')
  1717. console.log('tankSolenoidDisinfect_ON')
  1718. var time = new Date();
  1719. while ((new Date() - time) < 1000) { };
  1720. console.log('請開啟水龍頭進水')
  1721. }
  1722. </script>
  1723. </td>
  1724. <td>
  1725. <button type="submit" class="btn btn-primary" onclick="tank_Disinfect_OFF_testing()">消毒/打菌 OFF</button>
  1726. <script>
  1727. // <font color="#FF0000">水龍頭 OFF</font><br>消毒電磁閥 OFF
  1728. function tank_Disinfect_OFF_testing(){
  1729. console.log('請關閉水龍頭進水')
  1730. var time = new Date();
  1731. while ((new Date() - time) < 1000) { };
  1732. tankSolenoidDisinfect('0')
  1733. console.log('tankSolenoidDisinfect_OFF')
  1734. }
  1735. </script>
  1736. </td>
  1737. <td>
  1738. <button type="submit" class="btn btn-primary" onclick="tank_SensorPump_ON_testing()">感測器 pump 進水 ON</button>
  1739. <script>
  1740. // 桶內電磁閥 ON<br>pump ON
  1741. function tank_SensorPump_ON_testing(){
  1742. tankSolenoidWaterIn('1')
  1743. console.log('tankSolenoidWaterIn_ON')
  1744. var time = new Date();
  1745. while ((new Date() - time) < 2 * 1000) { };
  1746. tankPumpSensor('1')
  1747. console.log('tankPumpSensor_ON')
  1748. }
  1749. </script>
  1750. </td>
  1751. <td>
  1752. <button type="submit" class="btn btn-primary" onclick="tank_SensorPump_OFF_testing()">感測器 pump 進水 OFF</button>
  1753. <script>
  1754. // pump OFF<br>桶內電磁閥 OFF
  1755. function tank_SensorPump_OFF_testing(){
  1756. tankPumpSensor('0')
  1757. console.log('tankPumpSensor_OFF')
  1758. var time = new Date();
  1759. while ((new Date() - time) < 2 * 1000) { };
  1760. tankSolenoidWaterIn('0')
  1761. console.log('tankSolenoidWaterIn_OFF')
  1762. }
  1763. </script>
  1764. </td>
  1765. </tr>
  1766. </table>
  1767. <div id="coffee_footer">
  1768. <!-- 匯入共同使用的 footer.html 內容 -->
  1769. {% include 'footer.html' %}
  1770. </div>
  1771. </div>
  1772. </body>
  1773. </html>