tanks_comm.html 112 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937
  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. <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
  8. <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  9. <!-- 新 Bootstrap4 核心 CSS 文件 -->
  10. <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
  11. <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
  12. <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
  13. <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
  14. <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  15. <script language="JavaScript">
  16. $(function(){
  17. // 網頁 title
  18. $("#coffee_title_pc").text("設備單元整合運作");
  19. $("#coffee_title_phone").text("設備單元整合運作");
  20. // 使用者權限判斷
  21. // $('.select-input').prop('disabled', false);
  22. });
  23. </script>
  24. <style>
  25. /* .boardpic_position {
  26. position: absolute;
  27. top: 80px;
  28. left: 25px;
  29. } */
  30. .r5_position {
  31. position: absolute;
  32. top: 160px;
  33. left: 310px;
  34. width: 40px;
  35. height: 150px;
  36. border-style: solid;
  37. border-color: aqua;
  38. }
  39. .div_relay_css {
  40. position: absolute;
  41. border-style: solid;
  42. border-color: aqua;
  43. text-align: center;
  44. font-size: 12px;
  45. }
  46. /* header */
  47. /* 文字輸入框 */
  48. .input-text {
  49. height: 25px;
  50. width: 40px;
  51. text-align: center;
  52. margin-left: 2px;
  53. margin-right: 5px;
  54. }
  55. /* 致動器狀態表格置中 */
  56. .label_ActuatorStatus {
  57. margin: auto;
  58. }
  59. /* 致動器 ON 樣式 */
  60. .input-button-on {
  61. color: #008CBA;
  62. border: 2px rgb(182, 181, 181) solid;
  63. background-color: whitesmoke;
  64. padding: 1px 3px;
  65. width: 45px;
  66. }
  67. /* 致動器 OFF 樣式 */
  68. .input-button-off {
  69. color: #707070;
  70. border: 2px rgb(192, 192, 192) solid;
  71. background-color: whitesmoke;
  72. padding: 1px 3px;
  73. width: 45px;
  74. }
  75. /* 輸入按鈕 */
  76. .input-button {
  77. font-size: 14px;
  78. color: #008CBA;
  79. border: 2px rgb(182, 181, 181) solid;
  80. background-color: whitesmoke;
  81. padding: 1px 3px;
  82. }
  83. /* 大表格樣式 */
  84. .table-all {
  85. font-size:18px;
  86. border:2px #cccccc solid;
  87. margin-left: 10px;
  88. margin-right: 10px;
  89. width: 98%;
  90. }
  91. /* footer */
  92. .footer{
  93. height: 40px;
  94. box-sizing: border-box;
  95. /* 設定footer絕對位置在底部 */
  96. position: absolute;
  97. bottom: 0px;
  98. width: 100%;
  99. background-color: #eee;
  100. text-align: center;
  101. }
  102. html, body {
  103. height: 100%;
  104. /* margin: 0; */
  105. position: relative;
  106. }
  107. #wrapper {
  108. /* 設定高度最小為100%, 如果內容區塊很多, 可以長大 */
  109. /* min-height: 100%; */
  110. /* 位置設為relative, 作為footer區塊位置的參考 */
  111. position: relative;
  112. }
  113. </style>
  114. </head>
  115. <body style="font-size: 18px;">
  116. <div id="wrapper" style="height: 3000px;">
  117. <div id="coffee_header">
  118. <!-- 匯入共同使用的 header.html 內容 -->
  119. {% include 'header.html' %}
  120. </div>
  121. <table style="position: absolute; top: 75px; left: 25px; width: max-content;">
  122. <!-- coffee1.0 板子圖片 -->
  123. <!-- 燒錄制動器 / 感測器 -->
  124. <tr>
  125. <td style="width: 900px; vertical-align: top;">
  126. <img src="../static/img/0103_board_coffee1.0_tag.png" style="width: 100%;">
  127. </td>
  128. <td style="width: 20px;">
  129. </td>
  130. <td>
  131. <table border="5" style="border: 3px white solid;">
  132. <tr>
  133. <td colspan="3">
  134. ethernet :
  135. <select id="select_ethernet_1" onchange="" class="select-input">
  136. <option>OFF</option>
  137. <option>ON</option>
  138. </select>
  139. &nbsp;
  140. Wi-Fi :
  141. <select id="select_wifi_1" onchange="" class="select-input">
  142. <option>OFF</option>
  143. <option>ON</option>
  144. </select>
  145. &nbsp;
  146. zigbee :
  147. <select id="select_zigbee_1" onchange="" class="select-input">
  148. <option>OFF</option>
  149. <option>ON</option>
  150. </select>
  151. <br>
  152. </td>
  153. </tr>
  154. <tr>
  155. <!-- Relay 1-10 -->
  156. <td style="background-color: lightblue;">
  157. Relay 1 :
  158. <select id="select_relay_1" onchange="select_relay('1')" class="select-input">
  159. <option></option>
  160. <option value="vacuum">真空吸料機</option>
  161. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  162. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  163. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  164. <option value="diskvalve">蝴蝶閥</option>
  165. <option value="warninglight">警示燈</option>
  166. <option value="camera">攝影機</option>
  167. <option value="heater">電熱管</option>
  168. <option value="pump">雙核泵</option>
  169. </select>
  170. <br>
  171. Relay 2 :
  172. <select id="select_relay_2" onchange="select_relay('2')" class="select-input">
  173. <option></option>
  174. <option value="vacuum">真空吸料機</option>
  175. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  176. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  177. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  178. <option value="diskvalve">蝴蝶閥</option>
  179. <option value="warninglight">警示燈</option>
  180. <option value="camera">攝影機</option>
  181. <option value="heater">電熱管</option>
  182. <option value="pump">雙核泵</option>
  183. </select>
  184. <br>
  185. Relay 3 :
  186. <select id="select_relay_3" onchange="select_relay('3')" class="select-input">
  187. <option></option>
  188. <option value="vacuum">真空吸料機</option>
  189. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  190. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  191. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  192. <option value="diskvalve">蝴蝶閥</option>
  193. <option value="warninglight">警示燈</option>
  194. <option value="camera">攝影機</option>
  195. <option value="heater">電熱管</option>
  196. <option value="pump">雙核泵</option>
  197. </select>
  198. <br>
  199. Relay 4 :
  200. <select id="select_relay_4" onchange="select_relay('4')" class="select-input">
  201. <option></option>
  202. <option value="vacuum">真空吸料機</option>
  203. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  204. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  205. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  206. <option value="diskvalve">蝴蝶閥</option>
  207. <option value="warninglight">警示燈</option>
  208. <option value="camera">攝影機</option>
  209. <option value="heater">電熱管</option>
  210. <option value="pump">雙核泵</option>
  211. </select>
  212. <br>
  213. Relay 5 :
  214. <select id="select_relay_5" onchange="select_relay('5')" class="select-input">
  215. <option></option>
  216. <option value="vacuum">真空吸料機</option>
  217. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  218. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  219. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  220. <option value="diskvalve">蝴蝶閥</option>
  221. <option value="warninglight">警示燈</option>
  222. <option value="camera">攝影機</option>
  223. <option value="heater">電熱管</option>
  224. <option value="pump">雙核泵</option>
  225. </select>
  226. <br>
  227. Relay 6 :
  228. <select id="select_relay_6" onchange="select_relay('6')" class="select-input">
  229. <option></option>
  230. <option value="vacuum">真空吸料機</option>
  231. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  232. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  233. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  234. <option value="diskvalve">蝴蝶閥</option>
  235. <option value="warninglight">警示燈</option>
  236. <option value="camera">攝影機</option>
  237. <option value="heater">電熱管</option>
  238. <option value="pump">雙核泵</option>
  239. </select>
  240. <br>
  241. Relay 7 :
  242. <select id="select_relay_7" onchange="select_relay('7')" class="select-input">
  243. <option></option>
  244. <option value="vacuum">真空吸料機</option>
  245. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  246. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  247. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  248. <option value="diskvalve">蝴蝶閥</option>
  249. <option value="warninglight">警示燈</option>
  250. <option value="camera">攝影機</option>
  251. <option value="heater">電熱管</option>
  252. <option value="pump">雙核泵</option>
  253. </select>
  254. <br>
  255. Relay 8 :
  256. <select id="select_relay_8" onchange="select_relay('8')" class="select-input">
  257. <option></option>
  258. <option value="vacuum">真空吸料機</option>
  259. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  260. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  261. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  262. <option value="diskvalve">蝴蝶閥</option>
  263. <option value="warninglight">警示燈</option>
  264. <option value="camera">攝影機</option>
  265. <option value="heater">電熱管</option>
  266. <option value="pump">雙核泵</option>
  267. </select>
  268. <br>
  269. Relay 9 :
  270. <select id="select_relay_9" onchange="select_relay('9')" class="select-input">
  271. <option></option>
  272. <option value="vacuum">真空吸料機</option>
  273. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  274. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  275. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  276. <option value="diskvalve">蝴蝶閥</option>
  277. <option value="warninglight">警示燈</option>
  278. <option value="camera">攝影機</option>
  279. <option value="heater">電熱管</option>
  280. <option value="pump">雙核泵</option>
  281. </select>
  282. <br>
  283. Relay 10 :
  284. <select id="select_relay_10" onchange="select_relay('10')" class="select-input">
  285. <option></option>
  286. <option value="vacuum">真空吸料機</option>
  287. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  288. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  289. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  290. <option value="diskvalve">蝴蝶閥</option>
  291. <option value="warninglight">警示燈</option>
  292. <option value="camera">攝影機</option>
  293. <option value="heater">電熱管</option>
  294. <option value="pump">雙核泵</option>
  295. </select>
  296. </td>
  297. <td></td>
  298. <!-- Relay 11-20 -->
  299. <td style="background-color: lightblue;">
  300. Relay 11 :
  301. <select id="select_relay_11" onchange="select_relay('11')" class="select-input">
  302. <option></option>
  303. <option value="vacuum">真空吸料機</option>
  304. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  305. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  306. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  307. <option value="diskvalve">蝴蝶閥</option>
  308. <option value="warninglight">警示燈</option>
  309. <option value="camera">攝影機</option>
  310. <option value="heater">電熱管</option>
  311. <option value="pump">雙核泵</option>
  312. </select>
  313. <br>
  314. Relay 12 :
  315. <select id="select_relay_12" onchange="select_relay('12')" class="select-input">
  316. <option></option>
  317. <option value="vacuum">真空吸料機</option>
  318. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  319. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  320. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  321. <option value="diskvalve">蝴蝶閥</option>
  322. <option value="warninglight">警示燈</option>
  323. <option value="camera">攝影機</option>
  324. <option value="heater">電熱管</option>
  325. <option value="pump">雙核泵</option>
  326. </select>
  327. <br>
  328. Relay 13 :
  329. <select id="select_relay_13" onchange="select_relay('13')" class="select-input">
  330. <option></option>
  331. <option value="vacuum">真空吸料機</option>
  332. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  333. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  334. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  335. <option value="diskvalve">蝴蝶閥</option>
  336. <option value="warninglight">警示燈</option>
  337. <option value="camera">攝影機</option>
  338. <option value="heater">電熱管</option>
  339. <option value="pump">雙核泵</option>
  340. </select>
  341. <br>
  342. Relay 14 :
  343. <select id="select_relay_14" onchange="select_relay('14')" class="select-input">
  344. <option></option>
  345. <option value="vacuum">真空吸料機</option>
  346. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  347. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  348. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  349. <option value="diskvalve">蝴蝶閥</option>
  350. <option value="warninglight">警示燈</option>
  351. <option value="camera">攝影機</option>
  352. <option value="heater">電熱管</option>
  353. <option value="pump">雙核泵</option>
  354. </select>
  355. <br>
  356. Relay 15 :
  357. <select id="select_relay_15" onchange="select_relay('15')" class="select-input">
  358. <option></option>
  359. <option value="vacuum">真空吸料機</option>
  360. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  361. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  362. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  363. <option value="diskvalve">蝴蝶閥</option>
  364. <option value="warninglight">警示燈</option>
  365. <option value="camera">攝影機</option>
  366. <option value="heater">電熱管</option>
  367. <option value="pump">雙核泵</option>
  368. </select>
  369. <br>
  370. Relay 16 :
  371. <select id="select_relay_16" onchange="select_relay('16')" class="select-input">
  372. <option></option>
  373. <option value="vacuum">真空吸料機</option>
  374. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  375. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  376. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  377. <option value="diskvalve">蝴蝶閥</option>
  378. <option value="warninglight">警示燈</option>
  379. <option value="camera">攝影機</option>
  380. <option value="heater">電熱管</option>
  381. <option value="pump">雙核泵</option>
  382. </select>
  383. <br>
  384. Relay 17 :
  385. <select id="select_relay_17" onchange="select_relay('17')" class="select-input">
  386. <option></option>
  387. <option value="vacuum">真空吸料機</option>
  388. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  389. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  390. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  391. <option value="diskvalve">蝴蝶閥</option>
  392. <option value="warninglight">警示燈</option>
  393. <option value="camera">攝影機</option>
  394. <option value="heater">電熱管</option>
  395. <option value="pump">雙核泵</option>
  396. </select>
  397. <br>
  398. Relay 18 :
  399. <select id="select_relay_18" onchange="select_relay('18')" class="select-input">
  400. <option></option>
  401. <option value="vacuum">真空吸料機</option>
  402. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  403. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  404. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  405. <option value="diskvalve">蝴蝶閥</option>
  406. <option value="warninglight">警示燈</option>
  407. <option value="camera">攝影機</option>
  408. <option value="heater">電熱管</option>
  409. <option value="pump">雙核泵</option>
  410. </select>
  411. <br>
  412. Relay 19 :
  413. <select id="select_relay_19" onchange="select_relay('19')" class="select-input">
  414. <option></option>
  415. <option value="vacuum">真空吸料機</option>
  416. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  417. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  418. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  419. <option value="diskvalve">蝴蝶閥</option>
  420. <option value="warninglight">警示燈</option>
  421. <option value="camera">攝影機</option>
  422. <option value="heater">電熱管</option>
  423. <option value="pump">雙核泵</option>
  424. </select>
  425. <br>
  426. Relay 20 :
  427. <select id="select_relay_20" onchange="select_relay('20')" class="select-input">
  428. <option></option>
  429. <option value="vacuum">真空吸料機</option>
  430. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  431. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  432. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  433. <option value="diskvalve">蝴蝶閥</option>
  434. <option value="warninglight">警示燈</option>
  435. <option value="camera">攝影機</option>
  436. <option value="heater">電熱管</option>
  437. <option value="pump">雙核泵</option>
  438. </select>
  439. <br>
  440. </td>
  441. </tr>
  442. <tr>
  443. <td> </td>
  444. </tr>
  445. <tr>
  446. <!-- 類比 -->
  447. <td style="background-color: lightgreen;">
  448. 類比 M4 :
  449. <select id="selectSensor_M4" onchange="selectSensor('M4')" class="select-input">
  450. <option></option>
  451. <option>PH</option>
  452. <option>DO</option>
  453. <option>ORP</option>
  454. </select>
  455. <br>
  456. 類比 M5 :
  457. <select id="selectSensor_M5" onchange="selectSensor('M5')" class="select-input">
  458. <option></option>
  459. <option>PH</option>
  460. <option>DO</option>
  461. <option>ORP</option>
  462. </select>
  463. <br>
  464. 類比 M7 :
  465. <select id="selectSensor_M7" onchange="selectSensor('M7')" class="select-input">
  466. <option></option>
  467. <option>PH</option>
  468. <option>DO</option>
  469. <option>ORP</option>
  470. </select>
  471. <br>
  472. </td>
  473. <td></td>
  474. <!-- 數位 1-3 -->
  475. <td style="background-color: lightgoldenrodyellow;">
  476. 數位 M9 :
  477. <select id="selectSensor_M9" onchange="selectSensor('M9')" class="select-input">
  478. <option></option>
  479. <option>WATERLEVEL</option>
  480. <option>motorfeedback</option>
  481. <option>butterflyvalvefeedback</option>
  482. </select>
  483. <br>
  484. 數位 M12 :
  485. <select id="selectSensor_M12" onchange="selectSensor('M12')" class="select-input">
  486. <option></option>
  487. <option>WATERLEVEL</option>
  488. <option>motorfeedback</option>
  489. <option>butterflyvalvefeedback</option>
  490. </select>
  491. <br>
  492. 數位 M19 :
  493. <select id="selectSensor_M19" onchange="selectSensor('M19')" class="select-input">
  494. <option></option>
  495. <option>WATERLEVEL</option>
  496. <option>motorfeedback</option>
  497. <option>butterflyvalvefeedback</option>
  498. </select>
  499. <br>
  500. </td>
  501. </tr>
  502. <tr>
  503. <td></td>
  504. </tr>
  505. <tr>
  506. <!-- PWM -->
  507. <td style="background-color: lightcyan;">
  508. PWM M10 :
  509. <select id="selectSensor_M10" onchange="selectSensor('M10')" class="select-input">
  510. <option></option>
  511. <option>Motor</option>
  512. </select>
  513. <br>
  514. PWM M2 :
  515. <select id="selectSensor_M2" onchange="selectSensor('M2')" class="select-input">
  516. <option></option>
  517. <option>Servo</option>
  518. </select>
  519. <br>
  520. PWM M3 :
  521. <select id="selectSensor_M3" onchange="selectSensor('M3')" class="select-input">
  522. <option></option>
  523. <option>Servo</option>
  524. </select>
  525. <br>
  526. </td>
  527. <td></td>
  528. <!-- 數位 4-5 -->
  529. <td style="background-color: lightgoldenrodyellow;">
  530. 數位 M14 :
  531. <select id="selectSensor_M14" onchange="selectSensor('M14')" class="select-input">
  532. <option></option>
  533. <option>SHT11</option>
  534. <option>DS18B20</option>
  535. </select>
  536. <br>
  537. 數位 M11 :
  538. <select id="selectSensor_M11" onchange="selectSensor('M11')" class="select-input">
  539. <option></option>
  540. <option>WATERLEVEL</option>
  541. <option>motorfeedback</option>
  542. <option>butterflyvalvefeedback</option>
  543. </select>
  544. <br>
  545. <br>
  546. </td>
  547. </tr>
  548. <tr>
  549. <td> </td>
  550. </tr>
  551. <tr>
  552. <!-- UART -->
  553. <td style="background-color: linen;">
  554. UART M16 :
  555. <select id="selectSensor_M16" onchange="selectSensor('M16')" class="select-input">
  556. <option></option>
  557. <option>EC</option>
  558. <option>DS18B20</option>
  559. <option>Servo真空閥</option>
  560. </select>
  561. <br>
  562. UART M17 :
  563. <select id="selectSensor_M17" onchange="selectSensor('M17')" class="select-input">
  564. <option></option>
  565. <option>SHT11</option>
  566. <option>Servo真空閥</option>
  567. </select>
  568. <br>
  569. UART M18 :
  570. <select id="selectSensor_M18" onchange="selectSensor('M18')" class="select-input">
  571. <option></option>
  572. </select>
  573. <br>
  574. </td>
  575. <td></td>
  576. <!-- 分壓類比 1 -->
  577. <td style="background-color:lavender;">
  578. <br>
  579. <br>
  580. 分壓類比 M6:
  581. <select id="selectSensor_M6" onchange="selectSensor('M6')" class="select-input">
  582. <option></option>
  583. <option>SEN0189</option>
  584. </select>
  585. <br>
  586. </td>
  587. </tr>
  588. <tr>
  589. <!-- I2C -->
  590. <!-- 485 -->
  591. <td style="background-color: lightpink;">
  592. I2C M15:
  593. <select id="selectSensor_M15" onchange="selectSensor('M15')" class="select-input">
  594. <option></option>
  595. <option>BMP280</option>
  596. </select>
  597. <br>
  598. 485 M8:
  599. <select id="selectSensor_M8" onchange="selectSensor('M8')" class="select-input">
  600. <option></option>
  601. <option>Soil</option>
  602. </select>
  603. <br>
  604. </td>
  605. <td></td>
  606. <!-- 分壓類比 2-3 -->
  607. <td style="background-color:lavender;">
  608. 分壓類比 M13:
  609. <select id="selectSensor_M13" onchange="selectSensor('M13')" class="select-input">
  610. <option></option>
  611. <option>SEN0189</option>
  612. </select>
  613. <br>
  614. 分壓類比 M1:
  615. <select id="selectSensor_M1" onchange="selectSensor('M1')" class="select-input">
  616. <option></option>
  617. <option>SonicESMUS07</option>
  618. </select>
  619. <br>
  620. </td>
  621. </tr>
  622. <tr>
  623. <td> </td>
  624. </tr>
  625. </table>
  626. </td>
  627. </tr>
  628. <!-- 感測器取值頻率 -->
  629. <tr>
  630. <td colspan="5">
  631. <span style="background-color:burlywood">感測器取值頻率</span><br>
  632. <div id="SensorHz"></div><br>
  633. </td>
  634. </tr>
  635. <!-- 制動器感測器項目取值 -->
  636. <tr>
  637. <td colspan="5" style="background-color: red; height: 50px; vertical-align: middle; text-align: center;">
  638. <!-- <input type="button" value="制動器感測器項目取值" onclick="ItemGetValue()"> -->
  639. <input type="button" value="(單元測試保留) 腳位配置 toDB" onclick="ItemGetValueToDB()">
  640. <!-- <input type="button" value="ItemGetValue" onclick="ItemGetValue()"> -->
  641. </td>
  642. </tr>
  643. <!-- 0526 積木測試 -->
  644. <!-- <tr>
  645. <td colspan="5" style="background-color:aqua">
  646. test
  647. </td>
  648. </tr> -->
  649. <!-- 積木程式 -->
  650. <tr>
  651. <td>
  652. <span style="background-color:burlywood">積木條件</span><br>
  653. <span>入料儲豆槽為:{{tank_import}}</span><br>
  654. <span>出料儲豆槽為:{{tank_export}}</span><br>
  655. <div id="DBvalue">
  656. <!-- 積木條件 -->
  657. </div>
  658. <script>
  659. // 指令燒錄桶槽時, 跳出桶槽選項
  660. var Value = '';
  661. function renew_tank() {
  662. var prog_container_value = $("#prog_container").val();
  663. // console.log("prog_container_value: " + prog_container_value);
  664. Value = '';
  665. try {
  666. for (let i = 0; i < containerTOtank[prog_container_value].length; i++) {
  667. Value += '<option value="' + Object.keys(containerTOtank[prog_container_value][i]) + '">' + Object.values(containerTOtank[prog_container_value][i]) + '</option>';
  668. }
  669. } catch (error) {
  670. if (error.name === 'TypeError') {
  671. Value = '';
  672. }
  673. }
  674. var sectorSelect = document.getElementById("prog_tank");
  675. if (sectorSelect != null) {
  676. sectorSelect.innerHTML = Value;
  677. }
  678. }
  679. function DBvalue_btn(z_notempty_NUM, a_notempty_NUM, o_notempty_NUM) {
  680. var html = '<div id="box">';
  681. for (let condadd_parent_num = 1; condadd_parent_num <= z_notempty_NUM; condadd_parent_num++) {
  682. html += '' +
  683. '<div id="newcondition_' + condadd_parent_num + '" class="newcondition_css">' +
  684. '<div id="condition' + condadd_parent_num + '">' +
  685. '<div id="condition' + condadd_parent_num + '_' + '1' + '">' +
  686. '條件 ' +
  687. '<select id="cond_z' + condadd_parent_num + '_' + '1' + '">' +
  688. '<option value="if">if</option>' +
  689. '<option value="else if">else if</option>' +
  690. '<option value="else">else</option>' +
  691. '</select> ' +
  692. '<select id="cond_a' + condadd_parent_num + '_' + '1' + '">' +
  693. pin_data_sensor_option +
  694. '<option value="tankstatus">tankstatus</option>' +
  695. '</select> ' +
  696. '<select id="cond_b' + condadd_parent_num + '_' + '1' + '">' +
  697. '<option value=""></option>' +
  698. '<option value=">">&gt;</option>' +
  699. '<option value=">=">&gt;=</option>' +
  700. '<option value="==">==</option>' +
  701. '<option value="<=">&lt;=</option>' +
  702. '<option value="<">&lt;</option>' +
  703. '</select> ' +
  704. '<input list="cond_list_c' + condadd_parent_num + '_' + '1' + '" id="cond_c' + condadd_parent_num + '_' + '1' + '">' +
  705. '<datalist id="cond_list_c' + condadd_parent_num + '_' + '1' + '">' +
  706. '<option value="on">ON</option>' +
  707. '<option value="off">OFF</option>' +
  708. '<option value="">(或請自行輸入數值)</option>' +
  709. '<option value="Waiting">空桶等待</option>' +
  710. '<option value="InputtingBean">入豆中</option>' +
  711. '<option value="InputtingBean_Pause">入豆暫停</option>' +
  712. '<option value="InputtingBean_Finish">入豆完成</option>' +
  713. '<option value="InputtingWater">夾層入水</option>' +
  714. '<option value="Drying">乾燥中</option>' +
  715. '<option value="Drying_Finish">乾燥完成</option>' +
  716. '<option value="OutputtingBean">可出豆</option>' +
  717. '<option value="OutputtingBean_Finish">出豆完成</option>' +
  718. '</datalist> ' +
  719. '<input type="button" class="input-cond-add" id="cond_add' + condadd_parent_num + '_' + '1' + '" value="條件++" onclick="cond_add(cond_add' + condadd_parent_num + '_' + '1' + ')"><br>' +
  720. '</div>';
  721. for (let cond_add_child_i = 2; cond_add_child_i <= a_notempty_NUM; cond_add_child_i++) {
  722. // if (cond_d_data[condadd_parent_num][cond_add_child_i] == '') {
  723. // // alert("cond_d_data[" + condadd_parent_num + "][" + cond_add_child_i + " ] + 為空值")
  724. // continue
  725. // }
  726. html +=
  727. '<div id="condition' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  728. '<select id="cond_d' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  729. '<option value=""></option>' +
  730. '<option value="&&">&&</option>' +
  731. '<option value="||">||</option>' +
  732. '</select> ' +
  733. '<select id="cond_a' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  734. pin_data_sensor_option +
  735. '<option value="tankstatus">tankstatus</option>' +
  736. // '</optgroup>' +
  737. '</select> ' +
  738. '<select id="cond_b' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  739. '<option value=""></option>' +
  740. '<option value=">">&gt;</option>' +
  741. '<option value=">=">&gt;=</option>' +
  742. '<option value="==">==</option>' +
  743. '<option value="<=">&lt;=</option>' +
  744. '<option value="<">&lt;</option>' +
  745. '</select> ' +
  746. '<input list="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '" id="cond_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  747. '<datalist id="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  748. '<option value="on">ON</option>' +
  749. '<option value="off">OFF</option>' +
  750. '<option value="">(或請自行輸入數值)</option>' +
  751. '<option value="Waiting">空桶等待</option>' +
  752. '<option value="InputtingBean">入豆中</option>' +
  753. '<option value="InputtingBean_Pause">入豆暫停</option>' +
  754. '<option value="InputtingBean_Finish">入豆完成</option>' +
  755. '<option value="InputtingWater">夾層入水</option>' +
  756. '<option value="Drying">乾燥中</option>' +
  757. '<option value="Drying_Finish">乾燥完成</option>' +
  758. '<option value="OutputtingBean">可出豆</option>' +
  759. '<option value="OutputtingBean_Finish">出豆完成</option>' +
  760. '</datalist> ' +
  761. '<input type="button" class="input-cond-delete" id="cond_del' + condadd_parent_num + '_' + cond_add_child_i + '" value="條件--" onclick="cond_del(\'' + condadd_parent_num + '_' + cond_add_child_i + '\');">';
  762. if (cond_add_child_i == 2) {
  763. html +=
  764. '<input type="button" class="input-cond-add" id="cond_add' + condadd_parent_num + '_' + cond_add_child_i + '" value="條件++" onclick="cond_add(cond_add' + condadd_parent_num + '_' + cond_add_child_i + ');"><br>';
  765. } else {
  766. html +=
  767. '<input type="button" class="input-cond-add" id="cond_add' + condadd_parent_num + '_' + cond_add_child_i + '" value="條件++" onclick="cond_add(cond_add' + condadd_parent_num + '_' + cond_add_child_i + ');" style="display: none;"><br>';
  768. }
  769. html += '</div>';
  770. }
  771. html += '</div>';
  772. // 新增的物件動作
  773. html += '<div id="action' + condadd_parent_num + '">';
  774. for (let cond_add_child_i = 1; cond_add_child_i <= o_notempty_NUM; cond_add_child_i++) {
  775. // if (cond_obj_data[condadd_parent_num][cond_add_child_i] == '') {
  776. // // alert("cond_d_data[" + condadd_parent_num + "][" + cond_add_child_i + " ] + 為空值")
  777. // continue
  778. // }
  779. html +=
  780. '<div id="action' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  781. '物件 ' +
  782. '<select id="do_obj' + condadd_parent_num + '_' + cond_add_child_i + '" onChange="renew(\''+ condadd_parent_num + '_' + cond_add_child_i + '\', this.selectedIndex);">' +
  783. // '<option value=" ">制動器 / 暫停秒數 / 桶槽狀態</option>' +
  784. pin_data_relay_option +
  785. // '<option value="input_vacuum_status">入料儲豆槽真空吸料機</option>' +
  786. // '<option value="tank_vacuum_status">真空吸料機</option>' +
  787. // '<option value="tank_threewayvalve_vacuum_status">吸料機三通閥</option>' +
  788. // '<option value="tank_solenoid_disinfect_status">消毒電磁閥</option>' +
  789. // '<option value="tank_motor_status">馬達</option>' +
  790. // '<option value="outer_solenoid_water_status">桶外進水電磁閥</option>' +
  791. // '<option value="tank_solenoid_water_out_status">廢水排水電磁閥</option>' +
  792. // '<option value="tank_heater1_status">加熱棒 1</option>' +
  793. // '<option value="tank_heater2_status">加熱棒 2</option>' +
  794. // '<option value="tank_temp_enable">溫控開關</option>' +
  795. // '<option value="tank_temp">溫度設定</option>' +
  796. // '<option value="tank_diskvalve_status">蝴蝶閥</option>' +
  797. // '<option value="output_vacuum_status">出料儲豆槽真空吸料機</option>' +
  798. // '<option value="tank_magneticSwitch_status">電磁開關</option>' +
  799. // '<option value="tank_emergencySwitch_status">緊急開關</option>' +
  800. // '<option value="tank_camera_status">攝影機</option>' +
  801. // '<option value="tank_warningLight_status">警示燈</option>' +
  802. '</select>' +
  803. // '<select id="do_act' + new_condition_i + '_1">' +
  804. // '<option value="">請由左方選取物件' +
  805. // '</select> ' +
  806. ' 動作 ' +
  807. '<div id="do_action' + condadd_parent_num + '_' + cond_add_child_i + '" style="display: inline-block;">' +
  808. '</div>' +
  809. '<input type="button" class="input-act-delete" id="act_del' + condadd_parent_num + '_' + cond_add_child_i + '" value="物件動作--" onclick="act_del(\'' + condadd_parent_num + '_' + cond_add_child_i + '\');">';
  810. if (cond_add_child_i == 1) {
  811. html +=
  812. '<input type="button" class="input-act-add" id="act_add' + condadd_parent_num + '_' + cond_add_child_i + '" value="物件動作++" onclick="act_add(act_add' + condadd_parent_num + '_' + cond_add_child_i + ');"><br>';
  813. } else {
  814. html +=
  815. '<input type="button" class="input-act-add" id="act_add' + condadd_parent_num + '_' + cond_add_child_i + '" value="物件動作++" onclick="act_add(act_add' + condadd_parent_num + '_' + cond_add_child_i + ');" style="display: none;"><br>';
  816. }
  817. html += '</div>';
  818. }
  819. html += '</div>';
  820. // 新增的 條件物件動作++ 條件物件動作-- 按鈕
  821. html += '<input type="button" class="input-delete" id="del' + condadd_parent_num + '" value="條件物件動作--" onclick="Delete(' + condadd_parent_num + ');"><br>' +
  822. '<input type="button" class="input-add" id="add' + condadd_parent_num + '" value="條件物件動作++" onclick="Add(add' + condadd_parent_num + ');">' +
  823. '</div><br>' ;
  824. }
  825. html += '</div>' ;
  826. var divbox = document.getElementById('DBvalue');
  827. divbox.insertAdjacentHTML('beforeend', html);
  828. }
  829. </script>
  830. </td>
  831. </tr>
  832. <!-- 積木取值 -->
  833. <tr>
  834. <td colspan="5" style="background-color: red; height: 77px; vertical-align: middle; text-align: center;">
  835. <input type="button" id="test" value="(單元測試保留) 顯示積木條件" onclick="getValue();"><br>
  836. <input type="button" id="test" value="(單元測試保留) 積木條件 json 格式 + MQTT + toDB" onclick="MQTTgetValue();"><br>
  837. </td>
  838. </tr>
  839. <!-- 積木取值 文字輸出 -->
  840. <tr>
  841. <td colspan="2">
  842. *** 以下內容測試用, 之後會刪除<br>
  843. Value : <span id="show_Value"></span><br><br>
  844. <!-- MySQL : <span id="show_MySQLcommand"></span><br><br> -->
  845. MQTT : <span id="show_MQTTcommand"></span>
  846. </td>
  847. </tr>
  848. <!-- 燒錄 -->
  849. <tr>
  850. <td colspan="5" style="background-color: red; height: 77px; vertical-align: middle; text-align: center;">
  851. <input type="button" value="(單元測試保留) 更新 main.c 檔案" onclick="prog_creat_hex();"><br>
  852. <input type="button" value="(單元測試保留) 更新 SDIO.hex 檔案 + MQTT 其內容 + 備份 SDIO.hex toGit" onclick="programmer();">
  853. </td>
  854. </tr>
  855. <tr>
  856. <td colspan="5" style="background-color: red; height: 50px; vertical-align: middle; text-align: center;">
  857. <input type="button" value="進行 OTA 燒錄" onclick="prog_OTA();">
  858. </td>
  859. </tr>
  860. <script>
  861. function prog_creat_hex() {
  862. MQTTgetValue();
  863. $.ajax({
  864. type:"GET",
  865. url:"/creat_hex",
  866. data:TT,
  867. dataType:"text",
  868. async:false,
  869. success:function (res) {
  870. $("#creat_hex_Value").text(res);
  871. },
  872. error: function (thrownError) {
  873. alert(thrownError.statusText);
  874. $("#creat_hex_Value").text(thrownError.statusText);
  875. }
  876. })
  877. }
  878. function programmer(params) {
  879. var confirm_programmer = confirm("即將燒錄 Coffee1.0, 確定請按下 [確認] :");
  880. if (!confirm_programmer) {
  881. alert("已取消燒錄");
  882. } else {
  883. var prog_tank_data = $('#prog_tank').find(':selected').val();
  884. var prog_data = {'tank':prog_tank_data,
  885. 'USERNAME': USERNAME}
  886. $("#programmer_Value").text("控制板燒錄中 ...");
  887. $.get('/board_programmer', prog_data, function (res) {
  888. $("#programmer_Value").text(res);
  889. alert(res);
  890. }, 'text');
  891. }
  892. }
  893. function prog_OTA() {
  894. prog_creat_hex();
  895. programmer();
  896. }
  897. </script>
  898. <!-- 燒錄結果顯示 -->
  899. <tr>
  900. <td colspan="2">
  901. creat_hex 結果:<span id="creat_hex_Value"></span><br>
  902. <br>
  903. 燒錄結果:<span id="programmer_Value"></span>
  904. </td>
  905. </tr>
  906. </table>
  907. <!-- Relay、感測器選值時, 左側圖片顯示對應項目 -->
  908. <script>
  909. // 當右方的下拉式選單選擇時, 更新左方圖片上的文字 - relay
  910. function select_relay(id) {
  911. var select_relay_text = $("#select_relay_" + id).find(':selected').text()
  912. // console.log("select_relay_text: " + select_relay_text)
  913. if (select_relay_text == '') {
  914. $("#relay" + id).text('');
  915. document.getElementById("relay" + id).style.backgroundColor = 'transparent';
  916. } else {
  917. $("#relay" + id).text(select_relay_text);
  918. document.getElementById("relay" + id).style.backgroundColor = 'lightblue';
  919. document.getElementById("relay" + id).style.color = 'black';
  920. document.getElementById("relay" + id).style.fontWeight = '600';
  921. }
  922. }
  923. var sensorlist = ['', '分壓類比', 'PWM', 'PWM', '類比', '類比', '分壓類比', '類比', '485', '數位',
  924. 'PWM', '數位', '數位', '分壓類比', '數位', 'I2C', 'UART', 'UART', 'UART', '數位']
  925. // selectSensor
  926. function selectSensor(PinNum) {
  927. var Pin_sensor = $("#selectSensor_" + PinNum).find(':selected').text();
  928. // console.log("Pin_sensor: " + Pin_sensor)
  929. if (Pin_sensor == '') {
  930. $("#sensor_" + PinNum).text('');
  931. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'transparent';
  932. } else {
  933. $("#sensor_" + PinNum).text(Pin_sensor);
  934. // alert("sensorlist[PinNum]]\n" + sensorlist[PinNum.substring(1)])
  935. if (sensorlist[PinNum.substring(1)] == '類比') {
  936. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'lightgreen';
  937. } else if (sensorlist[PinNum.substring(1)] == 'PWM') {
  938. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'lightcyan';
  939. } else if (sensorlist[PinNum.substring(1)] == '數位') {
  940. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'lightgoldenrodyellow';
  941. } else if (sensorlist[PinNum.substring(1)] == 'UART') {
  942. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'linen';
  943. } else if (sensorlist[PinNum.substring(1)] == '分壓類比') {
  944. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'lavender';
  945. } else if (sensorlist[PinNum.substring(1)] == 'I2C' || sensorlist[PinNum.substring(1)] == '485') {
  946. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'lightpink';
  947. }
  948. document.getElementById("sensor_" + PinNum).style.color = 'black';
  949. document.getElementById("sensor_" + PinNum).style.fontWeight = '600';
  950. }
  951. }
  952. </script>
  953. <!-- -->
  954. <script>
  955. var relay_data = ''; // 積木程式 制動器選項
  956. var sensor_data = ''; // 積木程式 感測器選項
  957. var obj_data = ''; // 積木程式 物件選項:桶槽狀態 暫停秒數
  958. const list_R = ['R1','R2','R3','R4','R5','R6','R7','R8','R9','R10','R11','R12','R13','R14','R15','R16','R17','R18','R19','R20']
  959. var list_relay_item = []; // R1~R20 對應的 relay 取值
  960. const list_M = ['M1','M2','M3','M4','M5','M6','M7','M8','M9','M10','M11','M12','M13','M14','M15','M16','M17','M18','M19']
  961. var list_sensor_item = []; // M1~M19 對應的 sensor 取值
  962. const list_M_Hz = ['M1_Hz','M2_Hz','M3_Hz','M4_Hz','M5_Hz','M6_Hz','M7_Hz','M8_Hz','M9_Hz','M10_Hz',
  963. 'M11_Hz','M12_Hz','M13_Hz','M14_Hz','M15_Hz','M16_Hz','M17_Hz','M18_Hz','M19_Hz'];
  964. var list_sensorHz_item = [] // M1~M19 對應的取值頻率
  965. function ItemGetValueToDB() {
  966. var ethernet_text = $("#select_ethernet_1").find(':selected').val();
  967. var wifi_text = $("#select_wifi_1").find(':selected').val();
  968. var zigbee_text = $("#select_zigbee_1").find(':selected').val();
  969. var tank_text = $('#prog_tank').find(':selected').val();
  970. console.log("ethernet_text: " + ethernet_text);
  971. console.log("wifi_text: " + wifi_text);
  972. console.log("zigbee_text: " + zigbee_text);
  973. console.log("tank_text: " + tank_text);
  974. list_relay_item = [];
  975. for (let i = 1; i < 21; i++) {
  976. var relay_text = $("#select_relay_" + i).find(':selected').val();
  977. if (relay_text != '') {
  978. list_relay_item.push(relay_text);
  979. } else {
  980. list_relay_item.push('');
  981. }
  982. }
  983. console.log("list_relay_item: " + list_relay_item);
  984. list_sensor_item = [];
  985. for (let i = 1; i < 20; i++) {
  986. var sensor_text = $("#selectSensor_M" + i).find(':selected').val();
  987. if (sensor_text != '') {
  988. list_sensor_item.push(sensor_text);
  989. } else {
  990. list_sensor_item.push('');
  991. }
  992. }
  993. console.log("list_sensor_item: " + list_sensor_item);
  994. list_sensorHz_item = [];
  995. // list_M_Hz = ['M1_Hz','M2_Hz','M3_Hz','M4_Hz','M5_Hz','M6_Hz','M7_Hz','M8_Hz','M9_Hz','M10_Hz',
  996. // 'M11_Hz','M12_Hz','M13_Hz','M14_Hz','M15_Hz','M16_Hz','M17_Hz','M18_Hz','M19_Hz'];
  997. // var list_sensorHz_item
  998. for (let i = 1; i < 20; i++) {
  999. var sensor_text = $("#M" + i + "_Hz").val();
  1000. if (sensor_text !== undefined) {
  1001. console.log("sensor_text: ", sensor_text);
  1002. list_sensorHz_item.push(sensor_text);
  1003. } else {
  1004. list_sensorHz_item.push('');
  1005. }
  1006. }
  1007. var SQL_insert = 'INSERT INTO `coffee1_0_pin` (' +
  1008. '`datetime`, `tid`, `ethernet`, `wifi`, `zigbee`, `' +
  1009. list_R.join("`, `") +
  1010. '`, `' +
  1011. list_M.join("`, `") +
  1012. '`, `' +
  1013. list_M_Hz.join("`, `") +
  1014. '`) VALUES (' +
  1015. 'current_timestamp(), "' + Tank_ID + '", "' + ethernet_text + '", "' + wifi_text + '", "' + zigbee_text + '", "' +
  1016. list_relay_item.join('", "') +
  1017. '", "' +
  1018. list_sensor_item.join('", "') +
  1019. '", "' +
  1020. list_sensorHz_item.join('", "') +
  1021. '")';
  1022. var sql_data = { "sql":SQL_insert };
  1023. console.log("sql_data: ", sql_data)
  1024. $.get('/sql_get', sql_data, function (res) {
  1025. if (res['response'] == '') {
  1026. alert("OK");
  1027. } else {
  1028. alert(res['response']);
  1029. }
  1030. location.reload();
  1031. }, 'json');
  1032. // ItemGetValue();
  1033. // location.reload();
  1034. }
  1035. function ItemGetValue() {
  1036. list_relay_item = [];
  1037. // ethernet、wifi、zigbee 取值測試
  1038. // var select_ethernet_text = $("#select_ethernet_1").find(':selected').text()
  1039. // var select_wifi_text = $("#select_wifi_1").find(':selected').text()
  1040. // var select_zigbee_text = $("#select_zigbee_1").find(':selected').text()
  1041. // console.log("select_ethernet_text: " + select_ethernet_text)
  1042. // console.log("select_wifi_text: " + select_wifi_text)
  1043. // console.log("select_zigbee_text: " + select_zigbee_text)
  1044. // 制動器感測器 下拉式選單 不可更改
  1045. $('.select-input').prop('disabled', true);
  1046. // relay 取值
  1047. relay_dict = {};
  1048. for (let i = 1; i < 21; i++) {
  1049. var relay_text = $("#select_relay_" + i).find(':selected').val();
  1050. if (relay_text != '') {
  1051. relay_dict["R" + i] = "R" + i + "_" + relay_text;
  1052. // console.log("R" + i + " : " + relay_text);
  1053. list_relay_item.push(relay_text);
  1054. } else {
  1055. // relay_dict["R" + i] = "";
  1056. // console.log("R" + i + " : ");
  1057. list_relay_item.push('');
  1058. }
  1059. }
  1060. // console.log("list_relay_item: " + list_relay_item);
  1061. // relay_data = '<optgroup label="制動器狀態">';
  1062. relay_data = '<option value=""></option>';
  1063. for (let r in relay_dict) {
  1064. // console.log(r + " : " + relay_dict[r]);
  1065. relay_data += '<option value="' + relay_dict[r] + '">' + relay_dict[r] + '</option>';
  1066. }
  1067. relay_data += '<option value="sleep">sleep</option>' +
  1068. '<option value="tankstatus">tankstatus</option>';
  1069. // relay_data += '</optgroup>'
  1070. // console.log("relay_data: " + relay_data)
  1071. // sensor 取值 dict
  1072. sensor_dict = {};
  1073. for (let i = 1; i < 20; i++) {
  1074. var sensor_text = $("#selectSensor_M" + i).find(':selected').text();
  1075. if (sensor_text != '') {
  1076. sensor_dict["M" + i] = "M" + i + "_" + sensor_text;
  1077. // console.log("selectSensor_M" + i);
  1078. // console.log("M" + i + "_" + sensor_text);
  1079. } else {
  1080. // sensor_dict["M" + i] = "";
  1081. // console.log("selectSensor_M" + i);
  1082. // console.log("");
  1083. }
  1084. }
  1085. sensor_data = '';
  1086. // sensor_data = '<optgroup label="感測器數值">';
  1087. for (let s in sensor_dict) {
  1088. // console.log(s + " : " + sensor_dict[s])
  1089. sensor_data += '<option value="' + sensor_dict[s] + '">' + sensor_dict[s] + '</option>';
  1090. }
  1091. sensor_data += '<option value="tankstatus">tankstatus</option>';
  1092. // sensor_data += '</optgroup>';
  1093. // console.log("sensor_data: " + sensor_data)
  1094. console.log("relay_data: " + relay_data);
  1095. console.log("sensor_data: " + sensor_data);
  1096. var relay_select_data = document.getElementById("");
  1097. // // 賦值條件 a
  1098. // var sectorSelect = document.getElementById("cond_a1_1");
  1099. // sectorSelect.innerHTML = '<option value="">制動器 / 感測器</option>' + relay_data + sensor_data;
  1100. // obj_data = '<option value="' + 'sleep' + '">' + 'sleep' + '</option>' +
  1101. // '<option value="' + 'tankstatus' + '">' + 'tankstatus' + '</option>';
  1102. // // 賦值物件 a
  1103. // var sectorSelect = document.getElementById("do_obj1_1");
  1104. // sectorSelect.innerHTML = '<option value="">制動器 / 暫停秒數 / 桶槽狀態</option>' + relay_data + obj_data;
  1105. // ===== 下方傳值未測試 ====================================================
  1106. // var loader_data = {
  1107. // "ethernet_list":select_ethernet_text,
  1108. // "wifi_list":select_wifi_text,
  1109. // "zigbee_list":select_zigbee_text,
  1110. // "relay_list":String(relay_list),
  1111. // "pwm_list":String(pwm_list),
  1112. // "digital_list":String(digital_list),
  1113. // "uart_list":String(uart_list),
  1114. // "i2c_list":String(i2c_list),
  1115. // "s485_list":String(s485_list),
  1116. // "ppa_list":String(ppa_list)
  1117. // };
  1118. // $.ajax({
  1119. // type:"GET",
  1120. // url:"/loader",
  1121. // dataType:"JSON",
  1122. // data:loader_data,
  1123. // success:function (res) {
  1124. // alert("ItemGetValue loader: " + res.response)
  1125. // },
  1126. // error: function (thrownError) {
  1127. // alert(thrownError)
  1128. // }
  1129. // })
  1130. }
  1131. relay_obj2act = {'vacuum':['on', 'off'],
  1132. 'solenoidvalve':['on', 'off'],
  1133. 'diskvalve':['on', 'off'],
  1134. 'warninglight':['on', 'off'],
  1135. 'camera':['on', 'off'],
  1136. 'heater':['on', 'off'],
  1137. 'pump':['on', 'off'],
  1138. 'sleep':'',
  1139. 'tankstatus':['Waiting', 'InputtingBean', 'InputtingBean_Pause', 'InputtingBean_Finish',
  1140. 'Drying', 'OutputtingBean', 'InputtingWater']
  1141. }
  1142. dry_object = new Array();
  1143. dry_object['tankstatus'] = ["Waiting", "InputtingBean", "InputtingBean_Pause", "InputtingBean_Finish",
  1144. "InputtingWater", "Drying", "Drying_Finish", "OutputtingBean", "OutputtingBean_Finish"]; // 暫停秒數
  1145. // DRY_CONTAINER_STATUS 讓 do_act / dry_object 判斷用
  1146. const DRY_CONTAINER_STATUS = {
  1147. 'Waiting':'空桶等待',
  1148. 'InputtingBean':'入豆中',
  1149. 'InputtingBean_Pause':'入豆暫停',
  1150. 'InputtingBean_Finish':'入豆完成',
  1151. 'InputtingWater':'夾層入水',
  1152. 'Drying':'乾燥中',
  1153. 'Drying_Finish':'乾燥完成',
  1154. 'OutputtingBean':'可出豆',
  1155. 'OutputtingBean_Finish':'出豆完成'
  1156. }
  1157. function renew(obj_num, index) {
  1158. // console.log("renew!!!" + obj_num + "_____" + index);
  1159. var index_name = $('#do_obj' + obj_num).val();
  1160. // console.log("index_name: " + index_name);
  1161. var Value = '';
  1162. if (index_name === 'sleep') {
  1163. Value = ' 暫停秒數 : ' +
  1164. ' <input type="range" style="cursor: pointer;" id="do_act' + obj_num + '" min="5" max="60" step="5" value="10" oninput="showSleepValue(\'' + obj_num + '\', this.value)" onchange="showSleepValue(\'' + obj_num + '\', this.value)">' +
  1165. ' <span id="sleepValue_text' + obj_num + '">10s</span>';
  1166. } else if (index_name === 'tankstatus') {
  1167. Value = '<select id="do_act' + obj_num + '">';
  1168. for(var i=0; i<dry_object['tankstatus'].length; i++){
  1169. Value += '<option value=' + dry_object['tankstatus'][i] + '>' + DRY_CONTAINER_STATUS[dry_object['tankstatus'][i]] + '</option>';
  1170. }
  1171. Value += '</select>';
  1172. } else if (index_name.includes('Motor')) {
  1173. Value = ' 指定轉速 : ' +
  1174. ' <input type="range" style="cursor: pointer;" id="do_act' + obj_num + '" min="-50" max="50" step="5" value="20" oninput="showMotorValue(\'' + obj_num + '\', this.value)" onchange="showMotorValue(\'' + obj_num + '\', this.value)">' +
  1175. ' <span id="motorValue_text' + obj_num + '">20rpm</span>';
  1176. } else if (index_name === '' || index_name == undefined) {
  1177. } else {
  1178. Value = '<select id="do_act' + obj_num + '">' +
  1179. '<option value="on">on</option>' +
  1180. '<option value="off">off</option>' +
  1181. '</select>';
  1182. }
  1183. // try {
  1184. // Value = '<select id="do_act' + obj_num + '">';
  1185. // for(var i=0; i<dry_object[index].length; i++){
  1186. // Value += '<option value=' + dry_object[index][i] + '>' + dry_object[index][i] + '</option>';
  1187. // }
  1188. // Value += '</select>';
  1189. // } catch (e) {
  1190. // if (e.name == 'TypeError' && index == '5') {
  1191. // Value = ' 轉速 : ' +
  1192. // ' <input type="range" style="cursor: pointer;" id="do_act' + obj_num + '" min="-50" max="50" step="5" value="0" oninput="showMotorValue(\'' + obj_num + '\', this.value)" onchange="showMotorValue(\'' + obj_num + '\', this.value)">' +
  1193. // ' <span id="motorValue_text' + obj_num + '">0</span>';
  1194. // } else if (e.name == 'TypeError' && index == '11') {
  1195. // Value = ' 目標溫度 : ' +
  1196. // ' <input type="range" style="cursor: pointer;" id="do_act' + obj_num + '" min="20.0" max="50.0" step="0.5" value="28.0" oninput="showTempValue(\'' + obj_num + '\', this.value)" onchange="showTempValue(\'' + obj_num + '\', this.value)">' +
  1197. // ' <span id="tempValue_text' + obj_num + '">28.0</span>';
  1198. // } else if (e.name == 'TypeError' && index == '18') {
  1199. // Value = ' 暫停秒數 : ' +
  1200. // ' <input type="range" style="cursor: pointer;" id="do_act' + obj_num + '" min="5" max="60" step="5" value="10" oninput="showSleepValue(\'' + obj_num + '\', this.value)" onchange="showSleepValue(\'' + obj_num + '\', this.value)">' +
  1201. // ' <span id="sleepValue_text' + obj_num + '">10s</span>';
  1202. // }
  1203. // }
  1204. var sectorSelect = document.getElementById("do_action" + obj_num);
  1205. if (sectorSelect != null) {
  1206. sectorSelect.innerHTML = Value;
  1207. }
  1208. }
  1209. function showSleepValue(obj_num, value) {
  1210. document.getElementById("sleepValue_text" + obj_num).innerText = value + 's';
  1211. }
  1212. function showMotorValue(obj_num, value) {
  1213. document.getElementById("motorValue_text" + obj_num).innerText = value + 'rpm';
  1214. }
  1215. function showSensorHzValue(obj_num, value) {
  1216. document.getElementById(obj_num + "_HzText").innerText = value + 'Hz';
  1217. }
  1218. </script>
  1219. <script>
  1220. var cond_main = ''; // 主條件
  1221. var cond_add_list = []; // 附加條件 List
  1222. var cond_add_data = ''; // 欲加入附加條件的資料
  1223. var cond_com_list = []; // 動作 List
  1224. var cond_com_data = ''; // 欲加入動作的資料
  1225. var cond_item = []; // 主條件+附加條件+動作 List
  1226. function showValue() {
  1227. cond_item = [];
  1228. var command_test = '';
  1229. Z = 0;
  1230. TT = {}; // 將總條件句/附加條件句/物件動作句存入 字典, 後續傳給 dry_block_format 再組合
  1231. var SQL_insert_total = ''; // MySQL 指令 全部條件輸出
  1232. TT['mainLength'] = 0 // 總條件數
  1233. TT['addLength'] = 0 // 子條件數
  1234. TT['comLength'] = 0 // 子物件數
  1235. // 條件物件動作 取值
  1236. // for (let z = 1; z <= 2; z++) {
  1237. for (let z = 1; z <= new_condition_i; z++) {
  1238. var set_key = []; // List 加入變數名稱, INSERT DB 用
  1239. var set_value = []; // List 加入值, INSERT DB 用
  1240. // 初始清空
  1241. cond_main = '';
  1242. // if-while 取值
  1243. try {
  1244. var cond_z_value = document.getElementById("cond_z" + z + "_1").value;
  1245. if (cond_z_value == '') {
  1246. // alert('if/while 欄位未輸入')
  1247. } else {
  1248. Z = Z + 1;
  1249. // if (Z > 4) {
  1250. // alert("[Z > 4] 總條件數不得超過 3 項")
  1251. // break
  1252. // }
  1253. // set_key.push('cond_z' + z + '_1');
  1254. set_key.push('cond_z' + Z + '_1');
  1255. set_value.push(cond_z_value);
  1256. console.log("cond_z_value: " + cond_z_value);
  1257. cond_main += cond_z_value + ' ';
  1258. console.log("cond_main: " + cond_main);
  1259. }
  1260. } catch (error) {
  1261. if (error.name == 'TypeError') {
  1262. } else {
  1263. alert("cond_z" + z + "_1: " + error.name)
  1264. }
  1265. }
  1266. X = 1;
  1267. cond_add_list = []; // 附加條件 List 清空
  1268. for (let x = 1; x <= cond_add_child_i; x++) {
  1269. // for (let x = 1; x <= cond_add_child_i; x++) {
  1270. cond_add_data = ''; // 附加條件資料 清空
  1271. if (x == 1) {
  1272. // 主條件
  1273. try {
  1274. var cond_a_value = document.getElementById("cond_a" + z + "_" + x).value;
  1275. if (cond_a_value == '') {
  1276. // alert('主條件 感測器 欄位未輸入')
  1277. } else {
  1278. // set_key.push('cond_a' + z + '_' + X);
  1279. set_key.push('cond_a' + Z + '_' + X);
  1280. set_value.push(cond_a_value);
  1281. console.log("cond_a_value: " + cond_a_value);
  1282. cond_main += cond_a_value + ' ';
  1283. }
  1284. } catch (error) {
  1285. if (error.name == 'TypeError') {
  1286. } else {
  1287. alert("cond_a" + z + "_" + x + ": " + error.name)
  1288. }
  1289. }
  1290. // 子條件取值 : 條件中 > = <
  1291. try {
  1292. var cond_b_value = document.getElementById("cond_b" + z + "_" + x).value;
  1293. if (cond_b_value == '') {
  1294. // alert('主條件 比較運算子 欄位未輸入')
  1295. } else {
  1296. // set_key.push('cond_b' + z + '_' + X);
  1297. set_key.push('cond_b' + Z + '_' + X);
  1298. set_value.push(cond_b_value);
  1299. console.log("cond_b_value: " + cond_b_value);
  1300. // if (cond_b_value == 'MoreThan') { cond_main += '> '; }
  1301. // else if (cond_b_value == 'MoreThanEqualTo') { cond_main += '>= '; }
  1302. // else if (cond_b_value == 'Equal') { cond_main += '== '; }
  1303. // else if (cond_b_value == 'LessThanEqualTo') { cond_main += '<= '; }
  1304. // else if (cond_b_value == 'LessThan') { cond_main += '< '; }
  1305. cond_main += cond_b_value + ' ';
  1306. }
  1307. } catch (error) {
  1308. if (error.name == 'TypeError') {
  1309. } else {
  1310. alert("cond_b" + z + "_" + x + ": " + error.name)
  1311. }
  1312. }
  1313. // 子條件取值 : 條件右 ON / OFF / 輸入數值
  1314. try {
  1315. var cond_c_value = document.getElementById("cond_c" + z + "_" + x).value;
  1316. if (cond_c_value == '') {
  1317. // alert('主條件 數值 欄位未輸入')
  1318. } else {
  1319. // console.log("Ctest: " + typeof(cond_c_value))
  1320. set_key.push('cond_c' + Z + '_' + X);
  1321. set_value.push(cond_c_value);
  1322. console.log("cond_c_value: " + cond_c_value);
  1323. if (relay_obj2act['tankstatus'].includes(cond_c_value)) {
  1324. cond_main += "'" + cond_c_value + "'";
  1325. } else {
  1326. cond_main += cond_c_value;
  1327. }
  1328. // set_key.push('cond_c' + z + '_' + X);
  1329. }
  1330. } catch (error) {
  1331. if (error.name == 'TypeError') {
  1332. } else {
  1333. alert("cond_c" + z + "_" + x + ": " + error.name)
  1334. }
  1335. }
  1336. } else {
  1337. // 附加條件 x > 1
  1338. // 子條件取值 : 條件連接 and or
  1339. try {
  1340. var cond_d_value = document.getElementById("cond_d" + z + "_" + x).value;
  1341. if (cond_d_value == '') {
  1342. // alert('附加條件 and/or 欄位未輸入')
  1343. } else {
  1344. X = X + 1;
  1345. // if (X > 13) {
  1346. // alert("[X > 13] 子條件數不得超過 13 項")
  1347. // break
  1348. // }
  1349. // set_key.push('cond_d' + z + '_' + X);
  1350. set_key.push('cond_d' + Z + '_' + X);
  1351. set_value.push(cond_d_value);
  1352. cond_add_data += cond_d_value + ' ';
  1353. }
  1354. } catch (error) {
  1355. if (error.name == 'TypeError') {
  1356. } else {
  1357. alert("cond_d" + z + "_" + x + ": " + error.name)
  1358. }
  1359. }
  1360. // 感測器取值 :
  1361. try {
  1362. var cond_a_value = document.getElementById("cond_a" + z + "_" + x).value;
  1363. if (cond_a_value == '') {
  1364. // alert('附加條件 感測器 欄位未輸入')
  1365. } else {
  1366. // set_key.push('cond_a' + z + '_' + X);
  1367. set_key.push('cond_a' + Z + '_' + X);
  1368. set_value.push(cond_a_value);
  1369. cond_add_data += cond_a_value + ' ';
  1370. }
  1371. } catch (error) {
  1372. if (error.name == 'TypeError') {
  1373. } else {
  1374. alert("cond_a" + z + "_" + x + ": " + error.name)
  1375. }
  1376. }
  1377. // 子條件取值 : 條件中 > = <
  1378. try {
  1379. var cond_b_value = document.getElementById("cond_b" + z + "_" + x).value;
  1380. if (cond_b_value == '') {
  1381. // alert('附加條件 比較運算子 欄位未輸入')
  1382. } else {
  1383. // set_key.push('cond_b' + z + '_' + X);
  1384. set_key.push('cond_b' + Z + '_' + X);
  1385. set_value.push(cond_b_value);
  1386. // if (cond_b_value == 'MoreThan') { cond_main += '> '; }
  1387. // else if (cond_b_value == 'MoreThanEqualTo') { cond_main += '>= '; }
  1388. // else if (cond_b_value == 'Equal') { cond_main += '== '; }
  1389. // else if (cond_b_value == 'LessThanEqualTo') { cond_main += '<= '; }
  1390. // else if (cond_b_value == 'LessThan') { cond_main += '< '; }
  1391. cond_add_data += cond_b_value;
  1392. }
  1393. } catch (error) {
  1394. if (error.name == 'TypeError') {
  1395. } else {
  1396. alert("cond_b" + z + "_" + x + ": " + error.name)
  1397. }
  1398. }
  1399. // 子條件取值 : 條件右 ON / OFF / 輸入數值
  1400. try {
  1401. var cond_c_value = document.getElementById("cond_c" + z + "_" + x).value;
  1402. if (cond_c_value == '') {
  1403. // alert('附加條件 數值 欄位未輸入')
  1404. } else {
  1405. // console.log("Ctest: " + cond_c_value)
  1406. set_key.push('cond_c' + Z + '_' + X);
  1407. set_value.push(cond_c_value);
  1408. if (relay_obj2act['tankstatus'].includes(cond_c_value)) {
  1409. cond_add_data += " '" + cond_c_value + "'";
  1410. } else {
  1411. cond_add_data += " " + cond_c_value;
  1412. }
  1413. // set_key.push('cond_c' + z + '_' + X);
  1414. }
  1415. } catch (error) {
  1416. if (error.name == 'TypeError') {
  1417. } else {
  1418. alert("cond_c" + z + "_" + x + ": " + error.name)
  1419. }
  1420. }
  1421. if (cond_add_data != '') {
  1422. console.log("cond_add_list: " + cond_add_list)
  1423. console.log("cond_add_data: " + cond_add_data)
  1424. cond_add_list.push(cond_add_data)
  1425. }
  1426. }
  1427. }
  1428. // 子 物件動作 取值
  1429. Y = 0;
  1430. cond_com_list = [];
  1431. for (let y = 1; y <= act_add_child_i; y++) {
  1432. cond_com_data = '';
  1433. // 子物件動作取值 : 物件 do_obj1_1
  1434. try {
  1435. var do_obj_value = document.getElementById("do_obj" + z + "_" + y).value;
  1436. // console.log("do_obj" + z + "_" + y + " : " + do_obj_value)
  1437. if (do_obj_value == '') {
  1438. // alert('物件 欄位未輸入')
  1439. } else {
  1440. Y = Y + 1;
  1441. // if (Y > 20) {
  1442. // alert("[Y > 20] 子物件數不得超過 20 項")
  1443. // break
  1444. // }
  1445. set_key.push('do_obj' + Z + '_' + Y);
  1446. set_value.push(do_obj_value);
  1447. cond_com_data += do_obj_value + ' ';
  1448. }
  1449. } catch (error) {
  1450. if (error.name == 'TypeError') {
  1451. } else {
  1452. alert("do_obj" + z + "_" + y + ": " + error.name)
  1453. }
  1454. }
  1455. // 子物件動作取值 : 動作 do_act1_1
  1456. try {
  1457. var do_act_value = document.getElementById("do_act" + z + "_" + y).value;
  1458. // console.log("do_act" + z + "_" + y + " : " + do_act_value)
  1459. if (do_act_value == '') {
  1460. // alert('動作 欄位未輸入')
  1461. } else {
  1462. set_key.push('do_act' + Z + '_' + Y);
  1463. // if (DRY_CONTAINER_STATUS[do_act_value] != undefined ) {
  1464. // console.log("=== != undefined ===")
  1465. // console.log(DRY_CONTAINER_STATUS[do_act_value])
  1466. // set_value.push(DRY_CONTAINER_STATUS[do_act_value]);
  1467. // cond_com_data += DRY_CONTAINER_STATUS[do_act_value];
  1468. // cond_com_list.push(cond_com_data);
  1469. // } else {
  1470. set_value.push(do_act_value);
  1471. cond_com_data += do_act_value;
  1472. cond_com_list.push(cond_com_data);
  1473. // }
  1474. }
  1475. } catch (error) {
  1476. if (error.name == 'TypeError') {
  1477. } else {
  1478. alert("do_act" + z + "_" + y + ": " + error.name)
  1479. }
  1480. }
  1481. }
  1482. // ===== 0324 測試 OK 勿刪 ===================================================
  1483. var A = 1;
  1484. var B = 1;
  1485. console.log("cond_add_list: " + cond_add_list);
  1486. console.log("cond_com_list: " + cond_com_list);
  1487. if (cond_main != '') {
  1488. TT['cond_main' + Z] = cond_main;
  1489. for (let a = 0; a < cond_add_list.length; a++) {
  1490. TT['cond_add'+ Z + '_' + A] = cond_add_list[a];
  1491. A = A + 1;
  1492. }
  1493. for (let b = 0; b < cond_com_list.length; b++) {
  1494. TT['cond_com'+ Z + '_' + B] = cond_com_list[b];
  1495. B = B + 1;
  1496. }
  1497. cond_item.push(
  1498. '{"cond_main":"' + cond_main + '", ' +
  1499. '"cond_add":["' + cond_add_list.join('", "') + '"], ' +
  1500. '"cond_com":["' + cond_com_list.join('", "') + '"]}'
  1501. )
  1502. }
  1503. console.log("cond_add_list.length: " + cond_add_list.length + "__" + typeof(cond_add_list.length))
  1504. console.log("TT['addLength']: " + TT['addLength'] + "__" + typeof(TT['addLength']))
  1505. if (cond_add_list.length > TT['addLength']) {
  1506. TT['addLength'] = cond_add_list.length
  1507. }
  1508. if (cond_com_list.length > TT['comLength']) {
  1509. TT['comLength'] = cond_com_list.length
  1510. }
  1511. }
  1512. // ========================================================
  1513. TT['mainLength'] = Z
  1514. console.log("***TT['mainLength']: " + TT['mainLength']);
  1515. console.log("***TT['addLength']: " + TT['addLength']);
  1516. console.log("***TT['comLength']: " + TT['comLength']);
  1517. TT['tank_num'] = $('#prog_tank').find(':selected').val();
  1518. // ========================================================
  1519. document.getElementById('show_Value').innerText = '"cond": [' + cond_item + ']';
  1520. }
  1521. function getValue(){
  1522. var confirm_getValue = confirm("請確認積木條件無誤後, 再按下 [確認] :");
  1523. if (!confirm_getValue) {
  1524. alert("已取消積木取值測試");
  1525. } else {
  1526. showValue();
  1527. }
  1528. }
  1529. function MQTTgetValue() {
  1530. var confirm_getValue = confirm("請確認積木條件無誤後, 再按下 [確認] :");
  1531. if (!confirm_getValue) {
  1532. alert("已取消積木取值測試");
  1533. } else {
  1534. showValue();
  1535. var msg_data;
  1536. $.get('/dry_block_format', TT, function (res) {
  1537. // alert("MQTT OK")
  1538. document.getElementById('show_MQTTcommand').innerText = JSON.stringify(res.response);
  1539. msg_data = JSON.stringify(res.response);
  1540. // 存值
  1541. var prog_tank_data = $('#prog_tank').find(':selected').val();
  1542. var SQL_insert = 'INSERT INTO `block_cond_dry_t` (' +
  1543. '`datetime`, `UserName`, `tank_num`, `cond`) VALUES (' +
  1544. 'current_timestamp(), \'' + USERNAME + '\', \'' + prog_tank_data + '\', \''
  1545. + String(msg_data).replaceAll("'", "") + '\');';
  1546. console.log("SQL_insert: " + SQL_insert);
  1547. sql_data = { "sql" : SQL_insert };
  1548. $.get('/sql_get', sql_data, function (res) {
  1549. // alert("OK")
  1550. }, 'json');
  1551. }, 'json');
  1552. }
  1553. }
  1554. </script>
  1555. <!-- 條件物件 ++ -- -->
  1556. <script>
  1557. function act_add(evt) {
  1558. evt.style.display = "none";
  1559. var actadd_parent_num = String(evt.id).split('_')[1].slice(3, )
  1560. // console.log("actadd_parent_num: " + actadd_parent_num)
  1561. act_add_child_i++;
  1562. var html = '';
  1563. html +=
  1564. '<div id="action' + actadd_parent_num + '_' + act_add_child_i + '">' +
  1565. '物件 ' +
  1566. '<select id="do_obj' + actadd_parent_num + '_' + act_add_child_i + '" onChange="renew(\'' + actadd_parent_num + '_' + act_add_child_i + '\', this.selectedIndex);">' +
  1567. // '<option value=" ">制動器 / 暫停秒數 / 桶槽狀態</option>' +
  1568. pin_data_relay_option +
  1569. // '<option value="input_vacuum_status">入料儲豆槽真空吸料機</option>' +
  1570. // '<option value="tank_vacuum_status">真空吸料機</option>' +
  1571. // '<option value="tank_threewayvalve_vacuum_status">吸料機三通閥</option>' +
  1572. // '<option value="tank_solenoid_disinfect_status">消毒電磁閥</option>' +
  1573. // '<option value="tank_motor_status">馬達</option>' +
  1574. // '<option value="outer_solenoid_water_status">桶外進水電磁閥</option>' +
  1575. // '<option value="tank_solenoid_water_out_status">廢水排水電磁閥</option>' +
  1576. // '<option value="tank_heater1_status">加熱棒 1</option>' +
  1577. // '<option value="tank_heater2_status">加熱棒 2</option>' +
  1578. // '<option value="tank_temp_enable">溫控開關</option>' +
  1579. // '<option value="tank_temp">溫度設定</option>' +
  1580. // '<option value="tank_diskvalve_status">蝴蝶閥</option>' +
  1581. // '<option value="output_vacuum_status">出料儲豆槽真空吸料機</option>' +
  1582. // '<option value="tank_magneticSwitch_status">電磁開關</option>' +
  1583. // '<option value="tank_emergencySwitch_status">緊急開關</option>' +
  1584. // '<option value="tank_camera_status">攝影機</option>' +
  1585. // '<option value="tank_warningLight_status">警示燈</option>' +
  1586. '</select> ' +
  1587. '動作 ' +
  1588. '<div id="do_action' + actadd_parent_num + '_' + act_add_child_i + '" style="display: inline-block;">' +
  1589. '</div>' +
  1590. // '<select id="do_act' + actadd_parent_num + '_' + act_add_child_i + '">' +
  1591. // '<option value="">請由左方選取物件</option>' +
  1592. // '</select> ' +
  1593. '<input type="button" class="input-act-delete" id="act_del' + actadd_parent_num + '_' + act_add_child_i + '" value="物件動作--" onclick="act_del(\'' + actadd_parent_num + '_' + act_add_child_i + '\');">' +
  1594. '<input type="button" class="input-act-add" id="act_add' + actadd_parent_num + '_' + act_add_child_i + '" value="物件動作++" onclick="act_add(act_add' + actadd_parent_num + '_' + act_add_child_i + ');"><br>' +
  1595. '</div>';
  1596. var divbox = document.getElementById('action' + actadd_parent_num);
  1597. divbox.insertAdjacentHTML('beforeend', html);
  1598. }
  1599. function act_del(evt) {
  1600. var del_action = document.getElementById('action' + evt);
  1601. del_action.innerHTML = ""
  1602. var parentObj = del_action.parentNode; // 取得欲刪除 div 的父類別
  1603. parentObj.removeChild(del_action) // 刪除 div
  1604. var del_act_parent_num = String(evt).split('_')[0]
  1605. var del_act_child_num = String(evt).split('_')[1]
  1606. // console.log('del_act_parent_num: ' + del_act_parent_num)
  1607. // console.log('del_act_child_num: ' + del_act_child_num)
  1608. var button_return_id = document.getElementById('act_add' + del_act_parent_num + '_' + String(parseInt(del_act_child_num)-1));
  1609. // console.log("test: " + 'cond_add' + del_act_parent_num + '_' + String(parseInt(del_act_child_num)-1))
  1610. // console.log("button_return_id: " + button_return_id) // null
  1611. if (button_return_id == null) {
  1612. var button_return_id = document.getElementById('act_add' + del_act_parent_num + '_1');
  1613. }
  1614. button_return_id.style.display = "inline";
  1615. }
  1616. // --------------------------------------------------------------------------------------------------
  1617. function cond_add(evt) { // cond_add1_1 下一個是 cond_add1(條件)_2(子條件)
  1618. evt.style.display = "none"; // 不顯示原按鈕
  1619. var condadd_parent_num = String(evt.id).split('_')[1].slice(3, ) // 把第一個條件的編號記下
  1620. // console.log("condadd_parent_num: " + condadd_parent_num)
  1621. cond_add_child_i++
  1622. var html = '';
  1623. html +=
  1624. '<div id="condition' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1625. '<select id="cond_d' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1626. '<option value=""></option>' +
  1627. '<option value="&&">&&</option>' +
  1628. '<option value="||">||</option>' +
  1629. '</select> ' +
  1630. '<select id="cond_a' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1631. pin_data_sensor_option +
  1632. '<option value="tankstatus">tankstatus</option>' +
  1633. '</optgroup>' +
  1634. '</select> ' +
  1635. '<select id="cond_b' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1636. '<option value=""></option>' +
  1637. '<option value=">">&gt;</option>' +
  1638. '<option value=">=">&gt;=</option>' +
  1639. '<option value="==">==</option>' +
  1640. '<option value="<=">&lt;=</option>' +
  1641. '<option value="<">&lt;</option>' +
  1642. '</select> ' +
  1643. '<input list="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '" id="cond_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1644. '<datalist id="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1645. '<option value="on">ON</option>' +
  1646. '<option value="off">OFF</option>' +
  1647. '<option value="">(或請自行輸入數值)</option>' +
  1648. '<option value="Waiting">空桶等待</option>' +
  1649. '<option value="InputtingBean">入豆中</option>' +
  1650. '<option value="InputtingBean_Pause">入豆暫停</option>' +
  1651. '<option value="InputtingBean_Finish">入豆完成</option>' +
  1652. '<option value="InputtingWater">夾層入水</option>' +
  1653. '<option value="Drying">乾燥中</option>' +
  1654. '<option value="Drying_Finish">乾燥完成</option>' +
  1655. '<option value="OutputtingBean">可出豆</option>' +
  1656. '<option value="OutputtingBean_Finish">出豆完成</option>' +
  1657. '</datalist> ' +
  1658. '<input type="button" class="input-cond-delete" id="cond_del' + condadd_parent_num + '_' + cond_add_child_i + '" value="條件--" onclick="cond_del(\'' + condadd_parent_num + '_' + cond_add_child_i + '\');">' +
  1659. '<input type="button" class="input-cond-add" id="cond_add' + condadd_parent_num + '_' + cond_add_child_i + '" value="條件++" onclick="cond_add(cond_add' + condadd_parent_num + '_' + cond_add_child_i + ');"><br>' +
  1660. '</div>';
  1661. var divbox = document.getElementById('condition' + condadd_parent_num);
  1662. divbox.insertAdjacentHTML('beforeend', html);
  1663. }
  1664. function cond_del(evt) {
  1665. // console.log('evt: ' + evt)
  1666. var del_cond_child = document.getElementById('condition' + evt);
  1667. // console.log("del_cond_child: " + del_cond_child)
  1668. del_cond_child.innerHTML = ""
  1669. var parentObj = del_cond_child.parentNode; // 取得欲刪除 div 的父類別
  1670. parentObj.removeChild(del_cond_child) // 刪除 div
  1671. // 上一個按鈕要顯示出來
  1672. var del_cond_parent_num = String(evt).split('_')[0]
  1673. var del_cond_child_num = String(evt).split('_')[1]
  1674. console.log('del_cond_parent_num: ' + del_cond_parent_num)
  1675. console.log('del_cond_child_num: ' + del_cond_child_num)
  1676. var button_return_id = document.getElementById('cond_add' + del_cond_parent_num + '_' + String(parseInt(del_cond_child_num)-1));
  1677. console.log("test: " + 'cond_add' + del_cond_parent_num + '_' + String(parseInt(del_cond_child_num)-1))
  1678. console.log("button_return_id: " + button_return_id) // null
  1679. if (button_return_id == null) {
  1680. var button_return_id = document.getElementById('cond_add' + del_cond_parent_num + '_1');
  1681. }
  1682. try {
  1683. button_return_id.style.display = "inline";
  1684. } catch (error) {
  1685. if (error.name !== 'TypeError') {
  1686. alert("cond_add" + del_cond_parent_num + "_" + String(parseInt(del_cond_child_num)-1) + " 子條件刪除錯誤\n" +
  1687. error.name + "\n" +
  1688. error.message);
  1689. }
  1690. }
  1691. }
  1692. // -------------------------------------------------------------------------------------------------------------
  1693. function Add(evt) { // 網頁初始按鈕 onclick="Add(add1);
  1694. evt.style.display = "none"; // 元素不顯示。將 add1 的 input-button 不顯示
  1695. new_condition_i++; // 設定編號用
  1696. // var div = document.createElement('div'); // 輸出 <div></div>。此時並不會顯示,
  1697. // 需透過 appendChild()、insertBefore() 或 replaceChild() 等方法將新元素加入至指定的位置之後才會顯示。
  1698. // var cond_number = String(evt).slice(3, ) // 目前的 condition 條件物件動作 數 (最外層)
  1699. // var cond_a = 'cond_a' + cond_number + '_' + new_condition_i; // [條件] 左方 : 制動器感測器
  1700. // var cond_b = 'cond_b' + cond_number + '_' + new_condition_i; // [條件] 中間 : > / = / <
  1701. // var cond_c = 'cond_c' + cond_number + '_' + new_condition_i; // [條件] 右方 : ON / OFF / 數值
  1702. // var cond_d = 'cond_d' + cond_number + '_' + new_condition_i; // 條件] 最左方條件連接 : and / or
  1703. // div.id = 'newcondition_' + new_condition_i; // 設定 div 的 id
  1704. // div.style.marginTop = "10px"; // 新增的 div 設定 marginTop 屬性值
  1705. var html = ''
  1706. // 新增的條件
  1707. html +=
  1708. '<div id="newcondition_' + new_condition_i + '" class="newcondition_css">' +
  1709. // 新增的分隔線
  1710. // '<hr size="50" width="100%">' +
  1711. '<div id="condition' + new_condition_i + '">' +
  1712. '<div id="condition' + new_condition_i + '_1">' +
  1713. '條件 ' +
  1714. '<select id="cond_z' + new_condition_i + '_1">' +
  1715. '<option value="if">if</option>' +
  1716. '<option value="else if">else if</option>' +
  1717. '<option value="else">else</option>' +
  1718. '</select> ' +
  1719. '<select id="cond_a' + new_condition_i + '_1">' +
  1720. pin_data_sensor_option +
  1721. '<option value="tankstatus">tankstatus</option>' +
  1722. '</optgroup>' +
  1723. '</select> ' +
  1724. '<select id="cond_b' + new_condition_i + '_1">' +
  1725. '<option value=""></option>' +
  1726. '<option value=">">&gt;</option>' +
  1727. '<option value=">=">&gt;=</option>' +
  1728. '<option value="==">==</option>' +
  1729. '<option value="<=">&lt;=</option>' +
  1730. '<option value="<">&lt;</option>' +
  1731. '</select> ' +
  1732. '<input list="cond_list_c' + new_condition_i + '_1" id="cond_c' + new_condition_i + '_1">' +
  1733. '<datalist id="cond_list_c' + new_condition_i + '_1">' +
  1734. '<option value="on">ON</option>' +
  1735. '<option value="off">OFF</option>' +
  1736. '<option value="">(或請自行輸入數值)</option>' +
  1737. '<option value="Waiting">空桶等待</option>' +
  1738. '<option value="InputtingBean">入豆中</option>' +
  1739. '<option value="InputtingBean_Pause">入豆暫停</option>' +
  1740. '<option value="InputtingBean_Finish">入豆完成</option>' +
  1741. '<option value="InputtingWater">夾層入水</option>' +
  1742. '<option value="Drying">乾燥中</option>' +
  1743. '<option value="Drying_Finish">乾燥完成</option>' +
  1744. '<option value="OutputtingBean">可出豆</option>' +
  1745. '<option value="OutputtingBean_Finish">出豆完成</option>' +
  1746. '</datalist> ' +
  1747. '<input type="button" class="input-cond-add" id="cond_add' + new_condition_i + '_1" value="條件++" onclick="cond_add(cond_add' + new_condition_i + '_1)"><br>' +
  1748. '</div></div>';
  1749. // 新增的物件動作
  1750. html +=
  1751. '<div id="action' + new_condition_i + '">' +
  1752. '<div id="action' + new_condition_i + '_1">' +
  1753. '物件 ' +
  1754. '<select id="do_obj' + new_condition_i + '_1" onChange="renew(\''+ new_condition_i + '_1\', this.selectedIndex);">' +
  1755. pin_data_relay_option +
  1756. '</select>' +
  1757. '動作 ' +
  1758. '<div id="do_action' + new_condition_i + '_1" style="display: inline-block;">' +
  1759. '</div>' +
  1760. '<input type="button" class="input-act-add" id="act_add' + new_condition_i + '_1" value="物件動作++" onclick="act_add(act_add' + new_condition_i + '_1);"><br>' +
  1761. '</div>' +
  1762. '</div>' +
  1763. // 新增的 條件物件動作++ 條件物件動作-- 按鈕
  1764. '<input type="button" class="input-delete" id="del' + new_condition_i + '" value="條件物件動作--" onclick="Delete(' + new_condition_i + ');"><br>' +
  1765. '<input type="button" class="input-add" id="add' + new_condition_i + '" value="條件物件動作++" onclick="Add(add' + new_condition_i + ');">' +
  1766. '</div>' ;
  1767. var divbox = document.getElementById('box');
  1768. divbox.insertAdjacentHTML('beforeend', html);
  1769. };
  1770. function Delete(evt) {
  1771. var del_condition = document.getElementById('newcondition_' + evt);
  1772. del_condition.innerHTML = ""
  1773. var parentObj = del_condition.parentNode; // 取得欲刪除 div 的父類別
  1774. parentObj.removeChild(del_condition) // 刪除 div
  1775. // 上一個按鈕要顯示出來
  1776. var button_return_id = document.getElementById('add' + String(parseInt(evt)-1));
  1777. if (button_return_id == null) {
  1778. var button_return_id = document.getElementById('add1');
  1779. }
  1780. // console.log('button_return_id: ' + button_return_id)
  1781. button_return_id.style.display = "block"; // 元素顯示。顯示前一個 input-button
  1782. };
  1783. // --------------------------------------------------------------------------------------
  1784. </script>
  1785. <div id="coffee_footer">
  1786. <!-- 匯入共同使用的 footer.html 內容 -->
  1787. {% include 'footer.html' %}
  1788. <br>
  1789. <br>
  1790. </div>
  1791. </div>
  1792. </body>
  1793. </html>