board_loader-1.html 147 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550
  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. // TODO 要考慮 初始生成幾個後, 在定義 new_condition_i = (現有的)+1, new_condition_i 是生成總條件的總條件數
  17. var new_condition_i // 總條件數
  18. var cond_add_child_i // 子條件數
  19. var act_add_child_i // 子物件數
  20. // 乾燥桶槽 積木條件狀態
  21. const COND1 = {{BCD.cond|tojson}};
  22. // console.log("COND1: " + COND1);
  23. const pin_data_relay = ['', '{{pin_data.R1}}','{{pin_data.R2}}','{{pin_data.R3}}','{{pin_data.R4}}',
  24. '{{pin_data.R5}}','{{pin_data.R6}}','{{pin_data.R7}}','{{pin_data.R8}}','{{pin_data.R9}}',
  25. '{{pin_data.R10}}','{{pin_data.R11}}','{{pin_data.R12}}','{{pin_data.R13}}','{{pin_data.R14}}',
  26. '{{pin_data.R15}}','{{pin_data.R16}}','{{pin_data.R17}}','{{pin_data.R18}}','{{pin_data.R19}}','{{pin_data.R20}}'
  27. ]
  28. const pin_data_sensor = ['', '{{pin_data.M1}}','{{pin_data.M2}}','{{pin_data.M3}}','{{pin_data.M4}}',
  29. '{{pin_data.M5}}','{{pin_data.M6}}','{{pin_data.M7}}','{{pin_data.M8}}','{{pin_data.M9}}',
  30. '{{pin_data.M10}}','{{pin_data.M11}}','{{pin_data.M12}}','{{pin_data.M13}}','{{pin_data.M14}}',
  31. '{{pin_data.M15}}','{{pin_data.M16}}','{{pin_data.M17}}','{{pin_data.M18}}','{{pin_data.M19}}'
  32. ]
  33. const pin_data_sensorHz = ['', '{{pin_data.M1_Hz}}','{{pin_data.M2_Hz}}','{{pin_data.M3_Hz}}','{{pin_data.M4_Hz}}',
  34. '{{pin_data.M5_Hz}}','{{pin_data.M6_Hz}}','{{pin_data.M7_Hz}}','{{pin_data.M8_Hz}}','{{pin_data.M9_Hz}}',
  35. '{{pin_data.M10_Hz}}','{{pin_data.M11_Hz}}','{{pin_data.M12_Hz}}','{{pin_data.M13_Hz}}','{{pin_data.M14_Hz}}',
  36. '{{pin_data.M15_Hz}}','{{pin_data.M16_Hz}}','{{pin_data.M17_Hz}}','{{pin_data.M18_Hz}}','{{pin_data.M19_Hz}}'
  37. ]
  38. console.log("pin_data_sensorHz: " + pin_data_sensorHz)
  39. const Tank_ID = '{{TankID}}';
  40. const TANK_IMPORT = '{{tank_import}}';
  41. const TANK_EXPORT = '{{tank_export}}';
  42. var pin_data_sensor_option = ''; // 腳位配置-sensor 匯出整理成 下拉式選單的選項
  43. var pin_data_relay_option = ''; // 腳位配置-relay 匯出整理成 下拉式選單的選項
  44. var set_Hz_sensor = '';
  45. $(function(){
  46. // 網頁 title
  47. $("#coffee_title_pc").text("板子燒錄程式");
  48. $("#coffee_title_phone").text("板子燒錄程式");
  49. // 使用者權限判斷
  50. // $('.select-input').prop('disabled', false);
  51. const pin_data_ethernet = '{{pin_data.ethernet}}';
  52. if (pin_data_ethernet == 'ON') {
  53. $("#select_ethernet_1").val('ON');
  54. }
  55. const pin_data_wifi = '{{pin_data.wifi}}';
  56. if (pin_data_wifi == 'ON') {
  57. $("#select_wifi_1").val('ON');
  58. }
  59. const pin_data_zigbee = '{{pin_data.zigbee}}';
  60. if (pin_data_zigbee == 'ON') {
  61. $("#select_zigbee_1").val('ON');
  62. }
  63. // tid 燒錄桶槽初始判斷
  64. // console.log("Tank_ID: " + Tank_ID);
  65. if (Tank_ID.substring(0,1) === 'D') {
  66. $("#prog_container").val('DryContainer');
  67. renew_tank();
  68. $("#prog_tank").val(Tank_ID);
  69. } else if (Tank_ID.substring(0,1) === 'F') {
  70. $("#prog_container").val('FermentContainer');
  71. renew_tank();
  72. $("#prog_tank").val(Tank_ID);
  73. } else if (Tank_ID.substring(0,1) === 'C') {
  74. $("#prog_container").val('CleanContainer');
  75. renew_tank();
  76. $("#prog_tank").val(Tank_ID);
  77. } else {
  78. $("#prog_container").val('');
  79. $("#prog_tank").val('');
  80. }
  81. // 0531 0526 tttest start
  82. // 腳位配置-relay 匯出整理成 下拉式選單的選項
  83. pin_data_relay_option = '<option value=""></option>';
  84. for (let s_o = 0; s_o < pin_data_sensor.length; s_o++) {
  85. // console.log("pin_data_sensor[" + s_o + "]: " + pin_data_sensor[s_o]);
  86. if (pin_data_sensor[s_o] === 'Motor' || pin_data_sensor[s_o] === 'Servo') {
  87. pin_data_relay_option += '<option value="M' + s_o + '_' + pin_data_sensor[s_o] + '">M' + s_o + '_' + pin_data_sensor[s_o] + '</option>';
  88. }
  89. }
  90. for (let r_o = 1; r_o < pin_data_relay.length; r_o++) {
  91. if (pin_data_relay[r_o] !== '') {
  92. pin_data_relay_option += '<option value="R' + r_o + '_' + pin_data_relay[r_o] + '">R' + r_o + '_' + pin_data_relay[r_o] + '</option>';
  93. }
  94. }
  95. pin_data_relay_option += '<option value="sleep">sleep</option>' +
  96. '<option value="tankstatus">tankstatus</option>';
  97. // 腳位配置-sensor 匯出整理成 下拉式選單的選項
  98. // 感測器取值頻率 匯出整理成 輸入 range
  99. pin_data_sensor_option = '<option value=""></option>';
  100. for (let s_o = 0; s_o < pin_data_sensor.length; s_o++) {
  101. if (pin_data_sensor[s_o] !== '' && pin_data_sensor[s_o] !== 'Motor' && pin_data_sensor[s_o] !== 'Servo') {
  102. pin_data_sensor_option += '<option value="M' + s_o + '_' + pin_data_sensor[s_o] + '">M' + s_o + '_' + pin_data_sensor[s_o] + '</option>';
  103. set_Hz_sensor += 'M' + s_o + '_' + pin_data_sensor[s_o] + ' 取值頻率 ' +
  104. '<input type="range" style="cursor: pointer;" id="M' + s_o + '_Hz" min="0" max="60" step="5" value="10" oninput="showSensorHzValue(\'M' + s_o + '\', this.value)" onchange="showSensorHzValue(\'M' + s_o + '\', this.value)">' +
  105. '<span id="M' + s_o + '_HzText">10 秒/次</span>' +
  106. '<br>';
  107. }
  108. }
  109. var SensorHz_div = document.getElementById("SensorHz");
  110. SensorHz_div.insertAdjacentHTML('beforeend', set_Hz_sensor);
  111. // 腳位配置-relay 匯出整理成 下拉式選單的選項
  112. for (let p_r = 1; p_r <= pin_data_relay.length; p_r++) {
  113. if (pin_data_relay[p_r] != '') {
  114. $("#select_relay_" + p_r).val(pin_data_relay[p_r]);
  115. }
  116. }
  117. // 腳位配置-sensor 匯出整理成 下拉式選單的選項
  118. for (let p_m = 1; p_m <= pin_data_sensor.length; p_m++) {
  119. if (pin_data_sensor[p_m] != '') {
  120. $("#selectSensor_M" + p_m).val(pin_data_sensor[p_m]);
  121. }
  122. }
  123. // 板子圖片顯示對應 relay、sensor
  124. for (let RelayNum = 1; RelayNum < 21; RelayNum++) {
  125. select_relay(RelayNum);
  126. }
  127. for (let SensorNum = 1; SensorNum < 20; SensorNum++) {
  128. selectSensor("M" + SensorNum);
  129. }
  130. // 感測器取值頻率
  131. // pin_data_sensorHz.length
  132. for (let SensorHzNum = 1; SensorHzNum < pin_data_sensorHz.length; SensorHzNum++) {
  133. try {
  134. var target_Hz_range = $("#M" + SensorHzNum + "_Hz");
  135. if (pin_data_sensorHz[SensorHzNum] !== '' && pin_data_sensorHz[SensorHzNum] !== 'None') {
  136. $("#M" + SensorHzNum + "_Hz").val(pin_data_sensorHz[SensorHzNum]);
  137. eval('showSensorHzValue("M" + SensorHzNum, pin_data_sensorHz[SensorHzNum])');
  138. }
  139. } catch (error) {
  140. // console.log("M" + SensorHzNum + "_Hz:" + error)
  141. }
  142. // var target_Hz_range = $("#M" + SensorHzNum + "_Hz");
  143. // // $("#M" + SensorHzNum + "_Hz").val(pin_data_sensorHz[SensorHzNum]);
  144. // console.log("target_Hz_range: " + target_Hz_range);
  145. // if (target_Hz_range) {
  146. // $("#M" + SensorHzNum + "_Hz").val(pin_data_sensorHz[SensorHzNum]);
  147. // } else {
  148. // }
  149. }
  150. // // if 條件數量計算
  151. // var z_notempty_num = 0;
  152. // var a_notempty_num = 0;
  153. // var o_notempty_num = 0;
  154. // var a_n_n = 0;
  155. // var o_n_n = 0;
  156. // for (let z = 1; z < cond_z_data.length; z++) {
  157. // // if
  158. // if (cond_z_data[z] !== '' && cond_z_data[z] !== 'None' && cond_z_data[z] !== undefined) {
  159. // // console.log("cond_z_data[" + z + "]: " + cond_z_data[z]);
  160. // z_notempty_num += 1;
  161. // }
  162. // console.log("ALL z_notempty_num: " + z_notempty_num);
  163. // // (sensor)
  164. // a_n_n = 0;
  165. // for (let a = 1; a < cond_a_data[z].length; a++) {
  166. // // console.log("cond_a_data[" + z + "][" + a + "]: " + cond_a_data[z][a]);
  167. // if (cond_a_data[z][a] !== '' && cond_a_data[z][a] !== 'None' && cond_d_data[z][a] !== undefined) {
  168. // a_n_n += 1;
  169. // }
  170. // // console.log("a_notempty_num: " + a_notempty_num);
  171. // }
  172. // if (a_n_n > a_notempty_num) {
  173. // a_notempty_num = a_n_n;
  174. // }
  175. // console.log("ALL a_notempty_num: " + a_notempty_num);
  176. // // (obj)
  177. // o_n_n = 0;
  178. // for (let o = 1; o < cond_obj_data[z].length; o++) {
  179. // // console.log("cond_obj_data[" + z + "][" + o + "]: " + cond_obj_data[z][o]);
  180. // if (cond_obj_data[z][o] !== '' && cond_obj_data[z][o] !== 'None' && cond_obj_data[z][o] !== undefined) {
  181. // o_n_n += 1;
  182. // }
  183. // // console.log("o_notempty_num: " + o_notempty_num);
  184. // }
  185. // if (o_n_n > o_notempty_num) {
  186. // o_notempty_num = o_n_n;
  187. // }
  188. // console.log("ALL o_notempty_num: " + o_notempty_num);
  189. // }
  190. // // 生成空白積木 總條件 1 - 子條件 5 - 子物件 5
  191. // DBvalue_btn(z_notempty_num, a_notempty_num, o_notempty_num);
  192. // // ItemGetValue();
  193. // // 積木賦值
  194. // for (let z_d = 1; z_d < cond_z_data.length; z_d++) {
  195. // $("#cond_z" + z_d + "_1").val(cond_z_data[z_d]);
  196. // }
  197. // // for (let tank_d = 1; tank_d < cond_tank_data.length; tank_d++) {
  198. // // $("#cond_tank" + tank_d + "_1").val(cond_tank_data[tank_d]);
  199. // // }
  200. // for (let a_d = 1; a_d <= z_notempty_num; a_d++) {
  201. // for (let a_d_n = 1; a_d_n <= a_notempty_num; a_d_n++) {
  202. // console.log("#cond_a" + a_d + "_" + a_d_n + "---" + cond_a_data[a_d][a_d_n]);
  203. // $("#cond_a" + a_d + "_" + a_d_n).val(cond_a_data[a_d][a_d_n]);
  204. // }
  205. // }
  206. // for (let b_d = 1; b_d <= z_notempty_num; b_d++) {
  207. // for (let b_d_n = 1; b_d_n <= a_notempty_num; b_d_n++) {
  208. // // console.log("#cond_b" + b_d + "_" + b_d_n + "-----" + cond_b_data[b_d][b_d_n])
  209. // $("#cond_b" + b_d + "_" + b_d_n).val(cond_b_data[b_d][b_d_n]);
  210. // }
  211. // }
  212. // for (let c_d = 1; c_d <= z_notempty_num; c_d++) {
  213. // for (let c_d_n = 1; c_d_n <= a_notempty_num; c_d_n++) {
  214. // if (cond_c_data[c_d][c_d_n] !== 'None') {
  215. // $("#cond_c" + c_d + "_" + c_d_n).val(cond_c_data[c_d][c_d_n]);
  216. // }
  217. // }
  218. // }
  219. // for (let d_d = 1; d_d <= z_notempty_num; d_d++) {
  220. // for (let d_d_n = 2; d_d_n <= a_notempty_num; d_d_n++) {
  221. // $("#cond_d" + d_d + "_" + d_d_n).val(cond_d_data[d_d][d_d_n]);
  222. // // console.log("cond_d_data[" + d_d + "][" + d_d_n +"]: " + cond_d_data[d_d][d_d_n])
  223. // // if (cond_d_data[d_d][d_d_n] !== "None" && cond_d_data[d_d][d_d_n] !== "") { }
  224. // }
  225. // }
  226. // for (let obj_d = 1; obj_d <= z_notempty_num; obj_d++) {
  227. // for (let obj_d_n = 1; obj_d_n <= o_notempty_num; obj_d_n++) {
  228. // $("#do_obj" + obj_d + "_" + obj_d_n).val(cond_obj_data[obj_d][obj_d_n]);
  229. // // 設定物件後, 取得物件目前所選項目, 再呼叫 renew 顯示對應動作下拉式選單
  230. // const target_obj_index = $("#do_obj" + obj_d + "_" + obj_d_n).prop('selectedIndex')
  231. // // console.log("target_obj_index: " + target_obj_index)
  232. // renew(obj_d + '_' + obj_d_n, target_obj_index);
  233. // }
  234. // }
  235. // for (let act_d = 1; act_d <= z_notempty_num; act_d++) {
  236. // for (let act_d_n = 1; act_d_n <= o_notempty_num; act_d_n++) {
  237. // $("#do_act" + act_d + "_" + act_d_n).val(cond_act_data[act_d][act_d_n]);
  238. // // 若是 input range 要更新顯示文字
  239. // if ($("#do_obj" + act_d + "_" + act_d_n).val() === 'motor') {
  240. // let target_act_motorValue = $("#do_act" + act_d + "_" + act_d_n).prop('value')
  241. // showMotorValue(act_d + "_" + act_d_n, target_act_motorValue);
  242. // } else if ($("#do_obj" + act_d + "_" + act_d_n).val() === 'temp') {
  243. // let target_act_tempValue = $("#do_act" + act_d + "_" + act_d_n).prop('value')
  244. // showTempValue(act_d + "_" + act_d_n, target_act_tempValue);
  245. // } else if ($("#do_obj" + act_d + "_" + act_d_n).val() === 'sleep') {
  246. // let target_act_sleepValue = $("#do_act" + act_d + "_" + act_d_n).prop('value')
  247. // showSleepValue(act_d + "_" + act_d_n, target_act_sleepValue);
  248. // }
  249. // }
  250. // }
  251. try {
  252. var cond = JSON.parse(COND1); // cond: [object Object]
  253. // var cond = JSON.parse(COND1); // cond: [object Object]
  254. var cond_cond = cond.cond; // cond_cond: [object Object],[object Object]
  255. // console.log("cond_cond: " + cond_cond);
  256. // 取得總條件數、子條件數、子物件數最大值
  257. const COND_NUMS = cond_cond.length; // 總條件數
  258. // alert("COND_NUMS: " + COND_NUMS);
  259. var COND_ADD_NUMS_LIST = [];
  260. var COND_COM_NUMS_LIST = [];
  261. for (let Z = 0; Z < cond_cond.length; Z++) {
  262. COND_ADD_NUMS_LIST.push(cond_cond[Z].cond_add.length)
  263. COND_COM_NUMS_LIST.push(cond_cond[Z].cond_com.length)
  264. }
  265. // console.log("COND_ADD_NUMS_LIST: " + COND_ADD_NUMS_LIST);
  266. // console.log("COND_COM_NUMS_LIST: " + COND_COM_NUMS_LIST);
  267. const COND_ADD_NUMS = Math.max(...COND_ADD_NUMS_LIST)+1; // 子條件數
  268. const COND_COM_NUMS = Math.max(...COND_COM_NUMS_LIST); // 子物件數
  269. // console.log("COND_ADD_NUMS: " + COND_ADD_NUMS);
  270. // console.log("COND_COM_NUMS: " + COND_COM_NUMS);
  271. // 生成積木
  272. DBvalue_btn(COND_NUMS, COND_ADD_NUMS, COND_COM_NUMS);
  273. // 賦值
  274. for (let c_n = 0; c_n < cond_cond.length; c_n++) {
  275. // console.log("cond_cond[" + c_n + "]: " + cond_cond[c_n] + "_" + typeof(cond_cond[c_n]))
  276. if (typeof(cond_cond[c_n]) === 'object') {
  277. // main
  278. // console.log("cond_main: " + cond_cond[c_n].cond_main);
  279. var target_main = cond_cond[c_n].cond_main.split(' ');
  280. if (target_main[0] === 'else' && target_main[1] === 'if') {
  281. target_main[0] = target_main[0] + " " + target_main[1];
  282. target_main[1] = target_main[2];
  283. target_main[2] = target_main[3];
  284. target_main[3] = target_main[4];
  285. }
  286. $("#cond_z" + (c_n+1) + "_1").val(target_main[0]);
  287. $("#cond_a" + (c_n+1) + "_1").val(target_main[1]);
  288. $("#cond_b" + (c_n+1) + "_1").val(target_main[2]);
  289. $("#cond_c" + (c_n+1) + "_1").val(target_main[3]);
  290. // add
  291. // console.log("cond_add: " + cond_cond[c_n].cond_add + "_" + typeof(cond_cond[c_n].cond_add));
  292. if (typeof(cond_cond[c_n].cond_add) === 'object') {
  293. for (let add_n = 0; add_n < cond_cond[c_n].cond_add.length; add_n++) {
  294. // console.log("cond_cond[" + c_n + "].cond_add[" + add_n + "]: " + cond_cond[c_n].cond_add[add_n])
  295. var target_add = cond_cond[c_n].cond_add[add_n].split(' ');
  296. $("#cond_d" + (c_n+1) + "_" + (add_n+2) + "").val(target_add[0]);
  297. $("#cond_a" + (c_n+1) + "_" + (add_n+2) + "").val(target_add[1]);
  298. $("#cond_b" + (c_n+1) + "_" + (add_n+2) + "").val(target_add[2]);
  299. $("#cond_c" + (c_n+1) + "_" + (add_n+2) + "").val(target_add[3]);
  300. }
  301. }
  302. // com
  303. // console.log("cond_com: " + cond_cond[c_n].cond_com + "_" + typeof(cond_cond[c_n].cond_com));
  304. if (typeof(cond_cond[c_n].cond_com) === 'object') {
  305. for (let obj_n = 0; obj_n < cond_cond[c_n].cond_com.length; obj_n++) {
  306. // console.log("cond_cond[" + c_n + "].cond_com[" + obj_n + "]: " + cond_cond[c_n].cond_com[obj_n]) // R1_vacuum on
  307. var target_obj = cond_cond[c_n].cond_com[obj_n].split(' ');
  308. // console.log("target_obj: " + target_obj); // R1_vacuum,on
  309. // console.log(pin_data_relay_option.includes(target_obj[0]))
  310. if (pin_data_relay_option.includes(target_obj[0]) ) {
  311. // 物件動作包含此積木程式的物件
  312. $("#do_obj" + (c_n+1) + "_" + (obj_n+1) + "").val(target_obj[0]);
  313. // console.log('renew((' + (c_n+1) + ') + "_" + (' + (obj_n+1) + '))')
  314. eval('renew((c_n+1) + "_" + (obj_n+1))');
  315. $("#do_act" + (c_n+1) + "_" + (obj_n+1) + "").val(target_obj[1]);
  316. // console.log("target_obj[0]: " + target_obj[0]);
  317. if (target_obj[0] === 'sleep') {
  318. showSleepValue((c_n+1) + "_" + (obj_n+1), target_obj[1]);
  319. } else if (target_obj[0].includes("Motor")) {
  320. showMotorValue((c_n+1) + "_" + (obj_n+1), target_obj[1]);
  321. }
  322. }
  323. }
  324. }
  325. }
  326. }
  327. new_condition_i = COND_NUMS; // 總條件數
  328. cond_add_child_i = COND_ADD_NUMS; // 子條件數
  329. act_add_child_i = COND_COM_NUMS; // 子物件數
  330. } catch (error) {
  331. console.log("cond = JSON.parse(COND1) → catch error")
  332. DBvalue_btn(1, 2, 1);
  333. new_condition_i = 1; // 總條件數
  334. cond_add_child_i = 2; // 子條件數
  335. act_add_child_i = 1; // 子物件數
  336. }
  337. // console.log("new_condition_i: " + new_condition_i + "__type: " + typeof(new_condition_i))
  338. // console.log("cond_add_child_i: " + cond_add_child_i);
  339. // console.log("act_add_child_i: " + act_add_child_i);
  340. });
  341. var Z;
  342. var X;
  343. var Y;
  344. var TT = {}; // 將總條件句/附加條件句/物件動作句存入 字典, 後續傳給 dry_block_format 再組合
  345. </script>
  346. <style>
  347. /* .boardpic_position {
  348. position: absolute;
  349. top: 80px;
  350. left: 25px;
  351. } */
  352. .r5_position {
  353. position: absolute;
  354. top: 160px;
  355. left: 310px;
  356. width: 40px;
  357. height: 150px;
  358. border-style: solid;
  359. border-color: aqua;
  360. }
  361. .div_relay_css {
  362. position: absolute;
  363. border-style: solid;
  364. border-color: aqua;
  365. text-align: center;
  366. font-size: 12px;
  367. }
  368. /* header */
  369. /* 文字輸入框 */
  370. .input-text {
  371. height: 25px;
  372. width: 40px;
  373. text-align: center;
  374. margin-left: 2px;
  375. margin-right: 5px;
  376. }
  377. /* 致動器狀態表格置中 */
  378. .label_ActuatorStatus {
  379. margin: auto;
  380. }
  381. /* 致動器 ON 樣式 */
  382. .input-button-on {
  383. color: #008CBA;
  384. border: 2px rgb(182, 181, 181) solid;
  385. background-color: whitesmoke;
  386. padding: 1px 3px;
  387. width: 45px;
  388. }
  389. /* 致動器 OFF 樣式 */
  390. .input-button-off {
  391. color: #707070;
  392. border: 2px rgb(192, 192, 192) solid;
  393. background-color: whitesmoke;
  394. padding: 1px 3px;
  395. width: 45px;
  396. }
  397. /* 輸入按鈕 */
  398. .input-button {
  399. font-size: 14px;
  400. color: #008CBA;
  401. border: 2px rgb(182, 181, 181) solid;
  402. background-color: whitesmoke;
  403. padding: 1px 3px;
  404. }
  405. /* 大表格樣式 */
  406. .table-all {
  407. font-size:18px;
  408. border:2px #cccccc solid;
  409. margin-left: 10px;
  410. margin-right: 10px;
  411. width: 98%;
  412. }
  413. /* footer */
  414. .footer{
  415. height: 40px;
  416. box-sizing: border-box;
  417. /* 設定footer絕對位置在底部 */
  418. position: absolute;
  419. bottom: 0px;
  420. width: 100%;
  421. background-color: #eee;
  422. text-align: center;
  423. }
  424. html, body {
  425. height: 100%;
  426. /* margin: 0; */
  427. position: relative;
  428. }
  429. #wrapper {
  430. /* 設定高度最小為100%, 如果內容區塊很多, 可以長大 */
  431. /* min-height: 100%; */
  432. /* 位置設為relative, 作為footer區塊位置的參考 */
  433. position: relative;
  434. }
  435. </style>
  436. </head>
  437. <body style="font-size: 18px;">
  438. <div id="wrapper" style="height: 3000px;">
  439. <div id="coffee_header">
  440. <!-- 匯入共同使用的 header.html 內容 -->
  441. {% include 'header.html' %}
  442. </div>
  443. <table style="position: absolute; top: 75px; left: 25px; width: max-content;">
  444. <!-- 選擇燒錄桶槽 -->
  445. <tr>
  446. <td colspan="5">
  447. <script>
  448. // 貨櫃-桶槽對應
  449. const containerTOtank = {
  450. 'CleanContainer':[{'CCI1':'清洗貨櫃內'},
  451. {'CCO1':'清洗貨櫃外'},
  452. {'C1':'清洗槽 1'}, {'C2':'清洗槽 2'}, {'C3':'清洗槽 3'}, {'C4':'清洗槽 4'},
  453. {'R1':'中水桶 1'},
  454. {'S1':'色選機 1'}, {'S2':'色選機 2'},
  455. {'SO1':'色選機出料 1'}, {'SO2':'色選機出料 2'},
  456. {'P1':'脫皮機 1'}, {'P2':'脫皮機 2'},
  457. {'PO1':'脫皮機出料 1'}, {'PO2':'脫皮機出料 2'}
  458. ],
  459. 'FermentContainer':[{'FCI1':'發酵貨櫃內'},
  460. {'FCO1':'發酵貨櫃外'},
  461. {'FI1':'發酵槽入料 1'}, {'FI2':'發酵槽入料 2'},
  462. {'F1':'發酵槽 1'}, {'F2':'發酵槽 2'}, {'F3':'發酵槽 3'}, {'F4':'發酵槽 4'}, {'F5':'發酵槽 5'}, {'F6':'發酵槽 6'},
  463. {'F7':'發酵槽 7'}, {'F8':'發酵槽 8'}, {'F9':'發酵槽 9'}, {'F10':'發酵槽 10'}, {'F11':'發酵槽 11'}, {'F12':'發酵槽 12'},
  464. {'FO1':'發酵槽出料 1'}, {'FO2':'發酵槽出料 2'}
  465. ],
  466. 'DryContainer':[{'DCI1':'乾燥貨櫃內'},
  467. {'DCO1':'乾燥貨櫃外'},
  468. {'DI1':'乾燥槽入料 1'}, {'DI2':'乾燥槽入料 2'},
  469. {'D1':'乾燥槽 1'}, {'D2':'乾燥槽 2'}, {'D3':'乾燥槽 3'}, {'D4':'乾燥槽 4'}, {'D5':'乾燥槽 5'}, {'D6':'乾燥槽 6'},
  470. {'D7':'乾燥槽 7'}, {'D8':'乾燥槽 8'}, {'D9':'乾燥槽 9'}, {'D10':'乾燥槽 10'}, {'D11':'乾燥槽 11'}, {'D12':'乾燥槽 12'},
  471. {'DO1':'乾燥槽出料 1'}, {'DO2':'乾燥槽出料 2'}
  472. ]
  473. }
  474. </script>
  475. <u>欲燒錄之桶槽 : </u>
  476. <select id="prog_container" onchange="renew_tank()" class="select-input">
  477. <option value=""></option>
  478. <option value="CleanContainer">清洗槽</option>
  479. <option value="FermentContainer">發酵槽</option>
  480. <option value="DryContainer">乾燥槽</option>
  481. </select>
  482. <select id="prog_tank" onchange="" class="select-input">
  483. <option value=""></option>
  484. </select>
  485. <input type="button" value="前往指定燒錄桶槽" onclick="GoToBoardLoaderPage()">
  486. <script>
  487. function GoToBoardLoaderPage() {
  488. var target_tank = $("#prog_tank").val();
  489. var confirm_GoToBoardLoaderPage = confirm("目前燒錄桶槽為 " + Tank_ID + "\n點擊 [確定] 按鈕後, 前往指定燒錄桶槽介面 " + target_tank);
  490. if (confirm_GoToBoardLoaderPage) {
  491. location.href = "/board_loader_" + target_tank;
  492. }
  493. }
  494. </script>
  495. <br>
  496. </td>
  497. </tr>
  498. <!-- coffee1.0 板子圖片 -->
  499. <!-- 燒錄制動器 / 感測器 -->
  500. <tr>
  501. <td style="width: 900px; vertical-align: top;">
  502. <img src="../static/img/0103_board_coffee1.0_tag.png" style="width: 100%;">
  503. </td>
  504. <td style="width: 20px;">
  505. </td>
  506. <td>
  507. <table border="5" style="border: 3px white solid;">
  508. <tr>
  509. <td colspan="3">
  510. ethernet :
  511. <select id="select_ethernet_1" onchange="" class="select-input">
  512. <option>OFF</option>
  513. <option>ON</option>
  514. </select>
  515. &nbsp;
  516. Wi-Fi :
  517. <select id="select_wifi_1" onchange="" class="select-input">
  518. <option>OFF</option>
  519. <option>ON</option>
  520. </select>
  521. &nbsp;
  522. zigbee :
  523. <select id="select_zigbee_1" onchange="" class="select-input">
  524. <option>OFF</option>
  525. <option>ON</option>
  526. </select>
  527. <br>
  528. </td>
  529. </tr>
  530. <tr>
  531. <!-- Relay 1-10 -->
  532. <td style="background-color: lightblue;">
  533. Relay 1 :
  534. <select id="select_relay_1" onchange="select_relay('1')" class="select-input">
  535. <option></option>
  536. <option value="vacuum">真空吸料機</option>
  537. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  538. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  539. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  540. <option value="diskvalve">蝴蝶閥</option>
  541. <option value="warninglight">警示燈</option>
  542. <option value="camera">攝影機</option>
  543. <option value="heater">電熱管</option>
  544. <option value="pump">雙核泵</option>
  545. </select>
  546. <br>
  547. Relay 2 :
  548. <select id="select_relay_2" onchange="select_relay('2')" class="select-input">
  549. <option></option>
  550. <option value="vacuum">真空吸料機</option>
  551. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  552. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  553. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  554. <option value="diskvalve">蝴蝶閥</option>
  555. <option value="warninglight">警示燈</option>
  556. <option value="camera">攝影機</option>
  557. <option value="heater">電熱管</option>
  558. <option value="pump">雙核泵</option>
  559. </select>
  560. <br>
  561. Relay 3 :
  562. <select id="select_relay_3" onchange="select_relay('3')" class="select-input">
  563. <option></option>
  564. <option value="vacuum">真空吸料機</option>
  565. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  566. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  567. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  568. <option value="diskvalve">蝴蝶閥</option>
  569. <option value="warninglight">警示燈</option>
  570. <option value="camera">攝影機</option>
  571. <option value="heater">電熱管</option>
  572. <option value="pump">雙核泵</option>
  573. </select>
  574. <br>
  575. Relay 4 :
  576. <select id="select_relay_4" onchange="select_relay('4')" class="select-input">
  577. <option></option>
  578. <option value="vacuum">真空吸料機</option>
  579. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  580. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  581. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  582. <option value="diskvalve">蝴蝶閥</option>
  583. <option value="warninglight">警示燈</option>
  584. <option value="camera">攝影機</option>
  585. <option value="heater">電熱管</option>
  586. <option value="pump">雙核泵</option>
  587. </select>
  588. <br>
  589. Relay 5 :
  590. <select id="select_relay_5" onchange="select_relay('5')" class="select-input">
  591. <option></option>
  592. <option value="vacuum">真空吸料機</option>
  593. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  594. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  595. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  596. <option value="diskvalve">蝴蝶閥</option>
  597. <option value="warninglight">警示燈</option>
  598. <option value="camera">攝影機</option>
  599. <option value="heater">電熱管</option>
  600. <option value="pump">雙核泵</option>
  601. </select>
  602. <br>
  603. Relay 6 :
  604. <select id="select_relay_6" onchange="select_relay('6')" class="select-input">
  605. <option></option>
  606. <option value="vacuum">真空吸料機</option>
  607. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  608. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  609. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  610. <option value="diskvalve">蝴蝶閥</option>
  611. <option value="warninglight">警示燈</option>
  612. <option value="camera">攝影機</option>
  613. <option value="heater">電熱管</option>
  614. <option value="pump">雙核泵</option>
  615. </select>
  616. <br>
  617. Relay 7 :
  618. <select id="select_relay_7" onchange="select_relay('7')" class="select-input">
  619. <option></option>
  620. <option value="vacuum">真空吸料機</option>
  621. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  622. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  623. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  624. <option value="diskvalve">蝴蝶閥</option>
  625. <option value="warninglight">警示燈</option>
  626. <option value="camera">攝影機</option>
  627. <option value="heater">電熱管</option>
  628. <option value="pump">雙核泵</option>
  629. </select>
  630. <br>
  631. Relay 8 :
  632. <select id="select_relay_8" onchange="select_relay('8')" class="select-input">
  633. <option></option>
  634. <option value="vacuum">真空吸料機</option>
  635. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  636. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  637. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  638. <option value="diskvalve">蝴蝶閥</option>
  639. <option value="warninglight">警示燈</option>
  640. <option value="camera">攝影機</option>
  641. <option value="heater">電熱管</option>
  642. <option value="pump">雙核泵</option>
  643. </select>
  644. <br>
  645. Relay 9 :
  646. <select id="select_relay_9" onchange="select_relay('9')" class="select-input">
  647. <option></option>
  648. <option value="vacuum">真空吸料機</option>
  649. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  650. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  651. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  652. <option value="diskvalve">蝴蝶閥</option>
  653. <option value="warninglight">警示燈</option>
  654. <option value="camera">攝影機</option>
  655. <option value="heater">電熱管</option>
  656. <option value="pump">雙核泵</option>
  657. </select>
  658. <br>
  659. Relay 10 :
  660. <select id="select_relay_10" onchange="select_relay('10')" class="select-input">
  661. <option></option>
  662. <option value="vacuum">真空吸料機</option>
  663. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  664. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  665. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  666. <option value="diskvalve">蝴蝶閥</option>
  667. <option value="warninglight">警示燈</option>
  668. <option value="camera">攝影機</option>
  669. <option value="heater">電熱管</option>
  670. <option value="pump">雙核泵</option>
  671. </select>
  672. </td>
  673. <td></td>
  674. <!-- Relay 11-20 -->
  675. <td style="background-color: lightblue;">
  676. Relay 11 :
  677. <select id="select_relay_11" onchange="select_relay('11')" class="select-input">
  678. <option></option>
  679. <option value="vacuum">真空吸料機</option>
  680. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  681. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  682. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  683. <option value="diskvalve">蝴蝶閥</option>
  684. <option value="warninglight">警示燈</option>
  685. <option value="camera">攝影機</option>
  686. <option value="heater">電熱管</option>
  687. <option value="pump">雙核泵</option>
  688. </select>
  689. <br>
  690. Relay 12 :
  691. <select id="select_relay_12" onchange="select_relay('12')" class="select-input">
  692. <option></option>
  693. <option value="vacuum">真空吸料機</option>
  694. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  695. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  696. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  697. <option value="diskvalve">蝴蝶閥</option>
  698. <option value="warninglight">警示燈</option>
  699. <option value="camera">攝影機</option>
  700. <option value="heater">電熱管</option>
  701. <option value="pump">雙核泵</option>
  702. </select>
  703. <br>
  704. Relay 13 :
  705. <select id="select_relay_13" onchange="select_relay('13')" class="select-input">
  706. <option></option>
  707. <option value="vacuum">真空吸料機</option>
  708. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  709. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  710. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  711. <option value="diskvalve">蝴蝶閥</option>
  712. <option value="warninglight">警示燈</option>
  713. <option value="camera">攝影機</option>
  714. <option value="heater">電熱管</option>
  715. <option value="pump">雙核泵</option>
  716. </select>
  717. <br>
  718. Relay 14 :
  719. <select id="select_relay_14" onchange="select_relay('14')" class="select-input">
  720. <option></option>
  721. <option value="vacuum">真空吸料機</option>
  722. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  723. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  724. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  725. <option value="diskvalve">蝴蝶閥</option>
  726. <option value="warninglight">警示燈</option>
  727. <option value="camera">攝影機</option>
  728. <option value="heater">電熱管</option>
  729. <option value="pump">雙核泵</option>
  730. </select>
  731. <br>
  732. Relay 15 :
  733. <select id="select_relay_15" onchange="select_relay('15')" class="select-input">
  734. <option></option>
  735. <option value="vacuum">真空吸料機</option>
  736. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  737. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  738. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  739. <option value="diskvalve">蝴蝶閥</option>
  740. <option value="warninglight">警示燈</option>
  741. <option value="camera">攝影機</option>
  742. <option value="heater">電熱管</option>
  743. <option value="pump">雙核泵</option>
  744. </select>
  745. <br>
  746. Relay 16 :
  747. <select id="select_relay_16" onchange="select_relay('16')" class="select-input">
  748. <option></option>
  749. <option value="vacuum">真空吸料機</option>
  750. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  751. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  752. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  753. <option value="diskvalve">蝴蝶閥</option>
  754. <option value="warninglight">警示燈</option>
  755. <option value="camera">攝影機</option>
  756. <option value="heater">電熱管</option>
  757. <option value="pump">雙核泵</option>
  758. </select>
  759. <br>
  760. Relay 17 :
  761. <select id="select_relay_17" onchange="select_relay('17')" class="select-input">
  762. <option></option>
  763. <option value="vacuum">真空吸料機</option>
  764. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  765. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  766. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  767. <option value="diskvalve">蝴蝶閥</option>
  768. <option value="warninglight">警示燈</option>
  769. <option value="camera">攝影機</option>
  770. <option value="heater">電熱管</option>
  771. <option value="pump">雙核泵</option>
  772. </select>
  773. <br>
  774. Relay 18 :
  775. <select id="select_relay_18" onchange="select_relay('18')" class="select-input">
  776. <option></option>
  777. <option value="vacuum">真空吸料機</option>
  778. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  779. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  780. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  781. <option value="diskvalve">蝴蝶閥</option>
  782. <option value="warninglight">警示燈</option>
  783. <option value="camera">攝影機</option>
  784. <option value="heater">電熱管</option>
  785. <option value="pump">雙核泵</option>
  786. </select>
  787. <br>
  788. Relay 19 :
  789. <select id="select_relay_19" onchange="select_relay('19')" class="select-input">
  790. <option></option>
  791. <option value="vacuum">真空吸料機</option>
  792. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  793. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  794. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  795. <option value="diskvalve">蝴蝶閥</option>
  796. <option value="warninglight">警示燈</option>
  797. <option value="camera">攝影機</option>
  798. <option value="heater">電熱管</option>
  799. <option value="pump">雙核泵</option>
  800. </select>
  801. <br>
  802. Relay 20 :
  803. <select id="select_relay_20" onchange="select_relay('20')" class="select-input">
  804. <option></option>
  805. <option value="vacuum">真空吸料機</option>
  806. <option value="solenoidvalve_disinfect">電磁閥_消毒</option>
  807. <option value="solenoidvalve_innerwaterout">電磁閥_桶內排廢水</option>
  808. <option value="solenoidvalve_outerwaterin">電磁閥_外桶入水</option>
  809. <option value="diskvalve">蝴蝶閥</option>
  810. <option value="warninglight">警示燈</option>
  811. <option value="camera">攝影機</option>
  812. <option value="heater">電熱管</option>
  813. <option value="pump">雙核泵</option>
  814. </select>
  815. <br>
  816. </td>
  817. </tr>
  818. <tr>
  819. <td> </td>
  820. </tr>
  821. <tr>
  822. <!-- 類比 -->
  823. <td style="background-color: lightgreen;">
  824. 類比 M4 :
  825. <select id="selectSensor_M4" onchange="selectSensor('M4')" class="select-input">
  826. <option></option>
  827. <option>PH</option>
  828. <option>DO</option>
  829. <option>ORP</option>
  830. </select>
  831. <br>
  832. 類比 M5 :
  833. <select id="selectSensor_M5" onchange="selectSensor('M5')" class="select-input">
  834. <option></option>
  835. <option>PH</option>
  836. <option>DO</option>
  837. <option>ORP</option>
  838. </select>
  839. <br>
  840. 類比 M7 :
  841. <select id="selectSensor_M7" onchange="selectSensor('M7')" class="select-input">
  842. <option></option>
  843. <option>PH</option>
  844. <option>DO</option>
  845. <option>ORP</option>
  846. </select>
  847. <br>
  848. </td>
  849. <td></td>
  850. <!-- 數位 1-3 -->
  851. <td style="background-color: lightgoldenrodyellow;">
  852. 數位 M9 :
  853. <select id="selectSensor_M9" onchange="selectSensor('M9')" class="select-input">
  854. <option></option>
  855. <option>WATERLEVEL</option>
  856. <option>motorfeedback</option>
  857. <option>butterflyvalvefeedback</option>
  858. </select>
  859. <br>
  860. 數位 M12 :
  861. <select id="selectSensor_M12" onchange="selectSensor('M12')" class="select-input">
  862. <option></option>
  863. <option>WATERLEVEL</option>
  864. <option>motorfeedback</option>
  865. <option>butterflyvalvefeedback</option>
  866. </select>
  867. <br>
  868. 數位 M19 :
  869. <select id="selectSensor_M19" onchange="selectSensor('M19')" class="select-input">
  870. <option></option>
  871. <option>WATERLEVEL</option>
  872. <option>motorfeedback</option>
  873. <option>butterflyvalvefeedback</option>
  874. </select>
  875. <br>
  876. </td>
  877. </tr>
  878. <tr>
  879. <td></td>
  880. </tr>
  881. <tr>
  882. <!-- PWM -->
  883. <td style="background-color: lightcyan;">
  884. PWM M10 :
  885. <select id="selectSensor_M10" onchange="selectSensor('M10')" class="select-input">
  886. <option></option>
  887. <option>Motor</option>
  888. </select>
  889. <br>
  890. PWM M2 :
  891. <select id="selectSensor_M2" onchange="selectSensor('M2')" class="select-input">
  892. <option></option>
  893. <option>Servo</option>
  894. </select>
  895. <br>
  896. PWM M3 :
  897. <select id="selectSensor_M3" onchange="selectSensor('M3')" class="select-input">
  898. <option></option>
  899. <option>Servo</option>
  900. </select>
  901. <br>
  902. </td>
  903. <td></td>
  904. <!-- 數位 4-5 -->
  905. <td style="background-color: lightgoldenrodyellow;">
  906. 數位 M14 :
  907. <select id="selectSensor_M14" onchange="selectSensor('M14')" class="select-input">
  908. <option></option>
  909. <option>SHT11</option>
  910. <option>DS18B20</option>
  911. </select>
  912. <br>
  913. 數位 M11 :
  914. <select id="selectSensor_M11" onchange="selectSensor('M11')" class="select-input">
  915. <option></option>
  916. <option>WATERLEVEL</option>
  917. <option>motorfeedback</option>
  918. <option>butterflyvalvefeedback</option>
  919. </select>
  920. <br>
  921. <br>
  922. </td>
  923. </tr>
  924. <tr>
  925. <td> </td>
  926. </tr>
  927. <tr>
  928. <!-- UART -->
  929. <td style="background-color: linen;">
  930. UART M16 :
  931. <select id="selectSensor_M16" onchange="selectSensor('M16')" class="select-input">
  932. <option></option>
  933. <option>EC</option>
  934. <option>DS18B20</option>
  935. <option>Servo真空閥</option>
  936. </select>
  937. <br>
  938. UART M17 :
  939. <select id="selectSensor_M17" onchange="selectSensor('M17')" class="select-input">
  940. <option></option>
  941. <option>SHT11</option>
  942. <option>Servo真空閥</option>
  943. </select>
  944. <br>
  945. UART M18 :
  946. <select id="selectSensor_M18" onchange="selectSensor('M18')" class="select-input">
  947. <option></option>
  948. </select>
  949. <br>
  950. </td>
  951. <td></td>
  952. <!-- 分壓類比 1 -->
  953. <td style="background-color:lavender;">
  954. <br>
  955. <br>
  956. 分壓類比 M6:
  957. <select id="selectSensor_M6" onchange="selectSensor('M6')" class="select-input">
  958. <option></option>
  959. <option>SEN0189</option>
  960. </select>
  961. <br>
  962. </td>
  963. </tr>
  964. <tr>
  965. <!-- I2C -->
  966. <!-- 485 -->
  967. <td style="background-color: lightpink;">
  968. I2C M15:
  969. <select id="selectSensor_M15" onchange="selectSensor('M15')" class="select-input">
  970. <option></option>
  971. <option>BMP280</option>
  972. </select>
  973. <br>
  974. 485 M8:
  975. <select id="selectSensor_M8" onchange="selectSensor('M8')" class="select-input">
  976. <option></option>
  977. <option>Soil</option>
  978. </select>
  979. <br>
  980. </td>
  981. <td></td>
  982. <!-- 分壓類比 2-3 -->
  983. <td style="background-color:lavender;">
  984. 分壓類比 M13:
  985. <select id="selectSensor_M13" onchange="selectSensor('M13')" class="select-input">
  986. <option></option>
  987. <option>SEN0189</option>
  988. </select>
  989. <br>
  990. 分壓類比 M1:
  991. <select id="selectSensor_M1" onchange="selectSensor('M1')" class="select-input">
  992. <option></option>
  993. <option>SonicESMUS07</option>
  994. </select>
  995. <br>
  996. </td>
  997. </tr>
  998. <tr>
  999. <td> </td>
  1000. </tr>
  1001. </table>
  1002. </td>
  1003. </tr>
  1004. <!-- 感測器取值頻率 -->
  1005. <tr>
  1006. <td colspan="5">
  1007. <span style="background-color:burlywood">感測器取值頻率</span><br>
  1008. <div id="SensorHz"></div><br>
  1009. </td>
  1010. </tr>
  1011. <!-- 制動器感測器項目取值 -->
  1012. <tr>
  1013. <td colspan="5" style="background-color: red; height: 50px; vertical-align: middle; text-align: center;">
  1014. <!-- <input type="button" value="制動器感測器項目取值" onclick="ItemGetValue()"> -->
  1015. <input type="button" value="(單元測試保留) 腳位配置 toDB" onclick="ItemGetValueToDB()">
  1016. <!-- <input type="button" value="ItemGetValue" onclick="ItemGetValue()"> -->
  1017. </td>
  1018. </tr>
  1019. <!-- 0526 積木測試 -->
  1020. <!-- <tr>
  1021. <td colspan="5" style="background-color:aqua">
  1022. test
  1023. </td>
  1024. </tr> -->
  1025. <!-- 積木程式 -->
  1026. <tr>
  1027. <td>
  1028. 燒錄器 : <input type="text" id="burner_mac" value="b8:27:eb:7e:24:78"><br>
  1029. <br>
  1030. <span style="background-color:burlywood">積木條件</span><br>
  1031. <span>入料儲豆槽為:{{tank_import}}</span><br>
  1032. <span>出料儲豆槽為:{{tank_export}}</span><br>
  1033. <div id="DBvalue">
  1034. <!-- 積木條件 -->
  1035. </div>
  1036. <script>
  1037. // 指令燒錄桶槽時, 跳出桶槽選項
  1038. var Value = '';
  1039. function renew_tank() {
  1040. var prog_container_value = $("#prog_container").val();
  1041. // console.log("prog_container_value: " + prog_container_value);
  1042. Value = '';
  1043. try {
  1044. for (let i = 0; i < containerTOtank[prog_container_value].length; i++) {
  1045. Value += '<option value="' + Object.keys(containerTOtank[prog_container_value][i]) + '">' + Object.values(containerTOtank[prog_container_value][i]) + '</option>';
  1046. }
  1047. } catch (error) {
  1048. if (error.name === 'TypeError') {
  1049. Value = '';
  1050. }
  1051. }
  1052. var sectorSelect = document.getElementById("prog_tank");
  1053. if (sectorSelect != null) {
  1054. sectorSelect.innerHTML = Value;
  1055. }
  1056. }
  1057. function DBvalue_btn(z_notempty_NUM, a_notempty_NUM, o_notempty_NUM) {
  1058. var html = '<div id="box">';
  1059. for (let condadd_parent_num = 1; condadd_parent_num <= z_notempty_NUM; condadd_parent_num++) {
  1060. html += '' +
  1061. '<div id="newcondition_' + condadd_parent_num + '" class="newcondition_css">' +
  1062. '<div id="condition' + condadd_parent_num + '">' +
  1063. '<div id="condition' + condadd_parent_num + '_' + '1' + '">' +
  1064. '條件 ' +
  1065. '<select id="cond_z' + condadd_parent_num + '_' + '1' + '">' +
  1066. '<option value="if">if</option>' +
  1067. '<option value="else if">else if</option>' +
  1068. '<option value="else">else</option>' +
  1069. '</select> ' +
  1070. '<select id="cond_a' + condadd_parent_num + '_' + '1' + '">' +
  1071. pin_data_sensor_option +
  1072. '<option value="tankstatus">tankstatus</option>' +
  1073. '</select> ' +
  1074. '<select id="cond_b' + condadd_parent_num + '_' + '1' + '">' +
  1075. '<option value=""></option>' +
  1076. '<option value=">">&gt;</option>' +
  1077. '<option value=">=">&gt;=</option>' +
  1078. '<option value="==">==</option>' +
  1079. '<option value="<=">&lt;=</option>' +
  1080. '<option value="<">&lt;</option>' +
  1081. '</select> ' +
  1082. '<input list="cond_list_c' + condadd_parent_num + '_' + '1' + '" id="cond_c' + condadd_parent_num + '_' + '1' + '">' +
  1083. '<datalist id="cond_list_c' + condadd_parent_num + '_' + '1' + '">' +
  1084. '<option value="on">ON</option>' +
  1085. '<option value="off">OFF</option>' +
  1086. '<option value="">(或請自行輸入數值)</option>' +
  1087. '<option value="Waiting">空桶等待</option>' +
  1088. '<option value="InputtingBean">入豆中</option>' +
  1089. '<option value="InputtingBean_Pause">入豆暫停</option>' +
  1090. '<option value="InputtingBean_Finish">入豆完成</option>' +
  1091. '<option value="InputtingWater">夾層入水</option>' +
  1092. '<option value="Drying">乾燥中</option>' +
  1093. '<option value="Drying_Finish">乾燥完成</option>' +
  1094. '<option value="OutputtingBean">可出豆</option>' +
  1095. '<option value="OutputtingBean_Finish">出豆完成</option>' +
  1096. '</datalist> ' +
  1097. '<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>' +
  1098. '</div>';
  1099. for (let cond_add_child_i = 2; cond_add_child_i <= a_notempty_NUM; cond_add_child_i++) {
  1100. // if (cond_d_data[condadd_parent_num][cond_add_child_i] == '') {
  1101. // // alert("cond_d_data[" + condadd_parent_num + "][" + cond_add_child_i + " ] + 為空值")
  1102. // continue
  1103. // }
  1104. html +=
  1105. '<div id="condition' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1106. '<select id="cond_d' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1107. '<option value=""></option>' +
  1108. '<option value="&&">&&</option>' +
  1109. '<option value="||">||</option>' +
  1110. '</select> ' +
  1111. '<select id="cond_a' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1112. pin_data_sensor_option +
  1113. '<option value="tankstatus">tankstatus</option>' +
  1114. // '</optgroup>' +
  1115. '</select> ' +
  1116. '<select id="cond_b' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1117. '<option value=""></option>' +
  1118. '<option value=">">&gt;</option>' +
  1119. '<option value=">=">&gt;=</option>' +
  1120. '<option value="==">==</option>' +
  1121. '<option value="<=">&lt;=</option>' +
  1122. '<option value="<">&lt;</option>' +
  1123. '</select> ' +
  1124. '<input list="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '" id="cond_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1125. '<datalist id="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1126. '<option value="on">ON</option>' +
  1127. '<option value="off">OFF</option>' +
  1128. '<option value="">(或請自行輸入數值)</option>' +
  1129. '<option value="Waiting">空桶等待</option>' +
  1130. '<option value="InputtingBean">入豆中</option>' +
  1131. '<option value="InputtingBean_Pause">入豆暫停</option>' +
  1132. '<option value="InputtingBean_Finish">入豆完成</option>' +
  1133. '<option value="InputtingWater">夾層入水</option>' +
  1134. '<option value="Drying">乾燥中</option>' +
  1135. '<option value="Drying_Finish">乾燥完成</option>' +
  1136. '<option value="OutputtingBean">可出豆</option>' +
  1137. '<option value="OutputtingBean_Finish">出豆完成</option>' +
  1138. '</datalist> ' +
  1139. '<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 + '\');">';
  1140. if (cond_add_child_i == 2) {
  1141. html +=
  1142. '<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>';
  1143. } else {
  1144. html +=
  1145. '<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>';
  1146. }
  1147. html += '</div>';
  1148. }
  1149. html += '</div>';
  1150. // 新增的物件動作
  1151. html += '<div id="action' + condadd_parent_num + '">';
  1152. for (let cond_add_child_i = 1; cond_add_child_i <= o_notempty_NUM; cond_add_child_i++) {
  1153. // if (cond_obj_data[condadd_parent_num][cond_add_child_i] == '') {
  1154. // // alert("cond_d_data[" + condadd_parent_num + "][" + cond_add_child_i + " ] + 為空值")
  1155. // continue
  1156. // }
  1157. html +=
  1158. '<div id="action' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1159. '物件 ' +
  1160. '<select id="do_obj' + condadd_parent_num + '_' + cond_add_child_i + '" onChange="renew(\''+ condadd_parent_num + '_' + cond_add_child_i + '\', this.selectedIndex);">' +
  1161. // '<option value=" ">制動器 / 暫停秒數 / 桶槽狀態</option>' +
  1162. pin_data_relay_option +
  1163. // '<option value="input_vacuum_status">入料儲豆槽真空吸料機</option>' +
  1164. // '<option value="tank_vacuum_status">真空吸料機</option>' +
  1165. // '<option value="tank_threewayvalve_vacuum_status">吸料機三通閥</option>' +
  1166. // '<option value="tank_solenoid_disinfect_status">消毒電磁閥</option>' +
  1167. // '<option value="tank_motor_status">馬達</option>' +
  1168. // '<option value="outer_solenoid_water_status">桶外進水電磁閥</option>' +
  1169. // '<option value="tank_solenoid_water_out_status">廢水排水電磁閥</option>' +
  1170. // '<option value="tank_heater1_status">加熱棒 1</option>' +
  1171. // '<option value="tank_heater2_status">加熱棒 2</option>' +
  1172. // '<option value="tank_temp_enable">溫控開關</option>' +
  1173. // '<option value="tank_temp">溫度設定</option>' +
  1174. // '<option value="tank_diskvalve_status">蝴蝶閥</option>' +
  1175. // '<option value="output_vacuum_status">出料儲豆槽真空吸料機</option>' +
  1176. // '<option value="tank_magneticSwitch_status">電磁開關</option>' +
  1177. // '<option value="tank_emergencySwitch_status">緊急開關</option>' +
  1178. // '<option value="tank_camera_status">攝影機</option>' +
  1179. // '<option value="tank_warningLight_status">警示燈</option>' +
  1180. '</select>' +
  1181. // '<select id="do_act' + new_condition_i + '_1">' +
  1182. // '<option value="">請由左方選取物件' +
  1183. // '</select> ' +
  1184. ' 動作 ' +
  1185. '<div id="do_action' + condadd_parent_num + '_' + cond_add_child_i + '" style="display: inline-block;">' +
  1186. '</div>' +
  1187. '<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 + '\');">';
  1188. if (cond_add_child_i == 1) {
  1189. html +=
  1190. '<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>';
  1191. } else {
  1192. html +=
  1193. '<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>';
  1194. }
  1195. html += '</div>';
  1196. }
  1197. html += '</div>';
  1198. // 新增的 條件物件動作++ 條件物件動作-- 按鈕
  1199. html += '<input type="button" class="input-delete" id="del' + condadd_parent_num + '" value="條件物件動作--" onclick="Delete(' + condadd_parent_num + ');"><br>' +
  1200. '<input type="button" class="input-add" id="add' + condadd_parent_num + '" value="條件物件動作++" onclick="Add(add' + condadd_parent_num + ');">' +
  1201. '</div><br>' ;
  1202. }
  1203. html += '</div>' ;
  1204. var divbox = document.getElementById('DBvalue');
  1205. divbox.insertAdjacentHTML('beforeend', html);
  1206. }
  1207. </script>
  1208. </td>
  1209. </tr>
  1210. <!-- 積木取值 -->
  1211. <tr>
  1212. <td colspan="5" style="background-color: red; height: 77px; vertical-align: middle; text-align: center;">
  1213. <input type="button" id="test" value="(單元測試保留) 顯示積木條件" onclick="getValue();"><br>
  1214. <input type="button" id="test" value="(單元測試保留) 積木條件 json 格式 + MQTT + toDB" onclick="MQTTgetValue();"><br>
  1215. </td>
  1216. </tr>
  1217. <!-- 積木取值 文字輸出 -->
  1218. <tr>
  1219. <td colspan="2">
  1220. *** 以下內容測試用, 之後會刪除<br>
  1221. Value : <span id="show_Value"></span><br><br>
  1222. <!-- MySQL : <span id="show_MySQLcommand"></span><br><br> -->
  1223. MQTT : <span id="show_MQTTcommand"></span>
  1224. </td>
  1225. </tr>
  1226. <!-- 燒錄 -->
  1227. <tr>
  1228. <td colspan="5" style="background-color: red; height: 77px; vertical-align: middle; text-align: center;">
  1229. <input type="button" value="(單元測試保留) 更新 main.c 檔案" onclick="prog_creat_hex();"><br>
  1230. <input type="button" value="(單元測試保留) 更新 SDIO.hex 檔案 + MQTT 其內容 + 備份 SDIO.hex toGit" onclick="programmer();">
  1231. </td>
  1232. </tr>
  1233. <tr>
  1234. <td colspan="5" style="background-color: red; height: 50px; vertical-align: middle; text-align: center;">
  1235. <input type="button" value="進行 OTA 燒錄" onclick="prog_OTA();">
  1236. </td>
  1237. </tr>
  1238. <script>
  1239. function prog_creat_hex() {
  1240. MQTTgetValue();
  1241. $.ajax({
  1242. type:"GET",
  1243. url:"/creat_hex",
  1244. data:TT,
  1245. dataType:"text",
  1246. async:false,
  1247. success:function (res) {
  1248. $("#creat_hex_Value").text(res);
  1249. },
  1250. error: function (thrownError) {
  1251. alert(thrownError.statusText);
  1252. $("#creat_hex_Value").text(thrownError.statusText);
  1253. }
  1254. })
  1255. }
  1256. var prog_result_interval;
  1257. function programmer(params) {
  1258. var confirm_programmer = confirm("即將燒錄 Coffee1.0, 確定請按下 [確認] :");
  1259. if (!confirm_programmer) {
  1260. alert("已取消燒錄");
  1261. } else {
  1262. var prog_tank_data = $('#prog_tank').find(':selected').val();
  1263. var prog_burner_mac = $('#burner_mac').val();
  1264. console.log("prog_burner_mac: " + prog_burner_mac);
  1265. var prog_data = {'tank':prog_tank_data,
  1266. 'USERNAME': USERNAME,
  1267. 'burner_mac':prog_burner_mac}
  1268. $("#programmer_Value").text("準備燒錄...");
  1269. $.get('/board_programmer', prog_data, function (res) {
  1270. // $("#programmer_Value").text(res);
  1271. prog_result_interval = setInterval("board_programmer_result(\'" + prog_tank_data + "\')", 5000);
  1272. // if (res === 'no reply') {
  1273. // alert("控制板燒錄 Code_upload : no reply");
  1274. // } else {
  1275. // eval('var prog_result_interval = setInterval("board_programmer_result(\'' + prog_tank_data + '\')", 5000);');
  1276. // }
  1277. }, 'text');
  1278. }
  1279. }
  1280. // 燒錄結果取值時判斷用
  1281. var prog_tank_data = $('#prog_tank').find(':selected').val();
  1282. var board_programmer_process = 0;
  1283. function board_programmer_result(tid) {
  1284. if (board_programmer_process == 1) {
  1285. return;
  1286. }
  1287. board_programmer_process = 1;
  1288. $.ajax({
  1289. type:"GET",
  1290. url:"/board_programmer_result_" + tid,
  1291. dataType:"text",
  1292. async:false,
  1293. success:function(response){
  1294. console.log("board_programmer_result: " + response);
  1295. console.log(response != '0')
  1296. if (response != '0') {
  1297. $("#programmer_Value").text(response);
  1298. alert("燒錄結果: " + response);
  1299. clearInterval(prog_result_interval);
  1300. }
  1301. board_programmer_process = 0;
  1302. },
  1303. error: function(thrownError){
  1304. console.log(thrownError);
  1305. board_programmer_process = 0;
  1306. }
  1307. });
  1308. }
  1309. function prog_OTA() {
  1310. prog_creat_hex();
  1311. programmer();
  1312. }
  1313. </script>
  1314. <!-- 燒錄結果顯示 -->
  1315. <tr>
  1316. <td colspan="2">
  1317. creat_hex 結果:<span id="creat_hex_Value"></span><br>
  1318. <br>
  1319. 燒錄結果:<span id="programmer_Value"></span>
  1320. </td>
  1321. </tr>
  1322. </table>
  1323. <!-- Relay、感測器選值時, 左側圖片顯示對應項目 -->
  1324. <script>
  1325. // 當右方的下拉式選單選擇時, 更新左方圖片上的文字 - relay
  1326. function select_relay(id) {
  1327. var select_relay_text = $("#select_relay_" + id).find(':selected').text()
  1328. // console.log("select_relay_text: " + select_relay_text)
  1329. if (select_relay_text == '') {
  1330. $("#relay" + id).text('');
  1331. document.getElementById("relay" + id).style.backgroundColor = 'transparent';
  1332. } else {
  1333. $("#relay" + id).text(select_relay_text);
  1334. document.getElementById("relay" + id).style.backgroundColor = 'lightblue';
  1335. document.getElementById("relay" + id).style.color = 'black';
  1336. document.getElementById("relay" + id).style.fontWeight = '600';
  1337. }
  1338. }
  1339. var sensorlist = ['', '分壓類比', 'PWM', 'PWM', '類比', '類比', '分壓類比', '類比', '485', '數位',
  1340. 'PWM', '數位', '數位', '分壓類比', '數位', 'I2C', 'UART', 'UART', 'UART', '數位']
  1341. // selectSensor
  1342. function selectSensor(PinNum) {
  1343. var Pin_sensor = $("#selectSensor_" + PinNum).find(':selected').text();
  1344. // console.log("Pin_sensor: " + Pin_sensor)
  1345. if (Pin_sensor == '') {
  1346. $("#sensor_" + PinNum).text('');
  1347. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'transparent';
  1348. } else {
  1349. $("#sensor_" + PinNum).text(Pin_sensor);
  1350. // alert("sensorlist[PinNum]]\n" + sensorlist[PinNum.substring(1)])
  1351. if (sensorlist[PinNum.substring(1)] == '類比') {
  1352. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'lightgreen';
  1353. } else if (sensorlist[PinNum.substring(1)] == 'PWM') {
  1354. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'lightcyan';
  1355. } else if (sensorlist[PinNum.substring(1)] == '數位') {
  1356. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'lightgoldenrodyellow';
  1357. } else if (sensorlist[PinNum.substring(1)] == 'UART') {
  1358. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'linen';
  1359. } else if (sensorlist[PinNum.substring(1)] == '分壓類比') {
  1360. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'lavender';
  1361. } else if (sensorlist[PinNum.substring(1)] == 'I2C' || sensorlist[PinNum.substring(1)] == '485') {
  1362. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'lightpink';
  1363. }
  1364. document.getElementById("sensor_" + PinNum).style.color = 'black';
  1365. document.getElementById("sensor_" + PinNum).style.fontWeight = '600';
  1366. }
  1367. }
  1368. </script>
  1369. <!-- -->
  1370. <script>
  1371. var relay_data = ''; // 積木程式 制動器選項
  1372. var sensor_data = ''; // 積木程式 感測器選項
  1373. var obj_data = ''; // 積木程式 物件選項:桶槽狀態 暫停秒數
  1374. const list_R = ['R1','R2','R3','R4','R5','R6','R7','R8','R9','R10','R11','R12','R13','R14','R15','R16','R17','R18','R19','R20']
  1375. var list_relay_item = []; // R1~R20 對應的 relay 取值
  1376. const list_M = ['M1','M2','M3','M4','M5','M6','M7','M8','M9','M10','M11','M12','M13','M14','M15','M16','M17','M18','M19']
  1377. var list_sensor_item = []; // M1~M19 對應的 sensor 取值
  1378. const list_M_Hz = ['M1_Hz','M2_Hz','M3_Hz','M4_Hz','M5_Hz','M6_Hz','M7_Hz','M8_Hz','M9_Hz','M10_Hz',
  1379. 'M11_Hz','M12_Hz','M13_Hz','M14_Hz','M15_Hz','M16_Hz','M17_Hz','M18_Hz','M19_Hz'];
  1380. var list_sensorHz_item = [] // M1~M19 對應的取值頻率
  1381. function ItemGetValueToDB() {
  1382. var ethernet_text = $("#select_ethernet_1").find(':selected').val();
  1383. var wifi_text = $("#select_wifi_1").find(':selected').val();
  1384. var zigbee_text = $("#select_zigbee_1").find(':selected').val();
  1385. var tank_text = $('#prog_tank').find(':selected').val();
  1386. console.log("ethernet_text: " + ethernet_text);
  1387. console.log("wifi_text: " + wifi_text);
  1388. console.log("zigbee_text: " + zigbee_text);
  1389. console.log("tank_text: " + tank_text);
  1390. list_relay_item = [];
  1391. for (let i = 1; i < 21; i++) {
  1392. var relay_text = $("#select_relay_" + i).find(':selected').val();
  1393. if (relay_text != '') {
  1394. list_relay_item.push(relay_text);
  1395. } else {
  1396. list_relay_item.push('');
  1397. }
  1398. }
  1399. console.log("list_relay_item: " + list_relay_item);
  1400. list_sensor_item = [];
  1401. for (let i = 1; i < 20; i++) {
  1402. var sensor_text = $("#selectSensor_M" + i).find(':selected').val();
  1403. if (sensor_text != '') {
  1404. list_sensor_item.push(sensor_text);
  1405. } else {
  1406. list_sensor_item.push('');
  1407. }
  1408. }
  1409. console.log("list_sensor_item: " + list_sensor_item);
  1410. list_sensorHz_item = [];
  1411. // list_M_Hz = ['M1_Hz','M2_Hz','M3_Hz','M4_Hz','M5_Hz','M6_Hz','M7_Hz','M8_Hz','M9_Hz','M10_Hz',
  1412. // 'M11_Hz','M12_Hz','M13_Hz','M14_Hz','M15_Hz','M16_Hz','M17_Hz','M18_Hz','M19_Hz'];
  1413. // var list_sensorHz_item
  1414. for (let i = 1; i < 20; i++) {
  1415. var sensor_text = $("#M" + i + "_Hz").val();
  1416. if (sensor_text !== undefined) {
  1417. console.log("sensor_text: ", sensor_text);
  1418. list_sensorHz_item.push(sensor_text);
  1419. } else {
  1420. list_sensorHz_item.push('');
  1421. }
  1422. }
  1423. var SQL_insert = 'INSERT INTO `coffee1_0_pin` (' +
  1424. '`datetime`, `tid`, `ethernet`, `wifi`, `zigbee`, `' +
  1425. list_R.join("`, `") +
  1426. '`, `' +
  1427. list_M.join("`, `") +
  1428. '`, `' +
  1429. list_M_Hz.join("`, `") +
  1430. '`) VALUES (' +
  1431. 'current_timestamp(), "' + Tank_ID + '", "' + ethernet_text + '", "' + wifi_text + '", "' + zigbee_text + '", "' +
  1432. list_relay_item.join('", "') +
  1433. '", "' +
  1434. list_sensor_item.join('", "') +
  1435. '", "' +
  1436. list_sensorHz_item.join('", "') +
  1437. '")';
  1438. var sql_data = { "sql":SQL_insert };
  1439. console.log("sql_data: ", sql_data)
  1440. $.get('/sql_get', sql_data, function (res) {
  1441. if (res['response'] == '') {
  1442. alert("OK");
  1443. } else {
  1444. alert(res['response']);
  1445. }
  1446. location.reload();
  1447. }, 'json');
  1448. // ItemGetValue();
  1449. // location.reload();
  1450. }
  1451. function ItemGetValue() {
  1452. list_relay_item = [];
  1453. // ethernet、wifi、zigbee 取值測試
  1454. // var select_ethernet_text = $("#select_ethernet_1").find(':selected').text()
  1455. // var select_wifi_text = $("#select_wifi_1").find(':selected').text()
  1456. // var select_zigbee_text = $("#select_zigbee_1").find(':selected').text()
  1457. // console.log("select_ethernet_text: " + select_ethernet_text)
  1458. // console.log("select_wifi_text: " + select_wifi_text)
  1459. // console.log("select_zigbee_text: " + select_zigbee_text)
  1460. // 制動器感測器 下拉式選單 不可更改
  1461. $('.select-input').prop('disabled', true);
  1462. // relay 取值
  1463. relay_dict = {};
  1464. for (let i = 1; i < 21; i++) {
  1465. var relay_text = $("#select_relay_" + i).find(':selected').val();
  1466. if (relay_text != '') {
  1467. relay_dict["R" + i] = "R" + i + "_" + relay_text;
  1468. // console.log("R" + i + " : " + relay_text);
  1469. list_relay_item.push(relay_text);
  1470. } else {
  1471. // relay_dict["R" + i] = "";
  1472. // console.log("R" + i + " : ");
  1473. list_relay_item.push('');
  1474. }
  1475. }
  1476. // console.log("list_relay_item: " + list_relay_item);
  1477. // relay_data = '<optgroup label="制動器狀態">';
  1478. relay_data = '<option value=""></option>';
  1479. for (let r in relay_dict) {
  1480. // console.log(r + " : " + relay_dict[r]);
  1481. relay_data += '<option value="' + relay_dict[r] + '">' + relay_dict[r] + '</option>';
  1482. }
  1483. relay_data += '<option value="sleep">sleep</option>' +
  1484. '<option value="tankstatus">tankstatus</option>';
  1485. // relay_data += '</optgroup>'
  1486. // console.log("relay_data: " + relay_data)
  1487. // sensor 取值 dict
  1488. sensor_dict = {};
  1489. for (let i = 1; i < 20; i++) {
  1490. var sensor_text = $("#selectSensor_M" + i).find(':selected').text();
  1491. if (sensor_text != '') {
  1492. sensor_dict["M" + i] = "M" + i + "_" + sensor_text;
  1493. // console.log("selectSensor_M" + i);
  1494. // console.log("M" + i + "_" + sensor_text);
  1495. } else {
  1496. // sensor_dict["M" + i] = "";
  1497. // console.log("selectSensor_M" + i);
  1498. // console.log("");
  1499. }
  1500. }
  1501. sensor_data = '';
  1502. // sensor_data = '<optgroup label="感測器數值">';
  1503. for (let s in sensor_dict) {
  1504. // console.log(s + " : " + sensor_dict[s])
  1505. sensor_data += '<option value="' + sensor_dict[s] + '">' + sensor_dict[s] + '</option>';
  1506. }
  1507. sensor_data += '<option value="tankstatus">tankstatus</option>';
  1508. // sensor_data += '</optgroup>';
  1509. // console.log("sensor_data: " + sensor_data)
  1510. console.log("relay_data: " + relay_data);
  1511. console.log("sensor_data: " + sensor_data);
  1512. var relay_select_data = document.getElementById("");
  1513. // // 賦值條件 a
  1514. // var sectorSelect = document.getElementById("cond_a1_1");
  1515. // sectorSelect.innerHTML = '<option value="">制動器 / 感測器</option>' + relay_data + sensor_data;
  1516. // obj_data = '<option value="' + 'sleep' + '">' + 'sleep' + '</option>' +
  1517. // '<option value="' + 'tankstatus' + '">' + 'tankstatus' + '</option>';
  1518. // // 賦值物件 a
  1519. // var sectorSelect = document.getElementById("do_obj1_1");
  1520. // sectorSelect.innerHTML = '<option value="">制動器 / 暫停秒數 / 桶槽狀態</option>' + relay_data + obj_data;
  1521. // ===== 下方傳值未測試 ====================================================
  1522. // var loader_data = {
  1523. // "ethernet_list":select_ethernet_text,
  1524. // "wifi_list":select_wifi_text,
  1525. // "zigbee_list":select_zigbee_text,
  1526. // "relay_list":String(relay_list),
  1527. // "pwm_list":String(pwm_list),
  1528. // "digital_list":String(digital_list),
  1529. // "uart_list":String(uart_list),
  1530. // "i2c_list":String(i2c_list),
  1531. // "s485_list":String(s485_list),
  1532. // "ppa_list":String(ppa_list)
  1533. // };
  1534. // $.ajax({
  1535. // type:"GET",
  1536. // url:"/loader",
  1537. // dataType:"JSON",
  1538. // data:loader_data,
  1539. // success:function (res) {
  1540. // alert("ItemGetValue loader: " + res.response)
  1541. // },
  1542. // error: function (thrownError) {
  1543. // alert(thrownError)
  1544. // }
  1545. // })
  1546. }
  1547. relay_obj2act = {'vacuum':['on', 'off'],
  1548. 'solenoidvalve':['on', 'off'],
  1549. 'diskvalve':['on', 'off'],
  1550. 'warninglight':['on', 'off'],
  1551. 'camera':['on', 'off'],
  1552. 'heater':['on', 'off'],
  1553. 'pump':['on', 'off'],
  1554. 'sleep':'',
  1555. 'tankstatus':['Waiting', 'InputtingBean', 'InputtingBean_Pause', 'InputtingBean_Finish',
  1556. 'Drying', 'OutputtingBean', 'InputtingWater']
  1557. }
  1558. dry_object = new Array();
  1559. dry_object['tankstatus'] = ["Waiting", "InputtingBean", "InputtingBean_Pause", "InputtingBean_Finish",
  1560. "InputtingWater", "Drying", "Drying_Finish", "OutputtingBean", "OutputtingBean_Finish"]; // 暫停秒數
  1561. // DRY_CONTAINER_STATUS 讓 do_act / dry_object 判斷用
  1562. const DRY_CONTAINER_STATUS = {
  1563. 'Waiting':'空桶等待',
  1564. 'InputtingBean':'入豆中',
  1565. 'InputtingBean_Pause':'入豆暫停',
  1566. 'InputtingBean_Finish':'入豆完成',
  1567. 'InputtingWater':'夾層入水',
  1568. 'Drying':'乾燥中',
  1569. 'Drying_Finish':'乾燥完成',
  1570. 'OutputtingBean':'可出豆',
  1571. 'OutputtingBean_Finish':'出豆完成'
  1572. }
  1573. function renew(obj_num, index) {
  1574. // console.log("renew!!!" + obj_num + "_____" + index);
  1575. var index_name = $('#do_obj' + obj_num).val();
  1576. // console.log("index_name: " + index_name);
  1577. var Value = '';
  1578. if (index_name === 'sleep') {
  1579. Value = ' 暫停秒數 : ' +
  1580. ' <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)">' +
  1581. ' <span id="sleepValue_text' + obj_num + '">10s</span>';
  1582. } else if (index_name === 'tankstatus') {
  1583. Value = '<select id="do_act' + obj_num + '">';
  1584. for(var i=0; i<dry_object['tankstatus'].length; i++){
  1585. Value += '<option value=' + dry_object['tankstatus'][i] + '>' + DRY_CONTAINER_STATUS[dry_object['tankstatus'][i]] + '</option>';
  1586. }
  1587. Value += '</select>';
  1588. } else if (index_name.includes('Motor')) {
  1589. Value = ' 指定轉速 : ' +
  1590. ' <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)">' +
  1591. ' <span id="motorValue_text' + obj_num + '">20rpm</span>';
  1592. } else if (index_name === '' || index_name == undefined) {
  1593. } else {
  1594. Value = '<select id="do_act' + obj_num + '">' +
  1595. '<option value="on">on</option>' +
  1596. '<option value="off">off</option>' +
  1597. '</select>';
  1598. }
  1599. // try {
  1600. // Value = '<select id="do_act' + obj_num + '">';
  1601. // for(var i=0; i<dry_object[index].length; i++){
  1602. // Value += '<option value=' + dry_object[index][i] + '>' + dry_object[index][i] + '</option>';
  1603. // }
  1604. // Value += '</select>';
  1605. // } catch (e) {
  1606. // if (e.name == 'TypeError' && index == '5') {
  1607. // Value = ' 轉速 : ' +
  1608. // ' <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)">' +
  1609. // ' <span id="motorValue_text' + obj_num + '">0</span>';
  1610. // } else if (e.name == 'TypeError' && index == '11') {
  1611. // Value = ' 目標溫度 : ' +
  1612. // ' <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)">' +
  1613. // ' <span id="tempValue_text' + obj_num + '">28.0</span>';
  1614. // } else if (e.name == 'TypeError' && index == '18') {
  1615. // Value = ' 暫停秒數 : ' +
  1616. // ' <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)">' +
  1617. // ' <span id="sleepValue_text' + obj_num + '">10s</span>';
  1618. // }
  1619. // }
  1620. var sectorSelect = document.getElementById("do_action" + obj_num);
  1621. if (sectorSelect != null) {
  1622. sectorSelect.innerHTML = Value;
  1623. }
  1624. }
  1625. function showSleepValue(obj_num, value) {
  1626. document.getElementById("sleepValue_text" + obj_num).innerText = value + 's';
  1627. }
  1628. function showMotorValue(obj_num, value) {
  1629. document.getElementById("motorValue_text" + obj_num).innerText = value + 'rpm';
  1630. }
  1631. function showSensorHzValue(obj_num, value) {
  1632. document.getElementById(obj_num + "_HzText").innerText = value + ' 秒/次';
  1633. }
  1634. </script>
  1635. <script>
  1636. var cond_main = ''; // 主條件
  1637. var cond_add_list = []; // 附加條件 List
  1638. var cond_add_data = ''; // 欲加入附加條件的資料
  1639. var cond_com_list = []; // 動作 List
  1640. var cond_com_data = ''; // 欲加入動作的資料
  1641. var cond_item = []; // 主條件+附加條件+動作 List
  1642. function showValue() {
  1643. cond_item = [];
  1644. var command_test = '';
  1645. Z = 0;
  1646. TT = {}; // 將總條件句/附加條件句/物件動作句存入 字典, 後續傳給 dry_block_format 再組合
  1647. var SQL_insert_total = ''; // MySQL 指令 全部條件輸出
  1648. TT['mainLength'] = 0 // 總條件數
  1649. TT['addLength'] = 0 // 子條件數
  1650. TT['comLength'] = 0 // 子物件數
  1651. // 條件物件動作 取值
  1652. // for (let z = 1; z <= 2; z++) {
  1653. for (let z = 1; z <= new_condition_i; z++) {
  1654. var set_key = []; // List 加入變數名稱, INSERT DB 用
  1655. var set_value = []; // List 加入值, INSERT DB 用
  1656. // 初始清空
  1657. cond_main = '';
  1658. // if-while 取值
  1659. try {
  1660. var cond_z_value = document.getElementById("cond_z" + z + "_1").value;
  1661. if (cond_z_value == '') {
  1662. // alert('if/while 欄位未輸入')
  1663. } else {
  1664. Z = Z + 1;
  1665. // if (Z > 4) {
  1666. // alert("[Z > 4] 總條件數不得超過 3 項")
  1667. // break
  1668. // }
  1669. // set_key.push('cond_z' + z + '_1');
  1670. set_key.push('cond_z' + Z + '_1');
  1671. set_value.push(cond_z_value);
  1672. console.log("cond_z_value: " + cond_z_value);
  1673. cond_main += cond_z_value + ' ';
  1674. console.log("cond_main: " + cond_main);
  1675. }
  1676. } catch (error) {
  1677. if (error.name == 'TypeError') {
  1678. } else {
  1679. alert("cond_z" + z + "_1: " + error.name)
  1680. }
  1681. }
  1682. X = 1;
  1683. cond_add_list = []; // 附加條件 List 清空
  1684. for (let x = 1; x <= cond_add_child_i; x++) {
  1685. // for (let x = 1; x <= cond_add_child_i; x++) {
  1686. cond_add_data = ''; // 附加條件資料 清空
  1687. if (x == 1) {
  1688. // 主條件
  1689. try {
  1690. var cond_a_value = document.getElementById("cond_a" + z + "_" + x).value;
  1691. if (cond_a_value == '') {
  1692. // alert('主條件 感測器 欄位未輸入')
  1693. } else {
  1694. // set_key.push('cond_a' + z + '_' + X);
  1695. set_key.push('cond_a' + Z + '_' + X);
  1696. set_value.push(cond_a_value);
  1697. console.log("cond_a_value: " + cond_a_value);
  1698. cond_main += cond_a_value + ' ';
  1699. }
  1700. } catch (error) {
  1701. if (error.name == 'TypeError') {
  1702. } else {
  1703. alert("cond_a" + z + "_" + x + ": " + error.name)
  1704. }
  1705. }
  1706. // 子條件取值 : 條件中 > = <
  1707. try {
  1708. var cond_b_value = document.getElementById("cond_b" + z + "_" + x).value;
  1709. if (cond_b_value == '') {
  1710. // alert('主條件 比較運算子 欄位未輸入')
  1711. } else {
  1712. // set_key.push('cond_b' + z + '_' + X);
  1713. set_key.push('cond_b' + Z + '_' + X);
  1714. set_value.push(cond_b_value);
  1715. console.log("cond_b_value: " + cond_b_value);
  1716. // if (cond_b_value == 'MoreThan') { cond_main += '> '; }
  1717. // else if (cond_b_value == 'MoreThanEqualTo') { cond_main += '>= '; }
  1718. // else if (cond_b_value == 'Equal') { cond_main += '== '; }
  1719. // else if (cond_b_value == 'LessThanEqualTo') { cond_main += '<= '; }
  1720. // else if (cond_b_value == 'LessThan') { cond_main += '< '; }
  1721. cond_main += cond_b_value + ' ';
  1722. }
  1723. } catch (error) {
  1724. if (error.name == 'TypeError') {
  1725. } else {
  1726. alert("cond_b" + z + "_" + x + ": " + error.name)
  1727. }
  1728. }
  1729. // 子條件取值 : 條件右 ON / OFF / 輸入數值
  1730. try {
  1731. var cond_c_value = document.getElementById("cond_c" + z + "_" + x).value;
  1732. if (cond_c_value == '') {
  1733. // alert('主條件 數值 欄位未輸入')
  1734. } else {
  1735. // console.log("Ctest: " + typeof(cond_c_value))
  1736. set_key.push('cond_c' + Z + '_' + X);
  1737. set_value.push(cond_c_value);
  1738. console.log("cond_c_value: " + cond_c_value);
  1739. if (relay_obj2act['tankstatus'].includes(cond_c_value)) {
  1740. cond_main += "'" + cond_c_value + "'";
  1741. } else {
  1742. cond_main += cond_c_value;
  1743. }
  1744. // set_key.push('cond_c' + z + '_' + X);
  1745. }
  1746. } catch (error) {
  1747. if (error.name == 'TypeError') {
  1748. } else {
  1749. alert("cond_c" + z + "_" + x + ": " + error.name)
  1750. }
  1751. }
  1752. } else {
  1753. // 附加條件 x > 1
  1754. // 子條件取值 : 條件連接 and or
  1755. try {
  1756. var cond_d_value = document.getElementById("cond_d" + z + "_" + x).value;
  1757. if (cond_d_value == '') {
  1758. // alert('附加條件 and/or 欄位未輸入')
  1759. } else {
  1760. X = X + 1;
  1761. // if (X > 13) {
  1762. // alert("[X > 13] 子條件數不得超過 13 項")
  1763. // break
  1764. // }
  1765. // set_key.push('cond_d' + z + '_' + X);
  1766. set_key.push('cond_d' + Z + '_' + X);
  1767. set_value.push(cond_d_value);
  1768. cond_add_data += cond_d_value + ' ';
  1769. }
  1770. } catch (error) {
  1771. if (error.name == 'TypeError') {
  1772. } else {
  1773. alert("cond_d" + z + "_" + x + ": " + error.name)
  1774. }
  1775. }
  1776. // 感測器取值 :
  1777. try {
  1778. var cond_a_value = document.getElementById("cond_a" + z + "_" + x).value;
  1779. if (cond_a_value == '') {
  1780. // alert('附加條件 感測器 欄位未輸入')
  1781. } else {
  1782. // set_key.push('cond_a' + z + '_' + X);
  1783. set_key.push('cond_a' + Z + '_' + X);
  1784. set_value.push(cond_a_value);
  1785. cond_add_data += cond_a_value + ' ';
  1786. }
  1787. } catch (error) {
  1788. if (error.name == 'TypeError') {
  1789. } else {
  1790. alert("cond_a" + z + "_" + x + ": " + error.name)
  1791. }
  1792. }
  1793. // 子條件取值 : 條件中 > = <
  1794. try {
  1795. var cond_b_value = document.getElementById("cond_b" + z + "_" + x).value;
  1796. if (cond_b_value == '') {
  1797. // alert('附加條件 比較運算子 欄位未輸入')
  1798. } else {
  1799. // set_key.push('cond_b' + z + '_' + X);
  1800. set_key.push('cond_b' + Z + '_' + X);
  1801. set_value.push(cond_b_value);
  1802. // if (cond_b_value == 'MoreThan') { cond_main += '> '; }
  1803. // else if (cond_b_value == 'MoreThanEqualTo') { cond_main += '>= '; }
  1804. // else if (cond_b_value == 'Equal') { cond_main += '== '; }
  1805. // else if (cond_b_value == 'LessThanEqualTo') { cond_main += '<= '; }
  1806. // else if (cond_b_value == 'LessThan') { cond_main += '< '; }
  1807. cond_add_data += cond_b_value;
  1808. }
  1809. } catch (error) {
  1810. if (error.name == 'TypeError') {
  1811. } else {
  1812. alert("cond_b" + z + "_" + x + ": " + error.name)
  1813. }
  1814. }
  1815. // 子條件取值 : 條件右 ON / OFF / 輸入數值
  1816. try {
  1817. var cond_c_value = document.getElementById("cond_c" + z + "_" + x).value;
  1818. if (cond_c_value == '') {
  1819. // alert('附加條件 數值 欄位未輸入')
  1820. } else {
  1821. // console.log("Ctest: " + cond_c_value)
  1822. set_key.push('cond_c' + Z + '_' + X);
  1823. set_value.push(cond_c_value);
  1824. if (relay_obj2act['tankstatus'].includes(cond_c_value)) {
  1825. cond_add_data += " '" + cond_c_value + "'";
  1826. } else {
  1827. cond_add_data += " " + cond_c_value;
  1828. }
  1829. // set_key.push('cond_c' + z + '_' + X);
  1830. }
  1831. } catch (error) {
  1832. if (error.name == 'TypeError') {
  1833. } else {
  1834. alert("cond_c" + z + "_" + x + ": " + error.name)
  1835. }
  1836. }
  1837. if (cond_add_data != '') {
  1838. console.log("cond_add_list: " + cond_add_list)
  1839. console.log("cond_add_data: " + cond_add_data)
  1840. cond_add_list.push(cond_add_data)
  1841. }
  1842. }
  1843. }
  1844. // 子 物件動作 取值
  1845. Y = 0;
  1846. cond_com_list = [];
  1847. for (let y = 1; y <= act_add_child_i; y++) {
  1848. cond_com_data = '';
  1849. // 子物件動作取值 : 物件 do_obj1_1
  1850. try {
  1851. var do_obj_value = document.getElementById("do_obj" + z + "_" + y).value;
  1852. // console.log("do_obj" + z + "_" + y + " : " + do_obj_value)
  1853. if (do_obj_value == '') {
  1854. // alert('物件 欄位未輸入')
  1855. } else {
  1856. Y = Y + 1;
  1857. // if (Y > 20) {
  1858. // alert("[Y > 20] 子物件數不得超過 20 項")
  1859. // break
  1860. // }
  1861. set_key.push('do_obj' + Z + '_' + Y);
  1862. set_value.push(do_obj_value);
  1863. cond_com_data += do_obj_value + ' ';
  1864. }
  1865. } catch (error) {
  1866. if (error.name == 'TypeError') {
  1867. } else {
  1868. alert("do_obj" + z + "_" + y + ": " + error.name)
  1869. }
  1870. }
  1871. // 子物件動作取值 : 動作 do_act1_1
  1872. try {
  1873. var do_act_value = document.getElementById("do_act" + z + "_" + y).value;
  1874. // console.log("do_act" + z + "_" + y + " : " + do_act_value)
  1875. if (do_act_value == '') {
  1876. // alert('動作 欄位未輸入')
  1877. } else {
  1878. set_key.push('do_act' + Z + '_' + Y);
  1879. // if (DRY_CONTAINER_STATUS[do_act_value] != undefined ) {
  1880. // console.log("=== != undefined ===")
  1881. // console.log(DRY_CONTAINER_STATUS[do_act_value])
  1882. // set_value.push(DRY_CONTAINER_STATUS[do_act_value]);
  1883. // cond_com_data += DRY_CONTAINER_STATUS[do_act_value];
  1884. // cond_com_list.push(cond_com_data);
  1885. // } else {
  1886. set_value.push(do_act_value);
  1887. cond_com_data += do_act_value;
  1888. cond_com_list.push(cond_com_data);
  1889. // }
  1890. }
  1891. } catch (error) {
  1892. if (error.name == 'TypeError') {
  1893. } else {
  1894. alert("do_act" + z + "_" + y + ": " + error.name)
  1895. }
  1896. }
  1897. }
  1898. // ===== 0324 測試 OK 勿刪 ===================================================
  1899. var A = 1;
  1900. var B = 1;
  1901. console.log("cond_add_list: " + cond_add_list);
  1902. console.log("cond_com_list: " + cond_com_list);
  1903. if (cond_main != '') {
  1904. TT['cond_main' + Z] = cond_main;
  1905. for (let a = 0; a < cond_add_list.length; a++) {
  1906. TT['cond_add'+ Z + '_' + A] = cond_add_list[a];
  1907. A = A + 1;
  1908. }
  1909. for (let b = 0; b < cond_com_list.length; b++) {
  1910. TT['cond_com'+ Z + '_' + B] = cond_com_list[b];
  1911. B = B + 1;
  1912. }
  1913. cond_item.push(
  1914. '{"cond_main":"' + cond_main + '", ' +
  1915. '"cond_add":["' + cond_add_list.join('", "') + '"], ' +
  1916. '"cond_com":["' + cond_com_list.join('", "') + '"]}'
  1917. )
  1918. }
  1919. console.log("cond_add_list.length: " + cond_add_list.length + "__" + typeof(cond_add_list.length))
  1920. console.log("TT['addLength']: " + TT['addLength'] + "__" + typeof(TT['addLength']))
  1921. if (cond_add_list.length > TT['addLength']) {
  1922. TT['addLength'] = cond_add_list.length
  1923. }
  1924. if (cond_com_list.length > TT['comLength']) {
  1925. TT['comLength'] = cond_com_list.length
  1926. }
  1927. }
  1928. // ========================================================
  1929. TT['mainLength'] = Z
  1930. console.log("***TT['mainLength']: " + TT['mainLength']);
  1931. console.log("***TT['addLength']: " + TT['addLength']);
  1932. console.log("***TT['comLength']: " + TT['comLength']);
  1933. TT['tank_num'] = $('#prog_tank').find(':selected').val();
  1934. // ========================================================
  1935. document.getElementById('show_Value').innerText = '"cond": [' + cond_item + ']';
  1936. }
  1937. function getValue(){
  1938. var confirm_getValue = confirm("請確認積木條件無誤後, 再按下 [確認] :");
  1939. if (!confirm_getValue) {
  1940. alert("已取消積木取值測試");
  1941. } else {
  1942. showValue();
  1943. }
  1944. }
  1945. function MQTTgetValue() {
  1946. var confirm_getValue = confirm("請確認積木條件無誤後, 再按下 [確認] :");
  1947. if (!confirm_getValue) {
  1948. alert("已取消積木取值測試");
  1949. } else {
  1950. showValue();
  1951. var msg_data;
  1952. $.get('/dry_block_format', TT, function (res) {
  1953. // alert("MQTT OK")
  1954. document.getElementById('show_MQTTcommand').innerText = JSON.stringify(res.response);
  1955. msg_data = JSON.stringify(res.response);
  1956. // 存值
  1957. var prog_tank_data = $('#prog_tank').find(':selected').val();
  1958. var SQL_insert = 'INSERT INTO `block_cond_dry_t` (' +
  1959. '`datetime`, `UserName`, `tank_num`, `cond`) VALUES (' +
  1960. 'current_timestamp(), \'' + USERNAME + '\', \'' + prog_tank_data + '\', \''
  1961. + String(msg_data).replaceAll("'", "") + '\');';
  1962. console.log("SQL_insert: " + SQL_insert);
  1963. sql_data = { "sql" : SQL_insert };
  1964. $.get('/sql_get', sql_data, function (res) {
  1965. // alert("OK")
  1966. }, 'json');
  1967. }, 'json');
  1968. }
  1969. }
  1970. </script>
  1971. <!-- 條件物件 ++ -- -->
  1972. <script>
  1973. function act_add(evt) {
  1974. evt.style.display = "none";
  1975. var actadd_parent_num = String(evt.id).split('_')[1].slice(3, )
  1976. // console.log("actadd_parent_num: " + actadd_parent_num)
  1977. act_add_child_i++;
  1978. var html = '';
  1979. html +=
  1980. '<div id="action' + actadd_parent_num + '_' + act_add_child_i + '">' +
  1981. '物件 ' +
  1982. '<select id="do_obj' + actadd_parent_num + '_' + act_add_child_i + '" onChange="renew(\'' + actadd_parent_num + '_' + act_add_child_i + '\', this.selectedIndex);">' +
  1983. // '<option value=" ">制動器 / 暫停秒數 / 桶槽狀態</option>' +
  1984. pin_data_relay_option +
  1985. // '<option value="input_vacuum_status">入料儲豆槽真空吸料機</option>' +
  1986. // '<option value="tank_vacuum_status">真空吸料機</option>' +
  1987. // '<option value="tank_threewayvalve_vacuum_status">吸料機三通閥</option>' +
  1988. // '<option value="tank_solenoid_disinfect_status">消毒電磁閥</option>' +
  1989. // '<option value="tank_motor_status">馬達</option>' +
  1990. // '<option value="outer_solenoid_water_status">桶外進水電磁閥</option>' +
  1991. // '<option value="tank_solenoid_water_out_status">廢水排水電磁閥</option>' +
  1992. // '<option value="tank_heater1_status">加熱棒 1</option>' +
  1993. // '<option value="tank_heater2_status">加熱棒 2</option>' +
  1994. // '<option value="tank_temp_enable">溫控開關</option>' +
  1995. // '<option value="tank_temp">溫度設定</option>' +
  1996. // '<option value="tank_diskvalve_status">蝴蝶閥</option>' +
  1997. // '<option value="output_vacuum_status">出料儲豆槽真空吸料機</option>' +
  1998. // '<option value="tank_magneticSwitch_status">電磁開關</option>' +
  1999. // '<option value="tank_emergencySwitch_status">緊急開關</option>' +
  2000. // '<option value="tank_camera_status">攝影機</option>' +
  2001. // '<option value="tank_warningLight_status">警示燈</option>' +
  2002. '</select> ' +
  2003. '動作 ' +
  2004. '<div id="do_action' + actadd_parent_num + '_' + act_add_child_i + '" style="display: inline-block;">' +
  2005. '</div>' +
  2006. // '<select id="do_act' + actadd_parent_num + '_' + act_add_child_i + '">' +
  2007. // '<option value="">請由左方選取物件</option>' +
  2008. // '</select> ' +
  2009. '<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 + '\');">' +
  2010. '<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>' +
  2011. '</div>';
  2012. var divbox = document.getElementById('action' + actadd_parent_num);
  2013. divbox.insertAdjacentHTML('beforeend', html);
  2014. }
  2015. function act_del(evt) {
  2016. var del_action = document.getElementById('action' + evt);
  2017. del_action.innerHTML = ""
  2018. var parentObj = del_action.parentNode; // 取得欲刪除 div 的父類別
  2019. parentObj.removeChild(del_action) // 刪除 div
  2020. var del_act_parent_num = String(evt).split('_')[0]
  2021. var del_act_child_num = String(evt).split('_')[1]
  2022. // console.log('del_act_parent_num: ' + del_act_parent_num)
  2023. // console.log('del_act_child_num: ' + del_act_child_num)
  2024. var button_return_id = document.getElementById('act_add' + del_act_parent_num + '_' + String(parseInt(del_act_child_num)-1));
  2025. // console.log("test: " + 'cond_add' + del_act_parent_num + '_' + String(parseInt(del_act_child_num)-1))
  2026. // console.log("button_return_id: " + button_return_id) // null
  2027. if (button_return_id == null) {
  2028. var button_return_id = document.getElementById('act_add' + del_act_parent_num + '_1');
  2029. }
  2030. button_return_id.style.display = "inline";
  2031. }
  2032. // --------------------------------------------------------------------------------------------------
  2033. function cond_add(evt) { // cond_add1_1 下一個是 cond_add1(條件)_2(子條件)
  2034. evt.style.display = "none"; // 不顯示原按鈕
  2035. var condadd_parent_num = String(evt.id).split('_')[1].slice(3, ) // 把第一個條件的編號記下
  2036. // console.log("condadd_parent_num: " + condadd_parent_num)
  2037. cond_add_child_i++
  2038. var html = '';
  2039. html +=
  2040. '<div id="condition' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  2041. '<select id="cond_d' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  2042. '<option value=""></option>' +
  2043. '<option value="&&">&&</option>' +
  2044. '<option value="||">||</option>' +
  2045. '</select> ' +
  2046. '<select id="cond_a' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  2047. pin_data_sensor_option +
  2048. '<option value="tankstatus">tankstatus</option>' +
  2049. '</optgroup>' +
  2050. '</select> ' +
  2051. '<select id="cond_b' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  2052. '<option value=""></option>' +
  2053. '<option value=">">&gt;</option>' +
  2054. '<option value=">=">&gt;=</option>' +
  2055. '<option value="==">==</option>' +
  2056. '<option value="<=">&lt;=</option>' +
  2057. '<option value="<">&lt;</option>' +
  2058. '</select> ' +
  2059. '<input list="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '" id="cond_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  2060. '<datalist id="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  2061. '<option value="on">ON</option>' +
  2062. '<option value="off">OFF</option>' +
  2063. '<option value="">(或請自行輸入數值)</option>' +
  2064. '<option value="Waiting">空桶等待</option>' +
  2065. '<option value="InputtingBean">入豆中</option>' +
  2066. '<option value="InputtingBean_Pause">入豆暫停</option>' +
  2067. '<option value="InputtingBean_Finish">入豆完成</option>' +
  2068. '<option value="InputtingWater">夾層入水</option>' +
  2069. '<option value="Drying">乾燥中</option>' +
  2070. '<option value="Drying_Finish">乾燥完成</option>' +
  2071. '<option value="OutputtingBean">可出豆</option>' +
  2072. '<option value="OutputtingBean_Finish">出豆完成</option>' +
  2073. '</datalist> ' +
  2074. '<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 + '\');">' +
  2075. '<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>' +
  2076. '</div>';
  2077. var divbox = document.getElementById('condition' + condadd_parent_num);
  2078. divbox.insertAdjacentHTML('beforeend', html);
  2079. }
  2080. function cond_del(evt) {
  2081. // console.log('evt: ' + evt)
  2082. var del_cond_child = document.getElementById('condition' + evt);
  2083. // console.log("del_cond_child: " + del_cond_child)
  2084. del_cond_child.innerHTML = ""
  2085. var parentObj = del_cond_child.parentNode; // 取得欲刪除 div 的父類別
  2086. parentObj.removeChild(del_cond_child) // 刪除 div
  2087. // 上一個按鈕要顯示出來
  2088. var del_cond_parent_num = String(evt).split('_')[0]
  2089. var del_cond_child_num = String(evt).split('_')[1]
  2090. console.log('del_cond_parent_num: ' + del_cond_parent_num)
  2091. console.log('del_cond_child_num: ' + del_cond_child_num)
  2092. var button_return_id = document.getElementById('cond_add' + del_cond_parent_num + '_' + String(parseInt(del_cond_child_num)-1));
  2093. console.log("test: " + 'cond_add' + del_cond_parent_num + '_' + String(parseInt(del_cond_child_num)-1))
  2094. console.log("button_return_id: " + button_return_id) // null
  2095. if (button_return_id == null) {
  2096. var button_return_id = document.getElementById('cond_add' + del_cond_parent_num + '_1');
  2097. }
  2098. try {
  2099. button_return_id.style.display = "inline";
  2100. } catch (error) {
  2101. if (error.name !== 'TypeError') {
  2102. alert("cond_add" + del_cond_parent_num + "_" + String(parseInt(del_cond_child_num)-1) + " 子條件刪除錯誤\n" +
  2103. error.name + "\n" +
  2104. error.message);
  2105. }
  2106. }
  2107. }
  2108. // -------------------------------------------------------------------------------------------------------------
  2109. function Add(evt) { // 網頁初始按鈕 onclick="Add(add1);
  2110. evt.style.display = "none"; // 元素不顯示。將 add1 的 input-button 不顯示
  2111. new_condition_i++; // 設定編號用
  2112. // var div = document.createElement('div'); // 輸出 <div></div>。此時並不會顯示,
  2113. // 需透過 appendChild()、insertBefore() 或 replaceChild() 等方法將新元素加入至指定的位置之後才會顯示。
  2114. // var cond_number = String(evt).slice(3, ) // 目前的 condition 條件物件動作 數 (最外層)
  2115. // var cond_a = 'cond_a' + cond_number + '_' + new_condition_i; // [條件] 左方 : 制動器感測器
  2116. // var cond_b = 'cond_b' + cond_number + '_' + new_condition_i; // [條件] 中間 : > / = / <
  2117. // var cond_c = 'cond_c' + cond_number + '_' + new_condition_i; // [條件] 右方 : ON / OFF / 數值
  2118. // var cond_d = 'cond_d' + cond_number + '_' + new_condition_i; // 條件] 最左方條件連接 : and / or
  2119. // div.id = 'newcondition_' + new_condition_i; // 設定 div 的 id
  2120. // div.style.marginTop = "10px"; // 新增的 div 設定 marginTop 屬性值
  2121. var html = ''
  2122. // 新增的條件
  2123. html +=
  2124. '<div id="newcondition_' + new_condition_i + '" class="newcondition_css">' +
  2125. // 新增的分隔線
  2126. // '<hr size="50" width="100%">' +
  2127. '<div id="condition' + new_condition_i + '">' +
  2128. '<div id="condition' + new_condition_i + '_1">' +
  2129. '條件 ' +
  2130. '<select id="cond_z' + new_condition_i + '_1">' +
  2131. '<option value="if">if</option>' +
  2132. '<option value="else if">else if</option>' +
  2133. '<option value="else">else</option>' +
  2134. '</select> ' +
  2135. '<select id="cond_a' + new_condition_i + '_1">' +
  2136. pin_data_sensor_option +
  2137. '<option value="tankstatus">tankstatus</option>' +
  2138. '</optgroup>' +
  2139. '</select> ' +
  2140. '<select id="cond_b' + new_condition_i + '_1">' +
  2141. '<option value=""></option>' +
  2142. '<option value=">">&gt;</option>' +
  2143. '<option value=">=">&gt;=</option>' +
  2144. '<option value="==">==</option>' +
  2145. '<option value="<=">&lt;=</option>' +
  2146. '<option value="<">&lt;</option>' +
  2147. '</select> ' +
  2148. '<input list="cond_list_c' + new_condition_i + '_1" id="cond_c' + new_condition_i + '_1">' +
  2149. '<datalist id="cond_list_c' + new_condition_i + '_1">' +
  2150. '<option value="on">ON</option>' +
  2151. '<option value="off">OFF</option>' +
  2152. '<option value="">(或請自行輸入數值)</option>' +
  2153. '<option value="Waiting">空桶等待</option>' +
  2154. '<option value="InputtingBean">入豆中</option>' +
  2155. '<option value="InputtingBean_Pause">入豆暫停</option>' +
  2156. '<option value="InputtingBean_Finish">入豆完成</option>' +
  2157. '<option value="InputtingWater">夾層入水</option>' +
  2158. '<option value="Drying">乾燥中</option>' +
  2159. '<option value="Drying_Finish">乾燥完成</option>' +
  2160. '<option value="OutputtingBean">可出豆</option>' +
  2161. '<option value="OutputtingBean_Finish">出豆完成</option>' +
  2162. '</datalist> ' +
  2163. '<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>' +
  2164. '</div></div>';
  2165. // 新增的物件動作
  2166. html +=
  2167. '<div id="action' + new_condition_i + '">' +
  2168. '<div id="action' + new_condition_i + '_1">' +
  2169. '物件 ' +
  2170. '<select id="do_obj' + new_condition_i + '_1" onChange="renew(\''+ new_condition_i + '_1\', this.selectedIndex);">' +
  2171. pin_data_relay_option +
  2172. '</select>' +
  2173. '動作 ' +
  2174. '<div id="do_action' + new_condition_i + '_1" style="display: inline-block;">' +
  2175. '</div>' +
  2176. '<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>' +
  2177. '</div>' +
  2178. '</div>' +
  2179. // 新增的 條件物件動作++ 條件物件動作-- 按鈕
  2180. '<input type="button" class="input-delete" id="del' + new_condition_i + '" value="條件物件動作--" onclick="Delete(' + new_condition_i + ');"><br>' +
  2181. '<input type="button" class="input-add" id="add' + new_condition_i + '" value="條件物件動作++" onclick="Add(add' + new_condition_i + ');">' +
  2182. '</div>' ;
  2183. var divbox = document.getElementById('box');
  2184. divbox.insertAdjacentHTML('beforeend', html);
  2185. };
  2186. function Delete(evt) {
  2187. var del_condition = document.getElementById('newcondition_' + evt);
  2188. del_condition.innerHTML = ""
  2189. var parentObj = del_condition.parentNode; // 取得欲刪除 div 的父類別
  2190. parentObj.removeChild(del_condition) // 刪除 div
  2191. // 上一個按鈕要顯示出來
  2192. var button_return_id = document.getElementById('add' + String(parseInt(evt)-1));
  2193. if (button_return_id == null) {
  2194. var button_return_id = document.getElementById('add1');
  2195. }
  2196. // console.log('button_return_id: ' + button_return_id)
  2197. button_return_id.style.display = "block"; // 元素顯示。顯示前一個 input-button
  2198. };
  2199. // --------------------------------------------------------------------------------------
  2200. </script>
  2201. <!-- relay1 顯示框 -->
  2202. <div id="relay1" tabindex="0" role="button" class="div_relay_css"
  2203. style="top: 152px; left: 42px; width: 28px; height: 110px;">
  2204. </div>
  2205. <!-- relay2 顯示框 -->
  2206. <div id="relay2" tabindex="0" role="button" class="div_relay_css"
  2207. style="top: 152px; left: 85px; width: 28px; height: 110px;">
  2208. </div>
  2209. <!-- relay3 顯示框 -->
  2210. <div id="relay3" tabindex="0" role="button" class="div_relay_css"
  2211. style="top: 152px; left: 130px; width: 28px; height: 110px;">
  2212. </div>
  2213. <!-- relay4 顯示框 -->
  2214. <div id="relay4" tabindex="0" role="button" class="div_relay_css"
  2215. style="top: 152px; left: 170px; width: 28px; height: 110px;">
  2216. </div>
  2217. <!-- relay5 顯示框 -->
  2218. <div id="relay5" tabindex="0" role="button" class="div_relay_css"
  2219. style="top: 152px; left: 210px; width: 28px; height: 110px;">
  2220. </div>
  2221. <!-- relay6 顯示框 -->
  2222. <div id="relay6" tabindex="0" role="button" class="div_relay_css"
  2223. style="top: 152px; left: 250px; width: 28px; height: 110px;">
  2224. </div>
  2225. <!-- relay7 顯示框 -->
  2226. <div id="relay7" tabindex="0" role="button" class="div_relay_css"
  2227. style="top: 152px; left: 290px; width: 28px; height: 110px;">
  2228. </div>
  2229. <!-- relay8 顯示框 -->
  2230. <div id="relay8" tabindex="0" role="button" class="div_relay_css"
  2231. style="top: 152px; left: 335px; width: 28px; height: 110px;">
  2232. </div>
  2233. <!-- relay9 顯示框 -->
  2234. <div id="relay9" tabindex="0" role="button" class="div_relay_css"
  2235. style="top: 152px; left: 380px; width: 28px; height: 110px;">
  2236. </div>
  2237. <!-- relay10 顯示框 -->
  2238. <div id="relay10" tabindex="0" role="button" class="div_relay_css"
  2239. style="top: 152px; left: 420px; width: 28px; height: 110px;">
  2240. </div>
  2241. <!-- relay11 顯示框 -->
  2242. <div id="relay11" tabindex="0" role="button" class="div_relay_css"
  2243. style="top: 152px; left: 460px; width: 28px; height: 110px;">
  2244. </div>
  2245. <!-- relay12 顯示框 -->
  2246. <div id="relay12" tabindex="0" role="button" class="div_relay_css"
  2247. style="top: 152px; left: 504px; width: 28px; height: 110px;">
  2248. </div>
  2249. <!-- relay13 顯示框 -->
  2250. <div id="relay13" tabindex="0" role="button" class="div_relay_css"
  2251. style="top: 152px; left: 545px; width: 28px; height: 110px;">
  2252. </div>
  2253. <!-- relay14 顯示框 -->
  2254. <div id="relay14" tabindex="0" role="button" class="div_relay_css"
  2255. style="top: 152px; left: 585px; width: 28px; height: 110px;">
  2256. </div>
  2257. <!-- relay15 顯示框 -->
  2258. <div id="relay15" tabindex="0" role="button" class="div_relay_css"
  2259. style="top: 152px; left: 630px; width: 28px; height: 110px;">
  2260. </div>
  2261. <!-- relay16 顯示框 -->
  2262. <div id="relay16" tabindex="0" role="button" class="div_relay_css"
  2263. style="top: 152px; left: 670px; width: 28px; height: 110px;">
  2264. </div>
  2265. <!-- relay17 顯示框 -->
  2266. <div id="relay17" tabindex="0" role="button" class="div_relay_css"
  2267. style="top: 152px; left: 713px; width: 28px; height: 110px;">
  2268. </div>
  2269. <!-- relay18 顯示框 -->
  2270. <div id="relay18" tabindex="0" role="button" class="div_relay_css"
  2271. style="top: 152px; left: 755px; width: 28px; height: 110px;">
  2272. </div>
  2273. <!-- relay19 顯示框 -->
  2274. <div id="relay19" tabindex="0" role="button" class="div_relay_css"
  2275. style="top: 152px; left: 795px; width: 28px; height: 110px;">
  2276. </div>
  2277. <!-- relay20 顯示框 -->
  2278. <div id="relay20" tabindex="0" role="button" class="div_relay_css"
  2279. style="top: 152px; left: 840px; width: 28px; height: 110px;">
  2280. </div>
  2281. <!-- 類比 sensor_M4 顯示框 -->
  2282. <div id="sensor_M4" tabindex="0" role="button" class="div_relay_css"
  2283. style="top: 390px; left: 28px; width: 37px; height: 20px;">
  2284. </div>
  2285. <!-- 類比 sensor_M5 顯示框 -->
  2286. <div id="sensor_M5" tabindex="0" role="button" class="div_relay_css"
  2287. style="top: 420px; left: 28px; width: 37px; height: 20px;">
  2288. </div>
  2289. <!-- 類比 sensor_M7 顯示框 -->
  2290. <div id="sensor_M7" tabindex="0" role="button" class="div_relay_css"
  2291. style="top: 450px; left: 28px; width: 37px; height: 20px;">
  2292. </div>
  2293. <!-- PWM sensor_M10 顯示框 -->
  2294. <div id="sensor_M10" tabindex="0" role="button" class="div_relay_css"
  2295. style="top: 390px; left: 70px; width: 45px; height: 20px;">
  2296. </div>
  2297. <!-- PWM sensor_M2 顯示框 -->
  2298. <div id="sensor_M2" tabindex="0" role="button" class="div_relay_css"
  2299. style="top: 420px; left: 70px; width: 45px; height: 20px;">
  2300. </div>
  2301. <!-- PWM sensor_M3 顯示框 -->
  2302. <div id="sensor_M3" tabindex="0" role="button" class="div_relay_css"
  2303. style="top: 450px; left: 70px; width: 45px; height: 20px;">
  2304. </div>
  2305. <!-- 數位 sensor_M9 顯示框 -->
  2306. <div id="sensor_M9" tabindex="0" role="button" class="div_relay_css"
  2307. style="top: 480px; left: 28px; width: 37px; height: 20px;">
  2308. </div>
  2309. <!-- 數位 sensor_M12 顯示框 -->
  2310. <div id="sensor_M12" tabindex="0" role="button" class="div_relay_css"
  2311. style="top: 510px; left: 28px; width: 37px; height: 20px;">
  2312. </div>
  2313. <!-- 數位 sensor_M19 顯示框 -->
  2314. <div id="sensor_M19" tabindex="0" role="button" class="div_relay_css"
  2315. style="top: 535px; left: 28px; width: 37px; height: 20px;">
  2316. </div>
  2317. <!-- 數位 sensor_M14 顯示框 -->
  2318. <div id="sensor_M14" tabindex="0" role="button" class="div_relay_css"
  2319. style="top: 480px; left: 75px; width: 33px; height: 20px;">
  2320. </div>
  2321. <!-- 數位 sensor_M11 顯示框 -->
  2322. <div id="sensor_M11" tabindex="0" role="button" class="div_relay_css"
  2323. style="top: 510px; left: 75px; width: 33px; height: 20px;">
  2324. </div>
  2325. <!-- UART sensor_M16 顯示框 -->
  2326. <div id="sensor_M16" tabindex="0" role="button" class="div_relay_css"
  2327. style="top: 390px; left: 120px; width: 32px; height: 20px;">
  2328. </div>
  2329. <!-- UART sensor_M17 顯示框 -->
  2330. <div id="sensor_M17" tabindex="0" role="button" class="div_relay_css"
  2331. style="top: 420px; left: 120px; width: 32px; height: 20px;">
  2332. </div>
  2333. <!-- UART sensor_M18 顯示框 -->
  2334. <div id="sensor_M18" tabindex="0" role="button" class="div_relay_css"
  2335. style="top: 450px; left: 120px; width: 32px; height: 20px;">
  2336. </div>
  2337. <!-- i2c sensor_M15 顯示框 -->
  2338. <div id="sensor_M15" tabindex="0" role="button" class="div_relay_css"
  2339. style="top: 480px; left: 115px; width: 42px; height: 20px;">
  2340. </div>
  2341. <!-- 485 sensor_M8 顯示框 -->
  2342. <div id="sensor_M8" tabindex="0" role="button" class="div_relay_css"
  2343. style="top: 510px; left: 115px; width: 42px; height: 20px;">
  2344. </div>
  2345. <!-- ppa sensor_M6 顯示框 -->
  2346. <div id="sensor_M6" tabindex="0" role="button" class="div_relay_css"
  2347. style="top: 450px; left: 165px; width: 42px; height: 20px;">
  2348. </div>
  2349. <!-- ppa sensor_M13 顯示框 -->
  2350. <div id="sensor_M13" tabindex="0" role="button" class="div_relay_css"
  2351. style="top: 480px; left: 165px; width: 42px; height: 20px;">
  2352. </div>
  2353. <!-- ppa3 sensor_M1 顯示框 -->
  2354. <div id="sensor_M1" tabindex="0" role="button" class="div_relay_css"
  2355. style="top: 510px; left: 165px; width: 42px; height: 20px;">
  2356. </div>
  2357. <div id="coffee_footer">
  2358. <!-- 匯入共同使用的 footer.html 內容 -->
  2359. {% include 'footer.html' %}
  2360. <br>
  2361. <br>
  2362. </div>
  2363. </div>
  2364. </body>
  2365. </html>