board_loader-1.html 190 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201
  1. <!-- 宣告我們要套用模板 -->
  2. {% extends "base.html" %}
  3. {% block title %}{{ title }}{% endblock %}
  4. {% block script %}
  5. <script src="../static/js/blockly_compressed.js"></script>
  6. <script src="../static/js/blocks_compressed.js"></script>
  7. <script src="../static/js/en.js"></script>
  8. <script>
  9. var status = '{{status}}';
  10. var username = '{{username}}';
  11. $(document).ready(function(){
  12. $('#navbarDropdown_user_pc').text(username);
  13. $('#navbarDropdown_user_phone').text(username);
  14. });
  15. </script>
  16. <script language="JavaScript">
  17. // TODO 要考慮 初始生成幾個後, 在定義 new_condition_i = (現有的)+1, new_condition_i 是生成總條件的總條件數
  18. var new_condition_i // 總條件數
  19. var cond_add_child_i // 子條件數
  20. var act_add_child_i // 子物件數
  21. // 乾燥桶槽 積木條件狀態
  22. const COND1 = {{BCD.cond|tojson}};
  23. // console.log("COND1: " + COND1);
  24. const pin_data_relay = ['', '{{pin_data.R1}}','{{pin_data.R2}}','{{pin_data.R3}}','{{pin_data.R4}}',
  25. '{{pin_data.R5}}','{{pin_data.R6}}','{{pin_data.R7}}','{{pin_data.R8}}','{{pin_data.R9}}',
  26. '{{pin_data.R10}}','{{pin_data.R11}}','{{pin_data.R12}}','{{pin_data.R13}}','{{pin_data.R14}}',
  27. '{{pin_data.R15}}','{{pin_data.R16}}','{{pin_data.R17}}','{{pin_data.R18}}','{{pin_data.R19}}','{{pin_data.R20}}'
  28. ]
  29. const pin_data_sensor = ['', '{{pin_data.M1}}','{{pin_data.M2}}','{{pin_data.M3}}','{{pin_data.M4}}',
  30. '{{pin_data.M5}}','{{pin_data.M6}}','{{pin_data.M7}}','{{pin_data.M8}}','{{pin_data.M9}}',
  31. '{{pin_data.M10}}','{{pin_data.M11}}','{{pin_data.M12}}','{{pin_data.M13}}','{{pin_data.M14}}',
  32. '{{pin_data.M15}}','{{pin_data.M16}}','{{pin_data.M17}}','{{pin_data.M18}}','{{pin_data.M19}}'
  33. ]
  34. const pin_data_sensorHz = ['', '{{pin_data.M1_Hz}}','{{pin_data.M2_Hz}}','{{pin_data.M3_Hz}}','{{pin_data.M4_Hz}}',
  35. '{{pin_data.M5_Hz}}','{{pin_data.M6_Hz}}','{{pin_data.M7_Hz}}','{{pin_data.M8_Hz}}','{{pin_data.M9_Hz}}',
  36. '{{pin_data.M10_Hz}}','{{pin_data.M11_Hz}}','{{pin_data.M12_Hz}}','{{pin_data.M13_Hz}}','{{pin_data.M14_Hz}}',
  37. '{{pin_data.M15_Hz}}','{{pin_data.M16_Hz}}','{{pin_data.M17_Hz}}','{{pin_data.M18_Hz}}','{{pin_data.M19_Hz}}'
  38. ]
  39. console.log("pin_data_sensorHz: " + pin_data_sensorHz)
  40. const Tank_ID = '{{TankID}}';
  41. var pin_data_sensor_option = ''; // 腳位配置-sensor 匯出整理成 下拉式選單的選項
  42. var pin_data_relay_option = ''; // 腳位配置-relay 匯出整理成 下拉式選單的選項
  43. var set_Hz_sensor = '';
  44. $(function(){
  45. // 網頁 title
  46. $("#coffee_title_pc").text("板子燒錄程式");
  47. $("#coffee_title_phone").text("板子燒錄程式");
  48. // 使用者權限判斷
  49. // $('.select-input').prop('disabled', false);
  50. const pin_data_ethernet = '{{pin_data.ethernet}}';
  51. if (pin_data_ethernet == 'ON') {
  52. $("#select_ethernet_1").val('ON');
  53. }
  54. const pin_data_wifi = '{{pin_data.wifi}}';
  55. if (pin_data_wifi == 'ON') {
  56. $("#select_wifi_1").val('ON');
  57. }
  58. const pin_data_zigbee = '{{pin_data.zigbee}}';
  59. if (pin_data_zigbee == 'ON') {
  60. $("#select_zigbee_1").val('ON');
  61. }
  62. // tid 燒錄桶槽初始判斷
  63. if (Tank_ID.substring(0,2) === 'DI') {
  64. $("#prog_container").val('DI');
  65. renew_tank();
  66. $("#prog_tank").val(Tank_ID);
  67. } else if (Tank_ID.substring(0,2) === 'DO') {
  68. $("#prog_container").val('DO');
  69. renew_tank();
  70. $("#prog_tank").val(Tank_ID);
  71. } else if (Tank_ID.substring(0,1) === 'D') {
  72. $("#prog_container").val('D');
  73. renew_tank();
  74. $("#prog_tank").val(Tank_ID);
  75. } else if (Tank_ID.substring(0,2) === 'FI') {
  76. $("#prog_container").val('FI');
  77. renew_tank();
  78. $("#prog_tank").val(Tank_ID);
  79. } else if (Tank_ID.substring(0,2) === 'FO') {
  80. $("#prog_container").val('FO');
  81. renew_tank();
  82. $("#prog_tank").val(Tank_ID);
  83. } else if (Tank_ID.substring(0,1) === 'F') {
  84. $("#prog_container").val('F');
  85. renew_tank();
  86. $("#prog_tank").val(Tank_ID);
  87. } else if (Tank_ID.substring(0,2) === 'CI') {
  88. $("#prog_container").val('CI');
  89. renew_tank();
  90. $("#prog_tank").val(Tank_ID);
  91. } else if (Tank_ID.substring(0,1) === 'C') {
  92. $("#prog_container").val('C');
  93. renew_tank();
  94. $("#prog_tank").val(Tank_ID);
  95. } else if (Tank_ID.substring(0,1) === 'R') {
  96. $("#prog_container").val('R');
  97. renew_tank();
  98. $("#prog_tank").val(Tank_ID);
  99. } else if (Tank_ID.substring(0,2) === 'SO') {
  100. $("#prog_container").val('SO');
  101. renew_tank();
  102. $("#prog_tank").val(Tank_ID);
  103. } else if (Tank_ID.substring(0,1) === 'S') {
  104. $("#prog_container").val('S');
  105. renew_tank();
  106. $("#prog_tank").val(Tank_ID);
  107. } else if (Tank_ID.substring(0,2) === 'PO') {
  108. $("#prog_container").val('PO');
  109. renew_tank();
  110. $("#prog_tank").val(Tank_ID);
  111. } else if (Tank_ID.substring(0,1) === 'P') {
  112. $("#prog_container").val('P');
  113. renew_tank();
  114. $("#prog_tank").val(Tank_ID);
  115. } else {
  116. $("#prog_container").val('');
  117. $("#prog_tank").val('');
  118. }
  119. // 0531 0526 tttest start
  120. // 腳位配置-relay 匯出整理成 下拉式選單的選項
  121. pin_data_relay_option = '<option value=""></option>';
  122. for (let s_o = 0; s_o < pin_data_sensor.length; s_o++) {
  123. // console.log("pin_data_sensor[" + s_o + "]: " + pin_data_sensor[s_o]);
  124. if (pin_data_sensor[s_o] === 'Motor' || pin_data_sensor[s_o] === 'Servo') {
  125. pin_data_relay_option += '<option value="M' + s_o + '_' + pin_data_sensor[s_o] + '">M' + s_o + '_' + pin_data_sensor[s_o] + '</option>';
  126. }
  127. }
  128. for (let r_o = 1; r_o < pin_data_relay.length; r_o++) {
  129. if (pin_data_relay[r_o] !== '') {
  130. pin_data_relay_option += '<option value="R' + r_o + '_' + pin_data_relay[r_o] + '">R' + r_o + '_' + pin_data_relay[r_o] + '</option>';
  131. }
  132. }
  133. pin_data_relay_option += '<option value="sleep">sleep</option>' +
  134. '<option value="tankstatus">tankstatus</option>';
  135. // 腳位配置-sensor 匯出整理成 下拉式選單的選項
  136. // 感測器取值頻率 匯出整理成 輸入 range
  137. pin_data_sensor_option = '<option value=""></option>';
  138. for (let s_o = 0; s_o < pin_data_sensor.length; s_o++) {
  139. if (pin_data_sensor[s_o] !== '' && pin_data_sensor[s_o] !== 'Motor' && pin_data_sensor[s_o] !== 'Servo') {
  140. pin_data_sensor_option += '<option value="M' + s_o + '_' + pin_data_sensor[s_o] + '">M' + s_o + '_' + pin_data_sensor[s_o] + '</option>';
  141. set_Hz_sensor += 'M' + s_o + '_' + pin_data_sensor[s_o] + ' 取值頻率 ' +
  142. '<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)">' +
  143. '<span id="M' + s_o + '_HzText">10 秒/次</span>' +
  144. '<br>';
  145. }
  146. }
  147. var SensorHz_div = document.getElementById("SensorHz");
  148. SensorHz_div.insertAdjacentHTML('beforeend', set_Hz_sensor);
  149. // 腳位配置-relay 匯出整理成 下拉式選單的選項
  150. for (let p_r = 1; p_r <= pin_data_relay.length; p_r++) {
  151. if (pin_data_relay[p_r] != '') {
  152. $("#select_relay_" + p_r).val(pin_data_relay[p_r]);
  153. }
  154. }
  155. // 腳位配置-sensor 匯出整理成 下拉式選單的選項
  156. for (let p_m = 1; p_m <= pin_data_sensor.length; p_m++) {
  157. if (pin_data_sensor[p_m] != '') {
  158. $("#selectSensor_M" + p_m).val(pin_data_sensor[p_m]);
  159. }
  160. }
  161. // 板子圖片顯示對應 relay、sensor
  162. for (let RelayNum = 1; RelayNum < 21; RelayNum++) {
  163. select_relay(RelayNum);
  164. }
  165. for (let SensorNum = 1; SensorNum < 20; SensorNum++) {
  166. selectSensor("M" + SensorNum);
  167. }
  168. // 感測器取值頻率
  169. // pin_data_sensorHz.length
  170. for (let SensorHzNum = 1; SensorHzNum < pin_data_sensorHz.length; SensorHzNum++) {
  171. try {
  172. var target_Hz_range = $("#M" + SensorHzNum + "_Hz");
  173. if (pin_data_sensorHz[SensorHzNum] !== '' && pin_data_sensorHz[SensorHzNum] !== 'None') {
  174. $("#M" + SensorHzNum + "_Hz").val(pin_data_sensorHz[SensorHzNum]);
  175. eval('showSensorHzValue("M" + SensorHzNum, pin_data_sensorHz[SensorHzNum])');
  176. }
  177. } catch (error) {
  178. // console.log("M" + SensorHzNum + "_Hz:" + error)
  179. }
  180. // var target_Hz_range = $("#M" + SensorHzNum + "_Hz");
  181. // // $("#M" + SensorHzNum + "_Hz").val(pin_data_sensorHz[SensorHzNum]);
  182. // console.log("target_Hz_range: " + target_Hz_range);
  183. // if (target_Hz_range) {
  184. // $("#M" + SensorHzNum + "_Hz").val(pin_data_sensorHz[SensorHzNum]);
  185. // } else {
  186. // }
  187. }
  188. try {
  189. var cond = JSON.parse(COND1); // cond: [object Object]
  190. // var cond = JSON.parse(COND1); // cond: [object Object]
  191. var cond_cond = cond.cond; // cond_cond: [object Object],[object Object]
  192. // console.log("cond_cond: " + cond_cond);
  193. // 取得總條件數、子條件數、子物件數最大值
  194. const COND_NUMS = cond_cond.length; // 總條件數
  195. // alert("COND_NUMS: " + COND_NUMS);
  196. var COND_ADD_NUMS_LIST = [];
  197. var COND_COM_NUMS_LIST = [];
  198. for (let Z = 0; Z < cond_cond.length; Z++) {
  199. COND_ADD_NUMS_LIST.push(cond_cond[Z].cond_add.length)
  200. COND_COM_NUMS_LIST.push(cond_cond[Z].cond_com.length)
  201. }
  202. // console.log("COND_ADD_NUMS_LIST: " + COND_ADD_NUMS_LIST);
  203. // console.log("COND_COM_NUMS_LIST: " + COND_COM_NUMS_LIST);
  204. const COND_ADD_NUMS = Math.max(...COND_ADD_NUMS_LIST)+1; // 子條件數
  205. const COND_COM_NUMS = Math.max(...COND_COM_NUMS_LIST); // 子物件數
  206. // console.log("COND_ADD_NUMS: " + COND_ADD_NUMS);
  207. // console.log("COND_COM_NUMS: " + COND_COM_NUMS);
  208. // 生成積木
  209. DBvalue_btn(COND_NUMS, COND_ADD_NUMS, COND_COM_NUMS);
  210. // 賦值
  211. for (let c_n = 0; c_n < cond_cond.length; c_n++) {
  212. // console.log("cond_cond[" + c_n + "]: " + cond_cond[c_n] + "_" + typeof(cond_cond[c_n]))
  213. if (typeof(cond_cond[c_n]) === 'object') {
  214. // main
  215. // console.log("cond_main: " + cond_cond[c_n].cond_main);
  216. var target_main = cond_cond[c_n].cond_main.split(' ');
  217. if (target_main[0] === 'else' && target_main[1] === 'if') {
  218. target_main[0] = target_main[0] + " " + target_main[1];
  219. target_main[1] = target_main[2];
  220. target_main[2] = target_main[3];
  221. target_main[3] = target_main[4];
  222. }
  223. $("#cond_z" + (c_n+1) + "_1").val(target_main[0]);
  224. $("#cond_a" + (c_n+1) + "_1").val(target_main[1]);
  225. $("#cond_b" + (c_n+1) + "_1").val(target_main[2]);
  226. $("#cond_c" + (c_n+1) + "_1").val(target_main[3]);
  227. // add
  228. // console.log("cond_add: " + cond_cond[c_n].cond_add + "_" + typeof(cond_cond[c_n].cond_add));
  229. if (typeof(cond_cond[c_n].cond_add) === 'object') {
  230. for (let add_n = 0; add_n < cond_cond[c_n].cond_add.length; add_n++) {
  231. // console.log("cond_cond[" + c_n + "].cond_add[" + add_n + "]: " + cond_cond[c_n].cond_add[add_n])
  232. var target_add = cond_cond[c_n].cond_add[add_n].split(' ');
  233. $("#cond_d" + (c_n+1) + "_" + (add_n+2) + "").val(target_add[0]);
  234. $("#cond_a" + (c_n+1) + "_" + (add_n+2) + "").val(target_add[1]);
  235. $("#cond_b" + (c_n+1) + "_" + (add_n+2) + "").val(target_add[2]);
  236. $("#cond_c" + (c_n+1) + "_" + (add_n+2) + "").val(target_add[3]);
  237. }
  238. }
  239. // com
  240. // console.log("cond_com: " + cond_cond[c_n].cond_com + "_" + typeof(cond_cond[c_n].cond_com));
  241. if (typeof(cond_cond[c_n].cond_com) === 'object') {
  242. for (let obj_n = 0; obj_n < cond_cond[c_n].cond_com.length; obj_n++) {
  243. // console.log("cond_cond[" + c_n + "].cond_com[" + obj_n + "]: " + cond_cond[c_n].cond_com[obj_n]) // R1_vacuum on
  244. var target_obj = cond_cond[c_n].cond_com[obj_n].split(' ');
  245. // console.log("target_obj: " + target_obj); // R1_vacuum,on
  246. // console.log(pin_data_relay_option.includes(target_obj[0]))
  247. if (pin_data_relay_option.includes(target_obj[0]) ) {
  248. // 物件動作包含此積木程式的物件
  249. $("#do_obj" + (c_n+1) + "_" + (obj_n+1) + "").val(target_obj[0]);
  250. // console.log('renew((' + (c_n+1) + ') + "_" + (' + (obj_n+1) + '))')
  251. eval('renew((c_n+1) + "_" + (obj_n+1))');
  252. $("#do_act" + (c_n+1) + "_" + (obj_n+1) + "").val(target_obj[1]);
  253. // console.log("target_obj[0]: " + target_obj[0]);
  254. if (target_obj[0] === 'sleep') {
  255. showSleepValue((c_n+1) + "_" + (obj_n+1), target_obj[1]);
  256. } else if (target_obj[0].includes("Motor")) {
  257. showMotorValue((c_n+1) + "_" + (obj_n+1), target_obj[1]);
  258. }
  259. }
  260. }
  261. }
  262. }
  263. }
  264. new_condition_i = COND_NUMS; // 總條件數
  265. cond_add_child_i = COND_ADD_NUMS; // 子條件數
  266. act_add_child_i = COND_COM_NUMS; // 子物件數
  267. } catch (error) {
  268. console.log("cond = JSON.parse(COND1) → catch error")
  269. DBvalue_btn(1, 2, 1);
  270. new_condition_i = 1; // 總條件數
  271. cond_add_child_i = 2; // 子條件數
  272. act_add_child_i = 1; // 子物件數
  273. }
  274. // console.log("new_condition_i: " + new_condition_i + "__type: " + typeof(new_condition_i))
  275. // console.log("cond_add_child_i: " + cond_add_child_i);
  276. // console.log("act_add_child_i: " + act_add_child_i);
  277. });
  278. var Z;
  279. var X;
  280. var Y;
  281. var TT = {}; // 將總條件句/附加條件句/物件動作句存入 字典, 後續傳給 dry_block_format 再組合
  282. </script>
  283. {% endblock %}
  284. {% block style %}
  285. <style>
  286. /* .boardpic_position {
  287. position: absolute;
  288. top: 80px;
  289. left: 25px;
  290. } */
  291. .r5_position {
  292. position: absolute;
  293. top: 160px;
  294. left: 310px;
  295. width: 40px;
  296. height: 150px;
  297. border-style: solid;
  298. border-color: aqua;
  299. }
  300. /* header */
  301. /* 文字輸入框 */
  302. .input-text {
  303. height: 25px;
  304. width: 40px;
  305. text-align: center;
  306. margin-left: 2px;
  307. margin-right: 5px;
  308. }
  309. /* 致動器狀態表格置中 */
  310. .label_ActuatorStatus {
  311. margin: auto;
  312. }
  313. /* 致動器 ON 樣式 */
  314. .input-button-on {
  315. color: #008CBA;
  316. border: 2px rgb(182, 181, 181) solid;
  317. background-color: whitesmoke;
  318. padding: 1px 3px;
  319. width: 45px;
  320. }
  321. /* 致動器 OFF 樣式 */
  322. .input-button-off {
  323. color: #707070;
  324. border: 2px rgb(192, 192, 192) solid;
  325. background-color: whitesmoke;
  326. padding: 1px 3px;
  327. width: 45px;
  328. }
  329. /* 輸入按鈕 */
  330. .input-button {
  331. font-size: 14px;
  332. color: #008CBA;
  333. border: 2px rgb(182, 181, 181) solid;
  334. background-color: whitesmoke;
  335. padding: 1px 3px;
  336. }
  337. /* 大表格樣式 */
  338. .table-all {
  339. font-size:18px;
  340. border:2px #cccccc solid;
  341. margin-left: 10px;
  342. margin-right: 10px;
  343. width: 98%;
  344. }
  345. /* footer */
  346. .footer{
  347. height: 40px;
  348. box-sizing: border-box;
  349. /* 設定footer絕對位置在底部 */
  350. position: absolute;
  351. bottom: 0px;
  352. width: 100%;
  353. background-color: #eee;
  354. text-align: center;
  355. }
  356. html, body {
  357. height: 100%;
  358. /* margin: 0; */
  359. position: relative;
  360. }
  361. #wrapper {
  362. /* 設定高度最小為100%, 如果內容區塊很多, 可以長大 */
  363. /* min-height: 100%; */
  364. /* 位置設為relative, 作為footer區塊位置的參考 */
  365. position: relative;
  366. }
  367. .div_relay_css {
  368. position: absolute;
  369. border-style: solid;
  370. border-color: transparent;
  371. text-align: center;
  372. font-size: 12px;
  373. }
  374. .div_analog_css {
  375. position: absolute;
  376. border-style: solid;
  377. border-color: transparent;
  378. text-align: center;
  379. font-size: 12px;
  380. }
  381. .div_digital_css {
  382. position: absolute;
  383. border-style: solid;
  384. border-color: transparent;
  385. text-align: center;
  386. font-size: 12px;
  387. }
  388. .div_PWM_css {
  389. position: absolute;
  390. border-style: solid;
  391. border-color: transparent;
  392. text-align: center;
  393. font-size: 12px;
  394. }
  395. .div_UART_css {
  396. position: absolute;
  397. border-style: solid;
  398. border-color: transparent;
  399. text-align: center;
  400. font-size: 12px;
  401. }
  402. .div_I2C_css {
  403. position: absolute;
  404. border-style: solid;
  405. border-color: transparent;
  406. text-align: center;
  407. font-size: 12px;
  408. }
  409. .div_485_css {
  410. position: absolute;
  411. border-style: solid;
  412. border-color: transparent;
  413. text-align: center;
  414. font-size: 12px;
  415. }
  416. .div_analog2_css {
  417. position: absolute;
  418. border-color: transparent;
  419. border-style: solid;
  420. text-align: center;
  421. font-size: 12px;
  422. }
  423. .demo {
  424. padding: 1rem;
  425. }
  426. </style>
  427. {% endblock %}
  428. {% block main %}
  429. <div id="wrapper" style="height: 1900px;">
  430. <table align="center">
  431. <!-- 選擇燒錄桶槽 -->
  432. <tr>
  433. <td colspan="5" align="center">
  434. <script>
  435. // 貨櫃-桶槽對應
  436. const containerTOtank = {
  437. 'CI':[{'CI1':'1'}, {'CI2':'2'}],
  438. 'C':[{'C1':'1'}, {'C2':'2'}, {'C3':'3'}, {'C4':'4'}],
  439. 'R':[{'R1':'1'}],
  440. 'S':[{'S1':'1'},{'S2':'2'}],
  441. 'SO':[{'SO1':'1'},{'SO2':'2'}],
  442. 'P':[{'P1':'1'},{'P2':'2'}],
  443. 'PO':[{'PO1':'1'},{'PO2':'2'}],
  444. 'FI':[{'FI1':'1'},{'FI2':'2'}],
  445. 'F':[{'F1':'1'}, {'F2':'2'}, {'F3':'3'}, {'F4':'4'}, {'F5':'5'}, {'F6':'6'},
  446. {'F7':'7'}, {'F8':'8'}, {'F9':'9'}, {'F10':'10'}, {'F11':'11'}, {'F12':'12'}],
  447. 'FO':[{'FO1':'1'}, {'FO2':'2'}],
  448. 'DI':[{'DI1':'1'}, {'DI2':'2'}],
  449. 'D':[{'D1':'1'}, {'D2':'2'}, {'D3':'3'}, {'D4':'4'}, {'D5':'5'}, {'D6':'6'},
  450. {'D7':'7'}, {'D8':'8'}, {'D9':'9'}, {'D10':'10'}, {'D11':'11'}, {'D12':'12'}],
  451. 'DO':[{'DO1':'1'}, {'DO2':'2'}]
  452. }
  453. </script>
  454. <h1 class="h3 mb-4 fw-normal"style="background-color: Silver; height: 50px; text-align:center;">選擇燒錄桶槽:</h1>
  455. <div style="height: 30px">
  456. <select id="prog_container" onchange="renew_tank()" class="select-input">
  457. <option value="CI">清洗入料槽</option>
  458. <option value="C">清洗槽</option>
  459. <option value="R">中水桶</option>
  460. <option value="S">色選機</option>
  461. <option value="SO">色選機出料槽</option>
  462. <option value="P">脫皮機</option>
  463. <option value="PO">脫皮機出料槽</option>
  464. <option value="FI">發酵入料槽</option>
  465. <option value="F">發酵槽</option>
  466. <option value="FO">發酵出料槽</option>
  467. <option value="DI">乾燥入料槽</option>
  468. <option value="D">乾燥槽</option>
  469. <option value="DO">乾燥出料槽</option>
  470. </select>
  471. <select id="prog_tank" onchange="" class="select-input">
  472. <option value="CI1">1</option>
  473. <option value="CI2">2</option>
  474. </select>
  475. <input type="button" class="btn btn-secondary" value="確認" onclick="GoToBoardLoaderPage()">
  476. </div>
  477. <script>
  478. function GoToBoardLoaderPage() {
  479. var target_tank = $("#prog_tank").val();
  480. var confirm_GoToBoardLoaderPage = confirm("目前燒錄桶槽為 " + Tank_ID + "\n點擊 [確定] 按鈕後, 前往指定燒錄桶槽介面 " + target_tank);
  481. if (confirm_GoToBoardLoaderPage) {
  482. location.href = "/board_loader_" + target_tank;
  483. }
  484. }
  485. </script>
  486. <br>
  487. </td>
  488. </tr>
  489. <!-- coffee1.0 板子圖片 -->
  490. <!-- 燒錄制動器 / 感測器 -->
  491. <center><tr>
  492. <td colspan="5" align="center">
  493. <h1 class="h3 mb-4 fw-normal"style="text-align:center; background-color: Silver; height: 50px; vertical-align: middle;">桶槽腳位設定:</h1>
  494. <input type="button" id= "crl_RF" class="btn btn-secondary" value="通訊介面設定">
  495. <input type="button" id= "crl" class="btn btn-secondary" value="致動器腳位設定">
  496. <input type="button" id= "crl_sensor" class="btn btn-secondary" value="感測器腳位設定">
  497. <input type="button" class="btn btn-secondary" value="保存腳位配置" onclick="ItemGetValueToDB()">
  498. </td>
  499. </tr></center>
  500. <tr style="height: 30px">
  501. </tr>
  502. <tr>
  503. <td style="width: 900px; vertical-align: top;">
  504. <div style="position:relative;">
  505. <!-- relay1 顯示框 -->
  506. <div id="relay1" tabindex="0" role="button" class="div_relay_css"
  507. style=" top: 45px; left: 20px; width: 28px; height: 110px;">
  508. </div>
  509. <!-- relay2 顯示框 -->
  510. <div id="relay2" tabindex="0" role="button" class="div_relay_css"
  511. style="top: 45px; left: 63px; width: 28px; height: 110px;">
  512. </div>
  513. <!-- relay3 顯示框 -->
  514. <div id="relay3" tabindex="0" role="button" class="div_relay_css"
  515. style="top: 45px; left: 103px; width: 28px; height: 110px;">
  516. </div>
  517. <!-- relay4 顯示框 -->
  518. <div id="relay4" tabindex="0" role="button" class="div_relay_css"
  519. style="top: 45px; left: 146px; width: 28px; height: 110px;">
  520. </div>
  521. <!-- relay5 顯示框 -->
  522. <div id="relay5" tabindex="0" role="button" class="div_relay_css"
  523. style="top: 45px; left: 189px; width: 28px; height: 110px;">
  524. </div>
  525. <!-- relay6 顯示框 -->
  526. <div id="relay6" tabindex="0" role="button" class="div_relay_css"
  527. style="top: 45px; left: 232px; width: 28px; height: 110px;">
  528. </div>
  529. <!-- relay7 顯示框 -->
  530. <div id="relay7" tabindex="0" role="button" class="div_relay_css"
  531. style="top: 45px; left: 275px; width: 28px; height: 110px;">
  532. </div>
  533. <!-- relay8 顯示框 -->
  534. <div id="relay8" tabindex="0" role="button" class="div_relay_css"
  535. style="top: 45px; left: 318px; width: 28px; height: 110px;">
  536. </div>
  537. <!-- relay9 顯示框 -->
  538. <div id="relay9" tabindex="0" role="button" class="div_relay_css"
  539. style="top: 45px; left: 361px; width: 28px; height: 110px;">
  540. </div>
  541. <!-- relay10 顯示框 -->
  542. <div id="relay10" tabindex="0" role="button" class="div_relay_css"
  543. style="top: 45px; left: 404px; width: 28px; height: 110px;">
  544. </div>
  545. <!-- relay11 顯示框 -->
  546. <div id="relay11" tabindex="0" role="button" class="div_relay_css"
  547. style="top: 45px; left: 447px; width: 28px; height: 110px;">
  548. </div>
  549. <!-- relay12 顯示框 -->
  550. <div id="relay12" tabindex="0" role="button" class="div_relay_css"
  551. style="top: 45px; left: 490px; width: 28px; height: 110px;">
  552. </div>
  553. <!-- relay13 顯示框 -->
  554. <div id="relay13" tabindex="0" role="button" class="div_relay_css"
  555. style="top: 45px; left: 533px; width: 28px; height: 110px;">
  556. </div>
  557. <!-- relay14 顯示框 -->
  558. <div id="relay14" tabindex="0" role="button" class="div_relay_css"
  559. style="top: 45px; left: 576px; width: 28px; height: 110px;">
  560. </div>
  561. <!-- relay15 顯示框 -->
  562. <div id="relay15" tabindex="0" role="button" class="div_relay_css"
  563. style="top: 45px; left: 619px; width: 28px; height: 110px;">
  564. </div>
  565. <!-- relay16 顯示框 -->
  566. <div id="relay16" tabindex="0" role="button" class="div_relay_css"
  567. style="top: 45px; left: 662px; width: 28px; height: 110px;">
  568. </div>
  569. <!-- relay17 顯示框 -->
  570. <div id="relay17" tabindex="0" role="button" class="div_relay_css"
  571. style="top: 45px; left: 705px; width: 28px; height: 110px;">
  572. </div>
  573. <!-- relay18 顯示框 -->
  574. <div id="relay18" tabindex="0" role="button" class="div_relay_css"
  575. style="top: 45px; left: 748px; width: 28px; height: 110px;">
  576. </div>
  577. <!-- relay19 顯示框 -->
  578. <div id="relay19" tabindex="0" role="button" class="div_relay_css"
  579. style="top: 45px; left: 791px; width: 28px; height: 110px;">
  580. </div>
  581. <!-- relay20 顯示框 -->
  582. <div id="relay20" tabindex="0" role="button" class="div_relay_css"
  583. style="top: 45px; left: 834px; width: 28px; height: 110px;">
  584. </div>
  585. <!-- 類比 sensor_M4 顯示框 -->
  586. <div id="sensor_M4" tabindex="0" role="button" class="div_analog_css"
  587. style="top: 290px; left: 0px; width: 42px; height: 20px;">
  588. </div>
  589. <!-- 類比 sensor_M5 顯示框 -->
  590. <div id="sensor_M5" tabindex="0" role="button" class="div_analog_css"
  591. style="top: 320px; left: 0px; width: 42px; height: 20px;">
  592. </div>
  593. <!-- 類比 sensor_M7 顯示框 -->
  594. <div id="sensor_M7" tabindex="0" role="button" class="div_analog_css"
  595. style="top: 350px; left: 0px; width: 42px; height: 20px;">
  596. </div>
  597. <!-- PWM sensor_M10 顯示框 -->
  598. <div id="sensor_M10" tabindex="0" role="button" class="div_PWM_css"
  599. style="top: 290px; left: 40px; width: 45px; height: 20px;">
  600. </div>
  601. <!-- PWM sensor_M2 顯示框 -->
  602. <div id="sensor_M2" tabindex="0" role="button" class="div_PWM_css"
  603. style="top: 320px; left: 40px; width: 45px; height: 20px;">
  604. </div>
  605. <!-- PWM sensor_M3 顯示框 -->
  606. <div id="sensor_M3" tabindex="0" role="button" class="div_PWM_css"
  607. style="top: 350px; left: 40px; width: 45px; height: 20px;">
  608. </div>
  609. <!-- 數位 sensor_M9 顯示框 -->
  610. <div id="sensor_M9" tabindex="0" role="button" class="div_digital_css"
  611. style="top: 380px; left: 0px; width: 42px; height: 20px;">
  612. </div>
  613. <!-- 數位 sensor_M12 顯示框 -->
  614. <div id="sensor_M12" tabindex="0" role="button" class="div_digital_css"
  615. style="top: 410px; left: 0px; width: 42px; height: 20px;">
  616. </div>
  617. <!-- 數位 sensor_M19 顯示框 -->
  618. <div id="sensor_M19" tabindex="0" role="button" class="div_digital_css"
  619. style="top: 440px; left: 0px; width: 42px; height: 20px;">
  620. </div>
  621. <!-- 數位 sensor_M14 顯示框 -->
  622. <div id="sensor_M14" tabindex="0" role="button" class="div_digital_css"
  623. style="top: 380px; left: 45px; width: 42px; height: 20px;">
  624. </div>
  625. <!-- 數位 sensor_M11 顯示框 -->
  626. <div id="sensor_M11" tabindex="0" role="button" class="div_digital_css"
  627. style="top: 410px; left: 45px; width: 42px; height: 20px;">
  628. </div>
  629. <!-- UART sensor_M16 顯示框 -->
  630. <div id="sensor_M16" tabindex="0" role="button" class="div_UART_css"
  631. style="top: 290px; left: 90px; width: 42px; height: 20px;">
  632. </div>
  633. <!-- UART sensor_M17 顯示框 -->
  634. <div id="sensor_M17" tabindex="0" role="button" class="div_UART_css"
  635. style="top: 320px; left: 90px; width: 42px; height: 20px;">
  636. </div>
  637. <!-- UART sensor_M18 顯示框 -->
  638. <div id="sensor_M18" tabindex="0" role="button" class="div_UART_css"
  639. style="top: 350px; left: 90px; width: 42px; height: 20px;">
  640. </div>
  641. <!-- i2c sensor_M15 顯示框 -->
  642. <div id="sensor_M15" tabindex="0" role="button" class="div_I2C_css"
  643. style="top: 380px; left: 90px; width: 45px; height: 20px;">
  644. </div>
  645. <!-- 485 sensor_M8 顯示框 -->
  646. <div id="sensor_M8" tabindex="0" role="button" class="div_485_css"
  647. style="top: 410px; left: 90px; width: 45px; height: 20px;">
  648. </div>
  649. <!-- ppa sensor_M6 顯示框 -->
  650. <div id="sensor_M6" tabindex="0" role="button" class="div_analog2_css"
  651. style="top: 350px; left: 140px; width: 42px; height: 20px;">
  652. </div>
  653. <!-- ppa sensor_M13 顯示框 -->
  654. <div id="sensor_M13" tabindex="0" role="button" class="div_analog2_css"
  655. style="top: 380px; left: 140px; width: 42px; height: 20px;">
  656. </div>
  657. <!-- ppa3 sensor_M1 顯示框 -->
  658. <div id="sensor_M1" tabindex="0" role="button" class="div_analog2_css"
  659. style="top: 410px; left: 140px; width: 42px; height: 20px;">
  660. </div>
  661. <img src="../static/img/board.png" style="width: 100%;">
  662. </div>
  663. </td>
  664. </tr>
  665. <!-- 感測器取值頻率 -->
  666. <tr>
  667. <td colspan="5">
  668. <span style="background-color: Silver">感測器取值頻率</span><br>
  669. <div id="SensorHz">
  670. </div><br>
  671. </td>
  672. </tr>
  673. <!-- 0526 積木測試 -->
  674. <!-- <tr>
  675. <td colspan="5" style="background-color:aqua">
  676. test
  677. </td>
  678. </tr> -->
  679. <!-- 積木程式 -->
  680. <tr>
  681. <td>
  682. 燒錄器 : <input type="text" id="burner_mac" value="b8:27:eb:7e:24:78"><br>
  683. <br>
  684. <span style="background-color: Silver">積木條件</span><br>
  685. <div class="demo">
  686. <div id="blocklyDiv" style="height: 400px; width: 100%;"></div>
  687. </div>
  688. <!--<span>入料儲豆槽為:{{tank_import}}</span><br>-->
  689. <!--<span>出料儲豆槽為:{{tank_export}}</span><br>-->
  690. <div id="DBvalue">
  691. <!-- 積木條件 -->
  692. </div>
  693. <script>
  694. // 指令燒錄桶槽時, 跳出桶槽選項
  695. var Value = '';
  696. function renew_tank() {
  697. var prog_container_value = $("#prog_container").val();
  698. // console.log("prog_container_value: " + prog_container_value);
  699. Value = '';
  700. try {
  701. for (let i = 0; i < containerTOtank[prog_container_value].length; i++) {
  702. Value += '<option value="' + Object.keys(containerTOtank[prog_container_value][i]) + '">' + Object.values(containerTOtank[prog_container_value][i]) + '</option>';
  703. }
  704. } catch (error) {
  705. if (error.name === 'TypeError') {
  706. Value = '';
  707. }
  708. }
  709. var sectorSelect = document.getElementById("prog_tank");
  710. if (sectorSelect != null) {
  711. sectorSelect.innerHTML = Value;
  712. }
  713. }
  714. function DBvalue_btn(z_notempty_NUM, a_notempty_NUM, o_notempty_NUM) {
  715. var html = '<div id="box">';
  716. for (let condadd_parent_num = 1; condadd_parent_num <= z_notempty_NUM; condadd_parent_num++) {
  717. html += '' +
  718. '<div id="newcondition_' + condadd_parent_num + '" class="newcondition_css">' +
  719. '<div id="condition' + condadd_parent_num + '">' +
  720. '<div id="condition' + condadd_parent_num + '_' + '1' + '">' +
  721. '條件 ' +
  722. '<select id="cond_z' + condadd_parent_num + '_' + '1' + '">' +
  723. '<option value="if">if</option>' +
  724. '<option value="else if">else if</option>' +
  725. '<option value="else">else</option>' +
  726. '</select> ' +
  727. '<select id="cond_a' + condadd_parent_num + '_' + '1' + '">' +
  728. pin_data_sensor_option +
  729. '<option value="tankstatus">tankstatus</option>' +
  730. '</select> ' +
  731. '<select id="cond_b' + condadd_parent_num + '_' + '1' + '">' +
  732. '<option value=""></option>' +
  733. '<option value=">">&gt;</option>' +
  734. '<option value=">=">&gt;=</option>' +
  735. '<option value="==">==</option>' +
  736. '<option value="<=">&lt;=</option>' +
  737. '<option value="<">&lt;</option>' +
  738. '</select> ' +
  739. '<input list="cond_list_c' + condadd_parent_num + '_' + '1' + '" id="cond_c' + condadd_parent_num + '_' + '1' + '">' +
  740. '<datalist id="cond_list_c' + condadd_parent_num + '_' + '1' + '">' +
  741. '<option value="on">ON</option>' +
  742. '<option value="off">OFF</option>' +
  743. '<option value="">(或請自行輸入數值)</option>' +
  744. '<option value="Waiting">空桶等待</option>' +
  745. '<option value="InputtingBean">入豆中</option>' +
  746. '<option value="InputtingBean_Pause">入豆暫停</option>' +
  747. '<option value="InputtingBean_Finish">入豆完成</option>' +
  748. '<option value="InputtingWater">夾層入水</option>' +
  749. '<option value="Drying">乾燥中</option>' +
  750. '<option value="Drying_Finish">乾燥完成</option>' +
  751. '<option value="OutputtingBean">可出豆</option>' +
  752. '<option value="OutputtingBean_Finish">出豆完成</option>' +
  753. '</datalist> ' +
  754. '<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>' +
  755. '</div>';
  756. for (let cond_add_child_i = 2; cond_add_child_i <= a_notempty_NUM; cond_add_child_i++) {
  757. // if (cond_d_data[condadd_parent_num][cond_add_child_i] == '') {
  758. // // alert("cond_d_data[" + condadd_parent_num + "][" + cond_add_child_i + " ] + 為空值")
  759. // continue
  760. // }
  761. html +=
  762. '<div id="condition' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  763. '<select id="cond_d' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  764. '<option value=""></option>' +
  765. '<option value="&&">&&</option>' +
  766. '<option value="||">||</option>' +
  767. '</select> ' +
  768. '<select id="cond_a' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  769. pin_data_sensor_option +
  770. '<option value="tankstatus">tankstatus</option>' +
  771. // '</optgroup>' +
  772. '</select> ' +
  773. '<select id="cond_b' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  774. '<option value=""></option>' +
  775. '<option value=">">&gt;</option>' +
  776. '<option value=">=">&gt;=</option>' +
  777. '<option value="==">==</option>' +
  778. '<option value="<=">&lt;=</option>' +
  779. '<option value="<">&lt;</option>' +
  780. '</select> ' +
  781. '<input list="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '" id="cond_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  782. '<datalist id="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  783. '<option value="on">ON</option>' +
  784. '<option value="off">OFF</option>' +
  785. '<option value="">(或請自行輸入數值)</option>' +
  786. '<option value="Waiting">空桶等待</option>' +
  787. '<option value="InputtingBean">入豆中</option>' +
  788. '<option value="InputtingBean_Pause">入豆暫停</option>' +
  789. '<option value="InputtingBean_Finish">入豆完成</option>' +
  790. '<option value="InputtingWater">夾層入水</option>' +
  791. '<option value="Drying">乾燥中</option>' +
  792. '<option value="Drying_Finish">乾燥完成</option>' +
  793. '<option value="OutputtingBean">可出豆</option>' +
  794. '<option value="OutputtingBean_Finish">出豆完成</option>' +
  795. '</datalist> ' +
  796. '<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 + '\');">';
  797. if (cond_add_child_i == 2) {
  798. html +=
  799. '<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>';
  800. } else {
  801. html +=
  802. '<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>';
  803. }
  804. html += '</div>';
  805. }
  806. html += '</div>';
  807. // 新增的物件動作
  808. html += '<div id="action' + condadd_parent_num + '">';
  809. for (let cond_add_child_i = 1; cond_add_child_i <= o_notempty_NUM; cond_add_child_i++) {
  810. // if (cond_obj_data[condadd_parent_num][cond_add_child_i] == '') {
  811. // // alert("cond_d_data[" + condadd_parent_num + "][" + cond_add_child_i + " ] + 為空值")
  812. // continue
  813. // }
  814. html +=
  815. '<div id="action' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  816. '物件 ' +
  817. '<select id="do_obj' + condadd_parent_num + '_' + cond_add_child_i + '" onChange="renew(\''+ condadd_parent_num + '_' + cond_add_child_i + '\', this.selectedIndex);">' +
  818. // '<option value=" ">制動器 / 暫停秒數 / 桶槽狀態</option>' +
  819. pin_data_relay_option +
  820. // '<option value="input_vacuum_status">入料儲豆槽真空吸料機</option>' +
  821. // '<option value="tank_vacuum_status">真空吸料機</option>' +
  822. // '<option value="tank_threewayvalve_vacuum_status">吸料機三通閥</option>' +
  823. // '<option value="tank_solenoid_disinfect_status">消毒電磁閥</option>' +
  824. // '<option value="tank_motor_status">馬達</option>' +
  825. // '<option value="outer_solenoid_water_status">桶外進水電磁閥</option>' +
  826. // '<option value="tank_solenoid_water_out_status">廢水排水電磁閥</option>' +
  827. // '<option value="tank_heater1_status">加熱棒 1</option>' +
  828. // '<option value="tank_heater2_status">加熱棒 2</option>' +
  829. // '<option value="tank_temp_enable">溫控開關</option>' +
  830. // '<option value="tank_temp">溫度設定</option>' +
  831. // '<option value="tank_diskvalve_status">蝴蝶閥</option>' +
  832. // '<option value="output_vacuum_status">出料儲豆槽真空吸料機</option>' +
  833. // '<option value="tank_magneticSwitch_status">電磁開關</option>' +
  834. // '<option value="tank_emergencySwitch_status">緊急開關</option>' +
  835. // '<option value="tank_camera_status">攝影機</option>' +
  836. // '<option value="tank_warningLight_status">警示燈</option>' +
  837. '</select>' +
  838. // '<select id="do_act' + new_condition_i + '_1">' +
  839. // '<option value="">請由左方選取物件' +
  840. // '</select> ' +
  841. ' 動作 ' +
  842. '<div id="do_action' + condadd_parent_num + '_' + cond_add_child_i + '" style="display: inline-block;">' +
  843. '</div>' +
  844. '<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 + '\');">';
  845. if (cond_add_child_i == 1) {
  846. html +=
  847. '<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>';
  848. } else {
  849. html +=
  850. '<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>';
  851. }
  852. html += '</div>';
  853. }
  854. html += '</div>';
  855. // 新增的 條件物件動作++ 條件物件動作-- 按鈕
  856. html += '<input type="button" class="input-delete" id="del' + condadd_parent_num + '" value="條件物件動作--" onclick="Delete(' + condadd_parent_num + ');"><br>' +
  857. '<input type="button" class="input-add" id="add' + condadd_parent_num + '" value="條件物件動作++" onclick="Add(add' + condadd_parent_num + ');">' +
  858. '</div><br>' ;
  859. }
  860. html += '</div>' ;
  861. var divbox = document.getElementById('DBvalue');
  862. divbox.insertAdjacentHTML('beforeend', html);
  863. }
  864. </script>
  865. <center><input type="button" class="btn btn-secondary" value="燒錄" onclick="prog_OTA();"></center>
  866. </td>
  867. </tr>
  868. <tr style="height: 30px">
  869. </tr>
  870. <tr>
  871. <td colspan="5" style="background-color: Silver; height: 50px; vertical-align: middle; text-align: center;">
  872. <h1 class="h3 mb-4 fw-normal">燒錄結果:</h1>
  873. </td>
  874. </tr>
  875. <script>
  876. function prog_creat_hex() {
  877. MQTTgetValue();
  878. $.ajax({
  879. type:"GET",
  880. url:"/creat_hex",
  881. data:TT,
  882. dataType:"text",
  883. async:false,
  884. success:function (res) {
  885. $("#creat_hex_Value").text(res);
  886. return 0;
  887. },
  888. error: function (thrownError) {
  889. alert(thrownError.statusText);
  890. $("#creat_hex_Value").text(thrownError.statusText);
  891. return 1;
  892. }
  893. })
  894. }
  895. var prog_result_interval;
  896. function programmer(params) {
  897. MQTTgetValue();
  898. var msg;
  899. $.ajax({
  900. type:"GET",
  901. url:"/creat_hex",
  902. data:TT,
  903. dataType:"text",
  904. async:false,
  905. success:function (res) {
  906. if(res=="NG")
  907. {
  908. $("#creat_hex_Value").text("生成hex檔失敗");
  909. }
  910. else
  911. {
  912. $("#creat_hex_Value").text("生成hex檔成功");
  913. }
  914. msg=res;
  915. }
  916. })
  917. if(msg=="NG")
  918. {
  919. $("#programmer_Value").text("上一步驟失敗");
  920. }
  921. else
  922. {
  923. var USERNAME = '{{username}}';
  924. var confirm_programmer = confirm("即將燒錄 Coffee1.0, 確定請按下 [確認] :");
  925. if (!confirm_programmer) {
  926. alert("已取消燒錄");
  927. }
  928. else {
  929. var prog_tank_data = $('#prog_tank').find(':selected').val();
  930. var prog_burner_mac = $('#burner_mac').val();
  931. console.log("prog_burner_mac: " + prog_burner_mac);
  932. var prog_data = {'tank':prog_tank_data,
  933. 'USERNAME': USERNAME,
  934. 'burner_mac':prog_burner_mac}
  935. $("#programmer_Value").text("準備燒錄...");
  936. $.get('/board_programmer', prog_data, function (res) {
  937. prog_result_interval = setInterval("board_programmer_result(\'" + prog_tank_data + "\')", 5000);
  938. }, 'text');
  939. }
  940. }
  941. }
  942. // 燒錄結果取值時判斷用
  943. var prog_tank_data = $('#prog_tank').find(':selected').val();
  944. var board_programmer_process = 0;
  945. function board_programmer_result(tid) {
  946. if (board_programmer_process == 1) {
  947. return;
  948. }
  949. board_programmer_process = 1;
  950. $.ajax({
  951. type:"GET",
  952. url:"/board_programmer_result_" + tid,
  953. dataType:"text",
  954. async:false,
  955. success:function(response){
  956. console.log("board_programmer_result: " + response);
  957. console.log(response != '0')
  958. if (response != '0') {
  959. $("#programmer_Value").text(response);
  960. alert("燒錄結果: " + response);
  961. clearInterval(prog_result_interval);
  962. }
  963. board_programmer_process = 0;
  964. },
  965. error: function(thrownError){
  966. console.log(thrownError);
  967. board_programmer_process = 0;
  968. }
  969. });
  970. }
  971. function prog_OTA() {
  972. //prog_creat_hex();
  973. programmer();
  974. }
  975. </script>
  976. <!-- 燒錄結果顯示 -->
  977. <tr>
  978. <td colspan="2">
  979. 積木條件 : <span id="show_MQTTcommand"></span>
  980. <br>
  981. <br>
  982. 生成hex檔:<span id="creat_hex_Value"></span>
  983. <br>
  984. <br>
  985. 燒錄hex檔:<span id="programmer_Value"></span>
  986. </td>
  987. </tr>
  988. </table>
  989. <!-- Relay、感測器選值時, 左側圖片顯示對應項目 -->
  990. <script>
  991. // 當右方的下拉式選單選擇時, 更新左方圖片上的文字 - relay
  992. function select_relay(id) {
  993. var select_relay_text = $("#select_relay_" + id).find(':selected').text()
  994. console.log("select_relay_text: " + select_relay_text)
  995. if (select_relay_text == '') {
  996. $("#relay" + id).text('');
  997. document.getElementById("relay" + id).style.backgroundColor = 'transparent';
  998. }
  999. else {
  1000. $("#relay" + id).text(select_relay_text);
  1001. document.getElementById("relay" + id).style.backgroundColor = 'transparent';
  1002. document.getElementById("relay" + id).style.color = 'white';
  1003. document.getElementById("relay" + id).style.fontWeight = '600';
  1004. }
  1005. }
  1006. var sensorlist = ['', '分壓類比', 'PWM', 'PWM', '類比', '類比', '分壓類比', '類比', '485', '數位',
  1007. 'PWM', '數位', '數位', '分壓類比', '數位', 'I2C', 'UART', 'UART', 'UART', '數位']
  1008. // selectSensor
  1009. function selectSensor(PinNum) {
  1010. var Pin_sensor = $("#selectSensor_" + PinNum).find(':selected').text();
  1011. // console.log("Pin_sensor: " + Pin_sensor)
  1012. if (Pin_sensor == '') {
  1013. $("#sensor_" + PinNum).text('');
  1014. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'transparent';
  1015. } else {
  1016. $("#sensor_" + PinNum).text(Pin_sensor);
  1017. // alert("sensorlist[PinNum]]\n" + sensorlist[PinNum.substring(1)])
  1018. document.getElementById("sensor_" + PinNum).style.backgroundColor = 'transparent';
  1019. document.getElementById("sensor_" + PinNum).style.color = 'white';
  1020. document.getElementById("sensor_" + PinNum).style.fontWeight = '600';
  1021. }
  1022. }
  1023. </script>
  1024. <!-- -->
  1025. <script>
  1026. var relay_data = ''; // 積木程式 制動器選項
  1027. var sensor_data = ''; // 積木程式 感測器選項
  1028. var obj_data = ''; // 積木程式 物件選項:桶槽狀態 暫停秒數
  1029. const list_R = ['R1','R2','R3','R4','R5','R6','R7','R8','R9','R10','R11','R12','R13','R14','R15','R16','R17','R18','R19','R20']
  1030. var list_relay_item = []; // R1~R20 對應的 relay 取值
  1031. const list_M = ['M1','M2','M3','M4','M5','M6','M7','M8','M9','M10','M11','M12','M13','M14','M15','M16','M17','M18','M19']
  1032. var list_sensor_item = []; // M1~M19 對應的 sensor 取值
  1033. const list_M_Hz = ['M1_Hz','M2_Hz','M3_Hz','M4_Hz','M5_Hz','M6_Hz','M7_Hz','M8_Hz','M9_Hz','M10_Hz',
  1034. 'M11_Hz','M12_Hz','M13_Hz','M14_Hz','M15_Hz','M16_Hz','M17_Hz','M18_Hz','M19_Hz'];
  1035. var list_sensorHz_item = [] // M1~M19 對應的取值頻率
  1036. function ItemGetValueToDB() {
  1037. var ethernet_text = $("#select_ethernet_1").find(':selected').val();
  1038. var wifi_text = $("#select_wifi_1").find(':selected').val();
  1039. var zigbee_text = $("#select_zigbee_1").find(':selected').val();
  1040. var tank_text = $('#prog_tank').find(':selected').val();
  1041. console.log("ethernet_text: " + ethernet_text);
  1042. console.log("wifi_text: " + wifi_text);
  1043. console.log("zigbee_text: " + zigbee_text);
  1044. console.log("tank_text: " + tank_text);
  1045. list_relay_item = [];
  1046. for (let i = 1; i < 21; i++) {
  1047. var relay_text = $("#select_relay_" + i).find(':selected').val();
  1048. if (relay_text != '') {
  1049. list_relay_item.push(relay_text);
  1050. } else {
  1051. list_relay_item.push('');
  1052. }
  1053. }
  1054. console.log("list_relay_item: " + list_relay_item);
  1055. list_sensor_item = [];
  1056. for (let i = 1; i < 20; i++) {
  1057. var sensor_text = $("#selectSensor_M" + i).find(':selected').val();
  1058. if (sensor_text != '') {
  1059. list_sensor_item.push(sensor_text);
  1060. } else {
  1061. list_sensor_item.push('');
  1062. }
  1063. }
  1064. console.log("list_sensor_item: " + list_sensor_item);
  1065. list_sensorHz_item = [];
  1066. // list_M_Hz = ['M1_Hz','M2_Hz','M3_Hz','M4_Hz','M5_Hz','M6_Hz','M7_Hz','M8_Hz','M9_Hz','M10_Hz',
  1067. // 'M11_Hz','M12_Hz','M13_Hz','M14_Hz','M15_Hz','M16_Hz','M17_Hz','M18_Hz','M19_Hz'];
  1068. // var list_sensorHz_item
  1069. for (let i = 1; i < 20; i++) {
  1070. var sensor_text = $("#M" + i + "_Hz").val();
  1071. if (sensor_text !== undefined) {
  1072. console.log("sensor_text: ", sensor_text);
  1073. list_sensorHz_item.push(sensor_text);
  1074. } else {
  1075. list_sensorHz_item.push('');
  1076. }
  1077. }
  1078. var SQL_insert = 'INSERT INTO `coffee1_0_pin` (' +
  1079. '`datetime`, `tid`, `ethernet`, `wifi`, `zigbee`, `' +
  1080. list_R.join("`, `") +
  1081. '`, `' +
  1082. list_M.join("`, `") +
  1083. '`, `' +
  1084. list_M_Hz.join("`, `") +
  1085. '`) VALUES (' +
  1086. 'current_timestamp(), "' + Tank_ID + '", "' + ethernet_text + '", "' + wifi_text + '", "' + zigbee_text + '", "' +
  1087. list_relay_item.join('", "') +
  1088. '", "' +
  1089. list_sensor_item.join('", "') +
  1090. '", "' +
  1091. list_sensorHz_item.join('", "') +
  1092. '")';
  1093. var sql_data = { "sql":SQL_insert };
  1094. console.log(sql_data)
  1095. $.get('/sql_get', sql_data, function (res) {
  1096. if (res['response'] == '') {
  1097. alert("OK");
  1098. } else {
  1099. alert(res['response']);
  1100. }
  1101. location.reload();
  1102. }, 'json');
  1103. // ItemGetValue();
  1104. // location.reload();
  1105. }
  1106. function ItemGetValue() {
  1107. list_relay_item = [];
  1108. // ethernet、wifi、zigbee 取值測試
  1109. // var select_ethernet_text = $("#select_ethernet_1").find(':selected').text()
  1110. // var select_wifi_text = $("#select_wifi_1").find(':selected').text()
  1111. // var select_zigbee_text = $("#select_zigbee_1").find(':selected').text()
  1112. // console.log("select_ethernet_text: " + select_ethernet_text)
  1113. // console.log("select_wifi_text: " + select_wifi_text)
  1114. // console.log("select_zigbee_text: " + select_zigbee_text)
  1115. // 制動器感測器 下拉式選單 不可更改
  1116. $('.select-input').prop('disabled', true);
  1117. // relay 取值
  1118. relay_dict = {};
  1119. for (let i = 1; i < 21; i++) {
  1120. var relay_text = $("#select_relay_" + i).find(':selected').val();
  1121. if (relay_text != '') {
  1122. relay_dict["R" + i] = "R" + i + "_" + relay_text;
  1123. // console.log("R" + i + " : " + relay_text);
  1124. list_relay_item.push(relay_text);
  1125. } else {
  1126. // relay_dict["R" + i] = "";
  1127. // console.log("R" + i + " : ");
  1128. list_relay_item.push('');
  1129. }
  1130. }
  1131. // console.log("list_relay_item: " + list_relay_item);
  1132. // relay_data = '<optgroup label="制動器狀態">';
  1133. relay_data = '<option value=""></option>';
  1134. for (let r in relay_dict) {
  1135. // console.log(r + " : " + relay_dict[r]);
  1136. relay_data += '<option value="' + relay_dict[r] + '">' + relay_dict[r] + '</option>';
  1137. }
  1138. relay_data += '<option value="sleep">sleep</option>' +
  1139. '<option value="tankstatus">tankstatus</option>';
  1140. // relay_data += '</optgroup>'
  1141. // console.log("relay_data: " + relay_data)
  1142. // sensor 取值 dict
  1143. sensor_dict = {};
  1144. for (let i = 1; i < 20; i++) {
  1145. var sensor_text = $("#selectSensor_M" + i).find(':selected').text();
  1146. if (sensor_text != '') {
  1147. sensor_dict["M" + i] = "M" + i + "_" + sensor_text;
  1148. // console.log("selectSensor_M" + i);
  1149. // console.log("M" + i + "_" + sensor_text);
  1150. } else {
  1151. // sensor_dict["M" + i] = "";
  1152. // console.log("selectSensor_M" + i);
  1153. // console.log("");
  1154. }
  1155. }
  1156. sensor_data = '';
  1157. // sensor_data = '<optgroup label="感測器數值">';
  1158. for (let s in sensor_dict) {
  1159. // console.log(s + " : " + sensor_dict[s])
  1160. sensor_data += '<option value="' + sensor_dict[s] + '">' + sensor_dict[s] + '</option>';
  1161. }
  1162. sensor_data += '<option value="tankstatus">tankstatus</option>';
  1163. // sensor_data += '</optgroup>';
  1164. // console.log("sensor_data: " + sensor_data)
  1165. console.log("relay_data: " + relay_data);
  1166. console.log("sensor_data: " + sensor_data);
  1167. var relay_select_data = document.getElementById("");
  1168. // // 賦值條件 a
  1169. // var sectorSelect = document.getElementById("cond_a1_1");
  1170. // sectorSelect.innerHTML = '<option value="">制動器 / 感測器</option>' + relay_data + sensor_data;
  1171. // obj_data = '<option value="' + 'sleep' + '">' + 'sleep' + '</option>' +
  1172. // '<option value="' + 'tankstatus' + '">' + 'tankstatus' + '</option>';
  1173. // // 賦值物件 a
  1174. // var sectorSelect = document.getElementById("do_obj1_1");
  1175. // sectorSelect.innerHTML = '<option value="">制動器 / 暫停秒數 / 桶槽狀態</option>' + relay_data + obj_data;
  1176. // ===== 下方傳值未測試 ====================================================
  1177. // var loader_data = {
  1178. // "ethernet_list":select_ethernet_text,
  1179. // "wifi_list":select_wifi_text,
  1180. // "zigbee_list":select_zigbee_text,
  1181. // "relay_list":String(relay_list),
  1182. // "pwm_list":String(pwm_list),
  1183. // "digital_list":String(digital_list),
  1184. // "uart_list":String(uart_list),
  1185. // "i2c_list":String(i2c_list),
  1186. // "s485_list":String(s485_list),
  1187. // "ppa_list":String(ppa_list)
  1188. // };
  1189. // $.ajax({
  1190. // type:"GET",
  1191. // url:"/loader",
  1192. // dataType:"JSON",
  1193. // data:loader_data,
  1194. // success:function (res) {
  1195. // alert("ItemGetValue loader: " + res.response)
  1196. // },
  1197. // error: function (thrownError) {
  1198. // alert(thrownError)
  1199. // }
  1200. // })
  1201. }
  1202. relay_obj2act = {'vacuum':['on', 'off'],
  1203. 'solenoidvalve':['on', 'off'],
  1204. 'diskvalve':['on', 'off'],
  1205. 'warninglight':['on', 'off'],
  1206. 'camera':['on', 'off'],
  1207. 'heater':['on', 'off'],
  1208. 'pump':['on', 'off'],
  1209. 'sleep':'',
  1210. 'tankstatus':['Waiting', 'InputtingBean', 'InputtingBean_Pause', 'InputtingBean_Finish',
  1211. 'Drying', 'OutputtingBean', 'InputtingWater']
  1212. }
  1213. dry_object = new Array();
  1214. dry_object['tankstatus'] = ["Waiting", "InputtingBean", "InputtingBean_Pause", "InputtingBean_Finish",
  1215. "InputtingWater", "Drying", "Drying_Finish", "OutputtingBean", "OutputtingBean_Finish"]; // 暫停秒數
  1216. // DRY_CONTAINER_STATUS 讓 do_act / dry_object 判斷用
  1217. const DRY_CONTAINER_STATUS = {
  1218. 'Waiting':'空桶等待',
  1219. 'InputtingBean':'入豆中',
  1220. 'InputtingBean_Pause':'入豆暫停',
  1221. 'InputtingBean_Finish':'入豆完成',
  1222. 'InputtingWater':'夾層入水',
  1223. 'Drying':'乾燥中',
  1224. 'Drying_Finish':'乾燥完成',
  1225. 'OutputtingBean':'可出豆',
  1226. 'OutputtingBean_Finish':'出豆完成'
  1227. }
  1228. function renew(obj_num, index) {
  1229. // console.log("renew!!!" + obj_num + "_____" + index);
  1230. var index_name = $('#do_obj' + obj_num).val();
  1231. // console.log("index_name: " + index_name);
  1232. var Value = '';
  1233. if (index_name === 'sleep') {
  1234. Value = ' 暫停秒數 : ' +
  1235. ' <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)">' +
  1236. ' <span id="sleepValue_text' + obj_num + '">10s</span>';
  1237. } else if (index_name === 'tankstatus') {
  1238. Value = '<select id="do_act' + obj_num + '">';
  1239. for(var i=0; i<dry_object['tankstatus'].length; i++){
  1240. Value += '<option value=' + dry_object['tankstatus'][i] + '>' + DRY_CONTAINER_STATUS[dry_object['tankstatus'][i]] + '</option>';
  1241. }
  1242. Value += '</select>';
  1243. } else if (index_name.includes('Motor')) {
  1244. Value = ' 指定轉速 : ' +
  1245. ' <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)">' +
  1246. ' <span id="motorValue_text' + obj_num + '">20rpm</span>';
  1247. } else if (index_name === '' || index_name == undefined) {
  1248. } else {
  1249. Value = '<select id="do_act' + obj_num + '">' +
  1250. '<option value="on">on</option>' +
  1251. '<option value="off">off</option>' +
  1252. '</select>';
  1253. }
  1254. // try {
  1255. // Value = '<select id="do_act' + obj_num + '">';
  1256. // for(var i=0; i<dry_object[index].length; i++){
  1257. // Value += '<option value=' + dry_object[index][i] + '>' + dry_object[index][i] + '</option>';
  1258. // }
  1259. // Value += '</select>';
  1260. // } catch (e) {
  1261. // if (e.name == 'TypeError' && index == '5') {
  1262. // Value = ' 轉速 : ' +
  1263. // ' <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)">' +
  1264. // ' <span id="motorValue_text' + obj_num + '">0</span>';
  1265. // } else if (e.name == 'TypeError' && index == '11') {
  1266. // Value = ' 目標溫度 : ' +
  1267. // ' <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)">' +
  1268. // ' <span id="tempValue_text' + obj_num + '">28.0</span>';
  1269. // } else if (e.name == 'TypeError' && index == '18') {
  1270. // Value = ' 暫停秒數 : ' +
  1271. // ' <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)">' +
  1272. // ' <span id="sleepValue_text' + obj_num + '">10s</span>';
  1273. // }
  1274. // }
  1275. var sectorSelect = document.getElementById("do_action" + obj_num);
  1276. if (sectorSelect != null) {
  1277. sectorSelect.innerHTML = Value;
  1278. }
  1279. }
  1280. function showSleepValue(obj_num, value) {
  1281. document.getElementById("sleepValue_text" + obj_num).innerText = value + 's';
  1282. }
  1283. function showMotorValue(obj_num, value) {
  1284. document.getElementById("motorValue_text" + obj_num).innerText = value + 'rpm';
  1285. }
  1286. function showSensorHzValue(obj_num, value) {
  1287. document.getElementById(obj_num + "_HzText").innerText = value + ' 秒/次';
  1288. }
  1289. </script>
  1290. <script>
  1291. var cond_main = ''; // 主條件
  1292. var cond_add_list = []; // 附加條件 List
  1293. var cond_add_data = ''; // 欲加入附加條件的資料
  1294. var cond_com_list = []; // 動作 List
  1295. var cond_com_data = ''; // 欲加入動作的資料
  1296. var cond_item = []; // 主條件+附加條件+動作 List
  1297. function showValue() {
  1298. cond_item = [];
  1299. var command_test = '';
  1300. Z = 0;
  1301. TT = {}; // 將總條件句/附加條件句/物件動作句存入 字典, 後續傳給 dry_block_format 再組合
  1302. var SQL_insert_total = ''; // MySQL 指令 全部條件輸出
  1303. TT['mainLength'] = 0 // 總條件數
  1304. TT['addLength'] = 0 // 子條件數
  1305. TT['comLength'] = 0 // 子物件數
  1306. // 條件物件動作 取值
  1307. // for (let z = 1; z <= 2; z++) {
  1308. for (let z = 1; z <= new_condition_i; z++) {
  1309. var set_key = []; // List 加入變數名稱, INSERT DB 用
  1310. var set_value = []; // List 加入值, INSERT DB 用
  1311. // 初始清空
  1312. cond_main = '';
  1313. // if-while 取值
  1314. try {
  1315. var cond_z_value = document.getElementById("cond_z" + z + "_1").value;
  1316. if (cond_z_value == '') {
  1317. // alert('if/while 欄位未輸入')
  1318. } else {
  1319. Z = Z + 1;
  1320. // if (Z > 4) {
  1321. // alert("[Z > 4] 總條件數不得超過 3 項")
  1322. // break
  1323. // }
  1324. // set_key.push('cond_z' + z + '_1');
  1325. set_key.push('cond_z' + Z + '_1');
  1326. set_value.push(cond_z_value);
  1327. console.log("cond_z_value: " + cond_z_value);
  1328. cond_main += cond_z_value + ' ';
  1329. console.log("cond_main: " + cond_main);
  1330. }
  1331. } catch (error) {
  1332. if (error.name == 'TypeError') {
  1333. } else {
  1334. alert("cond_z" + z + "_1: " + error.name)
  1335. }
  1336. }
  1337. X = 1;
  1338. cond_add_list = []; // 附加條件 List 清空
  1339. for (let x = 1; x <= cond_add_child_i; x++) {
  1340. // for (let x = 1; x <= cond_add_child_i; x++) {
  1341. cond_add_data = ''; // 附加條件資料 清空
  1342. if (x == 1) {
  1343. // 主條件
  1344. try {
  1345. var cond_a_value = document.getElementById("cond_a" + z + "_" + x).value;
  1346. if (cond_a_value == '') {
  1347. // alert('主條件 感測器 欄位未輸入')
  1348. } else {
  1349. // set_key.push('cond_a' + z + '_' + X);
  1350. set_key.push('cond_a' + Z + '_' + X);
  1351. set_value.push(cond_a_value);
  1352. console.log("cond_a_value: " + cond_a_value);
  1353. cond_main += cond_a_value + ' ';
  1354. }
  1355. } catch (error) {
  1356. if (error.name == 'TypeError') {
  1357. } else {
  1358. alert("cond_a" + z + "_" + x + ": " + error.name)
  1359. }
  1360. }
  1361. // 子條件取值 : 條件中 > = <
  1362. try {
  1363. var cond_b_value = document.getElementById("cond_b" + z + "_" + x).value;
  1364. if (cond_b_value == '') {
  1365. // alert('主條件 比較運算子 欄位未輸入')
  1366. } else {
  1367. // set_key.push('cond_b' + z + '_' + X);
  1368. set_key.push('cond_b' + Z + '_' + X);
  1369. set_value.push(cond_b_value);
  1370. console.log("cond_b_value: " + cond_b_value);
  1371. // if (cond_b_value == 'MoreThan') { cond_main += '> '; }
  1372. // else if (cond_b_value == 'MoreThanEqualTo') { cond_main += '>= '; }
  1373. // else if (cond_b_value == 'Equal') { cond_main += '== '; }
  1374. // else if (cond_b_value == 'LessThanEqualTo') { cond_main += '<= '; }
  1375. // else if (cond_b_value == 'LessThan') { cond_main += '< '; }
  1376. cond_main += cond_b_value + ' ';
  1377. }
  1378. } catch (error) {
  1379. if (error.name == 'TypeError') {
  1380. } else {
  1381. alert("cond_b" + z + "_" + x + ": " + error.name)
  1382. }
  1383. }
  1384. // 子條件取值 : 條件右 ON / OFF / 輸入數值
  1385. try {
  1386. var cond_c_value = document.getElementById("cond_c" + z + "_" + x).value;
  1387. if (cond_c_value == '') {
  1388. // alert('主條件 數值 欄位未輸入')
  1389. } else {
  1390. // console.log("Ctest: " + typeof(cond_c_value))
  1391. set_key.push('cond_c' + Z + '_' + X);
  1392. set_value.push(cond_c_value);
  1393. console.log("cond_c_value: " + cond_c_value);
  1394. if (relay_obj2act['tankstatus'].includes(cond_c_value)) {
  1395. cond_main += "'" + cond_c_value + "'";
  1396. } else {
  1397. cond_main += cond_c_value;
  1398. }
  1399. // set_key.push('cond_c' + z + '_' + X);
  1400. }
  1401. } catch (error) {
  1402. if (error.name == 'TypeError') {
  1403. } else {
  1404. alert("cond_c" + z + "_" + x + ": " + error.name)
  1405. }
  1406. }
  1407. } else {
  1408. // 附加條件 x > 1
  1409. // 子條件取值 : 條件連接 and or
  1410. try {
  1411. var cond_d_value = document.getElementById("cond_d" + z + "_" + x).value;
  1412. if (cond_d_value == '') {
  1413. // alert('附加條件 and/or 欄位未輸入')
  1414. } else {
  1415. X = X + 1;
  1416. // if (X > 13) {
  1417. // alert("[X > 13] 子條件數不得超過 13 項")
  1418. // break
  1419. // }
  1420. // set_key.push('cond_d' + z + '_' + X);
  1421. set_key.push('cond_d' + Z + '_' + X);
  1422. set_value.push(cond_d_value);
  1423. cond_add_data += cond_d_value + ' ';
  1424. }
  1425. } catch (error) {
  1426. if (error.name == 'TypeError') {
  1427. } else {
  1428. alert("cond_d" + z + "_" + x + ": " + error.name)
  1429. }
  1430. }
  1431. // 感測器取值 :
  1432. try {
  1433. var cond_a_value = document.getElementById("cond_a" + z + "_" + x).value;
  1434. if (cond_a_value == '') {
  1435. // alert('附加條件 感測器 欄位未輸入')
  1436. } else {
  1437. // set_key.push('cond_a' + z + '_' + X);
  1438. set_key.push('cond_a' + Z + '_' + X);
  1439. set_value.push(cond_a_value);
  1440. cond_add_data += cond_a_value + ' ';
  1441. }
  1442. } catch (error) {
  1443. if (error.name == 'TypeError') {
  1444. } else {
  1445. alert("cond_a" + z + "_" + x + ": " + error.name)
  1446. }
  1447. }
  1448. // 子條件取值 : 條件中 > = <
  1449. try {
  1450. var cond_b_value = document.getElementById("cond_b" + z + "_" + x).value;
  1451. if (cond_b_value == '') {
  1452. // alert('附加條件 比較運算子 欄位未輸入')
  1453. } else {
  1454. // set_key.push('cond_b' + z + '_' + X);
  1455. set_key.push('cond_b' + Z + '_' + X);
  1456. set_value.push(cond_b_value);
  1457. // if (cond_b_value == 'MoreThan') { cond_main += '> '; }
  1458. // else if (cond_b_value == 'MoreThanEqualTo') { cond_main += '>= '; }
  1459. // else if (cond_b_value == 'Equal') { cond_main += '== '; }
  1460. // else if (cond_b_value == 'LessThanEqualTo') { cond_main += '<= '; }
  1461. // else if (cond_b_value == 'LessThan') { cond_main += '< '; }
  1462. cond_add_data += cond_b_value;
  1463. }
  1464. } catch (error) {
  1465. if (error.name == 'TypeError') {
  1466. } else {
  1467. alert("cond_b" + z + "_" + x + ": " + error.name)
  1468. }
  1469. }
  1470. // 子條件取值 : 條件右 ON / OFF / 輸入數值
  1471. try {
  1472. var cond_c_value = document.getElementById("cond_c" + z + "_" + x).value;
  1473. if (cond_c_value == '') {
  1474. // alert('附加條件 數值 欄位未輸入')
  1475. } else {
  1476. // console.log("Ctest: " + cond_c_value)
  1477. set_key.push('cond_c' + Z + '_' + X);
  1478. set_value.push(cond_c_value);
  1479. if (relay_obj2act['tankstatus'].includes(cond_c_value)) {
  1480. cond_add_data += " '" + cond_c_value + "'";
  1481. } else {
  1482. cond_add_data += " " + cond_c_value;
  1483. }
  1484. // set_key.push('cond_c' + z + '_' + X);
  1485. }
  1486. } catch (error) {
  1487. if (error.name == 'TypeError') {
  1488. } else {
  1489. alert("cond_c" + z + "_" + x + ": " + error.name)
  1490. }
  1491. }
  1492. if (cond_add_data != '') {
  1493. console.log("cond_add_list: " + cond_add_list)
  1494. console.log("cond_add_data: " + cond_add_data)
  1495. cond_add_list.push(cond_add_data)
  1496. }
  1497. }
  1498. }
  1499. // 子 物件動作 取值
  1500. Y = 0;
  1501. cond_com_list = [];
  1502. for (let y = 1; y <= act_add_child_i; y++) {
  1503. cond_com_data = '';
  1504. // 子物件動作取值 : 物件 do_obj1_1
  1505. try {
  1506. var do_obj_value = document.getElementById("do_obj" + z + "_" + y).value;
  1507. // console.log("do_obj" + z + "_" + y + " : " + do_obj_value)
  1508. if (do_obj_value == '') {
  1509. // alert('物件 欄位未輸入')
  1510. } else {
  1511. Y = Y + 1;
  1512. // if (Y > 20) {
  1513. // alert("[Y > 20] 子物件數不得超過 20 項")
  1514. // break
  1515. // }
  1516. set_key.push('do_obj' + Z + '_' + Y);
  1517. set_value.push(do_obj_value);
  1518. cond_com_data += do_obj_value + ' ';
  1519. }
  1520. } catch (error) {
  1521. if (error.name == 'TypeError') {
  1522. } else {
  1523. alert("do_obj" + z + "_" + y + ": " + error.name)
  1524. }
  1525. }
  1526. // 子物件動作取值 : 動作 do_act1_1
  1527. try {
  1528. var do_act_value = document.getElementById("do_act" + z + "_" + y).value;
  1529. // console.log("do_act" + z + "_" + y + " : " + do_act_value)
  1530. if (do_act_value == '') {
  1531. // alert('動作 欄位未輸入')
  1532. } else {
  1533. set_key.push('do_act' + Z + '_' + Y);
  1534. // if (DRY_CONTAINER_STATUS[do_act_value] != undefined ) {
  1535. // console.log("=== != undefined ===")
  1536. // console.log(DRY_CONTAINER_STATUS[do_act_value])
  1537. // set_value.push(DRY_CONTAINER_STATUS[do_act_value]);
  1538. // cond_com_data += DRY_CONTAINER_STATUS[do_act_value];
  1539. // cond_com_list.push(cond_com_data);
  1540. // } else {
  1541. set_value.push(do_act_value);
  1542. cond_com_data += do_act_value;
  1543. cond_com_list.push(cond_com_data);
  1544. // }
  1545. }
  1546. } catch (error) {
  1547. if (error.name == 'TypeError') {
  1548. } else {
  1549. alert("do_act" + z + "_" + y + ": " + error.name)
  1550. }
  1551. }
  1552. }
  1553. // ===== 0324 測試 OK 勿刪 ===================================================
  1554. var A = 1;
  1555. var B = 1;
  1556. console.log("cond_add_list: " + cond_add_list);
  1557. console.log("cond_com_list: " + cond_com_list);
  1558. if (cond_main != '') {
  1559. TT['cond_main' + Z] = cond_main;
  1560. for (let a = 0; a < cond_add_list.length; a++) {
  1561. TT['cond_add'+ Z + '_' + A] = cond_add_list[a];
  1562. A = A + 1;
  1563. }
  1564. for (let b = 0; b < cond_com_list.length; b++) {
  1565. TT['cond_com'+ Z + '_' + B] = cond_com_list[b];
  1566. B = B + 1;
  1567. }
  1568. cond_item.push(
  1569. '{"cond_main":"' + cond_main + '", ' +
  1570. '"cond_add":["' + cond_add_list.join('", "') + '"], ' +
  1571. '"cond_com":["' + cond_com_list.join('", "') + '"]}'
  1572. )
  1573. }
  1574. console.log("cond_add_list.length: " + cond_add_list.length + "__" + typeof(cond_add_list.length))
  1575. console.log("TT['addLength']: " + TT['addLength'] + "__" + typeof(TT['addLength']))
  1576. if (cond_add_list.length > TT['addLength']) {
  1577. TT['addLength'] = cond_add_list.length
  1578. }
  1579. if (cond_com_list.length > TT['comLength']) {
  1580. TT['comLength'] = cond_com_list.length
  1581. }
  1582. }
  1583. // ========================================================
  1584. TT['mainLength'] = Z
  1585. console.log("***TT['mainLength']: " + TT['mainLength']);
  1586. console.log("***TT['addLength']: " + TT['addLength']);
  1587. console.log("***TT['comLength']: " + TT['comLength']);
  1588. TT['tank_num'] = $('#prog_tank').find(':selected').val();
  1589. // ========================================================
  1590. //document.getElementById('show_Value').innerText = '"cond": [' + cond_item + ']';
  1591. }
  1592. function getValue(){
  1593. var confirm_getValue = confirm("請確認積木條件無誤後, 再按下 [確認] :");
  1594. if (!confirm_getValue) {
  1595. alert("已取消積木取值測試");
  1596. } else {
  1597. showValue();
  1598. }
  1599. }
  1600. function MQTTgetValue() {
  1601. var confirm_getValue = confirm("請確認積木條件無誤後, 再按下 [確認] :");
  1602. if (!confirm_getValue) {
  1603. alert("已取消積木取值測試");
  1604. } else {
  1605. showValue();
  1606. var msg_data;
  1607. var USERNAME = '{{username}}';
  1608. $.get('/dry_block_format', TT, function (res) {
  1609. //alert("MQTT OK")
  1610. document.getElementById('show_MQTTcommand').innerText = JSON.stringify(res.response);
  1611. msg_data = JSON.stringify(res.response);
  1612. // 存值
  1613. var prog_tank_data = $('#prog_tank').find(':selected').val();
  1614. var SQL_insert = 'INSERT INTO `block_cond_dry_t` (' +
  1615. '`datetime`, `UserName`, `tank_num`, `cond`) VALUES (' +
  1616. 'current_timestamp(), \'' + USERNAME + '\', \'' + prog_tank_data + '\', \''
  1617. + String(msg_data).replaceAll("'", "") + '\');';
  1618. console.log("SQL_insert: " + SQL_insert);
  1619. sql_data = { "sql" : SQL_insert };
  1620. $.get('/sql_get', sql_data, function (res) {
  1621. //alert("OK")
  1622. }, 'json');
  1623. }, 'json');
  1624. }
  1625. }
  1626. </script>
  1627. <!-- 條件物件 ++ -- -->
  1628. <script>
  1629. function act_add(evt) {
  1630. evt.style.display = "none";
  1631. var actadd_parent_num = String(evt.id).split('_')[1].slice(3, )
  1632. // console.log("actadd_parent_num: " + actadd_parent_num)
  1633. act_add_child_i++;
  1634. var html = '';
  1635. html +=
  1636. '<div id="action' + actadd_parent_num + '_' + act_add_child_i + '">' +
  1637. '物件 ' +
  1638. '<select id="do_obj' + actadd_parent_num + '_' + act_add_child_i + '" onChange="renew(\'' + actadd_parent_num + '_' + act_add_child_i + '\', this.selectedIndex);">' +
  1639. // '<option value=" ">制動器 / 暫停秒數 / 桶槽狀態</option>' +
  1640. pin_data_relay_option +
  1641. // '<option value="input_vacuum_status">入料儲豆槽真空吸料機</option>' +
  1642. // '<option value="tank_vacuum_status">真空吸料機</option>' +
  1643. // '<option value="tank_threewayvalve_vacuum_status">吸料機三通閥</option>' +
  1644. // '<option value="tank_solenoid_disinfect_status">消毒電磁閥</option>' +
  1645. // '<option value="tank_motor_status">馬達</option>' +
  1646. // '<option value="outer_solenoid_water_status">桶外進水電磁閥</option>' +
  1647. // '<option value="tank_solenoid_water_out_status">廢水排水電磁閥</option>' +
  1648. // '<option value="tank_heater1_status">加熱棒 1</option>' +
  1649. // '<option value="tank_heater2_status">加熱棒 2</option>' +
  1650. // '<option value="tank_temp_enable">溫控開關</option>' +
  1651. // '<option value="tank_temp">溫度設定</option>' +
  1652. // '<option value="tank_diskvalve_status">蝴蝶閥</option>' +
  1653. // '<option value="output_vacuum_status">出料儲豆槽真空吸料機</option>' +
  1654. // '<option value="tank_magneticSwitch_status">電磁開關</option>' +
  1655. // '<option value="tank_emergencySwitch_status">緊急開關</option>' +
  1656. // '<option value="tank_camera_status">攝影機</option>' +
  1657. // '<option value="tank_warningLight_status">警示燈</option>' +
  1658. '</select> ' +
  1659. '動作 ' +
  1660. '<div id="do_action' + actadd_parent_num + '_' + act_add_child_i + '" style="display: inline-block;">' +
  1661. '</div>' +
  1662. // '<select id="do_act' + actadd_parent_num + '_' + act_add_child_i + '">' +
  1663. // '<option value="">請由左方選取物件</option>' +
  1664. // '</select> ' +
  1665. '<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 + '\');">' +
  1666. '<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>' +
  1667. '</div>';
  1668. var divbox = document.getElementById('action' + actadd_parent_num);
  1669. divbox.insertAdjacentHTML('beforeend', html);
  1670. }
  1671. function act_del(evt) {
  1672. var del_action = document.getElementById('action' + evt);
  1673. del_action.innerHTML = ""
  1674. var parentObj = del_action.parentNode; // 取得欲刪除 div 的父類別
  1675. parentObj.removeChild(del_action) // 刪除 div
  1676. var del_act_parent_num = String(evt).split('_')[0]
  1677. var del_act_child_num = String(evt).split('_')[1]
  1678. // console.log('del_act_parent_num: ' + del_act_parent_num)
  1679. // console.log('del_act_child_num: ' + del_act_child_num)
  1680. var button_return_id = document.getElementById('act_add' + del_act_parent_num + '_' + String(parseInt(del_act_child_num)-1));
  1681. // console.log("test: " + 'cond_add' + del_act_parent_num + '_' + String(parseInt(del_act_child_num)-1))
  1682. // console.log("button_return_id: " + button_return_id) // null
  1683. if (button_return_id == null) {
  1684. var button_return_id = document.getElementById('act_add' + del_act_parent_num + '_1');
  1685. }
  1686. button_return_id.style.display = "inline";
  1687. }
  1688. // --------------------------------------------------------------------------------------------------
  1689. function cond_add(evt) { // cond_add1_1 下一個是 cond_add1(條件)_2(子條件)
  1690. evt.style.display = "none"; // 不顯示原按鈕
  1691. var condadd_parent_num = String(evt.id).split('_')[1].slice(3, ) // 把第一個條件的編號記下
  1692. // console.log("condadd_parent_num: " + condadd_parent_num)
  1693. cond_add_child_i++
  1694. var html = '';
  1695. html +=
  1696. '<div id="condition' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1697. '<select id="cond_d' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1698. '<option value=""></option>' +
  1699. '<option value="&&">&&</option>' +
  1700. '<option value="||">||</option>' +
  1701. '</select> ' +
  1702. '<select id="cond_a' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1703. pin_data_sensor_option +
  1704. '<option value="tankstatus">tankstatus</option>' +
  1705. '</optgroup>' +
  1706. '</select> ' +
  1707. '<select id="cond_b' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1708. '<option value=""></option>' +
  1709. '<option value=">">&gt;</option>' +
  1710. '<option value=">=">&gt;=</option>' +
  1711. '<option value="==">==</option>' +
  1712. '<option value="<=">&lt;=</option>' +
  1713. '<option value="<">&lt;</option>' +
  1714. '</select> ' +
  1715. '<input list="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '" id="cond_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1716. '<datalist id="cond_list_c' + condadd_parent_num + '_' + cond_add_child_i + '">' +
  1717. '<option value="on">ON</option>' +
  1718. '<option value="off">OFF</option>' +
  1719. '<option value="">(或請自行輸入數值)</option>' +
  1720. '<option value="Waiting">空桶等待</option>' +
  1721. '<option value="InputtingBean">入豆中</option>' +
  1722. '<option value="InputtingBean_Pause">入豆暫停</option>' +
  1723. '<option value="InputtingBean_Finish">入豆完成</option>' +
  1724. '<option value="InputtingWater">夾層入水</option>' +
  1725. '<option value="Drying">乾燥中</option>' +
  1726. '<option value="Drying_Finish">乾燥完成</option>' +
  1727. '<option value="OutputtingBean">可出豆</option>' +
  1728. '<option value="OutputtingBean_Finish">出豆完成</option>' +
  1729. '</datalist> ' +
  1730. '<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 + '\');">' +
  1731. '<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>' +
  1732. '</div>';
  1733. var divbox = document.getElementById('condition' + condadd_parent_num);
  1734. divbox.insertAdjacentHTML('beforeend', html);
  1735. }
  1736. function cond_del(evt) {
  1737. // console.log('evt: ' + evt)
  1738. var del_cond_child = document.getElementById('condition' + evt);
  1739. // console.log("del_cond_child: " + del_cond_child)
  1740. del_cond_child.innerHTML = ""
  1741. var parentObj = del_cond_child.parentNode; // 取得欲刪除 div 的父類別
  1742. parentObj.removeChild(del_cond_child) // 刪除 div
  1743. // 上一個按鈕要顯示出來
  1744. var del_cond_parent_num = String(evt).split('_')[0]
  1745. var del_cond_child_num = String(evt).split('_')[1]
  1746. console.log('del_cond_parent_num: ' + del_cond_parent_num)
  1747. console.log('del_cond_child_num: ' + del_cond_child_num)
  1748. var button_return_id = document.getElementById('cond_add' + del_cond_parent_num + '_' + String(parseInt(del_cond_child_num)-1));
  1749. console.log("test: " + 'cond_add' + del_cond_parent_num + '_' + String(parseInt(del_cond_child_num)-1))
  1750. console.log("button_return_id: " + button_return_id) // null
  1751. if (button_return_id == null) {
  1752. var button_return_id = document.getElementById('cond_add' + del_cond_parent_num + '_1');
  1753. }
  1754. try {
  1755. button_return_id.style.display = "inline";
  1756. } catch (error) {
  1757. if (error.name !== 'TypeError') {
  1758. alert("cond_add" + del_cond_parent_num + "_" + String(parseInt(del_cond_child_num)-1) + " 子條件刪除錯誤\n" +
  1759. error.name + "\n" +
  1760. error.message);
  1761. }
  1762. }
  1763. }
  1764. // -------------------------------------------------------------------------------------------------------------
  1765. function Add(evt) { // 網頁初始按鈕 onclick="Add(add1);
  1766. evt.style.display = "none"; // 元素不顯示。將 add1 的 input-button 不顯示
  1767. new_condition_i++; // 設定編號用
  1768. // var div = document.createElement('div'); // 輸出 <div></div>。此時並不會顯示,
  1769. // 需透過 appendChild()、insertBefore() 或 replaceChild() 等方法將新元素加入至指定的位置之後才會顯示。
  1770. // var cond_number = String(evt).slice(3, ) // 目前的 condition 條件物件動作 數 (最外層)
  1771. // var cond_a = 'cond_a' + cond_number + '_' + new_condition_i; // [條件] 左方 : 制動器感測器
  1772. // var cond_b = 'cond_b' + cond_number + '_' + new_condition_i; // [條件] 中間 : > / = / <
  1773. // var cond_c = 'cond_c' + cond_number + '_' + new_condition_i; // [條件] 右方 : ON / OFF / 數值
  1774. // var cond_d = 'cond_d' + cond_number + '_' + new_condition_i; // 條件] 最左方條件連接 : and / or
  1775. // div.id = 'newcondition_' + new_condition_i; // 設定 div 的 id
  1776. // div.style.marginTop = "10px"; // 新增的 div 設定 marginTop 屬性值
  1777. var html = ''
  1778. // 新增的條件
  1779. html +=
  1780. '<div id="newcondition_' + new_condition_i + '" class="newcondition_css">' +
  1781. // 新增的分隔線
  1782. // '<hr size="50" width="100%">' +
  1783. '<div id="condition' + new_condition_i + '">' +
  1784. '<div id="condition' + new_condition_i + '_1">' +
  1785. '條件 ' +
  1786. '<select id="cond_z' + new_condition_i + '_1">' +
  1787. '<option value="if">if</option>' +
  1788. '<option value="else if">else if</option>' +
  1789. '<option value="else">else</option>' +
  1790. '</select> ' +
  1791. '<select id="cond_a' + new_condition_i + '_1">' +
  1792. pin_data_sensor_option +
  1793. '<option value="tankstatus">tankstatus</option>' +
  1794. '</optgroup>' +
  1795. '</select> ' +
  1796. '<select id="cond_b' + new_condition_i + '_1">' +
  1797. '<option value=""></option>' +
  1798. '<option value=">">&gt;</option>' +
  1799. '<option value=">=">&gt;=</option>' +
  1800. '<option value="==">==</option>' +
  1801. '<option value="<=">&lt;=</option>' +
  1802. '<option value="<">&lt;</option>' +
  1803. '</select> ' +
  1804. '<input list="cond_list_c' + new_condition_i + '_1" id="cond_c' + new_condition_i + '_1">' +
  1805. '<datalist id="cond_list_c' + new_condition_i + '_1">' +
  1806. '<option value="on">ON</option>' +
  1807. '<option value="off">OFF</option>' +
  1808. '<option value="">(或請自行輸入數值)</option>' +
  1809. '<option value="Waiting">空桶等待</option>' +
  1810. '<option value="InputtingBean">入豆中</option>' +
  1811. '<option value="InputtingBean_Pause">入豆暫停</option>' +
  1812. '<option value="InputtingBean_Finish">入豆完成</option>' +
  1813. '<option value="InputtingWater">夾層入水</option>' +
  1814. '<option value="Drying">乾燥中</option>' +
  1815. '<option value="Drying_Finish">乾燥完成</option>' +
  1816. '<option value="OutputtingBean">可出豆</option>' +
  1817. '<option value="OutputtingBean_Finish">出豆完成</option>' +
  1818. '</datalist> ' +
  1819. '<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>' +
  1820. '</div></div>';
  1821. // 新增的物件動作
  1822. html +=
  1823. '<div id="action' + new_condition_i + '">' +
  1824. '<div id="action' + new_condition_i + '_1">' +
  1825. '物件 ' +
  1826. '<select id="do_obj' + new_condition_i + '_1" onChange="renew(\''+ new_condition_i + '_1\', this.selectedIndex);">' +
  1827. pin_data_relay_option +
  1828. '</select>' +
  1829. '動作 ' +
  1830. '<div id="do_action' + new_condition_i + '_1" style="display: inline-block;">' +
  1831. '</div>' +
  1832. '<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>' +
  1833. '</div>' +
  1834. '</div>' +
  1835. // 新增的 條件物件動作++ 條件物件動作-- 按鈕
  1836. '<input type="button" class="input-delete" id="del' + new_condition_i + '" value="條件物件動作--" onclick="Delete(' + new_condition_i + ');"><br>' +
  1837. '<input type="button" class="input-add" id="add' + new_condition_i + '" value="條件物件動作++" onclick="Add(add' + new_condition_i + ');">' +
  1838. '</div>' ;
  1839. var divbox = document.getElementById('box');
  1840. divbox.insertAdjacentHTML('beforeend', html);
  1841. };
  1842. function Delete(evt) {
  1843. var del_condition = document.getElementById('newcondition_' + evt);
  1844. del_condition.innerHTML = ""
  1845. var parentObj = del_condition.parentNode; // 取得欲刪除 div 的父類別
  1846. parentObj.removeChild(del_condition) // 刪除 div
  1847. // 上一個按鈕要顯示出來
  1848. var button_return_id = document.getElementById('add' + String(parseInt(evt)-1));
  1849. if (button_return_id == null) {
  1850. var button_return_id = document.getElementById('add1');
  1851. }
  1852. // console.log('button_return_id: ' + button_return_id)
  1853. button_return_id.style.display = "block"; // 元素顯示。顯示前一個 input-button
  1854. };
  1855. // --------------------------------------------------------------------------------------
  1856. </script>
  1857. <!-- 燒錄通訊器互動視窗 -->
  1858. <div class="modal fade" id="control_RF_Modal">
  1859. <div class="modal-dialog modal-dialog-centered" style="width: 400px;">
  1860. <div class="modal-content">
  1861. <!-- 互動視窗 標題 -->
  1862. <div class="modal-header">
  1863. <h4 id="Modal_RF_title_input" class="modal-title"></h4>
  1864. <button type="button" class="close" data-dismiss="modal">&times;</button>
  1865. </div>
  1866. <!-- 互動視窗 內容 -->
  1867. <div class="modal-body">
  1868. <table style="border:0px gray solid; width: 100%;" cellpadding="3">
  1869. <!--<table style="border:0px gray solid;-->
  1870. <tr>
  1871. <td><strong><a>通訊介面</a></strong></td>
  1872. </tr>
  1873. <tr>
  1874. <td style="vertical-align:text-top;">
  1875. <table style="border:0px gray solid;" cellpadding="3">
  1876. <!--font-size:12px; -->
  1877. <tr>
  1878. <td>
  1879. ethernet :
  1880. <select id="select_ethernet_1" onchange="" class="select-input">
  1881. <option>OFF</option>
  1882. <option>ON</option>
  1883. </select>
  1884. <!--<span id="tank_vacuum_t_status"></span>-->
  1885. </td>
  1886. <td>
  1887. Wi-Fi :
  1888. <select id="select_wifi_1" onchange="" class="select-input">
  1889. <option>OFF</option>
  1890. <option>ON</option>
  1891. </select>
  1892. </td>
  1893. <td>
  1894. zigbee :
  1895. <select id="select_zigbee_1" onchange="" class="select-input">
  1896. <option>OFF</option>
  1897. <option>ON</option>
  1898. </select>
  1899. </td>
  1900. </tr>
  1901. </table>
  1902. </td>
  1903. </tr>
  1904. </table>
  1905. </div>
  1906. </div>
  1907. </div>
  1908. </div>
  1909. <!-- 燒錄致動器互動視窗 -->
  1910. <div class="modal fade" id="control_Modal">
  1911. <div class="modal-dialog modal-dialog-centered modal-lg">
  1912. <div class="modal-content">
  1913. <!-- 互動視窗 標題 -->
  1914. <div class="modal-header">
  1915. <h4 id="Modal_title_input" class="modal-title"></h4>
  1916. <button type="button" class="close" data-dismiss="modal">&times;</button>
  1917. </div>
  1918. <!-- 互動視窗 內容 -->
  1919. <div class="modal-body">
  1920. <table style="border:0px gray solid; width: 100%;" cellpadding="4">
  1921. <!--<table style="border:0px gray solid;-->
  1922. <tr>
  1923. <td><strong><a id="actuator_link_input" >致動器</a></strong></td>
  1924. </tr>
  1925. <tr>
  1926. <td style="vertical-align:text-top;">
  1927. <table style="border:0px gray solid;" cellpadding="4">
  1928. <!--font-size:12px; -->
  1929. <tr>
  1930. <td>
  1931. Relay1:
  1932. <br>
  1933. <select id="select_relay_1" onchange="select_relay('1')" class="select-input">
  1934. <option></option>
  1935. <option value="vacuum">真空吸料機</option>
  1936. <option value="solenoid_reclaimed_in">中水入水</option>
  1937. <option value="solenoid_water_in">清水入水</option>
  1938. <option value="pump_water_in">幫浦</option>
  1939. <option value="solenoid_water_out">排水廢水</option>
  1940. <option value="solenoid_reclaimed_out">排水中水</option>
  1941. <option value="solenoidvalve_disinfect">桶內消毒</option>
  1942. <option value="pump_disinfect">混合槽幫浦</option>
  1943. <option value="diskvalve">蝴蝶閥</option>
  1944. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  1945. <option value="solenoid_outer_water">保溫夾層進水</option>
  1946. <option value="solenoid_tank_pump">逆洗幫浦</option>
  1947. <option value="pump_sensor">雙核隔膜泵</option>
  1948. <option value="warninglight">警示燈</option>
  1949. <option value="camera">攝影機</option>
  1950. <option value="heater1">加熱器</option>
  1951. <option value="heater2">加熱器</option>
  1952. <option value="vacuum_pump">乾燥真空機</option>
  1953. <option value="nozzle">喷嘴</option>
  1954. </select>
  1955. </td>
  1956. <td>
  1957. Relay2:
  1958. <br>
  1959. <select id="select_relay_2" onchange="select_relay('2')" class="select-input">
  1960. <option></option>
  1961. <option value="vacuum">真空吸料機</option>
  1962. <option value="solenoid_reclaimed_in">中水入水</option>
  1963. <option value="solenoid_water_in">清水入水</option>
  1964. <option value="pump_water_in">幫浦</option>
  1965. <option value="solenoid_water_out">排水廢水</option>
  1966. <option value="solenoid_reclaimed_out">排水中水</option>
  1967. <option value="solenoidvalve_disinfect">桶內消毒</option>
  1968. <option value="pump_disinfect">混合槽幫浦</option>
  1969. <option value="diskvalve">蝴蝶閥</option>
  1970. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  1971. <option value="solenoid_outer_water">保溫夾層進水</option>
  1972. <option value="solenoid_tank_pump">逆洗幫浦</option>
  1973. <option value="pump_sensor">雙核隔膜泵</option>
  1974. <option value="warninglight">警示燈</option>
  1975. <option value="camera">攝影機</option>
  1976. <option value="heater1">加熱器</option>
  1977. <option value="heater2">加熱器</option>
  1978. <option value="vacuum_pump">乾燥真空機</option>
  1979. <option value="nozzle">喷嘴</option>
  1980. </select>
  1981. </td>
  1982. <td>
  1983. Relay3:
  1984. <br>
  1985. <select id="select_relay_3" onchange="select_relay('3')" class="select-input">
  1986. <option></option>
  1987. <option value="vacuum">真空吸料機</option>
  1988. <option value="solenoid_reclaimed_in">中水入水</option>
  1989. <option value="solenoid_water_in">清水入水</option>
  1990. <option value="pump_water_in">幫浦</option>
  1991. <option value="solenoid_water_out">排水廢水</option>
  1992. <option value="solenoid_reclaimed_out">排水中水</option>
  1993. <option value="solenoidvalve_disinfect">桶內消毒</option>
  1994. <option value="pump_disinfect">混合槽幫浦</option>
  1995. <option value="diskvalve">蝴蝶閥</option>
  1996. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  1997. <option value="solenoid_outer_water">保溫夾層進水</option>
  1998. <option value="solenoid_tank_pump">逆洗幫浦</option>
  1999. <option value="pump_sensor">雙核隔膜泵</option>
  2000. <option value="warninglight">警示燈</option>
  2001. <option value="camera">攝影機</option>
  2002. <option value="heater1">加熱器</option>
  2003. <option value="heater2">加熱器</option>
  2004. <option value="vacuum_pump">乾燥真空機</option>
  2005. <option value="nozzle">喷嘴</option>
  2006. </select>
  2007. </td>
  2008. <td>
  2009. Relay4:
  2010. <br>
  2011. <select id="select_relay_4" onchange="select_relay('4')" class="select-input">
  2012. <option></option>
  2013. <option value="vacuum">真空吸料機</option>
  2014. <option value="solenoid_reclaimed_in">中水入水</option>
  2015. <option value="solenoid_water_in">清水入水</option>
  2016. <option value="pump_water_in">幫浦</option>
  2017. <option value="solenoid_water_out">排水廢水</option>
  2018. <option value="solenoid_reclaimed_out">排水中水</option>
  2019. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2020. <option value="pump_disinfect">混合槽幫浦</option>
  2021. <option value="diskvalve">蝴蝶閥</option>
  2022. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2023. <option value="solenoid_outer_water">保溫夾層進水</option>
  2024. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2025. <option value="pump_sensor">雙核隔膜泵</option>
  2026. <option value="warninglight">警示燈</option>
  2027. <option value="camera">攝影機</option>
  2028. <option value="heater1">加熱器</option>
  2029. <option value="heater2">加熱器</option>
  2030. <option value="vacuum_pump">乾燥真空機</option>
  2031. <option value="nozzle">喷嘴</option>
  2032. </select>
  2033. </td>
  2034. </table>
  2035. <table style="border:0px gray solid;" cellpadding="4">
  2036. <!--font-size:12px; -->
  2037. <tr>
  2038. <td>
  2039. Relay5:
  2040. <br>
  2041. <select id="select_relay_5" onchange="select_relay('5')" class="select-input">
  2042. <option></option>
  2043. <option value="vacuum">真空吸料機</option>
  2044. <option value="solenoid_reclaimed_in">中水入水</option>
  2045. <option value="solenoid_water_in">清水入水</option>
  2046. <option value="pump_water_in">幫浦</option>
  2047. <option value="solenoid_water_out">排水廢水</option>
  2048. <option value="solenoid_reclaimed_out">排水中水</option>
  2049. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2050. <option value="pump_disinfect">混合槽幫浦</option>
  2051. <option value="diskvalve">蝴蝶閥</option>
  2052. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2053. <option value="solenoid_outer_water">保溫夾層進水</option>
  2054. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2055. <option value="pump_sensor">雙核隔膜泵</option>
  2056. <option value="warninglight">警示燈</option>
  2057. <option value="camera">攝影機</option>
  2058. <option value="heater1">加熱器</option>
  2059. <option value="heater2">加熱器</option>
  2060. <option value="vacuum_pump">乾燥真空機</option>
  2061. <option value="nozzle">喷嘴</option>
  2062. </select>
  2063. </td>
  2064. <td>
  2065. Relay6:
  2066. <br>
  2067. <select id="select_relay_6" onchange="select_relay('6')" class="select-input">
  2068. <option></option>
  2069. <option value="vacuum">真空吸料機</option>
  2070. <option value="solenoid_reclaimed_in">中水入水</option>
  2071. <option value="solenoid_water_in">清水入水</option>
  2072. <option value="pump_water_in">幫浦</option>
  2073. <option value="solenoid_water_out">排水廢水</option>
  2074. <option value="solenoid_reclaimed_out">排水中水</option>
  2075. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2076. <option value="pump_disinfect">混合槽幫浦</option>
  2077. <option value="diskvalve">蝴蝶閥</option>
  2078. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2079. <option value="solenoid_outer_water">保溫夾層進水</option>
  2080. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2081. <option value="pump_sensor">雙核隔膜泵</option>
  2082. <option value="warninglight">警示燈</option>
  2083. <option value="camera">攝影機</option>
  2084. <option value="heater1">加熱器</option>
  2085. <option value="heater2">加熱器</option>
  2086. <option value="vacuum_pump">乾燥真空機</option>
  2087. <option value="nozzle">喷嘴</option>
  2088. </select>
  2089. </td>
  2090. <td>
  2091. Relay7:
  2092. <br>
  2093. <select id="select_relay_7" onchange="select_relay('7')" class="select-input">
  2094. <option></option>
  2095. <option value="vacuum">真空吸料機</option>
  2096. <option value="solenoid_reclaimed_in">中水入水</option>
  2097. <option value="solenoid_water_in">清水入水</option>
  2098. <option value="pump_water_in">幫浦</option>
  2099. <option value="solenoid_water_out">排水廢水</option>
  2100. <option value="solenoid_reclaimed_out">排水中水</option>
  2101. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2102. <option value="pump_disinfect">混合槽幫浦</option>
  2103. <option value="diskvalve">蝴蝶閥</option>
  2104. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2105. <option value="solenoid_outer_water">保溫夾層進水</option>
  2106. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2107. <option value="pump_sensor">雙核隔膜泵</option>
  2108. <option value="warninglight">警示燈</option>
  2109. <option value="camera">攝影機</option>
  2110. <option value="heater1">加熱器</option>
  2111. <option value="heater2">加熱器</option>
  2112. <option value="vacuum_pump">乾燥真空機</option>
  2113. <option value="nozzle">喷嘴</option>
  2114. </select>
  2115. </td>
  2116. <td>
  2117. Relay8:
  2118. <br>
  2119. <select id="select_relay_8" onchange="select_relay('8')" class="select-input">
  2120. <option></option>
  2121. <option value="vacuum">真空吸料機</option>
  2122. <option value="solenoid_reclaimed_in">中水入水</option>
  2123. <option value="solenoid_water_in">清水入水</option>
  2124. <option value="pump_water_in">幫浦</option>
  2125. <option value="solenoid_water_out">排水廢水</option>
  2126. <option value="solenoid_reclaimed_out">排水中水</option>
  2127. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2128. <option value="pump_disinfect">混合槽幫浦</option>
  2129. <option value="diskvalve">蝴蝶閥</option>
  2130. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2131. <option value="solenoid_outer_water">保溫夾層進水</option>
  2132. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2133. <option value="pump_sensor">雙核隔膜泵</option>
  2134. <option value="warninglight">警示燈</option>
  2135. <option value="camera">攝影機</option>
  2136. <option value="heater1">加熱器</option>
  2137. <option value="heater2">加熱器</option>
  2138. <option value="vacuum_pump">乾燥真空機</option>
  2139. <option value="nozzle">喷嘴</option>
  2140. </select>
  2141. </td>
  2142. </table>
  2143. <table style="border:0px gray solid;" cellpadding="4">
  2144. <!--font-size:12px; -->
  2145. <tr>
  2146. <td>
  2147. Relay9:
  2148. <br>
  2149. <select id="select_relay_9" onchange="select_relay('9')" class="select-input">
  2150. <option></option>
  2151. <option value="vacuum">真空吸料機</option>
  2152. <option value="solenoid_reclaimed_in">中水入水</option>
  2153. <option value="solenoid_water_in">清水入水</option>
  2154. <option value="pump_water_in">幫浦</option>
  2155. <option value="solenoid_water_out">排水廢水</option>
  2156. <option value="solenoid_reclaimed_out">排水中水</option>
  2157. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2158. <option value="pump_disinfect">混合槽幫浦</option>
  2159. <option value="diskvalve">蝴蝶閥</option>
  2160. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2161. <option value="solenoid_outer_water">保溫夾層進水</option>
  2162. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2163. <option value="pump_sensor">雙核隔膜泵</option>
  2164. <option value="warninglight">警示燈</option>
  2165. <option value="camera">攝影機</option>
  2166. <option value="heater1">加熱器</option>
  2167. <option value="heater2">加熱器</option>
  2168. <option value="vacuum_pump">乾燥真空機</option>
  2169. <option value="nozzle">喷嘴</option>
  2170. </select>
  2171. </td>
  2172. <td>
  2173. Relay10:
  2174. <br>
  2175. <select id="select_relay_10" onchange="select_relay('10')" class="select-input">
  2176. <option></option>
  2177. <option value="vacuum">真空吸料機</option>
  2178. <option value="solenoid_reclaimed_in">中水入水</option>
  2179. <option value="solenoid_water_in">清水入水</option>
  2180. <option value="pump_water_in">幫浦</option>
  2181. <option value="solenoid_water_out">排水廢水</option>
  2182. <option value="solenoid_reclaimed_out">排水中水</option>
  2183. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2184. <option value="pump_disinfect">混合槽幫浦</option>
  2185. <option value="diskvalve">蝴蝶閥</option>
  2186. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2187. <option value="solenoid_outer_water">保溫夾層進水</option>
  2188. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2189. <option value="pump_sensor">雙核隔膜泵</option>
  2190. <option value="warninglight">警示燈</option>
  2191. <option value="camera">攝影機</option>
  2192. <option value="heater1">加熱器</option>
  2193. <option value="heater2">加熱器</option>
  2194. <option value="vacuum_pump">乾燥真空機</option>
  2195. <option value="nozzle">喷嘴</option>
  2196. </select>
  2197. </td>
  2198. <td>
  2199. Relay11:
  2200. <br>
  2201. <select id="select_relay_11" onchange="select_relay('11')" class="select-input">
  2202. <option></option>
  2203. <option value="vacuum">真空吸料機</option>
  2204. <option value="solenoid_reclaimed_in">中水入水</option>
  2205. <option value="solenoid_water_in">清水入水</option>
  2206. <option value="pump_water_in">幫浦</option>
  2207. <option value="solenoid_water_out">排水廢水</option>
  2208. <option value="solenoid_reclaimed_out">排水中水</option>
  2209. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2210. <option value="pump_disinfect">混合槽幫浦</option>
  2211. <option value="diskvalve">蝴蝶閥</option>
  2212. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2213. <option value="solenoid_outer_water">保溫夾層進水</option>
  2214. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2215. <option value="pump_sensor">雙核隔膜泵</option>
  2216. <option value="warninglight">警示燈</option>
  2217. <option value="camera">攝影機</option>
  2218. <option value="heater1">加熱器</option>
  2219. <option value="heater2">加熱器</option>
  2220. <option value="vacuum_pump">乾燥真空機</option>
  2221. <option value="nozzle">喷嘴</option>
  2222. </select>
  2223. </td>
  2224. <td>
  2225. Relay12:
  2226. <br>
  2227. <select id="select_relay_12" onchange="select_relay('12')" class="select-input">
  2228. <option></option>
  2229. <option value="vacuum">真空吸料機</option>
  2230. <option value="solenoid_reclaimed_in">中水入水</option>
  2231. <option value="solenoid_water_in">清水入水</option>
  2232. <option value="pump_water_in">幫浦</option>
  2233. <option value="solenoid_water_out">排水廢水</option>
  2234. <option value="solenoid_reclaimed_out">排水中水</option>
  2235. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2236. <option value="pump_disinfect">混合槽幫浦</option>
  2237. <option value="diskvalve">蝴蝶閥</option>
  2238. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2239. <option value="solenoid_outer_water">保溫夾層進水</option>
  2240. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2241. <option value="pump_sensor">雙核隔膜泵</option>
  2242. <option value="warninglight">警示燈</option>
  2243. <option value="camera">攝影機</option>
  2244. <option value="heater1">加熱器</option>
  2245. <option value="heater2">加熱器</option>
  2246. <option value="vacuum_pump">乾燥真空機</option>
  2247. <option value="nozzle">喷嘴</option>
  2248. </select>
  2249. </td>
  2250. </table>
  2251. <table style="border:0px gray solid;" cellpadding="4">
  2252. <!--font-size:12px; -->
  2253. <tr>
  2254. <td>
  2255. Relay13:
  2256. <br>
  2257. <select id="select_relay_13" onchange="select_relay('13')" class="select-input">
  2258. <option></option>
  2259. <option value="vacuum">真空吸料機</option>
  2260. <option value="solenoid_reclaimed_in">中水入水</option>
  2261. <option value="solenoid_water_in">清水入水</option>
  2262. <option value="pump_water_in">幫浦</option>
  2263. <option value="solenoid_water_out">排水廢水</option>
  2264. <option value="solenoid_reclaimed_out">排水中水</option>
  2265. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2266. <option value="pump_disinfect">混合槽幫浦</option>
  2267. <option value="diskvalve">蝴蝶閥</option>
  2268. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2269. <option value="solenoid_outer_water">保溫夾層進水</option>
  2270. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2271. <option value="pump_sensor">雙核隔膜泵</option>
  2272. <option value="warninglight">警示燈</option>
  2273. <option value="camera">攝影機</option>
  2274. <option value="heater1">加熱器</option>
  2275. <option value="heater2">加熱器</option>
  2276. <option value="vacuum_pump">乾燥真空機</option>
  2277. <option value="nozzle">喷嘴</option>
  2278. </select>
  2279. </td>
  2280. <td>
  2281. Relay14:
  2282. <br>
  2283. <select id="select_relay_14" onchange="select_relay('14')" class="select-input">
  2284. <option></option>
  2285. <option value="vacuum">真空吸料機</option>
  2286. <option value="solenoid_reclaimed_in">中水入水</option>
  2287. <option value="solenoid_water_in">清水入水</option>
  2288. <option value="pump_water_in">幫浦</option>
  2289. <option value="solenoid_water_out">排水廢水</option>
  2290. <option value="solenoid_reclaimed_out">排水中水</option>
  2291. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2292. <option value="pump_disinfect">混合槽幫浦</option>
  2293. <option value="diskvalve">蝴蝶閥</option>
  2294. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2295. <option value="solenoid_outer_water">保溫夾層進水</option>
  2296. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2297. <option value="pump_sensor">雙核隔膜泵</option>
  2298. <option value="warninglight">警示燈</option>
  2299. <option value="camera">攝影機</option>
  2300. <option value="heater1">加熱器</option>
  2301. <option value="heater2">加熱器</option>
  2302. <option value="vacuum_pump">乾燥真空機</option>
  2303. <option value="nozzle">喷嘴</option>
  2304. </select>
  2305. </td>
  2306. <td>
  2307. Relay15:
  2308. <br>
  2309. <select id="select_relay_15" onchange="select_relay('15')" class="select-input">
  2310. <option></option>
  2311. <option value="vacuum">真空吸料機</option>
  2312. <option value="solenoid_reclaimed_in">中水入水</option>
  2313. <option value="solenoid_water_in">清水入水</option>
  2314. <option value="pump_water_in">幫浦</option>
  2315. <option value="solenoid_water_out">排水廢水</option>
  2316. <option value="solenoid_reclaimed_out">排水中水</option>
  2317. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2318. <option value="pump_disinfect">混合槽幫浦</option>
  2319. <option value="diskvalve">蝴蝶閥</option>
  2320. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2321. <option value="solenoid_outer_water">保溫夾層進水</option>
  2322. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2323. <option value="pump_sensor">雙核隔膜泵</option>
  2324. <option value="warninglight">警示燈</option>
  2325. <option value="camera">攝影機</option>
  2326. <option value="heater1">加熱器</option>
  2327. <option value="heater2">加熱器</option>
  2328. <option value="vacuum_pump">乾燥真空機</option>
  2329. <option value="nozzle">喷嘴</option>
  2330. </select>
  2331. </td>
  2332. <td>
  2333. Relay16:
  2334. <br>
  2335. <select id="select_relay_16" onchange="select_relay('16')" class="select-input">
  2336. <option></option>
  2337. <option value="vacuum">真空吸料機</option>
  2338. <option value="solenoid_reclaimed_in">中水入水</option>
  2339. <option value="solenoid_water_in">清水入水</option>
  2340. <option value="pump_water_in">幫浦</option>
  2341. <option value="solenoid_water_out">排水廢水</option>
  2342. <option value="solenoid_reclaimed_out">排水中水</option>
  2343. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2344. <option value="pump_disinfect">混合槽幫浦</option>
  2345. <option value="diskvalve">蝴蝶閥</option>
  2346. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2347. <option value="solenoid_outer_water">保溫夾層進水</option>
  2348. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2349. <option value="pump_sensor">雙核隔膜泵</option>
  2350. <option value="warninglight">警示燈</option>
  2351. <option value="camera">攝影機</option>
  2352. <option value="heater1">加熱器</option>
  2353. <option value="heater2">加熱器</option>
  2354. <option value="vacuum_pump">乾燥真空機</option>
  2355. <option value="nozzle">喷嘴</option>
  2356. </select>
  2357. </td>
  2358. </table>
  2359. <table style="border:0px gray solid;" cellpadding="4">
  2360. <!--font-size:12px; -->
  2361. <tr>
  2362. <td>
  2363. Relay17:
  2364. <br>
  2365. <select id="select_relay_17" onchange="select_relay('17')" class="select-input">
  2366. <option></option>
  2367. <option value="vacuum">真空吸料機</option>
  2368. <option value="solenoid_reclaimed_in">中水入水</option>
  2369. <option value="solenoid_water_in">清水入水</option>
  2370. <option value="pump_water_in">幫浦</option>
  2371. <option value="solenoid_water_out">排水廢水</option>
  2372. <option value="solenoid_reclaimed_out">排水中水</option>
  2373. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2374. <option value="pump_disinfect">混合槽幫浦</option>
  2375. <option value="diskvalve">蝴蝶閥</option>
  2376. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2377. <option value="solenoid_outer_water">保溫夾層進水</option>
  2378. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2379. <option value="pump_sensor">雙核隔膜泵</option>
  2380. <option value="warninglight">警示燈</option>
  2381. <option value="camera">攝影機</option>
  2382. <option value="heater1">加熱器</option>
  2383. <option value="heater2">加熱器</option>
  2384. <option value="vacuum_pump">乾燥真空機</option>
  2385. <option value="nozzle">喷嘴</option>
  2386. </select>
  2387. </td>
  2388. <td>
  2389. Relay18:
  2390. <br>
  2391. <select id="select_relay_18" onchange="select_relay('18')" class="select-input">
  2392. <option></option>
  2393. <option value="vacuum">真空吸料機</option>
  2394. <option value="solenoid_reclaimed_in">中水入水</option>
  2395. <option value="solenoid_water_in">清水入水</option>
  2396. <option value="pump_water_in">幫浦</option>
  2397. <option value="solenoid_water_out">排水廢水</option>
  2398. <option value="solenoid_reclaimed_out">排水中水</option>
  2399. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2400. <option value="pump_disinfect">混合槽幫浦</option>
  2401. <option value="diskvalve">蝴蝶閥</option>
  2402. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2403. <option value="solenoid_outer_water">保溫夾層進水</option>
  2404. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2405. <option value="pump_sensor">雙核隔膜泵</option>
  2406. <option value="warninglight">警示燈</option>
  2407. <option value="camera">攝影機</option>
  2408. <option value="heater1">加熱器</option>
  2409. <option value="heater2">加熱器</option>
  2410. <option value="vacuum_pump">乾燥真空機</option>
  2411. <option value="nozzle">喷嘴</option>
  2412. </select>
  2413. </td>
  2414. <td>
  2415. Relay19:
  2416. <br>
  2417. <select id="select_relay_19" onchange="select_relay('19')" class="select-input">
  2418. <option></option>
  2419. <option value="vacuum">真空吸料機</option>
  2420. <option value="solenoid_reclaimed_in">中水入水</option>
  2421. <option value="solenoid_water_in">清水入水</option>
  2422. <option value="pump_water_in">幫浦</option>
  2423. <option value="solenoid_water_out">排水廢水</option>
  2424. <option value="solenoid_reclaimed_out">排水中水</option>
  2425. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2426. <option value="pump_disinfect">混合槽幫浦</option>
  2427. <option value="diskvalve">蝴蝶閥</option>
  2428. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2429. <option value="solenoid_outer_water">保溫夾層進水</option>
  2430. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2431. <option value="pump_sensor">雙核隔膜泵</option>
  2432. <option value="warninglight">警示燈</option>
  2433. <option value="camera">攝影機</option>
  2434. <option value="heater1">加熱器</option>
  2435. <option value="heater2">加熱器</option>
  2436. <option value="vacuum_pump">乾燥真空機</option>
  2437. <option value="nozzle">喷嘴</option>
  2438. </select>
  2439. </td>
  2440. <td>
  2441. Relay20:
  2442. <br>
  2443. <select id="select_relay_20" onchange="select_relay('20')" class="select-input">
  2444. <option></option>
  2445. <option value="vacuum">真空吸料機</option>
  2446. <option value="solenoid_reclaimed_in">中水入水</option>
  2447. <option value="solenoid_water_in">清水入水</option>
  2448. <option value="pump_water_in">幫浦</option>
  2449. <option value="solenoid_water_out">排水廢水</option>
  2450. <option value="solenoid_reclaimed_out">排水中水</option>
  2451. <option value="solenoidvalve_disinfect">桶內消毒</option>
  2452. <option value="pump_disinfect">混合槽幫浦</option>
  2453. <option value="diskvalve">蝴蝶閥</option>
  2454. <option value="pump_reclaimed_out">入水清洗槽幫浦</option>
  2455. <option value="solenoid_outer_water">保溫夾層進水</option>
  2456. <option value="solenoid_tank_pump">逆洗幫浦</option>
  2457. <option value="pump_sensor">雙核隔膜泵</option>
  2458. <option value="warninglight">警示燈</option>
  2459. <option value="camera">攝影機</option>
  2460. <option value="heater1">加熱器</option>
  2461. <option value="heater2">加熱器</option>
  2462. <option value="vacuum_pump">乾燥真空機</option>
  2463. <option value="nozzle">喷嘴</option>
  2464. </select>
  2465. </td>
  2466. </table>
  2467. </td>
  2468. </tr>
  2469. </table>
  2470. </div>
  2471. </div>
  2472. </div>
  2473. </div>
  2474. <!-- 燒錄感測器互動視窗 -->
  2475. <div class="modal fade" id="control_sensor_Modal">
  2476. <div class="modal-dialog modal-dialog-centered modal-lg">
  2477. <div class="modal-content">
  2478. <!-- 互動視窗 標題 -->
  2479. <div class="modal-header">
  2480. <h4 id="Modal_sensor_title_input" class="modal-title"></h4>
  2481. <button type="button" class="close" data-dismiss="modal">&times;</button>
  2482. </div>
  2483. <!-- 互動視窗 內容 -->
  2484. <div class="modal-body">
  2485. <table style="border:0px gray solid; width: 100%;" cellpadding="4">
  2486. <!--<table style="border:0px gray solid;-->
  2487. <tr>
  2488. <td><strong><a>感測器</a></strong></td>
  2489. </tr>
  2490. <tr>
  2491. <td style="vertical-align:text-top;">
  2492. <table style="border:0px gray solid;" cellpadding="4">
  2493. <!--font-size:12px; -->
  2494. <tr>
  2495. <td>
  2496. 類比 M4 :
  2497. <br>
  2498. <select id="selectSensor_M4" onchange="selectSensor('M4')" class="select-input">
  2499. <option></option>
  2500. <option value="PH">PH計</option>
  2501. <option value="DO">DO計</option>
  2502. <option value="ORP">ORP計</option>
  2503. </select>
  2504. <br>
  2505. 類比 M5 :
  2506. <br>
  2507. <select id="selectSensor_M5" onchange="selectSensor('M5')" class="select-input">
  2508. <option></option>
  2509. <option value="PH">PH計</option>
  2510. <option value="DO">DO計</option>
  2511. <option value="ORP">ORP計</option>
  2512. </select>
  2513. <br>
  2514. 類比 M7 :
  2515. <br>
  2516. <select id="selectSensor_M7" onchange="selectSensor('M7')" class="select-input">
  2517. <option></option>
  2518. <option value="PH">PH計</option>
  2519. <option value="DO">DO計</option>
  2520. <option value="ORP">ORP計</option>
  2521. </select>
  2522. <br>
  2523. 數位 M9 :
  2524. <br>
  2525. <select id="selectSensor_M9" onchange="selectSensor('M9')" class="select-input">
  2526. <option></option>
  2527. <option value="WATERLEVEL">水位計</option>
  2528. <option value="motorfeedback">馬達編碼器</option>
  2529. <option value="butterflyvalvefeedback">蝴蝶閥編碼器</option>
  2530. </select>
  2531. <br>
  2532. 數位 M12 :
  2533. <br>
  2534. <select id="selectSensor_M12" onchange="selectSensor('M12')" class="select-input">
  2535. <option></option>
  2536. <option value="WATERLEVEL">水位計</option>
  2537. <option value="motorfeedback">馬達編碼器</option>
  2538. <option value="butterflyvalvefeedback">蝴蝶閥編碼器</option>
  2539. </select>
  2540. <br>
  2541. 數位 M19 :
  2542. <br>
  2543. <select id="selectSensor_M19" onchange="selectSensor('M19')" class="select-input">
  2544. <option></option>
  2545. <option value="WATERLEVEL">水位計</option>
  2546. <option value="motorfeedback">馬達編碼器</option>
  2547. <option value="butterflyvalvefeedback">蝴蝶閥編碼器</option>
  2548. </select>
  2549. </td>
  2550. <td>
  2551. PWM M10 :
  2552. <br>
  2553. <select id="selectSensor_M10" onchange="selectSensor('M10')" class="select-input">
  2554. <option></option>
  2555. <option value="Motor">馬達</option>
  2556. </select>
  2557. <br>
  2558. PWM M2 :
  2559. <br>
  2560. <select id="selectSensor_M2" onchange="selectSensor('M2')" class="select-input">
  2561. <option></option>
  2562. <option value="Servo">三通閥</option>
  2563. </select>
  2564. <br>
  2565. PWM M3 :
  2566. <br>
  2567. <select id="selectSensor_M3" onchange="selectSensor('M3')" class="select-input">
  2568. <option></option>
  2569. <option value="Servo">三通閥</option>
  2570. </select>
  2571. <br>
  2572. 數位 M14 :
  2573. <br>
  2574. <select id="selectSensor_M14" onchange="selectSensor('M14')" class="select-input">
  2575. <option></option>
  2576. <option value="SHT11">溫溼度</option>
  2577. <option value="DS18B20">水溫計</option>
  2578. </select>
  2579. <br>
  2580. 數位 M11 :
  2581. <br>
  2582. <select id="selectSensor_M11" onchange="selectSensor('M11')" class="select-input">
  2583. <option></option>
  2584. <option value="WATERLEVEL">水位計</option>
  2585. <option value="motorfeedback">馬達編碼器</option>
  2586. <option value="butterflyvalvefeedback">蝴蝶閥編碼器</option>
  2587. </select>
  2588. </td>
  2589. <td>
  2590. UART M16 :
  2591. <br>
  2592. <select id="selectSensor_M16" onchange="selectSensor('M16')" class="select-input">
  2593. <option></option>
  2594. <option value="EC">EC計</option>
  2595. <option value="DS18B20">水溫計</option>
  2596. <option value="Servo">真空閥</option>
  2597. </select>
  2598. <br>
  2599. UART M17 :
  2600. <br>
  2601. <select id="selectSensor_M17" onchange="selectSensor('M17')" class="select-input">
  2602. <option></option>
  2603. <option value="SHT11">溫溼度</option>
  2604. <option value="Servo">真空閥</option>
  2605. </select>
  2606. <br>
  2607. UART M18 :
  2608. <br>
  2609. <select id="selectSensor_M18" onchange="selectSensor('M18')" class="select-input">
  2610. <option></option>
  2611. <option>未定義</option>
  2612. </select>
  2613. <br>
  2614. I2C M15:
  2615. <br>
  2616. <select id="selectSensor_M15" onchange="selectSensor('M15')" class="select-input">
  2617. <option></option>
  2618. <option value="BMP280">大氣壓力計</option>
  2619. </select>
  2620. <br>
  2621. 485 M8:
  2622. <br>
  2623. <select id="selectSensor_M8" onchange="selectSensor('M8')" class="select-input">
  2624. <option></option>
  2625. <option value="Soil">土壤檢測計</option>
  2626. </select>
  2627. </td>
  2628. <td>
  2629. <br>
  2630. <br>
  2631. <br>
  2632. <br>
  2633. 分壓類比 M6:
  2634. <br>
  2635. <select id="selectSensor_M6" onchange="selectSensor('M6')" class="select-input">
  2636. <option></option>
  2637. <option value="SEN0189">濁度計</option>
  2638. </select>
  2639. <br>
  2640. 分壓類比 M13:
  2641. <br>
  2642. <select id="selectSensor_M13" onchange="selectSensor('M13')" class="select-input">
  2643. <option></option>
  2644. <option value="SEN0189">濁度計</option>
  2645. </select>
  2646. <br>
  2647. 分壓類比 M1:
  2648. <br>
  2649. <select id="selectSensor_M1" onchange="selectSensor('M1')" class="select-input">
  2650. <option></option>
  2651. <option value="SonicESMUS07">超音波</option>
  2652. </select>
  2653. </td>
  2654. </tr>
  2655. </table>
  2656. </td>
  2657. </tr>
  2658. </table>
  2659. </div>
  2660. </div>
  2661. </div>
  2662. </div>
  2663. </div>
  2664. {% endblock %}
  2665. {% block script2 %}
  2666. <script>
  2667. function update_data_crl(tid){
  2668. $('#Modal_title_input').text("控制板 " + tid+"致動器腳位設定" )
  2669. $('#control_Modal').modal('show');
  2670. };
  2671. function update_data_crl_sensor(tid){
  2672. $('#Modal_sensor_title_input').text("控制板 " + tid+"感測器腳位設定" )
  2673. $('#control_sensor_Modal').modal('show');
  2674. };
  2675. function update_data_crl_RF(tid){
  2676. $('#Modal_RF_title_input').text("控制板 " + tid+"通訊設定" )
  2677. $('#control_RF_Modal').modal('show');
  2678. };
  2679. var button_crl = document.getElementById('crl');
  2680. button_crl.addEventListener('click', function () { update_data_crl(Tank_ID) });
  2681. var button_crl_sensor = document.getElementById('crl_sensor');
  2682. button_crl_sensor.addEventListener('click', function () { update_data_crl_sensor(Tank_ID) });
  2683. var button_crl_RF = document.getElementById('crl_RF');
  2684. button_crl_RF.addEventListener('click', function () { update_data_crl_RF(Tank_ID) });
  2685. </script>
  2686. <script>
  2687. var toolbox = {
  2688. "kind":"categoryToolbox",
  2689. "contents":[
  2690. {
  2691. "kind":"category",
  2692. "name":"Logic",
  2693. "categorystyle":"logic_category",
  2694. "contents":[
  2695. {
  2696. "kind":"block",
  2697. "type":"controls_if",
  2698. },
  2699. {
  2700. "kind":"block",
  2701. "type":"controls_if",
  2702. "extraState":{
  2703. "hasElse":"true"
  2704. }
  2705. },
  2706. {
  2707. "kind":"block",
  2708. "type":"controls_if",
  2709. "extraState":{
  2710. "hasElse":"true",
  2711. "elseIfCount":1
  2712. }
  2713. }
  2714. ]
  2715. },
  2716. {
  2717. "kind":"category",
  2718. "name":"Boolean",
  2719. "categorystyle":"logic_category",
  2720. "contents":[
  2721. {
  2722. "kind":"block",
  2723. "type":"logic_compare"
  2724. },
  2725. {
  2726. "kind":"block",
  2727. "type":"logic_operation"
  2728. },
  2729. {
  2730. "kind":"block",
  2731. "type":"logic_negate"
  2732. },
  2733. {
  2734. "kind":"block",
  2735. "type":"logic_boolean"
  2736. },
  2737. {
  2738. "kind":"block",
  2739. "type":"logic_null"
  2740. },
  2741. {
  2742. "kind":"block",
  2743. "type":"logic_ternary"
  2744. }
  2745. ]
  2746. },
  2747. {
  2748. "kind":"category",
  2749. "name":"Loops",
  2750. "categorystyle":"loop_category",
  2751. "contents":[
  2752. {
  2753. "kind":"block",
  2754. "type":"controls_repeat_ext",
  2755. "inputs":{
  2756. "TIMES":{
  2757. "block":{
  2758. "type":"math_number",
  2759. "fields":{
  2760. "NUM":10
  2761. }
  2762. }
  2763. }
  2764. }
  2765. },
  2766. {
  2767. "kind":"block",
  2768. "type":"controls_whileUntil"
  2769. },
  2770. {
  2771. "kind":"block",
  2772. "type":"controls_for",
  2773. "fields":{
  2774. "VAR":"i"
  2775. },
  2776. "inputs":{
  2777. "FROM":{
  2778. "block":{
  2779. "type":"math_number",
  2780. "fields":{
  2781. "NUM":1
  2782. }
  2783. }
  2784. },
  2785. "TO":{
  2786. "block":{
  2787. "type":"math_number",
  2788. "fields":{
  2789. "NUM":10
  2790. }
  2791. }
  2792. },
  2793. "BY":{
  2794. "block":{
  2795. "type":"math_number",
  2796. "fields":{
  2797. "NUM":1
  2798. }
  2799. }
  2800. }
  2801. }
  2802. },
  2803. {
  2804. "kind":"block",
  2805. "type":"controls_forEach"
  2806. },
  2807. {
  2808. "kind":"block",
  2809. "type":"controls_flow_statements"
  2810. }
  2811. ]
  2812. },
  2813. {
  2814. "kind":"category",
  2815. "name":"Math",
  2816. "categorystyle":"math_category",
  2817. "contents":[
  2818. {
  2819. "kind":"block",
  2820. "type":"math_number",
  2821. "fields":{
  2822. "NUM":123
  2823. }
  2824. },
  2825. {
  2826. "kind":"block",
  2827. "type":"math_arithmetic",
  2828. "fields":{
  2829. "OP":"ADD"
  2830. }
  2831. },
  2832. {
  2833. "kind":"block",
  2834. "type":"math_single",
  2835. "fields":{
  2836. "OP":"ROOT"
  2837. }
  2838. },
  2839. {
  2840. "kind":"block",
  2841. "type":"math_trig",
  2842. "fields":{
  2843. "OP":"SIN"
  2844. }
  2845. },
  2846. {
  2847. "kind":"block",
  2848. "type":"math_constant",
  2849. "fields":{
  2850. "CONSTANT":"PI"
  2851. }
  2852. },
  2853. {
  2854. "kind":"block",
  2855. "type":"math_number_property",
  2856. "extraState":"<mutation divisor_input=\"false\"></mutation>",
  2857. "fields":{
  2858. "PROPERTY":"EVEN"
  2859. }
  2860. },
  2861. {
  2862. "kind":"block",
  2863. "type":"math_round",
  2864. "fields":{
  2865. "OP":"ROUND"
  2866. }
  2867. },
  2868. {
  2869. "kind":"block",
  2870. "type":"math_on_list",
  2871. "extraState":"<mutation op=\"SUM\"></mutation>",
  2872. "fields":{
  2873. "OP":"SUM"
  2874. }
  2875. },
  2876. {
  2877. "kind":"block",
  2878. "type":"math_modulo"
  2879. },
  2880. {
  2881. "kind":"block",
  2882. "type":"math_constrain",
  2883. "inputs":{
  2884. "LOW":{
  2885. "block":{
  2886. "type":"math_number",
  2887. "fields":{
  2888. "NUM":1
  2889. }
  2890. }
  2891. },
  2892. "HIGH":{
  2893. "block":{
  2894. "type":"math_number",
  2895. "fields":{
  2896. "NUM":100
  2897. }
  2898. }
  2899. }
  2900. }
  2901. },
  2902. {
  2903. "kind":"block",
  2904. "type":"math_random_int",
  2905. "inputs":{
  2906. "FROM":{
  2907. "block":{
  2908. "type":"math_number",
  2909. "fields":{
  2910. "NUM":1
  2911. }
  2912. }
  2913. },
  2914. "TO":{
  2915. "block":{
  2916. "type":"math_number",
  2917. "fields":{
  2918. "NUM":100
  2919. }
  2920. }
  2921. }
  2922. }
  2923. },
  2924. {
  2925. "kind":"block",
  2926. "type":"math_random_float"
  2927. },
  2928. {
  2929. "kind":"block",
  2930. "type":"math_atan2"
  2931. }
  2932. ]
  2933. },
  2934. {
  2935. "kind":"category",
  2936. "name":"Lists",
  2937. "categorystyle":"list_category",
  2938. "contents":[
  2939. {
  2940. "kind":"block",
  2941. "type":"lists_create_empty"
  2942. },
  2943. {
  2944. "kind":"block",
  2945. "type":"lists_create_with",
  2946. "extraState":{
  2947. "itemCount":3
  2948. }
  2949. },
  2950. {
  2951. "kind":"block",
  2952. "type":"lists_repeat",
  2953. "inputs":{
  2954. "NUM":{
  2955. "block":{
  2956. "type":"math_number",
  2957. "fields":{
  2958. "NUM":5
  2959. }
  2960. }
  2961. }
  2962. }
  2963. },
  2964. {
  2965. "kind":"block",
  2966. "type":"lists_length"
  2967. },
  2968. {
  2969. "kind":"block",
  2970. "type":"lists_isEmpty"
  2971. },
  2972. {
  2973. "kind":"block",
  2974. "type":"lists_indexOf",
  2975. "fields":{
  2976. "END":"FIRST"
  2977. }
  2978. },
  2979. {
  2980. "kind":"block",
  2981. "type":"lists_getIndex",
  2982. "fields":{
  2983. "MODE":"GET",
  2984. "WHERE":"FROM_START"
  2985. }
  2986. },
  2987. {
  2988. "kind":"block",
  2989. "type":"lists_setIndex",
  2990. "fields":{
  2991. "MODE":"SET",
  2992. "WHERE":"FROM_START"
  2993. }
  2994. }
  2995. ]
  2996. },
  2997. {
  2998. "kind":"sep"
  2999. },
  3000. {
  3001. "kind":"category",
  3002. "name":"Text",
  3003. "categorystyle":"text_category",
  3004. "contents":[
  3005. {
  3006. "kind":"block",
  3007. "type":"text"
  3008. }
  3009. ]
  3010. },
  3011. {
  3012. "kind":"category",
  3013. "name":"Variables",
  3014. "categorystyle":"variable_category",
  3015. "custom":"VARIABLE"
  3016. },
  3017. {
  3018. "kind":"category",
  3019. "name":"Functions",
  3020. "categorystyle":"procedure_category",
  3021. "custom":"PROCEDURE"
  3022. },
  3023. ]
  3024. }
  3025. var demoWorkspace = Blockly.inject('blocklyDiv',
  3026. {media: '../static/media/',
  3027. toolbox: toolbox});
  3028. </script>
  3029. {% endblock %}