dry_block.html 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  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. <!-- 新 Bootstrap4 核心 CSS 文件 -->
  8. <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
  9. <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
  10. <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  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. <!--可用來建立使用者小圖示-->
  16. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  17. <!-- W3 CSS 樣式 -->
  18. <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
  19. <script language="JavaScript">
  20. // 指定 秒 刷新網頁一次
  21. var dtn = '{{tid}}';
  22. var status = '{{status}}';
  23. console.log('dtn:' + dtn)
  24. var new_condition_i = 5 // 總條件數
  25. var cond_add_child_i = 5 // 這是子條件數
  26. var act_add_child_i = 5 // 子物件數
  27. const cond_z_data = ['', '{{DBW.cond_z1_1}}', '{{DBW.cond_z2_1}}', '{{DBW.cond_z3_1}}', '{{DBW.cond_z4_1}}', '{{DBW.cond_z5_1}}']
  28. const cond_tank_data = ['', '{{DBW.cond_tank1_1}}', '{{DBW.cond_tank2_1}}', '{{DBW.cond_tank3_1}}', '{{DBW.cond_tank4_1}}', '{{DBW.cond_tank5_1}}']
  29. const cond_a_data = [ ['','','','','',''],
  30. ['','{{DBW.cond_a1_1}}', '{{DBW.cond_a1_2}}', '{{DBW.cond_a1_3}}', '{{DBW.cond_a1_4}}', '{{DBW.cond_a1_5}}'],
  31. ['','{{DBW.cond_a2_1}}', '{{DBW.cond_a2_2}}', '{{DBW.cond_a2_3}}', '{{DBW.cond_a2_4}}', '{{DBW.cond_a2_5}}'],
  32. ['','{{DBW.cond_a3_1}}', '{{DBW.cond_a3_2}}', '{{DBW.cond_a3_3}}', '{{DBW.cond_a3_4}}', '{{DBW.cond_a3_5}}'],
  33. ['','{{DBW.cond_a4_1}}', '{{DBW.cond_a4_2}}', '{{DBW.cond_a4_3}}', '{{DBW.cond_a4_4}}', '{{DBW.cond_a4_5}}'],
  34. ['','{{DBW.cond_a5_1}}', '{{DBW.cond_a5_2}}', '{{DBW.cond_a5_3}}', '{{DBW.cond_a5_4}}', '{{DBW.cond_a5_5}}'] ]
  35. const cond_b_data = [ ['','','','','',''],
  36. ['','{{DBW.cond_b1_1}}', '{{DBW.cond_b1_2}}', '{{DBW.cond_b1_3}}', '{{DBW.cond_b1_4}}', '{{DBW.cond_b1_5}}'],
  37. ['','{{DBW.cond_b2_1}}', '{{DBW.cond_b2_2}}', '{{DBW.cond_b2_3}}', '{{DBW.cond_b2_4}}', '{{DBW.cond_b2_5}}'],
  38. ['','{{DBW.cond_b3_1}}', '{{DBW.cond_b3_2}}', '{{DBW.cond_b3_3}}', '{{DBW.cond_b3_4}}', '{{DBW.cond_b3_5}}'],
  39. ['','{{DBW.cond_b4_1}}', '{{DBW.cond_b4_2}}', '{{DBW.cond_b4_3}}', '{{DBW.cond_b4_4}}', '{{DBW.cond_b4_5}}'],
  40. ['','{{DBW.cond_b5_1}}', '{{DBW.cond_b5_2}}', '{{DBW.cond_b5_3}}', '{{DBW.cond_b5_4}}', '{{DBW.cond_b5_5}}'] ]
  41. const cond_c_data = [ ['','','','','',''],
  42. ['','{{DBW.cond_c1_1}}', '{{DBW.cond_c1_2}}', '{{DBW.cond_c1_3}}', '{{DBW.cond_c1_4}}', '{{DBW.cond_c1_5}}'],
  43. ['','{{DBW.cond_c2_1}}', '{{DBW.cond_c2_2}}', '{{DBW.cond_c2_3}}', '{{DBW.cond_c2_4}}', '{{DBW.cond_c2_5}}'],
  44. ['','{{DBW.cond_c3_1}}', '{{DBW.cond_c3_2}}', '{{DBW.cond_c3_3}}', '{{DBW.cond_c3_4}}', '{{DBW.cond_c3_5}}'],
  45. ['','{{DBW.cond_c4_1}}', '{{DBW.cond_c4_2}}', '{{DBW.cond_c4_3}}', '{{DBW.cond_c4_4}}', '{{DBW.cond_c4_5}}'],
  46. ['','{{DBW.cond_c5_1}}', '{{DBW.cond_c5_2}}', '{{DBW.cond_c5_3}}', '{{DBW.cond_c5_4}}', '{{DBW.cond_c5_5}}'] ]
  47. const cond_d_data = [ ['','','','','',''],
  48. ['','', '{{DBW.cond_d1_2}}', '{{DBW.cond_d1_3}}', '{{DBW.cond_d1_4}}', '{{DBW.cond_d1_5}}'],
  49. ['','', '{{DBW.cond_d2_2}}', '{{DBW.cond_d2_3}}', '{{DBW.cond_d2_4}}', '{{DBW.cond_d2_5}}'],
  50. ['','', '{{DBW.cond_d3_2}}', '{{DBW.cond_d3_3}}', '{{DBW.cond_d3_4}}', '{{DBW.cond_d3_5}}'],
  51. ['','', '{{DBW.cond_d4_2}}', '{{DBW.cond_d4_3}}', '{{DBW.cond_d4_4}}', '{{DBW.cond_d4_5}}'],
  52. ['','', '{{DBW.cond_d5_2}}', '{{DBW.cond_d5_3}}', '{{DBW.cond_d5_4}}', '{{DBW.cond_d5_5}}'] ]
  53. const cond_obj_data = [ ['','','','','',''],
  54. ['','{{DBW.do_obj1_1}}', '{{DBW.do_obj1_2}}', '{{DBW.do_obj1_3}}', '{{DBW.do_obj1_4}}', '{{DBW.do_obj1_5}}'],
  55. ['','{{DBW.do_obj2_1}}', '{{DBW.do_obj2_2}}', '{{DBW.do_obj2_3}}', '{{DBW.do_obj2_4}}', '{{DBW.do_obj2_5}}'],
  56. ['','{{DBW.do_obj3_1}}', '{{DBW.do_obj3_2}}', '{{DBW.do_obj3_3}}', '{{DBW.do_obj3_4}}', '{{DBW.do_obj3_5}}'],
  57. ['','{{DBW.do_obj4_1}}', '{{DBW.do_obj4_2}}', '{{DBW.do_obj4_3}}', '{{DBW.do_obj4_4}}', '{{DBW.do_obj4_5}}'],
  58. ['','{{DBW.do_obj5_1}}', '{{DBW.do_obj5_2}}', '{{DBW.do_obj5_3}}', '{{DBW.do_obj5_4}}', '{{DBW.do_obj5_5}}'] ]
  59. const cond_act_data = [ ['','','','','',''],
  60. ['','{{DBW.do_act1_1}}', '{{DBW.do_act1_2}}', '{{DBW.do_act1_3}}', '{{DBW.do_act1_4}}', '{{DBW.do_act1_5}}'],
  61. ['','{{DBW.do_act2_1}}', '{{DBW.do_act2_2}}', '{{DBW.do_act2_3}}', '{{DBW.do_act2_4}}', '{{DBW.do_act2_5}}'],
  62. ['','{{DBW.do_act3_1}}', '{{DBW.do_act3_2}}', '{{DBW.do_act3_3}}', '{{DBW.do_act3_4}}', '{{DBW.do_act3_5}}'],
  63. ['','{{DBW.do_act4_1}}', '{{DBW.do_act4_2}}', '{{DBW.do_act4_3}}', '{{DBW.do_act4_4}}', '{{DBW.do_act4_5}}'],
  64. ['','{{DBW.do_act5_1}}', '{{DBW.do_act5_2}}', '{{DBW.do_act5_3}}', '{{DBW.do_act5_4}}', '{{DBW.do_act5_5}}'] ]
  65. $(function(){
  66. $("#coffee_title_pc").text("乾燥槽積木程式介面");
  67. $("#coffee_title_phone").text("乾燥槽積木");
  68. if (status == 2) {
  69. $('input').prop('disabled', true);
  70. $('button').prop('disabled', true);
  71. } else if ( (status == 0) || (status == 1) ) {
  72. $('input').prop('disabled', false);
  73. $('button').prop('disabled', false);
  74. }
  75. DBvalue_btn();
  76. for (let z_d = 1; z_d < cond_z_data.length; z_d++) {
  77. $("#cond_z" + z_d + "_1").val(cond_z_data[z_d]);
  78. }
  79. for (let tank_d = 1; tank_d < cond_tank_data.length; tank_d++) {
  80. $("#cond_tank" + tank_d + "_1").val(cond_tank_data[tank_d]);
  81. }
  82. for (let a_d = 1; a_d < 6; a_d++) {
  83. for (let a_d_n = 1; a_d_n < 6; a_d_n++) {
  84. $("#cond_a" + a_d + "_" + a_d_n).val(cond_a_data[a_d][a_d_n]);
  85. }
  86. }
  87. for (let b_d = 1; b_d < 6; b_d++) {
  88. for (let b_d_n = 1; b_d_n < 6; b_d_n++) {
  89. $("#cond_b" + b_d + "_" + b_d_n).val(cond_b_data[b_d][b_d_n]);
  90. }
  91. }
  92. for (let c_d = 1; c_d < 6; c_d++) {
  93. for (let c_d_n = 1; c_d_n < 6; c_d_n++) {
  94. $("#cond_c" + c_d + "_" + c_d_n).val(cond_c_data[c_d][c_d_n]);
  95. }
  96. }
  97. for (let d_d = 1; d_d < 6; d_d++) {
  98. for (let d_d_n = 2; d_d_n < 6; d_d_n++) {
  99. $("#cond_d" + d_d + "_" + d_d_n).val(cond_d_data[d_d][d_d_n]);
  100. }
  101. }
  102. for (let obj_d = 1; obj_d < 6; obj_d++) {
  103. for (let obj_d_n = 1; obj_d_n < 6; obj_d_n++) {
  104. $("#do_obj" + obj_d + "_" + obj_d_n).val(cond_obj_data[obj_d][obj_d_n]);
  105. // 設定物件後, 取得物件目前所選項目, 再呼叫 renew 顯示對應動作下拉式選單
  106. const target_obj_index = $("#do_obj" + obj_d + "_" + obj_d_n).prop('selectedIndex')
  107. // console.log("target_obj_index: " + target_obj_index)
  108. renew(obj_d + '_' + obj_d_n, target_obj_index);
  109. }
  110. }
  111. for (let act_d = 1; act_d < 6; act_d++) {
  112. for (let act_d_n = 1; act_d_n < 6; act_d_n++) {
  113. $("#do_act" + act_d + "_" + act_d_n).val(cond_act_data[act_d][act_d_n]);
  114. // 若是 input range 要更新顯示文字
  115. if ($("#do_obj" + act_d + "_" + act_d_n).prop('selectedIndex') == '4') {
  116. let target_act_motorValue = $("#do_act" + act_d + "_" + act_d_n).prop('value')
  117. showMotorValue(act_d + "_" + act_d_n, target_act_motorValue);
  118. } else if ($("#do_obj" + act_d + "_" + act_d_n).prop('selectedIndex') == '13') {
  119. let target_act_tempValue = $("#do_act" + act_d + "_" + act_d_n).prop('value')
  120. showTempValue(act_d + "_" + act_d_n, target_act_tempValue);
  121. } else if ($("#do_obj" + act_d + "_" + act_d_n).prop('selectedIndex') == '15') {
  122. let target_act_sleepValue = $("#do_act" + act_d + "_" + act_d_n).prop('value')
  123. showSleepValue(act_d + "_" + act_d_n, target_act_sleepValue);
  124. }
  125. }
  126. }
  127. });
  128. </script>
  129. <style>
  130. .newcondition_css {
  131. padding: 10px;
  132. margin-top: 10px;
  133. background-color:honeydew;
  134. }
  135. hr {
  136. margin-top: 5px;
  137. margin-bottom: 5px;
  138. }
  139. .input-cond-delete {
  140. background: #E43030;
  141. border: 1px solid #CFCFCF;
  142. box-sizing: border-box;
  143. border-radius: 5px;
  144. margin-left: 5px;
  145. width: 65px;
  146. height: 33px;
  147. font-size: 16px;
  148. text-align: center;
  149. line-height: 16px;
  150. color: #FFFFFF;
  151. }
  152. .input-cond-add {
  153. background: #008CBA;
  154. border: 1px solid #CFCFCF;
  155. box-sizing: border-box;
  156. border-radius: 5px;
  157. margin-left: 5px;
  158. width: 65px;
  159. height: 33px;
  160. font-size: 16px;
  161. text-align: center;
  162. line-height: 16px;
  163. color: #FFFFFF;
  164. }
  165. .input-act-add {
  166. background: #008CBA;
  167. border: 1px solid #CFCFCF;
  168. box-sizing: border-box;
  169. border-radius: 5px;
  170. margin-left: 5px;
  171. width: 100px;
  172. height: 33px;
  173. font-size: 16px;
  174. text-align: center;
  175. line-height: 16px;
  176. color: #FFFFFF;
  177. }
  178. .input-act-delete {
  179. background: #E43030;
  180. border: 1px solid #CFCFCF;
  181. box-sizing: border-box;
  182. border-radius: 5px;
  183. margin-left: 5px;
  184. width: 100px;
  185. height: 33px;
  186. font-size: 16px;
  187. text-align: center;
  188. line-height: 16px;
  189. color: #FFFFFF;
  190. }
  191. .input-add {
  192. background: #008CBA;
  193. border: 1px solid #CFCFCF;
  194. box-sizing: border-box;
  195. border-radius: 5px;
  196. margin-left: 5px;
  197. margin-top: 5px;
  198. width: 150px;
  199. height: 40px;
  200. font-size: 18px;
  201. text-align: center;
  202. line-height: 16px;
  203. color: #FFFFFF;
  204. }
  205. .input-delete {
  206. background: #E43030;
  207. border: 1px solid #CFCFCF;
  208. box-sizing: border-box;
  209. border-radius: 5px;
  210. margin-left: 5px;
  211. margin-top: 5px;
  212. width: 150px;
  213. height: 40px;
  214. font-size: 18px;
  215. text-align: center;
  216. line-height: 16px;
  217. color: #FFFFFF;
  218. }
  219. select {
  220. font-size: 24px;
  221. height: 30px;
  222. padding: 2px 5px;
  223. margin-left: 5px;
  224. }
  225. /* https://rookiesavior.net/2020/12/08/css-accordion-effect/ */
  226. * {
  227. box-sizing: border-box;
  228. }
  229. .accordion {
  230. width: auto;
  231. /* width: 600px; */
  232. /* margin: 80px auto 0; */
  233. }
  234. .accordion label {
  235. display: block;
  236. width: 100%;
  237. text-align: left;
  238. border-radius: 5px;
  239. background-color: #ccc;
  240. margin-top: 10px;
  241. padding: 6px 10px;
  242. cursor: pointer;
  243. }
  244. .content {
  245. height: 0px;
  246. background-color: #fff;
  247. overflow: hidden;
  248. transition: 0.5s;
  249. }
  250. input[type=checkbox]{
  251. display: none;
  252. }
  253. input[type=checkbox]:checked + .content {
  254. /* 被選取的input[type=checkbox]
  255. 的下一個 .content 背景變成橘色。 */
  256. background-color: #fa0;
  257. height: auto;
  258. /* height: 100px; */
  259. padding: 10px 10px 10px 20px;
  260. }
  261. .content00 {
  262. height: 0px;
  263. background-color: #fff;
  264. overflow: hidden;
  265. transition: 0.5s;
  266. }
  267. input[type=checkbox]:checked + .content00 {
  268. /* 被選取的input[type=checkbox]
  269. 的下一個 .content 背景變成橘色。 */
  270. background-color: rgb(255, 236, 199);
  271. height: auto;
  272. /* height: 100px; */
  273. }
  274. label {
  275. content: "+";
  276. }
  277. </style>
  278. </head>
  279. <body style="font-size: 18px;">
  280. <div id="wrapper">
  281. <div id="coffee_header">
  282. <!-- 匯入共同使用的 header.html 內容 -->
  283. {% include 'header.html' %}
  284. </div>
  285. <!-- [物件]文字輸入框 選擇後連結 [動作]文字輸入框 -->
  286. <script>
  287. dry_object = new Array();
  288. dry_object[0] = ["-"]; // 制動器 / 感測器
  289. dry_object[1] = ["on", "off"]; // 入料儲豆槽真空吸料機
  290. dry_object[2] = ["on", "off"]; // 真空吸料機
  291. dry_object[3] = ["ON 吸料", "OFF 排氣"]; // 吸料機三通閥
  292. dry_object[4] = ["on", "off"]; // 消毒電磁閥
  293. // dry_object[5] = ["0", "10", "20", "30", "40", "50"]; // 馬達
  294. dry_object[6] = ["on", "off"]; // 桶外進水電磁閥
  295. dry_object[7] = ["on", "off"]; // 廢水排水電磁閥
  296. dry_object[8] = ["on", "off"]; // 加熱棒 1
  297. dry_object[9] = ["on", "off"]; // 加熱棒 2
  298. dry_object[10] = ["on", "off"]; // 溫控開關
  299. // dry_object[11] = ["on", "off"]; // 溫度設定
  300. dry_object[12] = ["on", "off"]; // 蝴蝶閥
  301. dry_object[13] = ["on", "off"]; // 出料儲豆槽真空吸料機
  302. dry_object[14] = ["on", "off"]; // 電磁開關
  303. dry_object[15] = ["on", "off"]; // 緊急開關
  304. dry_object[16] = ["on", "off"]; // 攝影機
  305. dry_object[17] = ["on", "off"]; // 警示燈
  306. // dry_object[18] = ["1", "5", "10", "30", "60"]; // 暫停秒數
  307. dry_object[19] = ["空桶等待", "入豆中", "入豆暫停", "入豆完成", "夾層入水", "乾燥", "可出豆"]; // 暫停秒數
  308. function renew(obj_num, index) {
  309. var Value = '';
  310. try {
  311. Value = '<select id="do_act' + obj_num + '">';
  312. for(var i=0; i<dry_object[index].length; i++){
  313. Value += '<option value=' + dry_object[index][i] + '>' + dry_object[index][i] + '</option>';
  314. }
  315. Value += '</select>';
  316. } catch (e) {
  317. if (e.name == 'TypeError' && index == '5') {
  318. Value = ' 轉速 : ' +
  319. ' <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)">' +
  320. ' <span id="motorValue_text' + obj_num + '">0</span>';
  321. } else if (e.name == 'TypeError' && index == '11') {
  322. Value = ' 目標溫度 : ' +
  323. ' <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)">' +
  324. ' <span id="tempValue_text' + obj_num + '">28.0</span>';
  325. } else if (e.name == 'TypeError' && index == '18') {
  326. Value = ' 暫停秒數 : ' +
  327. ' <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)">' +
  328. ' <span id="sleepValue_text' + obj_num + '">10s</span>';
  329. }
  330. }
  331. var sectorSelect = document.getElementById("do_action" + obj_num);
  332. if (sectorSelect != null) {
  333. sectorSelect.innerHTML = Value;
  334. }
  335. }
  336. </script>
  337. <!-- DB 取值測試 -->
  338. - - - DB 取值測試 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br>
  339. <!-- <input type="button" id="test" value="DB 取值測試" onclick="DBvalue_btn();"><br> -->
  340. <div id="DBvalue">
  341. </div>
  342. <script>
  343. function DBvalue_btn(params) {
  344. var html = '<div id="box">';
  345. for (let condadd_parent_num = 1; condadd_parent_num < 6; condadd_parent_num++) {
  346. html += '' +
  347. '<div id="newcondition_' + condadd_parent_num + '" class="newcondition_css">' +
  348. '<div id="condition' + condadd_parent_num + '">' +
  349. '<div id="condition' + condadd_parent_num + '_' + '1' + '">' +
  350. '條件 ' +
  351. '<select id="cond_z' + condadd_parent_num + '_' + '1' + '">' +
  352. '<option value="if">if</option>' +
  353. '<option value="elif">elif</option>' +
  354. '<option value="else">else</option>' +
  355. '</select> ' +
  356. '<select id="cond_tank' + condadd_parent_num + '_' + '1' + '">' +
  357. '<option value="D1">乾燥桶 D1</option>' +
  358. '<option value="D2">乾燥桶 D2</option>' +
  359. '<option value="D3">乾燥桶 D3</option>' +
  360. '<option value="D4">乾燥桶 D4</option>' +
  361. '<option value="D5">乾燥桶 D5</option>' +
  362. '<option value="D6">乾燥桶 D6</option>' +
  363. '<option value="D7">乾燥桶 D7</option>' +
  364. '<option value="D8">乾燥桶 D8</option>' +
  365. '<option value="D9">乾燥桶 D9</option>' +
  366. '<option value="D10">乾燥桶 D10</option>' +
  367. '<option value="D11">乾燥桶 D11</option>' +
  368. '<option value="D12">乾燥桶 D12</option>' +
  369. '</select> ' +
  370. '<select id="cond_a' + condadd_parent_num + '_' + '1' + '">' +
  371. '<option value="">制動器 / 感測器</option>' +
  372. '<optgroup label="制動器狀態">' +
  373. '<option value="input_vacuum_status">入料儲豆槽真空吸料機</option>' +
  374. '<option value="tank_vacuum_status">真空吸料機</option>' +
  375. '<option value="tank_threewayvalve_vacuum_status">吸料機三通閥</option>' +
  376. '<option value="tank_solenoid_disinfect_status">消毒電磁閥</option>' +
  377. '<option value="tank_motor_status">馬達</option>' +
  378. '<option value="outer_solenoid_water_status">桶外進水電磁閥</option>' +
  379. '<option value="tank_solenoid_water_out_status">廢水排水閥</option>' +
  380. '<option value="tank_heater1_status">加熱棒 1</option>' +
  381. '<option value="tank_heater2_status">加熱棒 2</option>' +
  382. '<option value="tank_temp_enable">溫控開關</option>' +
  383. '<option value="tank_temp">溫度設定</option>' +
  384. '<option value="tank_diskvalve_status">蝴蝶閥</option>' +
  385. '<option value="output_vacuum_status">出料儲豆槽真空吸料機</option>' +
  386. '<option value="tank_magneticSwitch_status">電磁開關</option>' +
  387. '<option value="tank_emergencySwitch_status">緊急開關</option>' +
  388. '<option value="tank_camera_status">攝影機</option>' +
  389. '<option value="tank_warningLight_status">警示燈</option>' +
  390. '</optgroup>' +
  391. '<optgroup label="感測器數值">' +
  392. '<option value="tank_ultrasonic_status">超音波感測器</option>' +
  393. '<option value="tank_pa_status">大氣壓力計</option>' +
  394. '<option value="tank_motorencoder_status">馬達編碼器</option>' +
  395. '<option value="tank_sht11_temp_status">溫溼度計_溫度</option>' +
  396. '<option value="tank_sht11_humidity_status">溫溼度計_濕度</option>' +
  397. '<option value="tank_soil_temp_status">三合一土壤感測器_溫度</option>' +
  398. '<option value="tank_soil_humidity_status">三合一土壤感測器_濕度</option>' +
  399. '<option value="tank_soil_ec_status">三合一土壤感測器_EC</option>' +
  400. '<option value="tank_diskvalve_monitor_status">蝴蝶閥狀態顯示器</option>' +
  401. '<option value="outer_waterlevel_status">夾層水位計</option>' +
  402. '</optgroup>' +
  403. '</select> ' +
  404. '<select id="cond_b' + condadd_parent_num + '_' + '1' + '">' +
  405. // '<option value="equal">==</option>' +
  406. // '<option value="morethan">&gt;=</option>' +
  407. // '<option value="lessthan">&lt;=</option>' +
  408. '<option value="MoreThan">&gt;</option>' +
  409. '<option value="MoreThanEqualTo">&gt;=</option>' +
  410. '<option value="Equal" selected>==</option>' +
  411. '<option value="LessThanEqualTo">&lt;=</option>' +
  412. '<option value="LessThan">&lt;</option>' +
  413. '</select> ' +
  414. '<input list="cond_list_c' + condadd_parent_num + '_' + '1' + '" id="cond_c' + condadd_parent_num + '_' + '1' + '">' +
  415. '<datalist id="cond_list_c' + condadd_parent_num + '_' + '1' + '">' +
  416. '<option value="on">' +
  417. '<option value="off">' +
  418. '<option value="(或請自行輸入數值)">' +
  419. '</datalist> ' +
  420. // '<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>' +
  421. '</div>';
  422. for (let cond_add_child_i = 2; cond_add_child_i < 6; cond_add_child_i++) {
  423. // if (cond_d_data[condadd_parent_num][cond_add_child_i] == '') {
  424. // // alert("cond_d_data[" + condadd_parent_num + "][" + cond_add_child_i + " ] + 為空值")
  425. // continue
  426. // }
  427. html +=
  428. '<div id="condition' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  429. '<select id="cond_d' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  430. '<option value="and">and</option>' +
  431. '<option value="or">or</option>' +
  432. '</select> ' +
  433. '<select id="cond_a' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  434. '<option value="">制動器 / 感測器</option>' +
  435. '<optgroup label="制動器狀態">' +
  436. '<option value="input_vacuum_status">入料儲豆槽真空吸料機</option>' +
  437. '<option value="tank_vacuum_status">真空吸料機</option>' +
  438. '<option value="tank_threewayvalve_vacuum_status">吸料機三通閥</option>' +
  439. '<option value="tank_solenoid_disinfect_status">消毒電磁閥</option>' +
  440. '<option value="tank_motor_status">馬達</option>' +
  441. '<option value="outer_solenoid_water_status">桶外進水電磁閥</option>' +
  442. '<option value="tank_solenoid_water_out_status">廢水排水閥</option>' +
  443. '<option value="tank_heater1_status">加熱棒 1</option>' +
  444. '<option value="tank_heater2_status">加熱棒 2</option>' +
  445. '<option value="tank_temp_enable">溫控開關</option>' +
  446. '<option value="tank_temp">溫度設定</option>' +
  447. '<option value="tank_diskvalve_status">蝴蝶閥</option>' +
  448. '<option value="output_vacuum_status">出料儲豆槽真空吸料機</option>' +
  449. '<option value="tank_magneticSwitch_status">電磁開關</option>' +
  450. '<option value="tank_emergencySwitch_status">緊急開關</option>' +
  451. '<option value="tank_camera_status">攝影機</option>' +
  452. '<option value="tank_warningLight_status">警示燈</option>' +
  453. '</optgroup>' +
  454. '<optgroup label="感測器數值">' +
  455. '<option value="tank_ultrasonic_status">超音波感測器</option>' +
  456. '<option value="tank_pa_status">大氣壓力計</option>' +
  457. '<option value="tank_motorencoder_status">馬達編碼器</option>' +
  458. '<option value="tank_sht11_temp_status">溫溼度計_溫度</option>' +
  459. '<option value="tank_sht11_humidity_status">溫溼度計_濕度</option>' +
  460. '<option value="tank_soil_temp_status">三合一土壤感測器_溫度</option>' +
  461. '<option value="tank_soil_humidity_status">三合一土壤感測器_濕度</option>' +
  462. '<option value="tank_soil_ec_status">三合一土壤感測器_EC</option>' +
  463. '<option value="tank_diskvalve_monitor_status">蝴蝶閥狀態顯示器</option>' +
  464. '<option value="outer_waterlevel_status">夾層水位計</option>' +
  465. '</optgroup>' +
  466. '</select> ' +
  467. '<select id="cond_b' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  468. // '<option value="equal">==</option>' +
  469. // '<option value="morethan">&gt;=</option>' +
  470. // '<option value="lessthan">&lt;=</option>' +
  471. '<option value="MoreThan">&gt;</option>' +
  472. '<option value="MoreThanEqualTo">&gt;=</option>' +
  473. '<option value="Equal" selected>==</option>' +
  474. '<option value="LessThanEqualTo">&lt;=</option>' +
  475. '<option value="LessThan">&lt;</option>' +
  476. '</select> ' +
  477. '<input list="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '" id="cond_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  478. '<datalist id="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  479. '<option value="on">' +
  480. '<option value="off">' +
  481. '<option value="(或請自行輸入數值)">' +
  482. '</datalist> ' +
  483. '<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 + '\');">';
  484. if (cond_add_child_i == 5) {
  485. html +=
  486. '<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>';
  487. } else {
  488. html +=
  489. '<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>';
  490. }
  491. html += '</div>';
  492. }
  493. html += '</div>';
  494. // 新增的物件動作
  495. html += '<div id="action' + condadd_parent_num + '">';
  496. for (let cond_add_child_i = 1; cond_add_child_i < 6; cond_add_child_i++) {
  497. // if (cond_obj_data[condadd_parent_num][cond_add_child_i] == '') {
  498. // // alert("cond_d_data[" + condadd_parent_num + "][" + cond_add_child_i + " ] + 為空值")
  499. // continue
  500. // }
  501. html +=
  502. '<div id="action' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  503. '物件 ' +
  504. '<select id="do_obj' + condadd_parent_num + '_' + cond_add_child_i + '" onChange="renew(\''+ condadd_parent_num + '_' + cond_add_child_i + '\', this.selectedIndex);">' +
  505. '<option value="">制動器 / 暫停秒數 / 桶槽狀態</option>' +
  506. '<option value="input_vacuum_status">入料儲豆槽真空吸料機</option>' +
  507. '<option value="tank_vacuum_status">真空吸料機</option>' +
  508. '<option value="tank_threewayvalve_vacuum_status">吸料機三通閥</option>' +
  509. '<option value="tank_solenoid_disinfect_status">消毒電磁閥</option>' +
  510. '<option value="tank_motor_status">馬達</option>' +
  511. '<option value="outer_solenoid_water_status">桶外進水電磁閥</option>' +
  512. '<option value="tank_solenoid_water_out_status">廢水排水電磁閥</option>' +
  513. '<option value="tank_heater1_status">加熱棒 1</option>' +
  514. '<option value="tank_heater2_status">加熱棒 2</option>' +
  515. '<option value="tank_temp_enable">溫控開關</option>' +
  516. '<option value="tank_temp">溫度設定</option>' +
  517. '<option value="tank_diskvalve_status">蝴蝶閥</option>' +
  518. '<option value="output_vacuum_status">出料儲豆槽真空吸料機</option>' +
  519. '<option value="tank_magneticSwitch_status">電磁開關</option>' +
  520. '<option value="tank_emergencySwitch_status">緊急開關</option>' +
  521. '<option value="tank_camera_status">攝影機</option>' +
  522. '<option value="tank_warningLight_status">警示燈</option>' +
  523. '<option value="time.sleep">暫停秒數</option>' +
  524. '<option value="dry_container_status">桶槽狀態</option>' +
  525. '</select>' +
  526. // '<select id="do_act' + new_condition_i + '_1">' +
  527. // '<option value="">請由左方選取物件' +
  528. // '</select> ' +
  529. ' 動作 ' +
  530. '<div id="do_action' + condadd_parent_num + '_' + cond_add_child_i + '" style="display: inline-block;">' +
  531. '</div>' +
  532. '<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 + '\');">';
  533. if (cond_add_child_i == 5) {
  534. html +=
  535. '<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>';
  536. } else {
  537. html +=
  538. '<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>';
  539. }
  540. html += '</div>';
  541. }
  542. html += '</div>';
  543. // 新增的 條件物件動作++ 條件物件動作-- 按鈕
  544. html += '<input type="button" class="input-delete" id="del' + condadd_parent_num + '" value="條件物件動作--" onclick="Delete(' + condadd_parent_num + ');"><br>' +
  545. '<input type="button" class="input-add" id="add' + condadd_parent_num + '" value="條件物件動作++" onclick="Add(add' + condadd_parent_num + ');">' +
  546. '</div>' ;
  547. }
  548. html += '</div>' ;
  549. var divbox = document.getElementById('DBvalue');
  550. divbox.insertAdjacentHTML('beforeend', html);
  551. }
  552. </script>
  553. - - - DB 取值測試 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br>
  554. <!-- 0225 手風琴測試 start -->
  555. - - - 手風琴測試 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br>
  556. - - - 手風琴測試 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br>
  557. <!-- 0225 手風琴測試 end -->
  558. 原本 BOX 的位置<br>
  559. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  560. <br>
  561. <input type="button" id="test" value="取值測試" onclick="test();"><br>
  562. <span id="value_test"> ( 取值測試 ) </span><br>
  563. <span id="command_test"> ( command 測試 ) </span><br>
  564. <input type="button" id="test" value="ajax 測試" onclick="AJAXtest();">
  565. <script>
  566. function act_add(evt) {
  567. evt.style.display = "none";
  568. var actadd_parent_num = String(evt.id).split('_')[1].slice(3, )
  569. // console.log("actadd_parent_num: " + actadd_parent_num)
  570. act_add_child_i++;
  571. var html = '';
  572. html +=
  573. '<div id="action' + actadd_parent_num + '_' + act_add_child_i + '">' +
  574. '物件 ' +
  575. '<select id="do_obj' + actadd_parent_num + '_' + act_add_child_i + '" onChange="renew(\'' + actadd_parent_num + '_' + act_add_child_i + '\', this.selectedIndex);">' +
  576. '<option value="">制動器 / 暫停秒數 / 桶槽狀態</option>' +
  577. '<option value="input_vacuum_status">入料儲豆槽真空吸料機</option>' +
  578. '<option value="tank_vacuum_status">真空吸料機</option>' +
  579. '<option value="tank_threewayvalve_vacuum_status">吸料機三通閥</option>' +
  580. '<option value="tank_solenoid_disinfect_status">消毒電磁閥</option>' +
  581. '<option value="tank_motor_status">馬達</option>' +
  582. '<option value="outer_solenoid_water_status">桶外進水電磁閥</option>' +
  583. '<option value="tank_solenoid_water_out_status">廢水排水電磁閥</option>' +
  584. '<option value="tank_heater1_status">加熱棒 1</option>' +
  585. '<option value="tank_heater2_status">加熱棒 2</option>' +
  586. '<option value="tank_temp_enable">溫控開關</option>' +
  587. '<option value="tank_temp">溫度設定</option>' +
  588. '<option value="tank_diskvalve_status">蝴蝶閥</option>' +
  589. '<option value="output_vacuum_status">出料儲豆槽真空吸料機</option>' +
  590. '<option value="tank_magneticSwitch_status">電磁開關</option>' +
  591. '<option value="tank_emergencySwitch_status">緊急開關</option>' +
  592. '<option value="tank_camera_status">攝影機</option>' +
  593. '<option value="tank_warningLight_status">警示燈</option>' +
  594. '<option value="time.sleep">暫停秒數</option>' +
  595. '<option value="dry_container_status">桶槽狀態</option>' +
  596. '</select> ' +
  597. '動作 ' +
  598. '<div id="do_action' + actadd_parent_num + '_' + act_add_child_i + '" style="display: inline-block;">' +
  599. '</div>' +
  600. // '<select id="do_act' + actadd_parent_num + '_' + act_add_child_i + '">' +
  601. // '<option value="">請由左方選取物件</option>' +
  602. // '</select> ' +
  603. '<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 + '\');">' +
  604. '<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>' +
  605. '</div>';
  606. var divbox = document.getElementById('action' + actadd_parent_num);
  607. divbox.insertAdjacentHTML('beforeend', html);
  608. }
  609. function act_del(evt) {
  610. var del_action = document.getElementById('action' + evt);
  611. del_action.innerHTML = ""
  612. var parentObj = del_action.parentNode; // 取得欲刪除 div 的父類別
  613. parentObj.removeChild(del_action) // 刪除 div
  614. var del_act_parent_num = String(evt).split('_')[0]
  615. var del_act_child_num = String(evt).split('_')[1]
  616. // console.log('del_act_parent_num: ' + del_act_parent_num)
  617. // console.log('del_act_child_num: ' + del_act_child_num)
  618. var button_return_id = document.getElementById('act_add' + del_act_parent_num + '_' + String(parseInt(del_act_child_num)-1));
  619. // console.log("test: " + 'cond_add' + del_act_parent_num + '_' + String(parseInt(del_act_child_num)-1))
  620. // console.log("button_return_id: " + button_return_id) // null
  621. if (button_return_id == null) {
  622. var button_return_id = document.getElementById('act_add' + del_act_parent_num + '_1');
  623. }
  624. button_return_id.style.display = "inline";
  625. }
  626. // --------------------------------------------------------------------------------------------------
  627. function cond_add(evt) { // cond_add1_1 下一個是 cond_add1(條件)_2(子條件)
  628. evt.style.display = "none"; // 不顯示原按鈕
  629. var condadd_parent_num = String(evt.id).split('_')[1].slice(3, ) // 把第一個條件的編號記下
  630. // console.log("condadd_parent_num: " + condadd_parent_num)
  631. cond_add_child_i++
  632. var html = '';
  633. html +=
  634. '<div id="condition' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  635. '<select id="cond_d' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  636. '<option value="and">and</option>' +
  637. '<option value="or">or</option>' +
  638. '</select> ' +
  639. '<select id="cond_a' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  640. '<option value="">制動器 / 感測器</option>' +
  641. '<optgroup label="制動器狀態">' +
  642. '<option value="input_vacuum_status">入料儲豆槽真空吸料機</option>' +
  643. '<option value="tank_vacuum_status">真空吸料機</option>' +
  644. '<option value="tank_threewayvalve_vacuum_status">吸料機三通閥</option>' +
  645. '<option value="tank_solenoid_disinfect_status">消毒電磁閥</option>' +
  646. '<option value="tank_motor_status">馬達</option>' +
  647. '<option value="outer_solenoid_water_status">桶外進水電磁閥</option>' +
  648. '<option value="tank_solenoid_water_out_status">廢水排水閥</option>' +
  649. '<option value="tank_heater1_status">加熱棒 1</option>' +
  650. '<option value="tank_heater2_status">加熱棒 2</option>' +
  651. '<option value="tank_temp_enable">溫控開關</option>' +
  652. '<option value="tank_temp">溫度設定</option>' +
  653. '<option value="tank_diskvalve_status">蝴蝶閥</option>' +
  654. '<option value="output_vacuum_status">出料儲豆槽真空吸料機</option>' +
  655. '<option value="tank_magneticSwitch_status">電磁開關</option>' +
  656. '<option value="tank_emergencySwitch_status">緊急開關</option>' +
  657. '<option value="tank_camera_status">攝影機</option>' +
  658. '<option value="tank_warningLight_status">警示燈</option>' +
  659. '</optgroup>' +
  660. '<optgroup label="感測器數值">' +
  661. '<option value="tank_ultrasonic_status">超音波感測器</option>' +
  662. '<option value="tank_pa_status">大氣壓力計</option>' +
  663. '<option value="tank_motorencoder_status">馬達編碼器</option>' +
  664. '<option value="tank_sht11_temp_status">溫溼度計_溫度</option>' +
  665. '<option value="tank_sht11_humidity_status">溫溼度計_濕度</option>' +
  666. '<option value="tank_soil_temp_status">三合一土壤感測器_溫度</option>' +
  667. '<option value="tank_soil_humidity_status">三合一土壤感測器_濕度</option>' +
  668. '<option value="tank_soil_ec_status">三合一土壤感測器_EC</option>' +
  669. '<option value="tank_diskvalve_monitor_status">蝴蝶閥狀態顯示器</option>' +
  670. '<option value="outer_waterlevel_status">夾層水位計</option>' +
  671. '</optgroup>' +
  672. '</select> ' +
  673. '<select id="cond_b' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  674. // '<option value="equal">==</option>' +
  675. // '<option value="morethan">&gt;=</option>' +
  676. // '<option value="lessthan">&lt;=</option>' +
  677. '<option value="MoreThan">&gt;</option>' +
  678. '<option value="MoreThanEqualTo">&gt;=</option>' +
  679. '<option value="Equal" selected>==</option>' +
  680. '<option value="LessThanEqualTo">&lt;=</option>' +
  681. '<option value="LessThan">&lt;</option>' +
  682. '</select> ' +
  683. '<input list="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '" id="cond_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  684. '<datalist id="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  685. '<option value="on">' +
  686. '<option value="off">' +
  687. '<option value="(或請自行輸入數值)">' +
  688. '</datalist> ' +
  689. '<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 + '\');">' +
  690. '<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>' +
  691. '</div>';
  692. var divbox = document.getElementById('condition' + condadd_parent_num);
  693. divbox.insertAdjacentHTML('beforeend', html);
  694. }
  695. function cond_del(evt) {
  696. // console.log('evt: ' + evt)
  697. var del_cond_child = document.getElementById('condition' + evt);
  698. // console.log("del_cond_child: " + del_cond_child)
  699. del_cond_child.innerHTML = ""
  700. var parentObj = del_cond_child.parentNode; // 取得欲刪除 div 的父類別
  701. parentObj.removeChild(del_cond_child) // 刪除 div
  702. // 上一個按鈕要顯示出來
  703. var del_cond_parent_num = String(evt).split('_')[0]
  704. var del_cond_child_num = String(evt).split('_')[1]
  705. console.log('del_cond_parent_num: ' + del_cond_parent_num)
  706. console.log('del_cond_child_num: ' + del_cond_child_num)
  707. var button_return_id = document.getElementById('cond_add' + del_cond_parent_num + '_' + String(parseInt(del_cond_child_num)-1));
  708. console.log("test: " + 'cond_add' + del_cond_parent_num + '_' + String(parseInt(del_cond_child_num)-1))
  709. console.log("button_return_id: " + button_return_id) // null
  710. if (button_return_id == null) {
  711. var button_return_id = document.getElementById('cond_add' + del_cond_parent_num + '_1');
  712. }
  713. button_return_id.style.display = "inline";
  714. }
  715. // -------------------------------------------------------------------------------------------------------------
  716. function Add(evt) { // 網頁初始按鈕 onclick="Add(add1);
  717. evt.style.display = "none"; // 元素不顯示。將 add1 的 input-button 不顯示
  718. new_condition_i++; // 設定編號用
  719. // var div = document.createElement('div'); // 輸出 <div></div>。此時並不會顯示,
  720. // 需透過 appendChild()、insertBefore() 或 replaceChild() 等方法將新元素加入至指定的位置之後才會顯示。
  721. // var cond_number = String(evt).slice(3, ) // 目前的 condition 條件物件動作 數 (最外層)
  722. // var cond_a = 'cond_a' + cond_number + '_' + new_condition_i; // [條件] 左方 : 制動器感測器
  723. // var cond_b = 'cond_b' + cond_number + '_' + new_condition_i; // [條件] 中間 : > / = / <
  724. // var cond_c = 'cond_c' + cond_number + '_' + new_condition_i; // [條件] 右方 : ON / OFF / 數值
  725. // var cond_d = 'cond_d' + cond_number + '_' + new_condition_i; // 條件] 最左方條件連接 : and / or
  726. // div.id = 'newcondition_' + new_condition_i; // 設定 div 的 id
  727. // div.style.marginTop = "10px"; // 新增的 div 設定 marginTop 屬性值
  728. var html = ''
  729. // 新增的條件
  730. html +=
  731. '<div id="newcondition_' + new_condition_i + '" class="newcondition_css">' +
  732. // 新增的分隔線
  733. // '<hr size="50" width="100%">' +
  734. '<div id="condition' + new_condition_i + '">' +
  735. '<div id="condition' + new_condition_i + '_1">' +
  736. '條件 ' +
  737. '<select id="cond_z' + new_condition_i + '_1">' +
  738. '<option value="if">if</option>' +
  739. '<option value="elif">elif</option>' +
  740. '<option value="else">else</option>' +
  741. '</select> ' +
  742. '<select id="cond_tank' + new_condition_i + '_1">' +
  743. '<option value="D1">乾燥桶 D1</option>' +
  744. '<option value="D2">乾燥桶 D2</option>' +
  745. '<option value="D3">乾燥桶 D3</option>' +
  746. '<option value="D4">乾燥桶 D4</option>' +
  747. '<option value="D5">乾燥桶 D5</option>' +
  748. '<option value="D6">乾燥桶 D6</option>' +
  749. '<option value="D7">乾燥桶 D7</option>' +
  750. '<option value="D8">乾燥桶 D8</option>' +
  751. '<option value="D9">乾燥桶 D9</option>' +
  752. '<option value="D10">乾燥桶 D10</option>' +
  753. '<option value="D11">乾燥桶 D11</option>' +
  754. '<option value="D12">乾燥桶 D12</option>' +
  755. '</select> ' +
  756. '<select id="cond_a' + new_condition_i + '_1">' +
  757. '<option value="">制動器 / 感測器</option>' +
  758. '<optgroup label="制動器狀態">' +
  759. '<option value="input_vacuum_status">入料儲豆槽真空吸料機</option>' +
  760. '<option value="tank_vacuum_status">真空吸料機</option>' +
  761. '<option value="tank_threewayvalve_vacuum_status">吸料機三通閥</option>' +
  762. '<option value="tank_solenoid_disinfect_status">消毒電磁閥</option>' +
  763. '<option value="tank_motor_status">馬達</option>' +
  764. '<option value="outer_solenoid_water_status">桶外進水電磁閥</option>' +
  765. '<option value="tank_solenoid_water_out_status">廢水排水閥</option>' +
  766. '<option value="tank_heater1_status">加熱棒 1</option>' +
  767. '<option value="tank_heater2_status">加熱棒 2</option>' +
  768. '<option value="tank_temp_enable">溫控開關</option>' +
  769. '<option value="tank_temp">溫度設定</option>' +
  770. '<option value="tank_diskvalve_status">蝴蝶閥</option>' +
  771. '<option value="output_vacuum_status">出料儲豆槽真空吸料機</option>' +
  772. '<option value="tank_magneticSwitch_status">電磁開關</option>' +
  773. '<option value="tank_emergencySwitch_status">緊急開關</option>' +
  774. '<option value="tank_camera_status">攝影機</option>' +
  775. '<option value="tank_warningLight_status">警示燈</option>' +
  776. '</optgroup>' +
  777. '<optgroup label="感測器數值">' +
  778. '<option value="tank_ultrasonic_status">超音波感測器</option>' +
  779. '<option value="tank_pa_status">大氣壓力計</option>' +
  780. '<option value="tank_motorencoder_status">馬達編碼器</option>' +
  781. '<option value="tank_sht11_temp_status">溫溼度計_溫度</option>' +
  782. '<option value="tank_sht11_humidity_status">溫溼度計_濕度</option>' +
  783. '<option value="tank_soil_temp_status">三合一土壤感測器_溫度</option>' +
  784. '<option value="tank_soil_humidity_status">三合一土壤感測器_濕度</option>' +
  785. '<option value="tank_soil_ec_status">三合一土壤感測器_EC</option>' +
  786. '<option value="tank_diskvalve_monitor_status">蝴蝶閥狀態顯示器</option>' +
  787. '<option value="outer_waterlevel_status">夾層水位計</option>' +
  788. '</optgroup>' +
  789. '</select> ' +
  790. '<select id="cond_b' + new_condition_i + '_1">' +
  791. // '<option value="equal">==</option>' +
  792. // '<option value="morethan">&gt;=</option>' +
  793. // '<option value="lessthan">&lt;=</option>' +
  794. '<option value="MoreThan">&gt;</option>' +
  795. '<option value="MoreThanEqualTo">&gt;=</option>' +
  796. '<option value="Equal" selected>==</option>' +
  797. '<option value="LessThanEqualTo">&lt;=</option>' +
  798. '<option value="LessThan">&lt;</option>' +
  799. '</select> ' +
  800. '<input list="cond_list_c' + new_condition_i + '_1" id="cond_c' + new_condition_i + '_1">' +
  801. '<datalist id="cond_list_c' + new_condition_i + '_1">' +
  802. '<option value="on">' +
  803. '<option value="off">' +
  804. '<option value="(或請自行輸入數值)">' +
  805. '</datalist> ' +
  806. '<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>' +
  807. '</div></div>';
  808. // 新增的物件動作
  809. html +=
  810. '<div id="action' + new_condition_i + '">' +
  811. '<div id="action' + new_condition_i + '_1">' +
  812. '物件 ' +
  813. '<select id="do_obj' + new_condition_i + '_1" onChange="renew(\''+ new_condition_i + '_1\', this.selectedIndex);">' +
  814. '<option value="">制動器 / 暫停秒數 / 桶槽狀態</option>' +
  815. '<option value="input_vacuum_status">入料儲豆槽真空吸料機</option>' +
  816. '<option value="tank_vacuum_status">真空吸料機</option>' +
  817. '<option value="tank_threewayvalve_vacuum_status">吸料機三通閥</option>' +
  818. '<option value="tank_solenoid_disinfect_status">消毒電磁閥</option>' +
  819. '<option value="tank_motor_status">馬達</option>' +
  820. '<option value="outer_solenoid_water_status">桶外進水電磁閥</option>' +
  821. '<option value="tank_solenoid_water_out_status">廢水排水電磁閥</option>' +
  822. '<option value="tank_heater1_status">加熱棒 1</option>' +
  823. '<option value="tank_heater2_status">加熱棒 2</option>' +
  824. '<option value="tank_temp_enable">溫控開關</option>' +
  825. '<option value="tank_temp">溫度設定</option>' +
  826. '<option value="tank_diskvalve_status">蝴蝶閥</option>' +
  827. '<option value="output_vacuum_status">出料儲豆槽真空吸料機</option>' +
  828. '<option value="tank_magneticSwitch_status">電磁開關</option>' +
  829. '<option value="tank_emergencySwitch_status">緊急開關</option>' +
  830. '<option value="tank_camera_status">攝影機</option>' +
  831. '<option value="tank_warningLight_status">警示燈</option>' +
  832. '<option value="time.sleep">暫停秒數</option>' +
  833. '<option value="dry_container_status">桶槽狀態</option>' +
  834. '</select>' +
  835. '動作 ' +
  836. '<div id="do_action' + new_condition_i + '_1" style="display: inline-block;">' +
  837. '</div>' +
  838. // '<select id="do_act' + new_condition_i + '_1">' +
  839. // '<option value="">請由左方選取物件' +
  840. // '</select> ' +
  841. '<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>' +
  842. '</div>' +
  843. '</div>' +
  844. // 新增的 條件物件動作++ 條件物件動作-- 按鈕
  845. '<input type="button" class="input-delete" id="del' + new_condition_i + '" value="條件物件動作--" onclick="Delete(' + new_condition_i + ');"><br>' +
  846. '<input type="button" class="input-add" id="add' + new_condition_i + '" value="條件物件動作++" onclick="Add(add' + new_condition_i + ');">' +
  847. '</div>' ;
  848. var divbox = document.getElementById('box');
  849. divbox.insertAdjacentHTML('beforeend', html);
  850. };
  851. function Delete(evt) {
  852. var del_condition = document.getElementById('newcondition_' + evt);
  853. del_condition.innerHTML = ""
  854. var parentObj = del_condition.parentNode; // 取得欲刪除 div 的父類別
  855. parentObj.removeChild(del_condition) // 刪除 div
  856. // 上一個按鈕要顯示出來
  857. var button_return_id = document.getElementById('add' + String(parseInt(evt)-1));
  858. if (button_return_id == null) {
  859. var button_return_id = document.getElementById('add1');
  860. }
  861. // console.log('button_return_id: ' + button_return_id)
  862. button_return_id.style.display = "block"; // 元素顯示。顯示前一個 input-button
  863. };
  864. // --------------------------------------------------------------------------------------
  865. var set_Schedule = '';
  866. function test(){
  867. // console.log("new_condition_i: " + new_condition_i) // 總數 : 條件物件動作
  868. // console.log("cond_add_child_i: " + cond_add_child_i) // 總數 : 子 條件
  869. // console.log("act_add_child_i: " + act_add_child_i) // 總數 : 子 物件動作
  870. // set_Schedule += 'set_Schedule = { ';
  871. set_Schedule = '{ ';
  872. var set_key = [];
  873. var set_value = [];
  874. var command_test = '';
  875. var Z = 0;
  876. // 條件物件動作 取值
  877. for (let z = 1; z <= new_condition_i; z++) {
  878. // if-while 取值
  879. try {
  880. var cond_z_value = document.getElementById("cond_z" + z + "_1").value;
  881. // console.log("cond_z" + z + "_1: " + cond_z_value)
  882. Z = Z + 1;
  883. set_Schedule += '"cond_z' + Z + '_1": "' + cond_z_value + '", ' ;
  884. set_key.push('cond_z' + Z + '_1');
  885. set_value.push(cond_z_value);
  886. } catch (error) {
  887. if (error.name == 'TypeError') {
  888. // console.log("cond_z" + z + "_1: null")
  889. // set_Schedule += '"cond_z' + Z + '_1": "", ' ;
  890. } else {
  891. alert("cond_z" + z + "_1: " + error.name)
  892. break
  893. }
  894. }
  895. // 桶槽號碼 取值
  896. try {
  897. var cond_tank_value = document.getElementById("cond_tank" + z + "_1").value;
  898. // console.log("cond_tank" + z + "_1: " + cond_tank_value)
  899. set_Schedule += '"cond_tank' + Z + '_1": "' + cond_tank_value + '", ' ;
  900. set_key.push('cond_tank' + Z + '_1');
  901. set_value.push(cond_tank_value);
  902. } catch (error) {
  903. if (error.name == 'TypeError') {
  904. // console.log("cond_tank" + z + "_1: null")
  905. // set_Schedule += '"cond_tank' + Z + '_1": "", ' ;
  906. } else {
  907. alert("cond_tank" + z + "_1: " + error.name)
  908. break
  909. }
  910. }
  911. // 子 條件 取值
  912. var X = 1;
  913. for (let x = 1; x <= cond_add_child_i; x++) {
  914. // 子條件取值 : 條件連接 and or
  915. if (x > 1) {
  916. try {
  917. var cond_d_value = document.getElementById("cond_d" + z + "_" + x).value;
  918. // console.log("cond_d" + z + "_" + x + ": " + cond_d_value)
  919. X = X + 1;
  920. set_Schedule += '"cond_d' + Z + '_' + X + '": "' + cond_d_value + '", ' ;
  921. set_key.push('cond_d' + Z + '_' + X);
  922. set_value.push(cond_d_value);
  923. } catch (error) {
  924. if (error.name == 'TypeError') {
  925. // console.log("cond_d" + z + "_" + x + ": null")
  926. // set_Schedule += '"cond_d' + Z + '_' + x + '": "", ' ;
  927. } else {
  928. alert("cond_d" + z + "_" + x + ": " + error.name)
  929. break
  930. }
  931. }
  932. }
  933. try {
  934. var cond_a_value = document.getElementById("cond_a" + z + "_" + x).value;
  935. // console.log("cond_a" + z + "_" + x + ": " + cond_a_value)
  936. set_Schedule += '"cond_a' + Z + '_' + X + '": "' + cond_a_value + '", ' ;
  937. set_key.push('cond_a' + Z + '_' + X);
  938. set_value.push(cond_a_value);
  939. if (cond_a_value == '') {
  940. alert('條件欄位輸入有誤, 請再次確認')
  941. break
  942. }
  943. } catch (error) {
  944. if (error.name == 'TypeError') {
  945. // console.log("cond_a" + z + "_" + x + ": null")
  946. // set_Schedule += '"cond_a' + z + '_' + x + '": "", ' ;
  947. } else {
  948. alert("cond_a" + z + "_" + x + ": " + error.name)
  949. break
  950. }
  951. }
  952. // 子條件取值 : 條件中 > = <
  953. try {
  954. var cond_b_value = document.getElementById("cond_b" + z + "_" + x).value;
  955. // console.log("cond_b" + z + "_" + x + ": " + cond_b_value)
  956. set_Schedule += '"cond_b' + Z + '_' + X + '": "' + cond_b_value + '", ' ;
  957. set_key.push('cond_b' + Z + '_' + X);
  958. set_value.push(cond_b_value);
  959. if (cond_b_value == '') {
  960. alert('條件欄位輸入有誤, 請再次確認')
  961. break
  962. }
  963. } catch (error) {
  964. if (error.name == 'TypeError') {
  965. // console.log("cond_b" + z + "_" + x + ": null")
  966. // set_Schedule += '"cond_b' + z + '_' + x + '": "", ' ;
  967. } else {
  968. alert("cond_b" + z + "_" + x + ": " + error.name)
  969. break
  970. }
  971. }
  972. // 子條件取值 : 條件右 ON / OFF / 輸入數值
  973. try {
  974. var cond_c_value = document.getElementById("cond_c" + z + "_" + x).value;
  975. // console.log("cond_c" + z + "_" + x + ": " + cond_c_value)
  976. set_Schedule += '"cond_c' + Z + '_' + X + '": "' + cond_c_value + '", ' ;
  977. set_key.push('cond_c' + Z + '_' + X);
  978. set_value.push(cond_c_value);
  979. if (cond_c_value == '') {
  980. alert('條件欄位輸入有誤, 請再次確認')
  981. break
  982. }
  983. } catch (error) {
  984. if (error.name == 'TypeError') {
  985. // console.log("cond_c" + z + "_" + x + ": null")
  986. // set_Schedule += '"cond_c' + z + '_' + x + '": "", ' ;
  987. } else {
  988. alert("cond_c" + z + "_" + x + ": " + error.name)
  989. break
  990. }
  991. }
  992. }
  993. // 子 物件動作 取值
  994. var Y = 0;
  995. for (let y = 1; y <= act_add_child_i; y++) {
  996. // 子物件動作取值 : 物件 do_obj1_1
  997. try {
  998. var do_obj_value = document.getElementById("do_obj" + z + "_" + y).value;
  999. if (do_obj_value == '') {
  1000. alert('物件欄位輸入有誤, 請再次確認')
  1001. break
  1002. }
  1003. // console.log("do_obj" + z + "_" + y + ": " + do_obj_value)
  1004. Y = Y + 1;
  1005. set_Schedule += '"do_obj' + Z + '_' + Y + '": "' + do_obj_value + '", ' ;
  1006. // command_test += '{"tank_num": "' + cond_tank_value + '", "command": "' + do_obj_value + '", "value":"';
  1007. set_key.push('do_obj' + Z + '_' + Y);
  1008. set_value.push(do_obj_value);
  1009. } catch (error) {
  1010. if (error.name == 'TypeError') {
  1011. // console.log("do_obj" + z + "_" + y + ": null")
  1012. // set_Schedule += '"do_obj' + z + '_' + y + '": "", ' ;
  1013. } else {
  1014. alert("do_obj" + z + "_" + y + ": " + error.name)
  1015. break
  1016. }
  1017. }
  1018. // 子物件動作取值 : 動作 do_act1_1
  1019. try {
  1020. var do_act_value = document.getElementById("do_act" + z + "_" + y).value;
  1021. if (do_act_value == '') {
  1022. alert('動作欄位輸入有誤, 請再次確認')
  1023. break
  1024. }
  1025. // console.log("do_act" + z + "_" + y + ": " + do_act_value)
  1026. set_Schedule += '"do_act' + Z + '_' + Y + '": "' + do_act_value + '", ' ;
  1027. // command_test += do_act_value + '" }';
  1028. set_key.push('do_act' + Z + '_' + Y);
  1029. set_value.push(do_act_value);
  1030. } catch (error) {
  1031. if (error.name == 'TypeError') {
  1032. // console.log("do_obj" + z + "_" + y + ": null")
  1033. // set_Schedule += '"do_act' + z + '_' + y + '": "", ' ;
  1034. } else {
  1035. alert("do_act" + z + "_" + y + ": " + error.name)
  1036. break
  1037. }
  1038. }
  1039. }
  1040. }
  1041. // 整理資料用
  1042. set_Schedule += '"": ""}' ;
  1043. // console.log('set_Schedule: ' + set_Schedule)
  1044. $('#value_test').text('set_Schedule: ' + set_Schedule)
  1045. // $('#command_test').text('command_test: ' + command_test)
  1046. // var SQL_insert = 'INSERT INTO `dry_block_waiting_setting`(' +
  1047. // '`datetime`, ' +
  1048. // '`cond_z1_1`, `cond_tank1_1`, `cond_a1_1`, `cond_b1_1`, `cond_c1_1`, ' +
  1049. // '`cond_d1_2`, `cond_a1_2`, `cond_b1_2`, `cond_c1_2`, ' +
  1050. // '`do_obj1_1`, `do_act1_1`, ' +
  1051. // '`do_obj1_2`, `do_act1_2`' +
  1052. // ') VALUES (' +
  1053. // 'current_timestamp(),' +
  1054. // '"A","A","A","A","A",' +
  1055. // '"A","A","A","A",' +
  1056. // '"A","A",' +
  1057. // '"A","A")'
  1058. var SQL_insert = 'INSERT INTO `dry_block_waiting` (' +
  1059. '`datetime`, `' + set_key.join("`, `") + '`) VALUES (' +
  1060. 'current_timestamp(), "' + set_value.join('", "') + '")';
  1061. var sql_data = { "sql":SQL_insert };
  1062. console.log("sql_data: ", sql_data)
  1063. // $.get('/sql_get', sql_data, function (res) {
  1064. // alert("OK")
  1065. // }, 'json');
  1066. }
  1067. function AJAXtest(params) {
  1068. test();
  1069. var schedule_data = {
  1070. "condition":new_condition_i,
  1071. "cond_add_child":cond_add_child_i,
  1072. "act_add_child":act_add_child_i,
  1073. "set_Schedule":set_Schedule
  1074. };
  1075. $.get('/dry_block_set', schedule_data, function (res) {
  1076. // console.log("res.condition: " + res.condition)
  1077. // console.log("res.cond_add_child: " + res.cond_add_child)
  1078. // console.log("res.act_add_child: " + res.act_add_child)
  1079. console.log("res.response: " + res.response)
  1080. }, 'json');
  1081. }
  1082. </script>
  1083. <div id="coffee_footer">
  1084. <!-- 匯入共同使用的 footer.html 內容 -->
  1085. {% include 'footer.html' %}
  1086. </div>
  1087. </div>
  1088. <script>
  1089. function showMotorValue(obj_num, value){
  1090. // document.getElementById("do_act1_1").innerHTML = value;
  1091. // console.log("newVal: " + newVal)
  1092. document.getElementById("motorValue_text" + obj_num).innerText = value;
  1093. }
  1094. function showTempValue(obj_num, value) {
  1095. document.getElementById("tempValue_text" + obj_num).innerText = value;
  1096. }
  1097. function showSleepValue(obj_num, value) {
  1098. document.getElementById("sleepValue_text" + obj_num).innerText = value + 's';
  1099. }
  1100. </script>
  1101. </body>
  1102. </html>