ferment_function.js 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291
  1. function inputVacuum() {
  2. var status = "off";
  3. var check = $("input[name=input_vacuum_status]:checked"); // 這裡面是 jQuery 撈取資料的方法, jQuery 常使用到 $ 錢字號
  4. console.log('check:', check);
  5. //大於0代表有被選中, 如果有多個可以呈現勾取的項目數量
  6. if (check.length > 0) {
  7. status = "on";
  8. $("#cmn-toggle-02").prop('checked', false); // 確認是否勾選
  9. if (!confirm("你確定要開啟入料儲豆槽真空吸料機嗎?")) {
  10. return false;
  11. };
  12. } else {
  13. $("#cmn-toggle-02").prop('checked', true);
  14. if (!confirm("你確定要關閉入料儲豆槽真空吸料機嗎?")) {
  15. return false;
  16. };
  17. };
  18. var data = { "tank_num": "FI" + tank_num, "command": "input_vacuum_status", "value": status };
  19. $.post('/mqtt/' + tank_num, data, function (res) { //res:HTTP response argument to the middleware function
  20. console.log('data:', data)
  21. if (res == 'on') {
  22. $("#cmn-toggle-02").prop('checked', true);
  23. setTimeout("alert('入料儲豆槽真空吸料機_開啟成功!')", 500);
  24. } else if (res == 'off') {
  25. $("#cmn-toggle-02").prop('checked', false);
  26. setTimeout("alert('入料儲豆槽真空吸料機_關閉成功!')", 500);
  27. } else {
  28. console.log('res error');
  29. };
  30. }, 'text')
  31. };
  32. function inputVacuum_ON() {
  33. var data = { "tank_num": "FI" + tank_num, "command": "input_vacuum_status", "value": "on" };
  34. $.post('/mqtt/' + tank_num, data, function (res) { //res:HTTP response argument to the middleware function
  35. console.log('data:', data)
  36. if (res == 'on') {
  37. $("#cmn-toggle-02").prop('checked', true);
  38. } else if (res == 'off') {
  39. $("#cmn-toggle-02").prop('checked', false);
  40. } else {
  41. console.log('res error');
  42. };
  43. }, 'text')
  44. };
  45. function inputVacuum_OFF() {
  46. var data = { "tank_num": "FI" + tank_num, "command": "input_vacuum_status", "value": "off" };
  47. $.post('/mqtt/' + tank_num, data, function (res) { //res:HTTP response argument to the middleware function
  48. console.log('data:', data)
  49. if (res == 'on') {
  50. $("#cmn-toggle-02").prop('checked', true);
  51. } else if (res == 'off') {
  52. $("#cmn-toggle-02").prop('checked', false);
  53. } else {
  54. console.log('res error');
  55. };
  56. }, 'text')
  57. // setTimeout(function () { location.reload(); }, 500);
  58. };
  59. function tankVacuum() {
  60. var status = "off";
  61. var check = $("input[name=tank_vacuum_status]:checked");
  62. console.log('check:', check);
  63. //大於0代表有被選中
  64. if (check.length > 0) {
  65. status = "on";
  66. $("#cmn-toggle-05").prop('checked', false);
  67. if (!confirm("你確定要開啟真空吸料機嗎?")) {
  68. return false;
  69. };
  70. } else {
  71. $("#cmn-toggle-05").prop('checked', true);
  72. if (!confirm("你確定要關閉真空吸料機嗎?")) {
  73. return false;
  74. };
  75. };
  76. var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": status };
  77. $.post('/mqtt/' + tank_num, data, function (res) {
  78. console.log('data:', data)
  79. if (res == 'on') {
  80. $("#cmn-toggle-05").prop('checked', true);
  81. setTimeout("alert('真空吸料機_開啟成功!')", 500);
  82. } else if (res == 'off') {
  83. $("#cmn-toggle-05").prop('checked', false);
  84. setTimeout("alert('真空吸料機_關閉成功!')", 500);
  85. } else {
  86. alert(res);
  87. };
  88. }, 'text')
  89. // setTimeout(function () { location.reload(); }, 500);
  90. };
  91. function tankVacuum_ON() {
  92. var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": "on" };
  93. $.post('/mqtt/' + tank_num, data, function (res) {
  94. console.log('data:', data)
  95. if (res == 'on') {
  96. $("#cmn-toggle-05").prop('checked', true);
  97. } else if (res == 'off') {
  98. $("#cmn-toggle-05").prop('checked', false);
  99. } else {
  100. console.log('res error');
  101. };
  102. }, 'text')
  103. // setTimeout(function () { location.reload(); }, 500);
  104. };
  105. function tankVacuum_OFF() {
  106. var data = { "tank_num": "F" + tank_num, "command": "tank_vacuum_status", "value": "off" };
  107. $.post('/mqtt/' + tank_num, data, function (res) {
  108. console.log('data:', data)
  109. if (res == 'on') {
  110. $("#cmn-toggle-05").prop('checked', true);
  111. } else if (res == 'off') {
  112. $("#cmn-toggle-05").prop('checked', false);
  113. } else {
  114. console.log('res error');
  115. };
  116. }, 'text')
  117. // setTimeout(function () { location.reload(); }, 500);
  118. };
  119. // Benson 真空吸料機 (END)
  120. function tankThreeWayValveInput() {
  121. //<!--setInterval(Relay,10000);-->
  122. var status = "off";
  123. var check = $("input[name=tank_threewayvalve_input_status]:checked");
  124. //大於0代表有被選中
  125. if (check.length > 0) {
  126. status = "on";
  127. $("#cmn-toggle-08").prop('checked', false);
  128. if (!confirm("你確定要開啟入料三通閥嗎?")) {
  129. return false;
  130. };
  131. } else {
  132. $("#cmn-toggle-08").prop('checked', true);
  133. if (!confirm("你確定要關閉入料三通閥嗎?")) {
  134. return false;
  135. };
  136. };
  137. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": status };
  138. $.post('/mqtt/' + tank_num, data, function (res) {
  139. console.log('data:', data)
  140. if (res == 'on') {
  141. $("#cmn-toggle-08").prop('checked', true);
  142. setTimeout("alert('入料三通閥入料_開啟成功!')", 500);
  143. } else if (res == 'off') {
  144. $("#cmn-toggle-08").prop('checked', false);
  145. setTimeout("alert('入料三通閥排氣_關閉成功!')", 500);
  146. } else {
  147. alert(res);
  148. };
  149. }, 'text')
  150. // setTimeout(function () { location.reload(); }, 500);
  151. };
  152. function tankThreeWayValveInput_ON() {
  153. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": "on" };
  154. $.post('/mqtt/' + tank_num, data, function (res) {
  155. console.log('data:', data)
  156. if (res == 'on') {
  157. $("#cmn-toggle-08").prop('checked', true);
  158. } else if (res == 'off') {
  159. $("#cmn-toggle-08").prop('checked', false);
  160. } else {
  161. console.log('res error');
  162. };
  163. }, 'text')
  164. // setTimeout(function () { location.reload(); }, 500);
  165. };
  166. function tankThreeWayValveInput_OFF() {
  167. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_input_status", "value": "off" };
  168. $.post('/mqtt/' + tank_num, data, function (res) {
  169. console.log('data:', data)
  170. if (res == 'on') {
  171. $("#cmn-toggle-08").prop('checked', true);
  172. } else if (res == 'off') {
  173. $("#cmn-toggle-08").prop('checked', false);
  174. } else {
  175. console.log('res error');
  176. };
  177. }, 'text')
  178. // setTimeout(function () { location.reload(); }, 500);
  179. };
  180. // Benson cargo2_actuator.html 控制蝴蝶閥函數 (START)
  181. function tankDiskValve() {
  182. //<!--setInterval(Relay,10000);-->
  183. var status = "off";
  184. var check = $("input[name=tank_diskvalve_status]:checked");
  185. //大於0代表有被選中
  186. if (check.length > 0) {
  187. status = "on";
  188. $("#cmn-toggle-11").prop('checked', false);
  189. if (!confirm("你確定要開啟蝴蝶閥嗎?")) {
  190. return false;
  191. };
  192. } else {
  193. $("#cmn-toggle-11").prop('checked', true);
  194. if (!confirm("你確定要關閉蝴蝶閥嗎?")) {
  195. return false;
  196. };
  197. };
  198. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": status };
  199. $.post('/mqtt/' + tank_num, data, function (res) {
  200. console.log('data:', data)
  201. if (res == 'on') {
  202. $("#cmn-toggle-11").prop('checked', true);
  203. setTimeout("alert('蝴蝶閥_開啟成功!')", 500);
  204. } else if (res == 'off') {
  205. $("#cmn-toggle-11").prop('checked', false);
  206. setTimeout("alert('蝴蝶閥_關閉成功!')", 500);
  207. } else {
  208. alert(res);
  209. };
  210. }, 'text')
  211. // setTimeout(function () { location.reload(); }, 500);
  212. };
  213. function tankDiskValve_ON() {
  214. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "on" };
  215. $.post('/mqtt/' + tank_num, data, function (res) {
  216. console.log('data:', data)
  217. if (res == 'on') {
  218. $("#cmn-toggle-11").prop('checked', true);
  219. } else if (res == 'off') {
  220. $("#cmn-toggle-11").prop('checked', false);
  221. } else {
  222. console.log('res error');
  223. };
  224. }, 'text')
  225. // setTimeout(function () { location.reload(); }, 500);
  226. };
  227. function tankDiskValve_OFF() {
  228. var data = { "tank_num": "F" + tank_num, "command": "tank_diskvalve_status", "value": "off" };
  229. $.post('/mqtt/' + tank_num, data, function (res) {
  230. console.log('data:', data)
  231. if (res == 'on') {
  232. $("#cmn-toggle-11").prop('checked', true);
  233. } else if (res == 'off') {
  234. $("#cmn-toggle-11").prop('checked', false);
  235. } else {
  236. console.log('res error');
  237. };
  238. }, 'text')
  239. // setTimeout(function () { location.reload(); }, 500);
  240. };
  241. // Benson cargo2_actuator.html 閥 (START) 電磁閥 總進水
  242. function tankSolenoidWaterTotal() {
  243. var status = "off";
  244. var check = $("input[name=tank_solenoid_water_total_status]:checked");
  245. //大於0代表有被選中
  246. if (check.length > 0) {
  247. status = "on";
  248. $("#cmn-toggle-14").prop('checked', false);
  249. if (!confirm("你確定要開啟總進水電磁閥嗎?")) {
  250. return false;
  251. };
  252. } else {
  253. $("#cmn-toggle-14").prop('checked', true);
  254. if (!confirm("你確定要關閉總進水電磁閥嗎?")) {
  255. return false;
  256. };
  257. };
  258. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_total_status", "value": status };
  259. $.post('/mqtt/' + tank_num, data, function (res) {
  260. console.log('data:', data)
  261. if (res == 'on') {
  262. $("#cmn-toggle-14").prop('checked', true);
  263. setTimeout("alert('總進水電磁閥_開啟成功!')", 500);
  264. } else if (res == 'off') {
  265. $("#cmn-toggle-14").prop('checked', false);
  266. setTimeout("alert('總進水電磁閥_關閉成功!')", 500);
  267. } else {
  268. alert(res);
  269. };
  270. }, 'text')
  271. // setTimeout(function () { location.reload(); }, 500);
  272. };
  273. function tankSolenoidWaterTotal_ON() {
  274. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_total_status", "value": "on" };
  275. $.post('/mqtt/' + tank_num, data, function (res) {
  276. console.log('data:', data)
  277. if (res == 'on') {
  278. $("#cmn-toggle-14").prop('checked', true);
  279. } else if (res == 'off') {
  280. $("#cmn-toggle-14").prop('checked', false);
  281. } else {
  282. console.log('res error');
  283. };
  284. }, 'text')
  285. // setTimeout(function () { location.reload(); }, 500);
  286. };
  287. function tankSolenoidWaterTotal_OFF() {
  288. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_total_status", "value": "off" };
  289. $.post('/mqtt/' + tank_num, data, function (res) {
  290. console.log('data:', data)
  291. if (res == 'on') {
  292. $("#cmn-toggle-14").prop('checked', true);
  293. } else if (res == 'off') {
  294. $("#cmn-toggle-14").prop('checked', false);
  295. } else {
  296. console.log('res error');
  297. };
  298. }, 'text')
  299. // setTimeout(function () { location.reload(); }, 500);
  300. };
  301. // Benson cargo2_actuator.html 閥 (START) 電磁閥消毒打菌
  302. function tankSolenoidDisinfect() {
  303. var status = "off";
  304. var check = $("input[name=tank_solenoid_disinfect_status]:checked");
  305. //大於0代表有被選中
  306. if (check.length > 0) {
  307. status = "on";
  308. $("#cmn-toggle-17").prop('checked', false);
  309. if (!confirm("你確定要開啟消毒電磁閥嗎?")) {
  310. return false;
  311. };
  312. } else {
  313. $("#cmn-toggle-17").prop('checked', true);
  314. if (!confirm("你確定要關閉消毒電磁閥嗎?")) {
  315. return false;
  316. };
  317. };
  318. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": status };
  319. $.post('/mqtt/' + tank_num, data, function (res) {
  320. console.log('data:', data)
  321. if (res == 'on') {
  322. $("#cmn-toggle-17").prop('checked', true);
  323. setTimeout("alert('消毒電磁閥_開啟成功!')", 500);
  324. } else if (res == 'off') {
  325. $("#cmn-toggle-17").prop('checked', false);
  326. setTimeout("alert('消毒電磁閥_關閉成功!')", 500);
  327. } else {
  328. alert(res);
  329. };
  330. }, 'text')
  331. // setTimeout(function () { location.reload(); }, 500);
  332. };
  333. function tankSolenoidDisinfect_ON() {
  334. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": "on" };
  335. $.post('/mqtt/' + tank_num, data, function (res) {
  336. console.log('data:', data)
  337. if (res == 'on') {
  338. $("#cmn-toggle-17").prop('checked', true);
  339. } else if (res == 'off') {
  340. $("#cmn-toggle-17").prop('checked', false);
  341. } else {
  342. console.log('res error');
  343. };
  344. }, 'text')
  345. // setTimeout(function () { location.reload(); }, 500);
  346. };
  347. function tankSolenoidDisinfect_OFF() {
  348. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_disinfect_status", "value": "off" };
  349. $.post('/mqtt/' + tank_num, data, function (res) {
  350. console.log('data:', data)
  351. if (res == 'on') {
  352. $("#cmn-toggle-17").prop('checked', true);
  353. } else if (res == 'off') {
  354. $("#cmn-toggle-17").prop('checked', false);
  355. } else {
  356. console.log('res error');
  357. };
  358. }, 'text')
  359. // setTimeout(function () { location.reload(); }, 500);
  360. };
  361. // 電磁閥 保溫夾層加水
  362. function outerSolenoidWater() {
  363. var status = "off";
  364. var check = $("input[name=outer_solenoid_water_status]:checked");
  365. //大於0代表有被選中
  366. if (check.length > 0) {
  367. status = "on";
  368. $("#cmn-toggle-38").prop('checked', false);
  369. if (!confirm("你確定要開啟\"保溫夾層\"進水電磁閥嗎?")) {
  370. return false;
  371. };
  372. } else {
  373. $("#cmn-toggle-38").prop('checked', true);
  374. if (!confirm("你確定要關閉\"保溫夾層\"進水電磁閥嗎?")) {
  375. return false;
  376. };
  377. };
  378. var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": status };
  379. $.post('/mqtt/' + tank_num, data, function (res) {
  380. console.log('data:', data)
  381. if (res == 'on') {
  382. $("#cmn-toggle-38").prop('checked', true);
  383. setTimeout("alert('\"保溫夾層\"進水電磁閥_開啟成功!')", 500);
  384. } else if (res == 'off') {
  385. $("#cmn-toggle-38").prop('checked', false);
  386. setTimeout("alert('\"保溫夾層\"進水電磁閥_關閉成功!')", 500);
  387. } else {
  388. alert(res);
  389. };
  390. }, 'text')
  391. // setTimeout(function () { location.reload(); }, 500);
  392. };
  393. function outerSolenoidWater_ON() {
  394. var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": "on" };
  395. $.post('/mqtt/' + tank_num, data, function (res) {
  396. console.log('data:', data)
  397. if (res == 'on') {
  398. $("#cmn-toggle-38").prop('checked', true);
  399. } else if (res == 'off') {
  400. $("#cmn-toggle-38").prop('checked', false);
  401. } else {
  402. console.log('res error');
  403. };
  404. }, 'text')
  405. // setTimeout(function () { location.reload(); }, 500);
  406. };
  407. function outerSolenoidWater_OFF() {
  408. var data = { "tank_num": "F" + tank_num, "command": "outer_solenoid_water_status", "value": "off" };
  409. $.post('/mqtt/' + tank_num, data, function (res) {
  410. console.log('data:', data)
  411. if (res == 'on') {
  412. $("#cmn-toggle-38").prop('checked', true);
  413. } else if (res == 'off') {
  414. $("#cmn-toggle-38").prop('checked', false);
  415. } else {
  416. console.log('res error');
  417. };
  418. }, 'text')
  419. // setTimeout(function () { location.reload(); }, 500);
  420. };
  421. // 電磁閥 桶內加水
  422. function tankSolenoidWaterIn() {
  423. var status = "off";
  424. var check = $("input[name=tank_solenoid_water_in_status]:checked");
  425. //大於0代表有被選中
  426. if (check.length > 0) {
  427. status = "on";
  428. $("#cmn-toggle-50").prop('checked', false);
  429. if (!confirm("你確定要開啟\"桶內進水\"電磁閥嗎?")) {
  430. return false;
  431. };
  432. } else {
  433. $("#cmn-toggle-50").prop('checked', true);
  434. if (!confirm("你確定要關閉\"桶內進水\"電磁閥嗎?")) {
  435. return false;
  436. };
  437. };
  438. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": status };
  439. $.post('/mqtt/' + tank_num, data, function (res) {
  440. console.log('data:', data)
  441. if (res == 'on') {
  442. $("#cmn-toggle-50").prop('checked', true);
  443. setTimeout("alert('\"桶內進水\"電磁閥_開啟成功!')", 500);
  444. } else if (res == 'off') {
  445. $("#cmn-toggle-50").prop('checked', false);
  446. setTimeout("alert('\"桶內進水\"電磁閥_關閉成功!')", 500);
  447. } else {
  448. alert(res);
  449. };
  450. }, 'text')
  451. // setTimeout(function () { location.reload(); }, 500);
  452. };
  453. function tankSolenoidWaterIn_ON() {
  454. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": "on" };
  455. $.post('/mqtt/' + tank_num, data, function (res) {
  456. console.log('data:', data)
  457. if (res == 'on') {
  458. $("#cmn-toggle-50").prop('checked', true);
  459. } else if (res == 'off') {
  460. $("#cmn-toggle-50").prop('checked', false);
  461. } else {
  462. console.log('res error');
  463. };
  464. }, 'text')
  465. // setTimeout(function () { location.reload(); }, 500);
  466. };
  467. function tankSolenoidWaterIn_OFF() {
  468. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_in_status", "value": "off" };
  469. $.post('/mqtt/' + tank_num, data, function (res) {
  470. console.log('data:', data)
  471. if (res == 'on') {
  472. $("#cmn-toggle-50").prop('checked', true);
  473. } else if (res == 'off') {
  474. $("#cmn-toggle-50").prop('checked', false);
  475. } else {
  476. console.log('res error');
  477. };
  478. }, 'text')
  479. // setTimeout(function () { location.reload(); }, 500);
  480. };
  481. // 電磁閥 桶內排水
  482. function tankSolenoidWaterOut() {
  483. var status = "off";
  484. var check = $("input[name=tank_solenoid_water_out_status]:checked");
  485. //大於0代表有被選中
  486. if (check.length > 0) {
  487. status = "on";
  488. $("#cmn-toggle-53").prop('checked', false);
  489. if (!confirm("你確定要開啟\"桶內排水\"電磁閥嗎?")) {
  490. return false;
  491. };
  492. } else {
  493. $("#cmn-toggle-53").prop('checked', true);
  494. if (!confirm("你確定要關閉\"桶內排水\"電磁閥嗎?")) {
  495. return false;
  496. };
  497. };
  498. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_out_status", "value": status };
  499. $.post('/mqtt/' + tank_num, data, function (res) {
  500. console.log('data:', data)
  501. if (res == 'on') {
  502. $("#cmn-toggle-53").prop('checked', true);
  503. setTimeout("alert('\"桶內排水\"電磁閥_開啟成功!')", 500);
  504. } else if (res == 'off') {
  505. $("#cmn-toggle-53").prop('checked', false);
  506. setTimeout("alert('\"桶內排水\"電磁閥_關閉成功!')", 500);
  507. } else {
  508. alert(res);
  509. };
  510. }, 'text')
  511. // setTimeout(function () { location.reload(); }, 500);
  512. };
  513. function tankSolenoidWaterOut_ON() {
  514. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_out_status", "value": "on" };
  515. $.post('/mqtt/' + tank_num, data, function (res) {
  516. console.log('data:', data)
  517. if (res == 'on') {
  518. $("#cmn-toggle-53").prop('checked', true);
  519. } else if (res == 'off') {
  520. $("#cmn-toggle-53").prop('checked', false);
  521. } else {
  522. alert(res);
  523. };
  524. }, 'text')
  525. // setTimeout(function () { location.reload(); }, 500);
  526. };
  527. function tankSolenoidWaterOut_OFF() {
  528. var data = { "tank_num": "F" + tank_num, "command": "tank_solenoid_water_out_status", "value": "off" };
  529. $.post('/mqtt/' + tank_num, data, function (res) {
  530. console.log('data:', data)
  531. if (res == 'on') {
  532. $("#cmn-toggle-53").prop('checked', true);
  533. } else if (res == 'off') {
  534. $("#cmn-toggle-53").prop('checked', false);
  535. } else {
  536. alert(res);
  537. };
  538. }, 'text')
  539. // setTimeout(function () { location.reload(); }, 500);
  540. };
  541. // 感測器用 pump 雙核隔膜泵
  542. function tankPumpSensor() {
  543. var status = "off";
  544. var check = $("input[name=tank_pump_sensor_status]:checked");
  545. //大於0代表有被選中
  546. if (check.length > 0) {
  547. status = "on";
  548. $("#cmn-toggle-41").prop('checked', false);
  549. if (!confirm("你確定要開啟感測器用 pump 雙核隔膜泵嗎?")) {
  550. return false;
  551. };
  552. } else {
  553. $("#cmn-toggle-41").prop('checked', true);
  554. if (!confirm("你確定要關閉感測器用 pump 雙核隔膜泵嗎?")) {
  555. return false;
  556. };
  557. };
  558. var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": status };
  559. $.post('/mqtt/' + tank_num, data, function (res) {
  560. console.log('data:', data)
  561. if (res == 'on') {
  562. $("#cmn-toggle-41").prop('checked', true);
  563. setTimeout("alert('感測器用 pump _開啟成功!')", 500);
  564. } else if (res == 'off') {
  565. $("#cmn-toggle-41").prop('checked', false);
  566. setTimeout("alert('感測器用 pump _關閉成功!')", 500);
  567. } else {
  568. alert(res);
  569. };
  570. }, 'text')
  571. // setTimeout(function () { location.reload(); }, 500);
  572. };
  573. function tankPumpSensor_ON() {
  574. var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": "on" };
  575. $.post('/mqtt/' + tank_num, data, function (res) {
  576. console.log('data:', data)
  577. if (res == 'on') {
  578. $("#cmn-toggle-41").prop('checked', true);
  579. } else if (res == 'off') {
  580. $("#cmn-toggle-41").prop('checked', false);
  581. } else {
  582. console.log('res error');
  583. };
  584. }, 'text')
  585. // setTimeout(function () { location.reload(); }, 500);
  586. }
  587. function tankPumpSensor_OFF() {
  588. var data = { "tank_num": "F" + tank_num, "command": "tank_pump_sensor_status", "value": "off" };
  589. $.post('/mqtt/' + tank_num, data, function (res) {
  590. console.log('data:', data)
  591. if (res == 'on') {
  592. $("#cmn-toggle-41").prop('checked', true);
  593. } else if (res == 'off') {
  594. $("#cmn-toggle-41").prop('checked', false);
  595. } else {
  596. console.log('res error');
  597. };
  598. }, 'text')
  599. // setTimeout(function () { location.reload(); }, 500);
  600. }
  601. // 感測模組下豆三通閥
  602. function tankThreeWayValveBean() {
  603. var status = "off";
  604. var check = $("input[name=tank_threewayvalve_bean_status]:checked");
  605. //大於0代表有被選中
  606. if (check.length > 0) {
  607. status = "on";
  608. $("#cmn-toggle-44").prop('checked', false);
  609. if (!confirm("你確定要開啟感測模組下豆三通閥嗎?")) {
  610. return false;
  611. };
  612. } else {
  613. $("#cmn-toggle-44").prop('checked', true);
  614. if (!confirm("你確定要關閉感測模組下豆三通閥嗎?")) {
  615. return false;
  616. };
  617. };
  618. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_bean_status", "value": status };
  619. $.post('/mqtt/' + tank_num, data, function (res) {
  620. console.log('data:', data)
  621. if (res == 'on') {
  622. $("#cmn-toggle-44").prop('checked', true);
  623. setTimeout("alert('感測模組下豆三通閥_開啟成功!')", 500);
  624. } else if (res == 'off') {
  625. $("#cmn-toggle-44").prop('checked', false);
  626. setTimeout("alert('感測模組下豆三通閥_關閉成功!')", 500);
  627. } else {
  628. alert(res);
  629. };
  630. }, 'text')
  631. // setTimeout(function () { location.reload(); }, 500);
  632. };
  633. function tankThreeWayValveBean_ON() {
  634. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_bean_status", "value": "on" };
  635. $.post('/mqtt/' + tank_num, data, function (res) {
  636. console.log('data:', data)
  637. if (res == 'on') {
  638. $("#cmn-toggle-44").prop('checked', true);
  639. } else if (res == 'off') {
  640. $("#cmn-toggle-44").prop('checked', false);
  641. } else {
  642. console.log('res error');
  643. };
  644. }, 'text')
  645. // setTimeout(function () { location.reload(); }, 500);
  646. };
  647. function tankThreeWayValveBean_OFF() {
  648. var data = { "tank_num": "F" + tank_num, "command": "tank_threewayvalve_bean_status", "value": "off" };
  649. $.post('/mqtt/' + tank_num, data, function (res) {
  650. console.log('data:', data)
  651. if (res == 'on') {
  652. $("#cmn-toggle-44").prop('checked', true);
  653. } else if (res == 'off') {
  654. $("#cmn-toggle-44").prop('checked', false);
  655. } else {
  656. console.log('res error');
  657. };
  658. }, 'text')
  659. // setTimeout(function () { location.reload(); }, 500);
  660. };
  661. // 外桶浮選三通閥
  662. function outerThreeWayValveFloat() {
  663. var status = "off";
  664. var check = $("input[name=outer_threewayvalve_float_status]:checked");
  665. //大於0代表有被選中
  666. if (check.length > 0) {
  667. status = "on";
  668. $("#cmn-toggle-47").prop('checked', false);
  669. if (!confirm("你確定要開啟外桶浮選三通閥嗎?")) {
  670. return false;
  671. };
  672. } else {
  673. $("#cmn-toggle-47").prop('checked', true);
  674. if (!confirm("你確定要關閉外桶浮選三通閥嗎?")) {
  675. return false;
  676. };
  677. };
  678. var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": status };
  679. $.post('/mqtt/' + tank_num, data, function (res) {
  680. console.log('data:', data)
  681. if (res == 'on') {
  682. $("#cmn-toggle-47").prop('checked', true);
  683. setTimeout("alert('外桶浮選三通閥_開啟成功!')", 500);
  684. } else if (res == 'off') {
  685. $("#cmn-toggle-47").prop('checked', false);
  686. setTimeout("alert('外桶浮選三通閥_關閉成功!')", 500);
  687. } else {
  688. alert(res);
  689. };
  690. }, 'text')
  691. // setTimeout(function () { location.reload(); }, 500);
  692. };
  693. function outerThreeWayValveFloat_ON() {
  694. var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": "on" };
  695. $.post('/mqtt/' + tank_num, data, function (res) {
  696. console.log('data:', data)
  697. if (res == 'on') {
  698. $("#cmn-toggle-47").prop('checked', true);
  699. } else if (res == 'off') {
  700. $("#cmn-toggle-47").prop('checked', false);
  701. } else {
  702. console.log('res error');
  703. };
  704. }, 'text')
  705. // setTimeout(function () { location.reload(); }, 500);
  706. };
  707. function outerThreeWayValveFloat_OFF() {
  708. var data = { "tank_num": "F" + tank_num, "command": "outer_threewayvalve_float_status", "value": "off" };
  709. $.post('/mqtt/' + tank_num, data, function (res) {
  710. console.log('data:', data)
  711. if (res == 'on') {
  712. $("#cmn-toggle-47").prop('checked', true);
  713. } else if (res == 'off') {
  714. $("#cmn-toggle-47").prop('checked', false);
  715. } else {
  716. console.log('res error');
  717. };
  718. }, 'text')
  719. // setTimeout(function () { location.reload(); }, 500);
  720. };
  721. // Benson cargo2_actuator.html 脫皮機馬達 (START) 馬達攪拌棒
  722. function tankMotor() {
  723. var motor_data = $("input[id=motor_rpm_data]").val();
  724. if (motor_data == '') {
  725. //$("#cmn-toggle-20").prop('checked', false);
  726. alert("請先輸入要運轉的值!");
  727. return false;
  728. } else if (motor_data == 0) {
  729. alert("轉速 0 為關閉馬達");
  730. } else if (Number(motor_data) < -50 || Number(motor_data) > 50 || !Number(motor_data)) {
  731. //
  732. //$("#cmn-toggle-20").prop('checked', false);
  733. alert("您輸入的值已超過範圍,請重新輸入!" + !Number(motor_data));
  734. return false;
  735. };
  736. var value = "off";
  737. //var check = $("input[name=peeling-machine-on]:checked");
  738. if (motor_data != 0) {
  739. value = motor_data;
  740. //$("#cmn-toggle-20").prop('checked', false);
  741. if (!confirm("你確定要開啟攪拌馬達,運轉速度為 " + motor_data + " RPM 嗎?")) {
  742. return false;
  743. };
  744. } else {
  745. //$("#cmn-toggle-20").prop('checked', true);
  746. if (!confirm("你確定要關閉攪拌馬達嗎?")) {
  747. return false;
  748. };
  749. };
  750. var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": motor_data };
  751. $.post('/mqtt/' + tank_num, data, function (res) {
  752. console.log('data:', data)
  753. if (res == 'on') {
  754. //$("#cmn-toggle-14").prop('checked', true); // prop 設置元素屬型與元素值, 設定 checked 屬性為 true
  755. setTimeout("alert('攪拌馬達_開啟成功!')", 500); // 設定時間執行函式 delay(500), 只執行一次
  756. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  757. } else if (res == 'off') {
  758. //$("#cmn-toggle-14").prop('checked', false);
  759. setTimeout("alert('攪拌馬達_關閉成功!')", 500);
  760. clearInterval(timer); // 取消 timer 的不斷執行
  761. $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
  762. } else {
  763. alert(res);
  764. };
  765. }, 'text')
  766. // setTimeout(function () { location.reload(); }, 500);
  767. };
  768. function tankMotor_ON() {
  769. var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": "20" };
  770. $.post('/mqtt/' + tank_num, data, function (res) {
  771. console.log('data:', data)
  772. if (res == 'on') {
  773. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  774. } else if (res == 'off') {
  775. clearInterval(timer); // 取消 timer 的不斷執行
  776. $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
  777. } else {
  778. console.log('res error');
  779. };
  780. }, 'text')
  781. // setTimeout(function () { location.reload(); }, 500);
  782. };
  783. function tankMotor_OFF() {
  784. var data = { "tank_num": "F" + tank_num, "command": "tank_motor_status", "value": "0" };
  785. $.post('/mqtt/' + tank_num, data, function (res) {
  786. console.log('data:', data)
  787. if (res == 'on') {
  788. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  789. } else if (res == 'off') {
  790. clearInterval(timer); // 取消 timer 的不斷執行
  791. $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
  792. } else {
  793. console.log('res error');
  794. };
  795. }, 'text')
  796. // setTimeout(function () { location.reload(); }, 500);
  797. };
  798. function Rotate() {
  799. $.get('/peeling', '', function (res) {
  800. //console.log(res.peeling);
  801. $("#motor_rpm_status-status").text(res.peeling + ' rpm(每1分鐘更新一次)');
  802. }, 'json');
  803. // setTimeout(function () { location.reload(); }, 500);
  804. };
  805. // Benson cargo2_actuator.html 鼓風機 (START)
  806. //電熱管1函數
  807. function tankHeater1() {
  808. var status = "off";
  809. var check = $("input[name=tank_heater1_status]:checked");
  810. //大於0代表有被選中
  811. if (check.length > 0) {
  812. status = "on";
  813. $("#cmn-toggle-26").prop('checked', false);
  814. if (!confirm("你確定要開啟電熱管1嗎?")) {
  815. return false;
  816. };
  817. } else {
  818. $("#cmn-toggle-26").prop('checked', true);
  819. if (!confirm("你確定要關閉電熱管1嗎?")) {
  820. return false;
  821. };
  822. };
  823. var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": status };
  824. $.post('/mqtt/' + tank_num, data, function (res) {
  825. console.log('data:', data)
  826. if (res == 'on') {
  827. $("#cmn-toggle-26").prop('checked', true);
  828. setTimeout("alert('電熱管1_開啟成功!')", 500);
  829. } else if (res == 'off') {
  830. $("#cmn-toggle-26").prop('checked', false);
  831. setTimeout("alert('電熱管1_關閉成功!')", 500);
  832. } else {
  833. alert(res);
  834. };
  835. }, 'text')
  836. // setTimeout(function () { location.reload(); }, 500);
  837. };
  838. function tankHeater1_ON() {
  839. var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": "on" };
  840. $.post('/mqtt/' + tank_num, data, function (res) {
  841. console.log('data:', data)
  842. if (res == 'on') {
  843. $("#cmn-toggle-26").prop('checked', true);
  844. } else if (res == 'off') {
  845. $("#cmn-toggle-26").prop('checked', false);
  846. } else {
  847. console.log('res error');
  848. };
  849. }, 'text')
  850. // setTimeout(function () { location.reload(); }, 500);
  851. };
  852. function tankHeater1_OFF() {
  853. var data = { "tank_num": "F" + tank_num, "command": "tank_heater1_status", "value": "off" };
  854. $.post('/mqtt/' + tank_num, data, function (res) {
  855. console.log('data:', data)
  856. if (res == 'on') {
  857. $("#cmn-toggle-26").prop('checked', true);
  858. } else if (res == 'off') {
  859. $("#cmn-toggle-26").prop('checked', false);
  860. } else {
  861. console.log('res error');
  862. };
  863. }, 'text')
  864. // setTimeout(function () { location.reload(); }, 500);
  865. };
  866. //電熱管2函數
  867. function tankHeater2() {
  868. var status = "off";
  869. var check = $("input[name=tank_heater2_status]:checked");
  870. //大於0代表有被選中
  871. if (check.length > 0) {
  872. status = "on";
  873. $("#cmn-toggle-29").prop('checked', false);
  874. if (!confirm("你確定要開啟電熱管2嗎?")) {
  875. return false;
  876. };
  877. } else {
  878. $("#cmn-toggle-29").prop('checked', true);
  879. if (!confirm("你確定要關閉電熱管2嗎?")) {
  880. return false;
  881. };
  882. };
  883. var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": status };
  884. $.post('/mqtt/' + tank_num, data, function (res) {
  885. console.log('data:', data)
  886. if (res == 'on') {
  887. $("#cmn-toggle-29").prop('checked', true);
  888. setTimeout("alert('電熱管2_開啟成功!')", 500);
  889. } else if (res == 'off') {
  890. $("#cmn-toggle-29").prop('checked', false);
  891. setTimeout("alert('電熱管2_關閉成功!')", 500);
  892. } else {
  893. alert(res);
  894. };
  895. }, 'text')
  896. // setTimeout(function () { location.reload(); }, 500);
  897. };
  898. function tankHeater2_ON() {
  899. var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": "on" };
  900. $.post('/mqtt/' + tank_num, data, function (res) {
  901. console.log('data:', data)
  902. if (res == 'on') {
  903. $("#cmn-toggle-29").prop('checked', true);
  904. } else if (res == 'off') {
  905. $("#cmn-toggle-29").prop('checked', false);
  906. } else {
  907. console.log('res error');
  908. };
  909. }, 'text')
  910. // setTimeout(function () { location.reload(); }, 500);
  911. };
  912. function tankHeater2_OFF() {
  913. var data = { "tank_num": "F" + tank_num, "command": "tank_heater2_status", "value": "off" };
  914. $.post('/mqtt/' + tank_num, data, function (res) {
  915. console.log('data:', data)
  916. if (res == 'on') {
  917. $("#cmn-toggle-29").prop('checked', true);
  918. } else if (res == 'off') {
  919. $("#cmn-toggle-29").prop('checked', false);
  920. } else {
  921. console.log('res error');
  922. };
  923. }, 'text')
  924. // setTimeout(function () { location.reload(); }, 500);
  925. };
  926. // 溫度控制
  927. function tankTempEnable() {
  928. var status = "off";
  929. var check = $("input[name=tank_temp_enable_status]:checked");
  930. //大於0代表有被選中
  931. if (check.length > 0) {
  932. status = "on";
  933. $("#cmn-toggle-35").prop('checked', false);
  934. if (!confirm("你確定要開啟溫度控制嗎?")) {
  935. return false;
  936. };
  937. } else {
  938. $("#cmn-toggle-35").prop('checked', true);
  939. if (!confirm("你確定要關閉溫度控制嗎?")) {
  940. return false;
  941. };
  942. };
  943. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": status };
  944. $.post('/mqtt/' + tank_num, data, function (res) {
  945. console.log('data:', data)
  946. if (res == 'on') {
  947. $("#cmn-toggle-35").prop('checked', true);
  948. setTimeout("alert('溫度控制_開啟成功!')", 500);
  949. } else if (res == 'off') {
  950. $("#cmn-toggle-35").prop('checked', false);
  951. setTimeout("alert('溫度控制_關閉成功!')", 500);
  952. } else {
  953. alert(res);
  954. };
  955. }, 'text')
  956. // setTimeout(function () { location.reload(); }, 500);
  957. };
  958. function tankTempEnable_ON() {
  959. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": "on" };
  960. $.post('/mqtt/' + tank_num, data, function (res) {
  961. console.log('data:', data)
  962. if (res == 'on') {
  963. $("#cmn-toggle-35").prop('checked', true);
  964. } else if (res == 'off') {
  965. $("#cmn-toggle-35").prop('checked', false);
  966. } else {
  967. console.log('res error');
  968. };
  969. }, 'text')
  970. // setTimeout(function () { location.reload(); }, 500);
  971. };
  972. function tankTempEnable_OFF() {
  973. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_enable_status", "value": "off" };
  974. $.post('/mqtt/' + tank_num, data, function (res) {
  975. console.log('data:', data)
  976. if (res == 'on') {
  977. $("#cmn-toggle-35").prop('checked', true);
  978. } else if (res == 'off') {
  979. $("#cmn-toggle-35").prop('checked', false);
  980. } else {
  981. console.log('res error');
  982. };
  983. }, 'text')
  984. // setTimeout(function () { location.reload(); }, 500);
  985. };
  986. // 判斷是否整數
  987. function isInteger(obj) {
  988. return obj % 1 === 0
  989. }
  990. isInteger(3) // true
  991. // 設定溫度
  992. function tankTemp() {
  993. var temp_data = $("input[id=tank_temp_data]").val();
  994. if (temp_data == '') {
  995. //$("#cmn-toggle-20").prop('checked', false);
  996. alert("請先輸入設定溫度!");
  997. return false;
  998. } else if (!isInteger(temp_data)) {
  999. //$("#cmn-toggle-20").prop('checked', false);
  1000. alert("溫度設定僅限整數,請重新輸入!" + !Number(temp_data));
  1001. return false;
  1002. };
  1003. var value = "0";
  1004. //var check = $("input[name=peeling-machine-on]:checked");
  1005. if ($("#cmn-toggle-35").prop('checked')) {
  1006. value = temp_data;
  1007. //$("#cmn-toggle-20").prop('checked', false);
  1008. if (!confirm("你確定要設定內桶溫度為 " + temp_data + " ℃ 嗎?")) {
  1009. return false;
  1010. };
  1011. } else {
  1012. //$("#cmn-toggle-20").prop('checked', true);
  1013. //你確定要停止桶內溫度設定嗎
  1014. if (!confirm("請先開啟溫控開關, 再設定桶內溫度")) {
  1015. return false;
  1016. };
  1017. };
  1018. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": temp_data };
  1019. $.post('/mqtt/' + tank_num, data, function (res) {
  1020. console.log('data:', data)
  1021. if (res == 'on') {
  1022. //$("#cmn-toggle-14").prop('checked', true); // prop 設置元素屬型與元素值, 設定 checked 屬性為 true
  1023. setTimeout("alert('溫度設定_開啟成功!')", 500); // 設定時間執行函式 delay(500), 只執行一次
  1024. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  1025. } else if (res == 'off') {
  1026. //$("#cmn-toggle-14").prop('checked', false);
  1027. setTimeout("alert('溫度設定_關閉成功!')", 500);
  1028. clearInterval(timer); // 取消 timer 的不斷執行
  1029. $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
  1030. } else {
  1031. alert(res);
  1032. };
  1033. }, 'text')
  1034. // setTimeout(function () { location.reload(); }, 500);
  1035. };
  1036. function setTemp(temp_data, temp_duration) {
  1037. // var temp_data = $("input[id=tank_temp_data]").val();
  1038. if (temp_data == '') {
  1039. alert("請先輸入設定溫度!");
  1040. return false;
  1041. } else if (temp_duration == '') {
  1042. alert("請先輸入持溫時間!");
  1043. return false;
  1044. }
  1045. tankTempEnable_ON()
  1046. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": temp_data, "duration": temp_duration};
  1047. $.post('/mqtt/' + tank_num, data, function (res) {
  1048. console.log('data:', data)
  1049. if (res == 'on') {
  1050. //$("#cmn-toggle-14").prop('checked', true); // prop 設置元素屬型與元素值, 設定 checked 屬性為 true
  1051. setTimeout("alert('溫度設定_開啟成功!')", 500); // 設定時間執行函式 delay(500), 只執行一次
  1052. } else if (res == 'off') {
  1053. //$("#cmn-toggle-14").prop('checked', false);
  1054. setTimeout("alert('溫度設定_關閉成功!')", 500);
  1055. } else {
  1056. console.log(res)
  1057. };
  1058. }, 'text')
  1059. /*
  1060. $.get('/loading/F' + tank_num, '', function (res) {
  1061. $("#tank_temp_data").attr("placeholder", res.tank_temp1);
  1062. }, 'json');
  1063. */
  1064. // window.location.reload();
  1065. };
  1066. function tankTemp_ON() {
  1067. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": "30" };
  1068. $.post('/mqtt/' + tank_num, data, function (res) {
  1069. console.log('data:', data)
  1070. if (res == 'on') {
  1071. } else if (res == 'off') {
  1072. } else {
  1073. console.log('res error');
  1074. };
  1075. }, 'text')
  1076. // setTimeout(function () { location.reload(); }, 500);
  1077. };
  1078. function tankTemp_OFF() {
  1079. var data = { "tank_num": "F" + tank_num, "command": "tank_temp_status", "value": "0" };
  1080. $.post('/mqtt/' + tank_num, data, function (res) {
  1081. console.log('data:', data)
  1082. if (res == 'on') {
  1083. } else if (res == 'off') {
  1084. } else {
  1085. console.log('res error');
  1086. };
  1087. }, 'text')
  1088. // setTimeout(function () { location.reload(); }, 500);
  1089. };
  1090. // Benson 真空吸料機 (START) 出料儲豆槽
  1091. function outputVacuum() {
  1092. var status = "off";
  1093. var check = $("input[name=output_vacuum_status]:checked");
  1094. //大於0代表有被選中
  1095. if (check.length > 0) {
  1096. status = "on";
  1097. $("#cmn-toggle-32").prop('checked', false);
  1098. if (!confirm("你確定要開啟出料儲豆槽真空吸料機嗎?")) {
  1099. return false;
  1100. };
  1101. } else {
  1102. $("#cmn-toggle-32").prop('checked', true);
  1103. if (!confirm("你確定要關閉出料儲豆槽真空吸料機嗎?")) {
  1104. return false;
  1105. };
  1106. };
  1107. var data = { "tank_num": "FO" + tank_num, "command": "output_vacuum_status", "value": status };
  1108. console.log('data:', data)
  1109. $.post('/mqtt/' + tank_num, data, function (res) {
  1110. if (res == 'on') {
  1111. $("#cmn-toggle-32").prop('checked', true);
  1112. setTimeout("alert('出料儲豆槽真空吸料機_開啟成功!')", 500);
  1113. } else if (res == 'off') {
  1114. $("#cmn-toggle-32").prop('checked', false);
  1115. setTimeout("alert('出料儲豆槽真空吸料機_關閉成功!')", 500);
  1116. } else {
  1117. alert(res);
  1118. };
  1119. }, 'text')
  1120. };
  1121. function outputVacuum_ON() {
  1122. var data = { "tank_num": "FO" + tank_num, "command": "output_vacuum_status", "value": "on" };
  1123. console.log('data:', data)
  1124. $.post('/mqtt/' + tank_num, data, function (res) {
  1125. if (res == 'on') {
  1126. $("#cmn-toggle-32").prop('checked', true);
  1127. } else if (res == 'off') {
  1128. $("#cmn-toggle-32").prop('checked', false);
  1129. } else {
  1130. console.log('res error');
  1131. };
  1132. }, 'text')
  1133. };
  1134. function outputVacuum_OFF() {
  1135. var data = { "tank_num": "FO" + tank_num, "command": "output_vacuum_status", "value": "off" };
  1136. console.log('data:', data)
  1137. $.post('/mqtt/' + tank_num, data, function (res) {
  1138. if (res == 'on') {
  1139. $("#cmn-toggle-32").prop('checked', true);
  1140. } else if (res == 'off') {
  1141. $("#cmn-toggle-32").prop('checked', false);
  1142. } else {
  1143. console.log('res error');
  1144. };
  1145. }, 'text')
  1146. };