1
0

dry_container_tank.html 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710
  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 dtn = '{{tid}}';
  21. var status = '{{status}}';
  22. console.log('dtn:' + dtn)
  23. $(function(){
  24. $("#coffee_title_pc").text("D" + dtn + " 乾燥槽操作介面");
  25. $("#coffee_title_phone").text("D" + dtn + " 操作介面");
  26. $("#dry_tank_page").text('乾燥槽 D' + dtn + ' 攝影機畫面')
  27. $('#dry_tank_page').attr("href", "/camera_D" + dtn)
  28. $("#dry_container_tank_title").text('乾燥槽 D' + dtn + ' 操作介面')
  29. if (status == 2) {
  30. $('input').prop('disabled', true);
  31. $('button').prop('disabled', true);
  32. } else if ( (status == 0) || (status == 1) ) {
  33. $('input').prop('disabled', false);
  34. $('button').prop('disabled', false);
  35. }
  36. });
  37. // WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 30 * 1000)
  38. </script>
  39. <script>
  40. // Rita 致動器運作
  41. var tank_num = '{{tid}}';
  42. function tankVacuum(params) {
  43. if (params == '1') {
  44. var data = { "tank_num": "D" + tank_num, "command": "tank_vacuum_status", "value": "on" };
  45. } else if (params == '0') {
  46. var data = { "tank_num": "D" + tank_num, "command": "tank_vacuum_status", "value": "off" };
  47. } else {
  48. var status = "off";
  49. var check = $("input[name=tank_vacuum_status]:checked");
  50. console.log('check:', check);
  51. //大於0代表有被選中
  52. if (check.length > 0) {
  53. status = "on";
  54. $("#cmn-toggle-05").prop('checked', false);
  55. if (!confirm("你確定要開啟真空吸料機嗎?")) {
  56. return false;
  57. };
  58. } else {
  59. $("#cmn-toggle-05").prop('checked', true);
  60. if (!confirm("你確定要關閉真空吸料機嗎?")) {
  61. return false;
  62. };
  63. };
  64. var data = { "tank_num": "D" + tank_num, "command": "tank_vacuum_status", "value": status };
  65. }
  66. $.post('/mqtt/{{tid}}', data, function (res) {
  67. console.log('data:', data)
  68. if (res == 'on') {
  69. $("#cmn-toggle-05").prop('checked', true);
  70. } else if (res == 'off') {
  71. $("#cmn-toggle-05").prop('checked', false);
  72. } else {
  73. console.log(res)
  74. };
  75. }, 'text')
  76. }
  77. function tankThreeWayValveInput(params) {
  78. if (params == '1') {
  79. var data = { "tank_num": "D" + tank_num, "command": "tank_threewayvalve_input_status", "value": "on" };
  80. } else if (params == '0') {
  81. var data = { "tank_num": "D" + tank_num, "command": "tank_threewayvalve_input_status", "value": "off" };
  82. } else {
  83. var status = "off";
  84. var check = $("input[name=tank_threewayvalve_input_status]:checked");
  85. if (check.length > 0) {
  86. status = "on";
  87. $("#cmn-toggle-08").prop('checked', false);
  88. if (!confirm("你確定要開啟入料三通閥嗎?")) {
  89. return false;
  90. };
  91. } else {
  92. $("#cmn-toggle-08").prop('checked', true);
  93. if (!confirm("你確定要關閉入料三通閥嗎?")) {
  94. return false;
  95. };
  96. };
  97. var data = { "tank_num": "D" + tank_num, "command": "tank_threewayvalve_input_status", "value": status };
  98. }
  99. $.post('/mqtt/{{tid}}', data, function (res) {
  100. console.log('data:', data)
  101. if (res == 'on') {
  102. $("#cmn-toggle-08").prop('checked', true);
  103. } else if (res == 'off') {
  104. $("#cmn-toggle-08").prop('checked', false);
  105. } else {
  106. console.log(res)
  107. };
  108. }, 'text')
  109. }
  110. function tankThreeWayValveBean(params) {
  111. if (params == '1') {
  112. var data = { "tank_num": "D" + tank_num, "command": "tank_threewayvalve_bean_status", "value": "on" };
  113. } else if (params == '0') {
  114. var data = { "tank_num": "D" + tank_num, "command": "tank_threewayvalve_bean_status", "value": "off" };
  115. } else {
  116. var status = "off";
  117. var check = $("input[name=tank_threewayvalve_bean_status]:checked");
  118. if (check.length > 0) {
  119. status = "on";
  120. $("#cmn-toggle-38").prop('checked', false);
  121. if (!confirm("你確定要開啟測豆三通閥嗎?")) {
  122. return false;
  123. };
  124. } else {
  125. $("#cmn-toggle-38").prop('checked', true);
  126. if (!confirm("你確定要關閉測豆三通閥嗎?")) {
  127. return false;
  128. };
  129. };
  130. var data = { "tank_num": "D" + tank_num, "command": "tank_threewayvalve_bean_status", "value": status };
  131. }
  132. $.post('/mqtt/{{tid}}', data, function (res) {
  133. console.log('data:', data)
  134. if (res == 'on') {
  135. $("#cmn-toggle-38").prop('checked', true);
  136. } else if (res == 'off') {
  137. $("#cmn-toggle-38").prop('checked', false);
  138. } else {
  139. console.log(res)
  140. };
  141. }, 'text')
  142. }
  143. function tankDiskValve(params) {
  144. if (params == '1') {
  145. var data = { "tank_num": "D" + tank_num, "command": "tank_diskvalve_status", "value": "on" };
  146. } else if (params == '0') {
  147. var data = { "tank_num": "D" + tank_num, "command": "tank_diskvalve_status", "value": "off" };
  148. } else {
  149. var status = "off";
  150. var check = $("input[name=tank_diskvalve_status]:checked");
  151. if (check.length > 0) {
  152. status = "on";
  153. $("#cmn-toggle-11").prop('checked', false);
  154. if (!confirm("你確定要開啟蝴蝶閥嗎?")) {
  155. return false;
  156. };
  157. } else {
  158. $("#cmn-toggle-11").prop('checked', true);
  159. if (!confirm("你確定要關閉蝴蝶閥嗎?")) {
  160. return false;
  161. };
  162. };
  163. var data = { "tank_num": "D" + tank_num, "command": "tank_diskvalve_status", "value": status };
  164. }
  165. $.post('/mqtt/{{tid}}', data, function (res) {
  166. console.log('data:', data)
  167. if (res == 'on') {
  168. $("#cmn-toggle-11").prop('checked', true);
  169. } else if (res == 'off') {
  170. $("#cmn-toggle-11").prop('checked', false);
  171. } else {
  172. console.log(res)
  173. };
  174. }, 'text')
  175. }
  176. function tankSolenoidDisinfect(params) {
  177. if (params == '1') {
  178. var data = { "tank_num": "D" + tank_num, "command": "tank_solenoid_disinfect_status", "value": "on" };
  179. } else if (params == '0') {
  180. var data = { "tank_num": "D" + tank_num, "command": "tank_solenoid_disinfect_status", "value": "off" };
  181. } else {
  182. var status = "off";
  183. var check = $("input[name=tank_solenoid_disinfect_status]:checked");
  184. if (check.length > 0) {
  185. status = "on";
  186. $("#cmn-toggle-14").prop('checked', false);
  187. if (!confirm("你確定要開啟電磁閥消毒嗎?")) {
  188. return false;
  189. };
  190. } else {
  191. $("#cmn-toggle-14").prop('checked', true);
  192. if (!confirm("你確定要關閉消毒電磁閥嗎?")) {
  193. return false;
  194. };
  195. };
  196. var data = { "tank_num": "D" + tank_num, "command": "tank_solenoid_disinfect_status", "value": status };
  197. }
  198. $.post('/mqtt/{{tid}}', data, function (res) {
  199. console.log('data:', data)
  200. if (res == 'on') {
  201. $("#cmn-toggle-14").prop('checked', true);
  202. } else if (res == 'off') {
  203. $("#cmn-toggle-14").prop('checked', false);
  204. } else {
  205. console.log(res)
  206. };
  207. }, 'text')
  208. }
  209. function tankSolenoidWater(params) {
  210. if (params == '1') {
  211. var data = { "tank_num": "D" + tank_num, "command": "tank_solenoid_water_status", "value": "on" };
  212. } else if (params == '0') {
  213. var data = { "tank_num": "D" + tank_num, "command": "tank_solenoid_water_status", "value": "off" };
  214. } else {
  215. var status = "off";
  216. var check = $("input[name=tank_solenoid_water_status]:checked");
  217. if (check.length > 0) {
  218. status = "on";
  219. $("#cmn-toggle-17").prop('checked', false);
  220. if (!confirm("你確定要開啟電磁閥排水嗎?")) {
  221. return false;
  222. };
  223. } else {
  224. $("#cmn-toggle-17").prop('checked', true);
  225. if (!confirm("你確定要關閉排水電磁閥嗎?")) {
  226. return false;
  227. };
  228. };
  229. var data = { "tank_num": "D" + tank_num, "command": "tank_solenoid_water_status", "value": status };
  230. }
  231. $.post('/mqtt/{{tid}}', data, function (res) {
  232. console.log('data:', data)
  233. if (res == 'on') {
  234. $("#cmn-toggle-17").prop('checked', true);
  235. } else if (res == 'off') {
  236. $("#cmn-toggle-17").prop('checked', false);
  237. } else {
  238. console.log(res)
  239. };
  240. }, 'text')
  241. }
  242. function tankSolenoidOuterWaterIn(params) {
  243. if (params == '1') {
  244. var data = { "tank_num": "D" + tank_num, "command": "outer_solenoid_water_status", "value": "on" };
  245. } else if (params == '0') {
  246. var data = { "tank_num": "D" + tank_num, "command": "outer_solenoid_water_status", "value": "off" };
  247. } else {
  248. var status = "off";
  249. var check = $("input[name=tank_outer_solenoid_water_status]:checked");
  250. if (check.length > 0) {
  251. status = "on";
  252. $("#cmn-toggle-41").prop('checked', false);
  253. if (!confirm("你確定要開啟夾層進水電磁閥嗎?")) {
  254. return false;
  255. };
  256. } else {
  257. $("#cmn-toggle-41").prop('checked', true);
  258. if (!confirm("你確定要關閉夾層進水電磁閥嗎?")) {
  259. return false;
  260. };
  261. };
  262. var data = { "tank_num": "D" + tank_num, "command": "outer_solenoid_water_status", "value": status };
  263. }
  264. $.post('/mqtt/{{tid}}', data, function (res) {
  265. console.log('data:', data)
  266. if (res == 'on') {
  267. $("#cmn-toggle-41").prop('checked', true);
  268. } else if (res == 'off') {
  269. $("#cmn-toggle-41").prop('checked', false);
  270. } else {
  271. console.log(res)
  272. };
  273. }, 'text')
  274. }
  275. // Benson cargo2_actuator.html 閥 (END) 電磁閥排水
  276. /*
  277. function Motor() {
  278. $.get('/peeling', '', function (res) {
  279. //console.log(res.peeling);
  280. $("#motor_encoder_status").text(res.peeling + ' rpm(每1分鐘更新一次)');
  281. }, 'json');
  282. };
  283. function ChangeMotor() {
  284. var motor_data = $("input[name=tank_motor_status]").val();
  285. if (!confirm("你確定要更改轉速為" + motor_data + "嗎?")) {
  286. return false;
  287. };
  288. var data = { "tank_num": "D" + tank_num, "command": "tank_motor_status", "value": motor_data };
  289. console.log('data:', data)
  290. $.post('/mqtt/{{tid}}', data, function (res) {
  291. if (res == 'on') {
  292. alert('更改成功');
  293. } else {
  294. alert(res);
  295. };
  296. }, 'text');
  297. setTimeout(function(){ location.reload(); }, 500);
  298. };
  299. */
  300. function tankMotor_set() {
  301. var motor_data = $("input[id=motor_rpm_data]").val();
  302. if (motor_data == '') {
  303. alert("請先輸入要運轉的值!");
  304. return false;
  305. } else if (motor_data == 0) {
  306. alert("轉速 0 為關閉馬達");
  307. } else if (Number(motor_data) < -50 || Number(motor_data) > 50 || !Number(motor_data)) {
  308. alert("您輸入的值已超過範圍,請重新輸入! " + !Number(motor_data));
  309. return false;
  310. };
  311. if (motor_data != 0) {
  312. if (!confirm("你確定要開啟攪拌馬達,運轉速度為 " + motor_data + " RPM 嗎?")) {
  313. return false;
  314. };
  315. } else {
  316. if (!confirm("你確定要關閉攪拌馬達嗎?")) {
  317. return false;
  318. };
  319. };
  320. var data = { "tank_num": "D" + tank_num, "command": "tank_motor_status", "value": motor_data };
  321. $.post('/mqtt/{{tid}}', data, function (res) {
  322. console.log('data:', data)
  323. if (res == 'on') {
  324. //$("#cmn-toggle-14").prop('checked', true); // prop 設置元素屬型與元素值, 設定 checked 屬性為 true
  325. setTimeout("alert('攪拌馬達_開啟成功!')", 500); // 設定時間 delay(500) 執行函式, 只執行一次
  326. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行
  327. } else if (res == 'off') {
  328. //$("#cmn-toggle-14").prop('checked', false);
  329. setTimeout("alert('攪拌馬達_關閉成功!')", 500);
  330. clearInterval(timer); // 取消 timer 的不斷執行
  331. $("#motor_encoder_status").text(''); // 設置 #motor_encoder_status 的文字為空, #井字號
  332. } else {
  333. alert(res);
  334. };
  335. }, 'text')
  336. };
  337. function tankMotor(params) {
  338. var data = { "tank_num": "D" + tank_num, "command": "tank_motor_status", "value": params };
  339. $.post('/mqtt/' + tank_num, data, function (res) {
  340. console.log('data:', data)
  341. if (res == 'on') {
  342. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  343. } else if (res == 'off') {
  344. clearInterval(timer)
  345. $("#motor_encoder_status").text(''); // 設置 #motor_encoder_status 的文字為空, #井字號
  346. } else {
  347. console.log(res)
  348. };
  349. }, 'text')
  350. $.get('/loading/D' + tank_num, '', function (res) {
  351. $("#motor_rpm_data").attr("placeholder", res.tank_motor)
  352. }, 'json');
  353. };
  354. function Rotate() {
  355. $.get('/peel', '', function (res) {
  356. console.log("res.peeling: " + res.peeling);
  357. $("#motor_encoder_status").text(res.peeling + ' rpm<br>(每1分鐘更新一次)');
  358. }, 'json');
  359. setTimeout(function () { location.reload(); }, 500);
  360. };
  361. function tankBlower(params) {
  362. if (params == '1') {
  363. var data = { "tank_num": "D" + tank_num, "command": "tank_blower_status", "value": "on" };
  364. } else if (params == '0') {
  365. var data = { "tank_num": "D" + tank_num, "command": "tank_blower_status", "value": "off" };
  366. } else {
  367. var status = "off";
  368. var check = $("input[name=tank_blower_status]:checked");
  369. if (check.length > 0) {
  370. status = "on";
  371. $("#cmn-toggle-23").prop('checked', false);
  372. if (!confirm("你確定要開啟鼓風機嗎?")) {
  373. return false;
  374. };
  375. } else {
  376. $("#cmn-toggle-23").prop('checked', true);
  377. if (!confirm("你確定要關閉鼓風機嗎?")) {
  378. return false;
  379. };
  380. };
  381. var data = { "tank_num": "D" + tank_num, "command": "tank_blower_status", "value": status };
  382. }
  383. $.post('/mqtt/{{tid}}', data, function (res) {
  384. console.log('data:', data)
  385. if (res == 'on') {
  386. $("#cmn-toggle-23").prop('checked', true);
  387. } else if (res == 'off') {
  388. $("#cmn-toggle-23").prop('checked', false);
  389. } else {
  390. console.log(res)
  391. };
  392. }, 'text')
  393. }
  394. function tankHeater1(params) {
  395. if (params == '1') {
  396. var data = { "tank_num": "D" + tank_num, "command": "tank_heater1_status", "value": "on" };
  397. } else if (params == '0') {
  398. var data = { "tank_num": "D" + tank_num, "command": "tank_heater1_status", "value": "off" };
  399. } else {
  400. var status = "off";
  401. var check = $("input[name=tank_heater1_status]:checked");
  402. if (check.length > 0) {
  403. status = "on";
  404. $("#cmn-toggle-26").prop('checked', false);
  405. if (!confirm("你確定要開啟電熱管1嗎?")) {
  406. return false;
  407. };
  408. } else {
  409. $("#cmn-toggle-26").prop('checked', true);
  410. if (!confirm("你確定要關閉電熱管1嗎?")) {
  411. return false;
  412. };
  413. };
  414. var data = { "tank_num": "D" + tank_num, "command": "tank_heater1_status", "value": status };
  415. }
  416. $.post('/mqtt/{{tid}}', data, function (res) {
  417. console.log('data:', data)
  418. if (res == 'on') {
  419. $("#cmn-toggle-26").prop('checked', true);
  420. } else if (res == 'off') {
  421. $("#cmn-toggle-26").prop('checked', false);
  422. } else {
  423. console.log(res)
  424. };
  425. }, 'text')
  426. }
  427. function tankHeater2(params) {
  428. if (params == '1') {
  429. var data = { "tank_num": "D" + tank_num, "command": "tank_heater2_status", "value": "on" };
  430. } else if (params == '0') {
  431. var data = { "tank_num": "D" + tank_num, "command": "tank_heater2_status", "value": "off" };
  432. } else {
  433. var status = "off";
  434. var check = $("input[name=tank_heater2_status]:checked");
  435. if (check.length > 0) {
  436. status = "on";
  437. $("#cmn-toggle-29").prop('checked', false);
  438. if (!confirm("你確定要開啟電熱管2嗎?")) {
  439. return false;
  440. };
  441. } else {
  442. $("#cmn-toggle-29").prop('checked', true);
  443. if (!confirm("你確定要關閉電熱管2嗎?")) {
  444. return false;
  445. };
  446. };
  447. var data = { "tank_num": "D" + tank_num, "command": "tank_heater2_status", "value": status };
  448. }
  449. $.post('/mqtt/{{tid}}', data, function (res) {
  450. console.log('data:', data)
  451. if (res == 'on') {
  452. $("#cmn-toggle-29").prop('checked', true);
  453. } else if (res == 'off') {
  454. $("#cmn-toggle-29").prop('checked', false);
  455. } else {
  456. console.log(res)
  457. };
  458. }, 'text')
  459. }
  460. function tankTemp1Enable(params) {
  461. if (params == '1') {
  462. var data = { "tank_num": "D" + tank_num, "command": "temp1_enable", "value": "on" };
  463. } else if (params == '0') {
  464. var data = { "tank_num": "D" + tank_num, "command": "temp1_enable", "value": "off" };
  465. } else {
  466. var status = "off";
  467. var check = $("input[name=tank_temp1_enable_status]:checked");
  468. if (check.length > 0) {
  469. status = "on";
  470. $("#cmn-toggle-35").prop('checked', false);
  471. if (!confirm("你確定要開啟溫度控制嗎?")) {
  472. return false;
  473. };
  474. } else {
  475. $("#cmn-toggle-35").prop('checked', true);
  476. if (!confirm("你確定要關閉溫度控制嗎?")) {
  477. return false;
  478. };
  479. };
  480. var data = { "tank_num": "D" + tank_num, "command": "temp1_enable", "value": status };
  481. }
  482. $.post('/mqtt/{{tid}}', data, function (res) {
  483. console.log('data:', data)
  484. if (res == 'on') {
  485. $("#cmn-toggle-35").prop('checked', true);
  486. } else if (res == 'off') {
  487. $("#cmn-toggle-35").prop('checked', false);
  488. } else {
  489. console.log(res)
  490. };
  491. }, 'text')
  492. }
  493. /* 判斷是否整數
  494. function isInteger(obj) {
  495. return obj % 1 === 0
  496. }
  497. isInteger(3) // true
  498. */
  499. // 設定溫度
  500. /*
  501. <h2>溫度控制設定(單位 ℃):(目前設定溫度) {{tank_temp1}}</h2>
  502. <input name="tank_temp1_data" type="text" placeholder="{{tank_temp1}}" style="width: 40px;">℃ (限整數數值)
  503. <span id="tank_temp1_status" style="color:red;"></span>
  504. <input type="button" value="送出(設定溫度時請點擊)" name="tank_temp1_status" onclick="ChangeTemp1()">
  505. */
  506. function tankTemp1_set() {
  507. var temp_data = $("input[id=tank_temp1_data]").val();
  508. if (temp_data == '') {
  509. alert("請先輸入設定溫度!");
  510. return false;
  511. }
  512. var value = "0";
  513. if ($("#cmn-toggle-35").prop('checked')) {
  514. value = temp_data;
  515. if (!confirm("你確定要設定內桶溫度為 " + temp_data + " ℃ 嗎?")) {
  516. return false;
  517. };
  518. } else {
  519. if (!confirm("請先開啟溫控開關, 再設定桶內溫度")) {
  520. return false;
  521. };
  522. };
  523. var data = { "tank_num": "D" + tank_num, "command": "tank_temp", "value": temp_data };
  524. $.post('/mqtt/{{tid}}', data, function (res) {
  525. console.log('data:', data)
  526. if (res == 'on') {
  527. setTimeout("alert('溫度設定_開啟成功!')", 500); // 設定時間執行函式 delay(500), 只執行一次
  528. } else if (res == 'off') {
  529. setTimeout("alert('溫度設定_關閉成功!')", 500);
  530. } else {
  531. alert(res);
  532. };
  533. }, 'text')
  534. };
  535. function tankTemp1(params) {
  536. var data = { "tank_num": "D" + tank_num, "command": "tank_temp", "value": params };
  537. $.post('/mqtt/{{tid}}', data, function (res) {
  538. console.log('data:', data)
  539. }, 'text')
  540. };
  541. </script>
  542. <script language="JavaScript">
  543. function changeUpdate() {
  544. clearInterval(WebUpdate_set);
  545. var webupdate_time = $("input[name=webupdate_time]").val()
  546. console.log('webupdate_time' + webupdate_time)
  547. WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , webupdate_time * 1000);
  548. }
  549. // jQuery 更新感測器致動器狀態
  550. function WebUpdate(dtn) {
  551. $.get('/loading/D' + dtn, '', function (res) {
  552. if (res.tank_vacuum == 0) {
  553. $("#cmn-toggle-05").prop('checked', false);
  554. } else if (res.tank_vacuum == 1) {
  555. $("#cmn-toggle-05").prop('checked', true);
  556. }
  557. if (res.tank_threewayvalve_input == 0) {
  558. $("#cmn-toggle-08").prop('checked', false);
  559. } else if (res.tank_threewayvalve_input == 1) {
  560. $("#cmn-toggle-08").prop('checked', true);
  561. }
  562. if (res.tank_threewayvalve_bean == 0) {
  563. $("#cmn-toggle-38").prop('checked', false);
  564. } else if (res.tank_threewayvalve_bean == 1) {
  565. $("#cmn-toggle-38").prop('checked', true);
  566. }
  567. if (res.tank_diskvalve == 0) {
  568. $("#cmn-toggle-11").prop('checked', false);
  569. } else if (res.tank_diskvalve == 1) {
  570. $("#cmn-toggle-11").prop('checked', true);
  571. }
  572. if (res.tank_solenoid_disinfect == 0) {
  573. $("#cmn-toggle-14").prop('checked', false);
  574. } else if (res.tank_solenoid_disinfect == 1) {
  575. $("#cmn-toggle-14").prop('checked', true);
  576. }
  577. if (res.tank_solenoid_water == 0) {
  578. $("#cmn-toggle-17").prop('checked', false);
  579. } else if (res.tank_solenoid_water == 1) {
  580. $("#cmn-toggle-17").prop('checked', true);
  581. }
  582. if (res.tank_solenoid_outer_water == 0) {
  583. $("#cmn-toggle-41").prop('checked', false);
  584. } else if (res.tank_solenoid_outer_water == 1) {
  585. $("#cmn-toggle-41").prop('checked', true);
  586. }
  587. if (res.tank_blower == 0) {
  588. $("#cmn-toggle-23").prop('checked', false);
  589. } else if (res.tank_blower == 1) {
  590. $("#cmn-toggle-23").prop('checked', true);
  591. }
  592. if (res.tank_heater1 == 0) {
  593. $("#cmn-toggle-26").prop('checked', false);
  594. } else if (res.tank_heater1 == 1) {
  595. $("#cmn-toggle-26").prop('checked', true);
  596. }
  597. if (res.tank_heater2 == 0) {
  598. $("#cmn-toggle-29").prop('checked', false);
  599. } else if (res.tank_heater2 == 1) {
  600. $("#cmn-toggle-29").prop('checked', true);
  601. }
  602. if (res.tank_temp1_enable == 0) {
  603. $("#cmn-toggle-35").prop('checked', false);
  604. } else if (res.tank_temp1_enable == 1) {
  605. $("#cmn-toggle-35").prop('checked', true);
  606. }
  607. $("#motor_rpm_data").attr("placeholder", res.tank_motor);
  608. $("#tank_temp1_data").attr("placeholder", res.tank_temp1);
  609. $("#UltraSonic_t_status").text(res.UltraSonic);
  610. $("#SHT11_Temp_t_status").text(res.SHT11_Temp);
  611. $("#SHT11_Humidity_t_status").text(res.SHT11_Humidity);
  612. $("#soil_Temp_t_status").text(res.soil_Temp);
  613. $("#soil_Humidity_t_status").text(res.soil_Humidity);
  614. $("#soil_EC_t_status").text(res.soil_EC);
  615. $("#PA_t_status").text(res.PA);
  616. var present_SHT11_Temp = res.SHT11_Temp
  617. var present_SOIL_Temp = res.soil_Temp
  618. var Temp_Weights_SHT11 = parseFloat($("#Temp_Weights_SHT11").val());
  619. var Temp_Weights_Soil = parseFloat($("#Temp_Weights_Soil").val());
  620. present_temp = Math.round((present_SHT11_Temp*Temp_Weights_SHT11 + present_SOIL_Temp*Temp_Weights_Soil)/(Temp_Weights_SHT11+Temp_Weights_Soil)*100) / 100
  621. $("#testing_Temp_Weight").text(present_temp);
  622. var float_SHT11_Temp = parseFloat(res.SHT11_Temp);
  623. }, 'json');
  624. }
  625. </script>
  626. </head>
  627. <body>
  628. <div id="wrapper">
  629. <div id="coffee_header">
  630. <!-- 匯入共同使用的 header.html 內容 -->
  631. {% include 'header.html' %}
  632. </div>
  633. <h4>致動器</h4>
  634. <table border="1" class="table-all" cellpadding="5" style="text-align: center;">
  635. <tr>
  636. <td style="color:red;">Valve</td>
  637. <td>真空吸料機</td>
  638. <td>吸料機<br>三通閥</td>
  639. <td>測豆<br>三通閥</td>
  640. <td>夾層進水<br>電磁閥</td>
  641. <td>馬達</td>
  642. <td>鼓風機</td>
  643. <td>加熱器 1</td>
  644. <td>加熱器 2</td>
  645. <td>溫控開關</td>
  646. <td>溫度設定</td>
  647. <td>排水<br>電磁閥</td>
  648. <td>消毒<br>電磁閥</td>
  649. <td>蝴蝶閥</td>
  650. </tr>
  651. <tr>
  652. <td>
  653. <span style="color:#C0C0C0;">off</span>
  654. <span style="color:#008CBA;">on</span>
  655. </td>
  656. <td>
  657. <div class="switch_div">
  658. <div class="switch">
  659. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-04">
  660. </div>
  661. <div class="switch text-center">
  662. {% if tank_vacuum == 1 %}
  663. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-05" checked
  664. name="tank_vacuum_status" value="ON" onclick="tankVacuum()">
  665. {% else %}
  666. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-05"
  667. name="tank_vacuum_status" value="OFF" onclick="tankVacuum()">
  668. {% endif %}
  669. <label class="label_ActuatorStatus" for="cmn-toggle-05"></label>
  670. </div>
  671. <div class="switch">
  672. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-06">
  673. </div>
  674. </div>
  675. </td>
  676. <td>
  677. <div class="switch_div">
  678. <div class="switch">
  679. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-07">
  680. </div>
  681. <div class="switch text-center">
  682. {% if tank_threewayvalve_input == 1 %}
  683. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-08" checked
  684. name="tank_threewayvalve_input_status" value="ON" onclick="tankThreeWayValveInput()">
  685. {% else %}
  686. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-08"
  687. name="tank_threewayvalve_input_status" value="OFF" onclick="tankThreeWayValveInput()">
  688. {% endif %}
  689. <label class="label_ActuatorStatus" for="cmn-toggle-08"></label>
  690. </div>
  691. <div class="switch">
  692. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-09">
  693. </div>
  694. </div>
  695. </td>
  696. <td>
  697. <div class="switch_div">
  698. <div class="switch">
  699. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-37">
  700. </div>
  701. <div class="switch text-center">
  702. {% if tank_threewayvalve_bean == 1 %}
  703. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-38" checked
  704. name="tank_threewayvalve_bean_status" value="ON" onclick="tankThreeWayValveBean()">
  705. {% else %}
  706. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-38"
  707. name="tank_threewayvalve_bean_status" value="OFF" onclick="tankThreeWayValveBean()">
  708. {% endif %}
  709. <label class="label_ActuatorStatus" for="cmn-toggle-38"></label>
  710. </div>
  711. <div class="switch">
  712. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-39">
  713. </div>
  714. </div>
  715. </td>
  716. <td>
  717. <div class="switch_div">
  718. <div class="switch">
  719. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-40">
  720. </div>
  721. <div class="switch text-center">
  722. {% if tank_solenoid_outer_water == 1 %}
  723. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-41" checked
  724. name="tank_outer_solenoid_water_status" value="ON" onclick="tankSolenoidOuterWaterIn()">
  725. {% else %}
  726. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-41"
  727. name="tank_outer_solenoid_water_status" value="OFF" onclick="tankSolenoidOuterWaterIn()">
  728. {% endif %}
  729. <label class="label_ActuatorStatus" for="cmn-toggle-41"></label>
  730. </div>
  731. <div class="switch">
  732. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-42">
  733. </div>
  734. </div>
  735. </td>
  736. <td>
  737. <input type="text" class="input-text" id="motor_rpm_data" placeholder="{{tank_motor}}" value="">RPM<br>
  738. <input type="button" class="input-button" value="Confirm" onclick="tankMotor_set()">
  739. </td>
  740. <td>
  741. <div class="switch_div">
  742. <div class="switch">
  743. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-22">
  744. </div>
  745. <div class="switch text-center">
  746. {% if tank_blower == 1 %}
  747. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-23" checked
  748. name="tank_blower_status" value="ON" onclick="tankBlower()">
  749. {% else %}
  750. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-23"
  751. name="tank_blower_status" value="OFF" onclick="tankBlower()">
  752. {% endif %}
  753. <label class="label_ActuatorStatus" for="cmn-toggle-23"></label>
  754. </div>
  755. <div class="switch">
  756. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-24">
  757. </div>
  758. </div>
  759. </td>
  760. <td>
  761. <div class="switch_div">
  762. <div class="switch">
  763. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-25">
  764. </div>
  765. <div class="switch text-center">
  766. {% if tank_heater1 == 1 %}
  767. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-26" checked
  768. name="tank_heater1_status" value="ON" onclick="tankHeater1()">
  769. {% else %}
  770. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-26"
  771. name="tank_heater1_status" value="OFF" onclick="tankHeater1()">
  772. {% endif %}
  773. <label class="label_ActuatorStatus" for="cmn-toggle-26"></label>
  774. </div>
  775. <div class="switch">
  776. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-27">
  777. </div>
  778. </div>
  779. </td>
  780. <td>
  781. <div class="switch_div">
  782. <div class="switch">
  783. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-28">
  784. </div>
  785. <div class="switch text-center">
  786. {% if tank_heater2== 1 %}
  787. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-29" checked
  788. name="tank_heater2_status" value="ON" onclick="tankHeater2()">
  789. {% else %}
  790. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-29"
  791. name="tank_heater2_status" value="OFF" onclick="tankHeater2()">
  792. {% endif %}
  793. <label class="label_ActuatorStatus" for="cmn-toggle-29"></label>
  794. </div>
  795. <div class="switch">
  796. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-30">
  797. </div>
  798. </div>
  799. </td>
  800. <td>
  801. <div class="switch_div">
  802. <div class="switch">
  803. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-34">
  804. </div>
  805. <div class="switch text-center">
  806. {% if tank_temp1_enable== 1 %}
  807. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-35" checked
  808. name="tank_temp1_enable_status" value="ON" onclick="tankTemp1Enable()">
  809. {% else %}
  810. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-35"
  811. name="tank_temp1_enable_status" value="OFF" onclick="tankTemp1Enable()">
  812. {% endif %}
  813. <label class="label_ActuatorStatus" for="cmn-toggle-35"></label>
  814. </div>
  815. <div class="switch">
  816. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-36">
  817. </div>
  818. </div>
  819. </td>
  820. <td>
  821. <input type="text" class="input-text" id="tank_temp1_data" placeholder="{{tank_temp1}}" value="">℃
  822. <br>
  823. <span id="tank_temp1_status" style="color:red;"></span>
  824. <input type="button" class="input-button" value="Confirm" onclick="tankTemp1_set()">
  825. </td>
  826. <td>
  827. <div class="switch_div">
  828. <div class="switch">
  829. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-16">
  830. </div>
  831. <div class="switch text-center">
  832. {% if tank_solenoid_water== 1 %}
  833. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-17" checked
  834. name="tank_solenoid_water_status" value="ON" onclick="tankSolenoidWater()">
  835. {% else %}
  836. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-17"
  837. name="tank_solenoid_water_status" value="OFF" onclick="tankSolenoidWater()">
  838. {% endif %}
  839. <label class="label_ActuatorStatus" for="cmn-toggle-17"></label>
  840. </div>
  841. <div class="switch">
  842. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-18">
  843. </div>
  844. </div>
  845. </td>
  846. <td>
  847. <div class="switch_div">
  848. <div class="switch">
  849. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-13">
  850. </div>
  851. <div class="switch text-center">
  852. {% if tank_solenoid_disinfect == 1 %}
  853. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-14" checked
  854. name="tank_solenoid_disinfect_status" value="ON" onclick="tankSolenoidDisinfect()">
  855. {% else %}
  856. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-14"
  857. name="tank_solenoid_disinfect_status" value="OFF" onclick="tankSolenoidDisinfect()">
  858. {% endif %}
  859. <label class="label_ActuatorStatus" for="cmn-toggle-14"></label>
  860. </div>
  861. <div class="switch">
  862. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-15">
  863. </div>
  864. </div>
  865. </td>
  866. <td>
  867. <div class="switch_div">
  868. <div class="switch">
  869. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-10">
  870. </div>
  871. <div class="switch text-center">
  872. {% if tank_diskvalve== 1 %}
  873. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-11" checked
  874. name="tank_diskvalve_status" value="ON" onclick="tankDiskValve()">
  875. {% else %}
  876. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-11"
  877. name="tank_diskvalve_status" value="OFF" onclick="tankDiskValve()">
  878. {% endif %}
  879. <label class="label_ActuatorStatus" for="cmn-toggle-11"></label>
  880. </div>
  881. <div class="switch">
  882. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-12">
  883. </div>
  884. </div>
  885. </td>
  886. </tr>
  887. <tr>
  888. <td><span style="color:#008CBA;"><b>ON</b></span></td>
  889. <td><input type="button" class="input-button-on" value="ON" onclick="tankVacuum('1')"></td>
  890. <td><input type="button" class="input-button-on" value="ON" onclick="tankThreeWayValveInput('1')"></td>
  891. <td><input type="button" class="input-button-on" value="ON" onclick="tankThreeWayValveBean('1')"></td>
  892. <td><input type="button" class="input-button-on" value="ON" onclick="tankSolenoidOuterWaterIn('1')"></td>
  893. <td><input type="button" class="input-button-on" value="30" onclick="tankMotor('30')"></td>
  894. <td><input type="button" class="input-button-on" value="ON" onclick="tankBlower('1')"></td>
  895. <td><input type="button" class="input-button-on" value="ON" onclick="tankHeater1('1')"></td>
  896. <td><input type="button" class="input-button-on" value="ON" onclick="tankHeater2('1')"></td>
  897. <td><input type="button" class="input-button-on" value="ON" onclick="tankTemp1Enable('1')"></td>
  898. <td><input type="button" class="input-button-on" value="30.0" onclick="tankTemp1('30.0')"></td>
  899. <td><input type="button" class="input-button-on" value="ON" onclick="tankSolenoidWater('1')"></td>
  900. <td><input type="button" class="input-button-on" value="ON" onclick="tankSolenoidDisinfect('1')"></td>
  901. <td><input type="button" class="input-button-on" value="ON" onclick="tankDiskValve('1')"></td>
  902. </tr>
  903. <tr>
  904. <td><span style="color:#C0C0C0;"><b>OFF</b></span></td>
  905. <td><input type="button" class="input-button-off" value="OFF" onclick="tankVacuum('0')"></td>
  906. <td><input type="button" class="input-button-off" value="OFF" onclick="tankThreeWayValveInput('0')"></td>
  907. <td><input type="button" class="input-button-off" value="OFF" onclick="tankThreeWayValveBean('0')"></td>
  908. <td><input type="button" class="input-button-off" value="OFF" onclick="tankSolenoidOuterWaterIn('0')"></td>
  909. <td><input type="button" class="input-button-off" value="0" onclick="tankMotor('0')"></td>
  910. <td><input type="button" class="input-button-off" value="OFF" onclick="tankBlower('0')"></td>
  911. <td><input type="button" class="input-button-off" value="OFF" onclick="tankHeater1('0')"></td>
  912. <td><input type="button" class="input-button-off" value="OFF" onclick="tankHeater2('0')"></td>
  913. <td><input type="button" class="input-button-off" value="OFF" onclick="tankTemp1Enable('0')"></td>
  914. <td><input type="button" class="input-button-off" value="0.0" onclick="tankTemp1('0.0')"></td>
  915. <td><input type="button" class="input-button-off" value="OFF" onclick="tankSolenoidWater('0')"></td>
  916. <td><input type="button" class="input-button-off" value="OFF" onclick="tankSolenoidDisinfect('0')"></td>
  917. <td><input type="button" class="input-button-off" value="OFF" onclick="tankDiskValve('0')"></td>
  918. </tr>
  919. </table>
  920. <br>
  921. <h4>感測器</h4>
  922. <table border="1" class="table-all" cellpadding="5">
  923. <tr>
  924. <td style="background-color:#f3f3f3">生豆高度</td>
  925. <td><span id="UltraSonic_t_status">{{tank_UltraSonic.UltraSonic}}</span> 公分</td>
  926. <td style="background-color:#f3f3f3">馬達編碼器</td>
  927. <!-- style="color:crimson; height: 25px; width: 40px; text-align: center; margin: 2px;" -->
  928. <td><span id="motor_encoder_status"></span></td>
  929. </tr>
  930. <tr>
  931. <td style="background-color:#f3f3f3">桶內溫度</td>
  932. <td><span id="SHT11_Temp_t_status">{{tank_SHT11.SHT11_Temp}}</span> ℃</td>
  933. <td style="background-color:#f3f3f3">桶內濕度</td>
  934. <td><span id="SHT11_Humidity_t_status">{{tank_SHT11.SHT11_Humidity}}</span> %</td>
  935. <td style="background-color:#f3f3f3">桶內壓力</td>
  936. <td><span id="PA_t_status">{{tank_PA.PA}}</span> Pa</td>
  937. </tr>
  938. <tr>
  939. <td style="background-color:#f3f3f3">咖啡生豆溫度</td>
  940. <td><span id="soil_Temp_t_status">{{tank_Soil.soil_Temp}}</span> ℃</td>
  941. <td style="background-color:#f3f3f3">咖啡生豆濕度</td>
  942. <td><span id="soil_Humidity_t_status">{{tank_Soil.soil_Humidity}}</span> %</td>
  943. <td style="background-color:#f3f3f3">咖啡生豆 EC</td>
  944. <td><span id="soil_EC_t_status">{{tank_Soil.soil_EC}}</span> uS/cm</td>
  945. </tr>
  946. </table>
  947. <br>
  948. <table border="1" class="table-all" cellpadding="5">
  949. <tr>
  950. <td>
  951. 溫度權重設定:
  952. 桶內溫度&nbsp;×&nbsp;
  953. <input type="text" class="input-text" id="Temp_Weights_SHT11" value="1">
  954. &nbsp;+&nbsp;咖啡生豆溫度&nbsp;×&nbsp;
  955. <input type="text" class="input-text" id="Temp_Weights_Soil" value="0">
  956. </td>
  957. <td>
  958. <strong>溫度[權重]:<span id="testing_Temp_Weight">計算中...</span></strong>
  959. </td>
  960. </tr>
  961. </table>
  962. <br>
  963. <h4>排程設計</h4>
  964. <table border="1" class="table-all" cellpadding="5">
  965. <tr>
  966. <td>乾燥</td>
  967. <td>入料</td>
  968. <td>攪拌加熱</td>
  969. <td>消毒清洗</td>
  970. <td>循環測試</td>
  971. </tr>
  972. <tr>
  973. <td>
  974. -- 入料 --<br>
  975. 指定生豆高度
  976. <input type="text" class="input-text" name="testing_BeanIn_Height_D" value="45">公分<br>
  977. 吸料時間
  978. <input type="text" class="input-text" name="testing_in_vacuum_in_D" value="3">秒<br>
  979. 放料時間(>10)
  980. <input type="text" class="input-text" name="testing_in_vacuum_out_D" value="5">秒<br>
  981. 循環次數
  982. <input type="text" class="input-text" name="testing_in_vacuum_loop_D" value="3">次<br>
  983. -- 乾燥 --<br>
  984. 馬達轉速
  985. <input type="text" class="input-text" name="testing_Heat_Motor_D" value="30">rpm<br>
  986. 指定溫度
  987. <input type="text" class="input-text" name="testing_Heat_Temp_D" value="35">℃<br>
  988. 指定濕度
  989. <input type="text" class="input-text" name="testing_Heat_Humidity_D" value="35">%<br>
  990. 乾燥秒數
  991. <input type="text" class="input-text" name="testing_Heat_time_D" value="20">秒<br>
  992. -- 出料 --<br>
  993. 指定空桶高度
  994. <input type="text" class="input-text" name="testing_BeanEmpty_Height_D" value="10">公分<br>
  995. 吸料時間
  996. <input type="text" class="input-text" name="testing_out_vacuum_in_D" value="3">秒<br>
  997. 放料時間(>10)
  998. <input type="text" class="input-text" name="testing_out_vacuum_out_D" value="5">秒<br>
  999. 循環次數
  1000. <input type="text" class="input-text" name="testing_out_vacuum_loop_D" value="3">次<br>
  1001. </td>
  1002. <td>
  1003. 指定桶內生豆高度
  1004. <input type="text" class="input-text" name="testing_BeanIn_Height" value="0">公分<br>
  1005. 吸料時間
  1006. <input type="text" class="input-text" name="testing_in_vacuum_in" value="1">秒<br>
  1007. 放料時間
  1008. <input type="text" class="input-text" name="testing_in_vacuum_out" value="10">秒<br>
  1009. 循環次數
  1010. <input type="text" class="input-text" name="testing_in_vacuum_loop" value="3">次<br>
  1011. </td>
  1012. <td>
  1013. 馬達轉速
  1014. <input type="text" class="input-text" name="testing_Heat_Motor" value="20">rpm<br>
  1015. 指定溫度
  1016. <input type="text" class="input-text" name="testing_Heat_Temp" value="25">℃<br>
  1017. 指定濕度
  1018. <input type="text" class="input-text" name="testing_Heat_Humidity" value="35">%<br>
  1019. 乾燥秒數
  1020. <input type="text" class="input-text" name="testing_Heat_time" value="20">秒<br>
  1021. </td>
  1022. <td>
  1023. 排水電磁閥 OFF<br>
  1024. 馬達轉速
  1025. <input type="text" class="input-text" id="testing_clean_motor" name="waiting_time_8" value="30">rpm<br>
  1026. 消毒噴灑時間
  1027. <input type="text" class="input-text" id="testing_disinfect_time" value="30">秒<br>
  1028. 排水電磁閥 ON
  1029. </td>
  1030. <td>
  1031. ON (開)
  1032. <input type="text" class="input-text" name="Testing_starttime" value="5">秒<br>
  1033. OFF (關)
  1034. <input type="text" class="input-text" name="Testing_endtime" value="10">秒<br>
  1035. 循環
  1036. <input type="text" class="input-text" name="Testing_loop" value="4">次
  1037. </td>
  1038. <tr>
  1039. <td>
  1040. <button type="submit" class="btn btn-primary" onclick="F_tankDiskValve_ON()">發酵槽蝴蝶閥 ON</button><br>
  1041. <button type="submit" class="btn btn-primary" onclick="F_tankDiskValve_OFF()">發酵槽蝴蝶閥 OFF</button><br>
  1042. <button type="submit" class="btn btn-primary" onclick="testing_D()">乾燥排程測試</button>
  1043. <script>
  1044. function F_tankDiskValve_ON() {
  1045. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "on" };
  1046. $.post('/mqtt/{{tid}}', data, function (res) {
  1047. console.log('data:', data)
  1048. }, 'text')
  1049. };
  1050. function F_tankDiskValve_OFF() {
  1051. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "off" };
  1052. $.post('/mqtt/{{tid}}', data, function (res) {
  1053. console.log('data:', data)
  1054. }, 'text')
  1055. };
  1056. function testing_D() {
  1057. clearInterval(WebUpdate_set);
  1058. var BeanIn_D_Process = 0; // 入豆
  1059. var Heat_D_Process = 0; // 乾燥
  1060. var BeanOut_D_Process = 0; // 出豆
  1061. var BeanIn_D_interval;
  1062. var Heat_D_interval;
  1063. var BeanOut_D_interval;
  1064. var testing_BeanIn_Height_D = $("input[name=testing_BeanIn_Height_D]").val();
  1065. var testing_in_vacuum_in_D = $("input[name=testing_in_vacuum_in_D]").val();
  1066. var testing_in_vacuum_out_D = $("input[name=testing_in_vacuum_out_D]").val();
  1067. var testing_in_vacuum_loop_D = $("input[name=testing_in_vacuum_loop_D]").val();
  1068. if (testing_BeanIn_Height_D != 0) {
  1069. console.log('以指定高度入豆')
  1070. BeanIn_D_interval = setInterval(BeanInHeight_D, 5000);
  1071. } else if (testing_BeanIn_Height_D == 0) {
  1072. console.log('以循環次數入豆')
  1073. for (step = 1; step <= testing_in_vacuum_loop_D; step++) {
  1074. console.log('-- 循環第 ' + step + ' 次 --');
  1075. // aaa tankVacuum('1')
  1076. console.log('tankVacuum_ON')
  1077. var time = new Date();
  1078. while ((new Date() - time) < testing_in_vacuum_in_D * 1000) { };
  1079. // aaa tankVacuum('0')
  1080. console.log('tankVacuum_OFF')
  1081. var time = new Date();
  1082. while ((new Date() - time) < testing_in_vacuum_out_D * 1000) { };
  1083. }
  1084. console.log('循環入豆結束')
  1085. var testing_Heat_Motor_D = $("input[name=testing_Heat_Motor_D]").val();
  1086. var testing_Heat_Temp_D = $("input[name=testing_Heat_Temp_D]").val();
  1087. var testing_Heat_Humidity_D = $("input[name=testing_Heat_Humidity_D]").val();
  1088. var testing_Heat_time_D = $("input[name=testing_Heat_time_D]").val();
  1089. console.log('指定馬達轉速: ' + testing_Heat_Motor_D)
  1090. console.log('指定溫度: ' + testing_Heat_Temp_D)
  1091. console.log('指定濕度: ' + testing_Heat_Humidity_D)
  1092. console.log('指定乾燥秒數: ' + testing_Heat_time_D)
  1093. $.get('/dry_SHT11_' + tank_num, '', function (res) {
  1094. present_temp = Math.round((res.SHT11_Temp*Temp_Weights_SHT11 + res.soil_Temp*Temp_Weights_Soil)/(Temp_Weights_SHT11+Temp_Weights_Soil)*100) / 100
  1095. if ( (present_temp < testing_Heat_Temp_D) || (res.SHT11_Humidity < testing_Heat_Humidity_D) ) {
  1096. // aaa tankHeater1('1')
  1097. console.log('tankHeater1_ON')
  1098. // aaa tankHeater2('1')
  1099. console.log('tankHeater2_ON')
  1100. // aaa tankBlower('1')
  1101. console.log('tankBlower_ON')
  1102. }
  1103. }, 'json');
  1104. var data = { "tank_num": "D" + tank_num, "command": "tank_motor_status", "value": testing_Heat_Motor_D };
  1105. $.post('/mqtt/{{tid}}', data, function (res) {
  1106. console.log('data:', data)
  1107. }, 'text')
  1108. console.log('Motor ' + testing_Heat_Motor_D)
  1109. Heat_D_interval = setInterval(Heater_D, 5000);
  1110. }
  1111. function BeanInHeight_D(){
  1112. if (BeanIn_D_Process == 1) {
  1113. return;
  1114. }
  1115. BeanIn_D_Process == 1;
  1116. $.ajax({
  1117. async:false,
  1118. type:"GET",
  1119. url:"/dry_UltraSonic_" + tank_num,
  1120. dataType:"json",
  1121. success:function(response){
  1122. var present_Bean_height = response.UltraSonic
  1123. console.log('目前生豆高度: ' + present_Bean_height)
  1124. if ( parseInt(present_Bean_height) < parseInt(testing_BeanIn_Height_D) ) {
  1125. // aaa tankVacuum('1')
  1126. console.log('tankVacuum_ON')
  1127. var time = new Date();
  1128. while ((new Date() - time) < testing_in_vacuum_in_D * 1000) { };
  1129. // aaa tankVacuum('0')
  1130. console.log('tankVacuum_OFF')
  1131. var time = new Date();
  1132. while ((new Date() - time) < testing_in_vacuum_out_D * 1000) { };
  1133. } else {
  1134. clearInterval(BeanIn_D_interval)
  1135. console.log('生豆已達指定高度!')
  1136. var testing_Heat_Motor_D = $("input[name=testing_Heat_Motor_D]").val();
  1137. var testing_Heat_Temp_D = $("input[name=testing_Heat_Temp_D]").val();
  1138. var testing_Heat_Humidity_D = $("input[name=testing_Heat_Humidity_D]").val();
  1139. var testing_Heat_time_D = $("input[name=testing_Heat_time_D]").val();
  1140. console.log('指定馬達轉速: ' + testing_Heat_Motor_D)
  1141. console.log('指定溫度: ' + testing_Heat_Temp_D)
  1142. console.log('指定濕度: ' + testing_Heat_Humidity_D)
  1143. console.log('指定乾燥秒數: ' + testing_Heat_time_D)
  1144. $.get('/dry_SHT11_' + tank_num, '', function (res) {
  1145. if ( (res.SHT11_Temp < testing_Heat_Temp_D) || (res.SHT11_Humidity < testing_Heat_Humidity_D) ) {
  1146. // aaa tankHeater1('1')
  1147. console.log('tankHeater1_ON')
  1148. // aaa tankHeater2('1')
  1149. console.log('tankHeater2_ON')
  1150. // aaa tankBlower('1')
  1151. console.log('tankBlower_ON')
  1152. var time = new Date();
  1153. while ((new Date() - time) < 5 * 1000) { };
  1154. }
  1155. }, 'json');
  1156. var data = { "tank_num": "D" + tank_num, "command": "tank_motor_status", "value": testing_Heat_Motor_D };
  1157. $.post('/mqtt/{{tid}}', data, function (res) {
  1158. console.log('data:', data)
  1159. }, 'text')
  1160. console.log('Motor ' + testing_Heat_Motor_D)
  1161. var time = new Date();
  1162. while ((new Date() - time) < 5 * 1000) { };
  1163. Heat_D_interval = setInterval(Heater_D, 5000);
  1164. }
  1165. BeanIn_D_Process == 0;
  1166. },
  1167. error:function(thrownError){
  1168. console.log('Error: ' + thrownError)
  1169. BeanIn_D_Process = 0;
  1170. }
  1171. })
  1172. };
  1173. function Heater_D(){
  1174. if ( Heat_D_Process == 1 ) {
  1175. return;
  1176. }
  1177. Heat_D_Process = 1;
  1178. $.ajax({
  1179. async:false,
  1180. type:"GET",
  1181. url:"/dry_SHT11_" + tank_num,
  1182. dataType:"json",
  1183. success:function(response){
  1184. var present_Humidity = response.SHT11_Humidity
  1185. var testing_Heat_Temp_D = $("input[name=testing_Heat_Temp_D]").val();
  1186. var testing_Heat_Humidity_D = $("input[name=testing_Heat_Humidity_D]").val();
  1187. var testing_Heat_time_D = $("input[name=testing_Heat_time_D]").val();
  1188. present_temp = Math.round((res.SHT11_Temp*Temp_Weights_SHT11 + res.soil_Temp*Temp_Weights_Soil)/(Temp_Weights_SHT11+Temp_Weights_Soil)*100) / 100
  1189. if ( (present_Humidity > testing_Heat_Humidity_D) && (present_temp > testing_Heat_Temp_D) ) {
  1190. clearInterval(Heat_D_interval)
  1191. console.log("已達指定溫濕度, 乾燥 " + testing_Heat_time_D + " 秒")
  1192. var time = new Date();
  1193. while ( (new Date() - time) < testing_Heat_time_D * 1000 ) { }
  1194. // aaa tankMotor('0')
  1195. console.log('tankMotor_OFF')
  1196. // aaa tankHeater1('0')
  1197. console.log('tankHeater1_OFF')
  1198. // aaa tankHeater2('0')
  1199. console.log('tankHeater2_OFF')
  1200. // aaa tankBlower('0')
  1201. console.log('tankBlower_OFF')
  1202. console.log('攪拌加熱完成!')
  1203. var testing_BeanEmpty_Height_D = $('input[name=testing_BeanEmpty_Height_D]').val();
  1204. var testing_out_vacuum_in_D = $('input[name=testing_out_vacuum_in_D]').val();
  1205. var testing_out_vacuum_out_D = $('input[name=testing_out_vacuum_out_D]').val();
  1206. var testing_out_vacuum_loop_D = $('input[name=testing_out_vacuum_loop_D]').val();
  1207. console.log('指定空桶高度: ' + testing_BeanEmpty_Height_D)
  1208. if (testing_BeanEmpty_Height_D != 0) {
  1209. console.log('以空桶高度出豆')
  1210. BeanOut_D_interval = setInterval(BeanOutHeight_D, 5000);
  1211. } else if (testing_BeanEmpty_Height == 0) {
  1212. console.log('以循環方式出豆')
  1213. for (step = 1; step <= testing_out_vacuum_loop; step++) {
  1214. console.log('-- 循環第 ' + step + ' 次 --');
  1215. tankVacuum('1')
  1216. console.log('tankVacuum_ON')
  1217. var time = new Date();
  1218. while ((new Date() - time) < testing_out_vacuum_in_D * 1000) { };
  1219. tankVacuum('0')
  1220. console.log('tankVacuum_OFF')
  1221. var time = new Date();
  1222. while ((new Date() - time) < testing_out_vacuum_out_D * 1000) { };
  1223. }
  1224. console.log('循環出豆結束')
  1225. }
  1226. } else if ( parseInt(present_Humidity) > parseInt(testing_Heat_Humidity_D) ) {
  1227. console.log("已達指定濕度!")
  1228. } else if ( parseInt(present_temp) > parseInt(testing_Heat_Temp_D) ){
  1229. console.log("已達指定溫度!")
  1230. } else {
  1231. console.log('加熱中, 溫: ' + present_temp + ' / 濕: ' + present_Humidity)
  1232. }
  1233. Heat_D_Process = 0;
  1234. },
  1235. error:function(thrownError){
  1236. console.log('Error: ' + thrownError)
  1237. Heat_D_Process = 0;
  1238. }
  1239. })
  1240. };
  1241. function BeanOutHeight_D(){
  1242. if (BeanOut_D_Process == 1) {
  1243. return;
  1244. }
  1245. BeanOut_D_Process = 1;
  1246. $.ajax({
  1247. async:false,
  1248. type:"GET",
  1249. url:"/dry_UltraSonic_" + tank_num,
  1250. dataType:"json",
  1251. success:function(response){
  1252. var present_Bean_height = response.UltraSonic
  1253. console.log("目前豆高: " + present_Bean_height)
  1254. var testing_BeanEmpty_Height_D = $('input[name=testing_BeanEmpty_Height_D]').val();
  1255. var testing_out_vacuum_in_D = $('input[name=testing_out_vacuum_in_D]').val();
  1256. var testing_out_vacuum_out_D = $('input[name=testing_out_vacuum_out_D]').val();
  1257. var testing_out_vacuum_loop_D = $('input[name=testing_out_vacuum_loop_D]').val();
  1258. if ( parseInt(present_Bean_height) < parseInt(testing_BeanEmpty_Height_D) ) {
  1259. clearInterval(BeanOut_D_interval)
  1260. console.log("已達指定空桶高度!")
  1261. } else {
  1262. // aaa outputVacuum('1')
  1263. console.log('outputVacuum_ON')
  1264. var time = new Date()
  1265. while ( (new Date() - time) < testing_out_vacuum_in_D * 1000) { }
  1266. // aaa outputVacuum('0')
  1267. console.log('outputVacuum_OFF')
  1268. var time = new Date()
  1269. while ( (new Date() - time) < testing_out_vacuum_out_D * 1000) { }
  1270. }
  1271. BeanOut_D_Process = 0;
  1272. },
  1273. error:function(thrownError){
  1274. console.log("Error: " + thrownError)
  1275. BeanOut_D_Process = 0;
  1276. }
  1277. })
  1278. };
  1279. WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000);
  1280. }
  1281. </script>
  1282. </td>
  1283. <td>
  1284. <button type="submit" class="btn btn-primary" onclick="BeanInput()">入料測試</button>
  1285. <script>
  1286. var BeanIn_Process = 0;
  1287. var BeanIn_interval;
  1288. function BeanInput() {
  1289. clearInterval(WebUpdate_set);
  1290. var testing_BeanIn_Height = $("input[name=testing_BeanIn_Height]").val();
  1291. var testing_in_vacuum_in = $("input[name=testing_in_vacuum_in]").val();
  1292. var testing_in_vacuum_out = $("input[name=testing_in_vacuum_out]").val();
  1293. var testing_in_vacuum_loop = $("input[name=testing_in_vacuum_loop]").val();
  1294. if (testing_BeanIn_Height != 0) {
  1295. console.log('以指定高度入豆')
  1296. var BeanIn_interval = setInterval(BeanInHeight, 5000);
  1297. function BeanInHeight(){
  1298. if (BeanIn_Process == 1) {
  1299. return;
  1300. }
  1301. BeanIn_Process == 1;
  1302. $.ajax({
  1303. async:false,
  1304. type:"GET",
  1305. url:"/dry_UltraSonic_" + tank_num,
  1306. dataType:"json",
  1307. success:function(response){
  1308. var present_Bean_height = response.UltraSonic
  1309. console.log('目前生豆高度: ' + present_Bean_height)
  1310. if ( parseInt(present_Bean_height) < parseInt(testing_BeanIn_Height) ) {
  1311. // aaa tankVacuum('1')
  1312. console.log('tankVacuum_ON')
  1313. var time = new Date();
  1314. while ((new Date() - time) < testing_in_vacuum_in * 1000) { };
  1315. // aaa tankVacuum('0')
  1316. console.log('tankVacuum_OFF')
  1317. var time = new Date();
  1318. while ((new Date() - time) < testing_in_vacuum_out * 1000) { };
  1319. } else {
  1320. clearInterval(BeanIn_interval)
  1321. console.log('生豆已達指定高度!')
  1322. }
  1323. BeanIn_Process == 0;
  1324. },
  1325. error:function(thrownError){
  1326. console.log('Error: ' + thrownError)
  1327. BeanIn_Process = 0;
  1328. }
  1329. })
  1330. };
  1331. } else if (testing_BeanIn_Height == 0) {
  1332. console.log('以循環次數入豆')
  1333. for (step = 1; step <= testing_in_vacuum_loop; step++) {
  1334. console.log('-- 循環第 ' + step + ' 次 --');
  1335. // aaa tankVacuum('1')
  1336. console.log('tankVacuum_ON')
  1337. var time = new Date();
  1338. while ((new Date() - time) < testing_in_vacuum_in * 1000) { };
  1339. // aaa tankVacuum('0')
  1340. console.log('tankVacuum_OFF')
  1341. var time = new Date();
  1342. while ((new Date() - time) < testing_in_vacuum_out * 1000) { };
  1343. }
  1344. console.log('循環入豆結束')
  1345. }
  1346. WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000);
  1347. }
  1348. </script>
  1349. </td>
  1350. <td>
  1351. <button type="submit" class="btn btn-primary" onclick="Heat()">攪拌加熱</button>
  1352. <script>
  1353. var Heat_Process = 0;
  1354. function Heat(){
  1355. clearInterval(WebUpdate_set);
  1356. var testing_Heat_Motor = $("input[name=testing_Heat_Motor]").val();
  1357. var testing_Heat_Temp = $("input[name=testing_Heat_Temp]").val();
  1358. var testing_Heat_Humidity = $("input[name=testing_Heat_Humidity]").val();
  1359. var testing_Heat_time = $("input[name=testing_Heat_time]").val();
  1360. console.log('指定馬達轉速: ' + testing_Heat_Motor)
  1361. console.log('指定溫度: ' + testing_Heat_Temp)
  1362. console.log('指定濕度: ' + testing_Heat_Humidity)
  1363. console.log('指定乾燥秒數: ' + testing_Heat_time)
  1364. $.get('/dry_SHT11_' + tank_num, '', function (res) {
  1365. if ( (res.SHT11_Temp < testing_Heat_Temp) || (res.SHT11_Humidity < testing_Heat_Humidity) ) {
  1366. // aaa tankHeater1('1')
  1367. console.log('tankHeater1_ON')
  1368. // aaa tankHeater2('1')
  1369. console.log('tankHeater2_ON')
  1370. // aaa tankBlower('1')
  1371. console.log('tankBlower_ON')
  1372. }
  1373. }, 'json');
  1374. var data = { "tank_num": "D" + tank_num, "command": "tank_motor_status", "value": testing_Heat_Motor };
  1375. $.post('/mqtt/{{tid}}', data, function (res) {
  1376. console.log('data:', data)
  1377. }, 'text')
  1378. console.log('Motor ' + testing_Heat_Motor)
  1379. var Heat_interval = setInterval(Heater, 5000);
  1380. function Heater(){
  1381. var Temp_Weights_SHT11 = parseFloat($("#Temp_Weights_SHT11").val());
  1382. var Temp_Weights_Soil = parseFloat($("#Temp_Weights_Soil").val());
  1383. if ( Heat_Process == 1 ) {
  1384. return;
  1385. }
  1386. Heat_Process = 1;
  1387. $.ajax({
  1388. async:false,
  1389. type:"GET",
  1390. url:"/dry_SHT11_" + tank_num,
  1391. dataType:"json",
  1392. success:function(response){
  1393. var present_temp = Math.round((response.SHT11_Temp*Temp_Weights_SHT11 + response.Soil_Temp*Temp_Weights_Soil)/(Temp_Weights_SHT11+Temp_Weights_Soil)*100) / 100
  1394. var present_Humidity = response.SHT11_Humidity
  1395. if ( (present_Humidity > testing_Heat_Humidity) &&
  1396. (present_temp > testing_Heat_Temp) ) {
  1397. console.log("已達指定溫濕度, 乾燥 " + testing_Heat_time + " 秒")
  1398. clearInterval(Heat_interval)
  1399. var time = new Date();
  1400. while ( (new Date() - time) < testing_Heat_time * 1000 ) { }
  1401. // aaa tankMotor('0')
  1402. console.log('tankMotor_OFF')
  1403. // aaa tankHeater1('0')
  1404. console.log('tankHeater1_OFF')
  1405. // aaa tankHeater2('0')
  1406. console.log('tankHeater2_OFF')
  1407. // aaa tankBlower('0')
  1408. console.log('tankBlower_OFF')
  1409. console.log('攪拌加熱完成!')
  1410. } else if ( present_Humidity > testing_Heat_Humidity ) {
  1411. console.log('已達指定濕度, 溫: ' + present_temp + ' / 濕: ' + present_Humidity)
  1412. } else if ( present_temp > testing_Heat_Temp ) {
  1413. console.log('已達指定溫度, 溫: ' + present_temp + ' / 濕: ' + present_Humidity)
  1414. } else {
  1415. console.log('加熱中, 溫: ' + present_temp + ' / 濕: ' + present_Humidity)
  1416. }
  1417. Heat_Process = 0;
  1418. },
  1419. error:function(thrownError){
  1420. console.log('Error: ' + thrownError)
  1421. Heat_Process = 0;
  1422. }
  1423. })
  1424. };
  1425. WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000);
  1426. };
  1427. </script>
  1428. </td>
  1429. <td>
  1430. <button type="submit" class="btn btn-primary" onclick="disinfectTest()">消毒清洗測試</button>
  1431. <script>
  1432. function disinfectTest(){
  1433. var testing_clean_motor = $('#testing_clean_motor').val();
  1434. var testing_disinfect_time = parseInt($('#testing_disinfect_time').val());
  1435. tankMotor(testing_clean_motor)
  1436. var time = new Date();
  1437. while ((new Date() - time) < 1 * 1000) { }
  1438. // aaa tankSolenoidDisinfect('1')
  1439. console.log('tankSolenoidDisinfect_ON')
  1440. var time = new Date();
  1441. while ((new Date() - time) < testing_disinfect_time * 1000) { }
  1442. // aaa tankSolenoidDisinfect('0')
  1443. console.log('tankSolenoidDisinfect_OFF')
  1444. tankMotor('0')
  1445. var time = new Date();
  1446. while ((new Date() - time) < 1 * 1000) { }
  1447. };
  1448. </script>
  1449. </td>
  1450. <td>
  1451. <button type="submit" class="btn btn-primary" onclick="diskValveTest()">蝴蝶閥測試(秒)</button><br>
  1452. <button type="submit" class="btn btn-primary" onclick="tankVacuumTest()">真空吸料機測試(秒)</button><br>
  1453. <button type="submit" class="btn btn-primary" onclick="threewayvalveTest()">三通閥測試(秒)</button>
  1454. <script>
  1455. function threewayvalveTest() {
  1456. clearInterval(WebUpdate_set);
  1457. var Testing_starttime = $("input[name=Testing_starttime]").val();
  1458. var Testing_endtime = $("input[name=Testing_endtime]").val();
  1459. var Testing_loop = $("input[name=Testing_loop]").val();
  1460. alert('測試間隔' + Testing_starttime + ':' + Testing_endtime + ' 次數' + Testing_loop)
  1461. var step;
  1462. for (step = 1; step <= Testing_loop; step++) {
  1463. console.log('循環第 ' + step + ' 次');
  1464. tankThreeWayValveInput('1')
  1465. console.log('tankThreeWayValveInput_ON')
  1466. var time = new Date();
  1467. while ((new Date() - time) < Testing_starttime * 1000) { }
  1468. tankThreeWayValveInput('0')
  1469. console.log('tankThreeWayValveInput_OFF')
  1470. var time = new Date();
  1471. while ((new Date() - time) < Testing_endtime * 1000) { }
  1472. }
  1473. WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000);
  1474. }
  1475. </script>
  1476. <script>
  1477. function tankVacuumTest() {
  1478. clearInterval(WebUpdate_set);
  1479. var Testing_starttime = $("input[name=Testing_starttime]").val();
  1480. var Testing_endtime = $("input[name=Testing_endtime]").val();
  1481. var Testing_loop = $("input[name=Testing_loop]").val();
  1482. alert('測試間隔' + Testing_starttime + ':' + Testing_endtime + ' 次數' + Testing_loop)
  1483. var step;
  1484. for (step = 1; step <= Testing_loop; step++) {
  1485. console.log('循環第 ' + step + ' 次');
  1486. tankVacuum('1')
  1487. console.log('tankVacuum_ON')
  1488. var time = new Date();
  1489. while ((new Date() - time) < Testing_starttime * 1000) { }
  1490. tankVacuum('0')
  1491. console.log('tankVacuum_OFF')
  1492. var time = new Date();
  1493. while ((new Date() - time) < Testing_endtime * 1000) { }
  1494. }
  1495. WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000);
  1496. }
  1497. </script>
  1498. <script>
  1499. function diskValveTest() {
  1500. clearInterval(WebUpdate_set);
  1501. var Testing_starttime = $("input[name=Testing_starttime]").val();
  1502. var Testing_endtime = $("input[name=Testing_endtime]").val();
  1503. var Testing_loop = $("input[name=Testing_loop]").val();
  1504. alert('測試間隔' + Testing_starttime + ':' + Testing_endtime + ' 次數' + Testing_loop)
  1505. var step;
  1506. for (step = 1; step <= Testing_loop; step++) {
  1507. console.log('循環第 ' + step + ' 次');
  1508. tankDiskValve('1')
  1509. console.log('tankDiskValve_ON')
  1510. var time = new Date();
  1511. while ((new Date() - time) < Testing_starttime * 1000) { }
  1512. tankDiskValve('0')
  1513. console.log('tankDiskValve_OFF')
  1514. var time = new Date();
  1515. while ((new Date() - time) < Testing_endtime * 1000) { }
  1516. }
  1517. WebUpdate_set = setInterval(function(){WebUpdate(dtn)} , 10 * 1000);
  1518. }
  1519. </script>
  1520. </td>
  1521. </tr>
  1522. </table>
  1523. <div id="coffee_footer">
  1524. <!-- 匯入共同使用的 footer.html 內容 -->
  1525. {% include 'footer.html' %}
  1526. </div>
  1527. </div>
  1528. </body>
  1529. </html>