actuator_chart_F.html 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. <!-- 宣告我們要套用模板 -->
  2. {% extends "base.html" %}
  3. {% block title %}{{ title }}{% endblock %}
  4. {% block script %}
  5. <!--引入 echarts.js -->
  6. <script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
  7. <script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js'></script>
  8. <script src='https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.js'></script>
  9. <script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-zoom/0.3.0/Chart.Zoom.min.js"></script>
  10. <script language="JavaScript">
  11. var tank = '{{tank}}';
  12. var sensor_name = '{{sensor_name}}';
  13. var status = '{{status}}';
  14. var username = '{{username}}';
  15. var tid = '{{tid}}';
  16. $(document).ready(function(){
  17. $("#coffee_title_pc").text(' 發酵槽致動器圖表');
  18. $("#coffee_title_phone").text(' 致動器');
  19. $('#navbarDropdown_user_pc').text(username);
  20. $('#navbarDropdown_user_phone').text(username);
  21. });
  22. </script>
  23. {% endblock %}
  24. {% block main %}
  25. <div class="album py-5 bg-light">
  26. <div class="container">
  27. <div class="row row-cols-1 row-cols-sm-1 row-cols-md-1 g-3">
  28. <div class="col">
  29. <div class="card shadow-sm">
  30. <div class="card-body">
  31. <div class="d-flex justify-content-between align-items-center">
  32. <table style="margin: auto; border:3px gray solid; width: 80%; text-align: center;" cellpadding="6" rules='ALL'>
  33. <tr>
  34. <td style="border:1px gray solid;">
  35. {% if tid == '2'%}
  36. <select id="tank_num">
  37. <option value="F1">發酵槽_1</option>
  38. <option value="F2" selected>發酵槽_2</option>
  39. <option value="F3">發酵槽_3</option>
  40. <option value="F4">發酵槽_4</option>
  41. <option value="F5">發酵槽_5</option>
  42. <option value="F6">發酵槽_6</option>
  43. <option value="F7">發酵槽_7</option>
  44. <option value="F8">發酵槽_8</option>
  45. <option value="F9">發酵槽_9</option>
  46. <option value="F10">發酵槽_10</option>
  47. <option value="F11">發酵槽_11</option>
  48. <option value="F12">發酵槽_12</option>
  49. </select>
  50. {% elif tid == '3'%}
  51. <select id="tank_num">
  52. <option value="F1">發酵槽_1</option>
  53. <option value="F2">發酵槽_2</option>
  54. <option value="F3" selected>發酵槽_3</option>
  55. <option value="F4">發酵槽_4</option>
  56. <option value="F5">發酵槽_5</option>
  57. <option value="F6">發酵槽_6</option>
  58. <option value="F7">發酵槽_7</option>
  59. <option value="F8">發酵槽_8</option>
  60. <option value="F9">發酵槽_9</option>
  61. <option value="F10">發酵槽_10</option>
  62. <option value="F11">發酵槽_11</option>
  63. <option value="F12">發酵槽_12</option>
  64. </select>
  65. {% elif tid == '4'%}
  66. <select id="tank_num">
  67. <option value="F1">發酵槽_1</option>
  68. <option value="F2">發酵槽_2</option>
  69. <option value="F3">發酵槽_3</option>
  70. <option value="F4" selected>發酵槽_4</option>
  71. <option value="F5">發酵槽_5</option>
  72. <option value="F6">發酵槽_6</option>
  73. <option value="F7">發酵槽_7</option>
  74. <option value="F8">發酵槽_8</option>
  75. <option value="F9">發酵槽_9</option>
  76. <option value="F10">發酵槽_10</option>
  77. <option value="F11">發酵槽_11</option>
  78. <option value="F12">發酵槽_12</option>
  79. </select>
  80. {% elif tid == '5'%}
  81. <select id="tank_num">
  82. <option value="F1">發酵槽_1</option>
  83. <option value="F2">發酵槽_2</option>
  84. <option value="F3">發酵槽_3</option>
  85. <option value="F4">發酵槽_4</option>
  86. <option value="F5" selected>發酵槽_5</option>
  87. <option value="F6">發酵槽_6</option>
  88. <option value="F7">發酵槽_7</option>
  89. <option value="F8">發酵槽_8</option>
  90. <option value="F9">發酵槽_9</option>
  91. <option value="F10">發酵槽_10</option>
  92. <option value="F11">發酵槽_11</option>
  93. <option value="F12">發酵槽_12</option>
  94. </select>
  95. {% elif tid == '6'%}
  96. <select id="tank_num">
  97. <option value="F1">發酵槽_1</option>
  98. <option value="F2">發酵槽_2</option>
  99. <option value="F3">發酵槽_3</option>
  100. <option value="F4">發酵槽_4</option>
  101. <option value="F5">發酵槽_5</option>
  102. <option value="F6" selected>發酵槽_6</option>
  103. <option value="F7">發酵槽_7</option>
  104. <option value="F8">發酵槽_8</option>
  105. <option value="F9">發酵槽_9</option>
  106. <option value="F10">發酵槽_10</option>
  107. <option value="F11">發酵槽_11</option>
  108. <option value="F12">發酵槽_12</option>
  109. </select>
  110. {% elif tid == '7'%}
  111. <select id="tank_num">
  112. <option value="F1">發酵槽_1</option>
  113. <option value="F2">發酵槽_2</option>
  114. <option value="F3">發酵槽_3</option>
  115. <option value="F4">發酵槽_4</option>
  116. <option value="F5">發酵槽_5</option>
  117. <option value="F6">發酵槽_6</option>
  118. <option value="F7" selected>發酵槽_7</option>
  119. <option value="F8">發酵槽_8</option>
  120. <option value="F9">發酵槽_9</option>
  121. <option value="F10">發酵槽_10</option>
  122. <option value="F11">發酵槽_11</option>
  123. <option value="F12">發酵槽_12</option>
  124. </select>
  125. {% elif tid == '8'%}
  126. <select id="tank_num">
  127. <option value="F1">發酵槽_1</option>
  128. <option value="F2">發酵槽_2</option>
  129. <option value="F3">發酵槽_3</option>
  130. <option value="F4">發酵槽_4</option>
  131. <option value="F5">發酵槽_5</option>
  132. <option value="F6">發酵槽_6</option>
  133. <option value="F7">發酵槽_7</option>
  134. <option value="F8" selected>發酵槽_8</option>
  135. <option value="F9">發酵槽_9</option>
  136. <option value="F10">發酵槽_10</option>
  137. <option value="F11">發酵槽_11</option>
  138. <option value="F12">發酵槽_12</option>
  139. </select>
  140. {% elif tid == '9'%}
  141. <select id="tank_num">
  142. <option value="F1">發酵槽_1</option>
  143. <option value="F2">發酵槽_2</option>
  144. <option value="F3">發酵槽_3</option>
  145. <option value="F4">發酵槽_4</option>
  146. <option value="F5">發酵槽_5</option>
  147. <option value="F6">發酵槽_6</option>
  148. <option value="F7">發酵槽_7</option>
  149. <option value="F8">發酵槽_8</option>
  150. <option value="F9" selected>發酵槽_9</option>
  151. <option value="F10">發酵槽_10</option>
  152. <option value="F11">發酵槽_11</option>
  153. <option value="F12">發酵槽_12</option>
  154. </select>
  155. {% elif tid == '10'%}
  156. <select id="tank_num">
  157. <option value="F1">發酵槽_1</option>
  158. <option value="F2">發酵槽_2</option>
  159. <option value="F3">發酵槽_3</option>
  160. <option value="F4">發酵槽_4</option>
  161. <option value="F5">發酵槽_5</option>
  162. <option value="F6">發酵槽_6</option>
  163. <option value="F7">發酵槽_7</option>
  164. <option value="F8">發酵槽_8</option>
  165. <option value="F9">發酵槽_9</option>
  166. <option value="F10" selected>發酵槽_10</option>
  167. <option value="F11">發酵槽_11</option>
  168. <option value="F12">發酵槽_12</option>
  169. </select>
  170. {% elif tid == '11'%}
  171. <select id="tank_num">
  172. <option value="F1">發酵槽_1</option>
  173. <option value="F2">發酵槽_2</option>
  174. <option value="F3">發酵槽_3</option>
  175. <option value="F4">發酵槽_4</option>
  176. <option value="F5">發酵槽_5</option>
  177. <option value="F6">發酵槽_6</option>
  178. <option value="F7">發酵槽_7</option>
  179. <option value="F8">發酵槽_8</option>
  180. <option value="F9">發酵槽_9</option>
  181. <option value="F10">發酵槽_10</option>
  182. <option value="F11" selected>發酵槽_11</option>
  183. <option value="F12">發酵槽_12</option>
  184. </select>
  185. {% elif tid == '12'%}
  186. <select id="tank_num">
  187. <option value="F1">發酵槽_1</option>
  188. <option value="F2">發酵槽_2</option>
  189. <option value="F3">發酵槽_3</option>
  190. <option value="F4">發酵槽_4</option>
  191. <option value="F5">發酵槽_5</option>
  192. <option value="F6">發酵槽_6</option>
  193. <option value="F7">發酵槽_7</option>
  194. <option value="F8">發酵槽_8</option>
  195. <option value="F9">發酵槽_9</option>
  196. <option value="F10">發酵槽_10</option>
  197. <option value="F11">發酵槽_11</option>
  198. <option value="F12" selected>發酵槽_12</option>
  199. </select>
  200. {% else %}
  201. <select id="tank_num">
  202. <option value="F1" selected>發酵槽_1</option>
  203. <option value="F2">發酵槽_2</option>
  204. <option value="F3">發酵槽_3</option>
  205. <option value="F4">發酵槽_4</option>
  206. <option value="F5">發酵槽_5</option>
  207. <option value="F6">發酵槽_6</option>
  208. <option value="F7">發酵槽_7</option>
  209. <option value="F8">發酵槽_8</option>
  210. <option value="F9">發酵槽_9</option>
  211. <option value="F10">發酵槽_10</option>
  212. <option value="F11">發酵槽_11</option>
  213. <option value="F12">發酵槽_12</option>
  214. </select>
  215. {% endif %}
  216. {% if sensor_name=='vacuum' %}
  217. <select id="sensors">
  218. <option value="vacuum" selected>真空吸料機</option>
  219. <option value="threewayvalve_input">入料三通閥</option>
  220. <option value="diskvalve">蝴蝶閥</option>
  221. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  222. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  223. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  224. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  225. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  226. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  227. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  228. <option value="motor">馬達</option>
  229. <option value="heater1">加熱器1</option>
  230. <option value="heater2">加熱器2</option>
  231. <option value="Warning_Light">警示燈</option>
  232. </select>
  233. {% elif sensor_name=='threewayvalve_input' %}
  234. <select id="sensors">
  235. <option value="vacuum">真空吸料機</option>
  236. <option value="threewayvalve_input"selected>入料三通閥</option>
  237. <option value="diskvalve">蝴蝶閥</option>
  238. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  239. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  240. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  241. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  242. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  243. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  244. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  245. <option value="motor">馬達</option>
  246. <option value="heater1">加熱器1</option>
  247. <option value="heater2">加熱器2</option>
  248. <option value="Warning_Light">警示燈</option>
  249. </select>
  250. {% elif sensor_name=='diskvalve' %}
  251. <select id="sensors">
  252. <option value="vacuum">真空吸料機</option>
  253. <option value="threewayvalve_input">入料三通閥</option>
  254. <option value="diskvalve"selected>蝴蝶閥</option>
  255. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  256. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  257. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  258. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  259. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  260. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  261. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  262. <option value="motor">馬達</option>
  263. <option value="heater1">加熱器1</option>
  264. <option value="heater2">加熱器2</option>
  265. <option value="Warning_Light">警示燈</option>
  266. </select>
  267. {% elif sensor_name=='solenoid_tank_pump' %}
  268. <select id="sensors">
  269. <option value="vacuum">真空吸料機</option>
  270. <option value="threewayvalve_input">入料三通閥</option>
  271. <option value="diskvalve">蝴蝶閥</option>
  272. <option value="solenoid_tank_pump"selected>逆洗幫浦電磁閥</option>
  273. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  274. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  275. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  276. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  277. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  278. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  279. <option value="motor">馬達</option>
  280. <option value="heater1">加熱器1</option>
  281. <option value="heater2">加熱器2</option>
  282. <option value="Warning_Light">警示燈</option>
  283. </select>
  284. {% elif sensor_name=='solenoid_tank_disinfect' %}
  285. <select id="sensors">
  286. <option value="vacuum">真空吸料機</option>
  287. <option value="threewayvalve_input">入料三通閥</option>
  288. <option value="diskvalve">蝴蝶閥</option>
  289. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  290. <option value="solenoid_tank_disinfect"selected>桶內消毒電磁閥</option>
  291. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  292. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  293. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  294. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  295. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  296. <option value="motor">馬達</option>
  297. <option value="heater1">加熱器1</option>
  298. <option value="heater2">加熱器2</option>
  299. <option value="Warning_Light">警示燈</option>
  300. </select>
  301. {% elif sensor_name=='solenoid_outer_water' %}
  302. <select id="sensors">
  303. <option value="vacuum">真空吸料機</option>
  304. <option value="threewayvalve_input">入料三通閥</option>
  305. <option value="diskvalve">蝴蝶閥</option>
  306. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  307. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  308. <option value="solenoid_outer_water"selected>保溫夾層進水電磁閥</option>
  309. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  310. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  311. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  312. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  313. <option value="motor">馬達</option>
  314. <option value="heater1">加熱器1</option>
  315. <option value="heater2">加熱器2</option>
  316. <option value="Warning_Light">警示燈</option>
  317. </select>
  318. {% elif sensor_name=='solenoid_tank_water_in' %}
  319. <select id="sensors">
  320. <option value="vacuum">真空吸料機</option>
  321. <option value="threewayvalve_input">入料三通閥</option>
  322. <option value="diskvalve">蝴蝶閥</option>
  323. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  324. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  325. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  326. <option value="solenoid_tank_water_in"selected>清水入水電磁閥</option>
  327. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  328. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  329. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  330. <option value="motor">馬達</option>
  331. <option value="heater1">加熱器1</option>
  332. <option value="heater2">加熱器2</option>
  333. <option value="Warning_Light">警示燈</option>
  334. </select>
  335. {% elif sensor_name=='solenoid_tank_water_out' %}
  336. <select id="sensors">
  337. <option value="vacuum">真空吸料機</option>
  338. <option value="threewayvalve_input">入料三通閥</option>
  339. <option value="diskvalve">蝴蝶閥</option>
  340. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  341. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  342. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  343. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  344. <option value="solenoid_tank_water_out"selected>排水廢水電磁閥</option>
  345. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  346. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  347. <option value="motor">馬達</option>
  348. <option value="heater1">加熱器1</option>
  349. <option value="heater2">加熱器2</option>
  350. <option value="Warning_Light">警示燈</option>
  351. </select>
  352. {% elif sensor_name=='pump_sensor' %}
  353. <select id="sensors">
  354. <option value="vacuum">真空吸料機</option>
  355. <option value="threewayvalve_input">入料三通閥</option>
  356. <option value="diskvalve">蝴蝶閥</option>
  357. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  358. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  359. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  360. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  361. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  362. <option value="pump_sensor"selected>感測器抽水雙核隔膜泵</option>
  363. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  364. <option value="motor">馬達</option>
  365. <option value="heater1">加熱器1</option>
  366. <option value="heater2">加熱器2</option>
  367. <option value="Warning_Light">警示燈</option>
  368. </select>
  369. {% elif sensor_name=='threewayvalve_outer_float' %}
  370. <select id="sensors">
  371. <option value="vacuum">真空吸料機</option>
  372. <option value="threewayvalve_input">入料三通閥</option>
  373. <option value="diskvalve">蝴蝶閥</option>
  374. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  375. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  376. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  377. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  378. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  379. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  380. <option value="threewayvalve_outer_float"selected>外桶浮選三通閥</option>
  381. <option value="motor">馬達</option>
  382. <option value="heater1">加熱器1</option>
  383. <option value="heater2">加熱器2</option>
  384. <option value="Warning_Light">警示燈</option>
  385. </select>
  386. {% elif sensor_name=='motor' %}
  387. <select id="sensors">
  388. <option value="vacuum">真空吸料機</option>
  389. <option value="threewayvalve_input">入料三通閥</option>
  390. <option value="diskvalve">蝴蝶閥</option>
  391. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  392. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  393. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  394. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  395. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  396. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  397. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  398. <option value="motor"selected>馬達</option>
  399. <option value="heater1">加熱器1</option>
  400. <option value="heater2">加熱器2</option>
  401. <option value="Warning_Light">警示燈</option>
  402. </select>
  403. {% elif sensor_name=='heater1' %}
  404. <select id="sensors">
  405. <option value="vacuum">真空吸料機</option>
  406. <option value="threewayvalve_input">入料三通閥</option>
  407. <option value="diskvalve">蝴蝶閥</option>
  408. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  409. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  410. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  411. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  412. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  413. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  414. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  415. <option value="motor">馬達</option>
  416. <option value="heater1"selected>加熱器1</option>
  417. <option value="heater2">加熱器2</option>
  418. <option value="Warning_Light">警示燈</option>
  419. </select>
  420. {% elif sensor_name=='heater2' %}
  421. <select id="sensors">
  422. <option value="vacuum">真空吸料機</option>
  423. <option value="threewayvalve_input">入料三通閥</option>
  424. <option value="diskvalve">蝴蝶閥</option>
  425. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  426. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  427. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  428. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  429. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  430. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  431. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  432. <option value="motor">馬達</option>
  433. <option value="heater1">加熱器1</option>
  434. <option value="heater2"selected>加熱器2</option>
  435. <option value="Warning_Light">警示燈</option>
  436. </select>
  437. {% elif sensor_name=='Warning_Light' %}
  438. <select id="sensors">
  439. <option value="vacuum">真空吸料機</option>
  440. <option value="threewayvalve_input">入料三通閥</option>
  441. <option value="diskvalve">蝴蝶閥</option>
  442. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  443. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  444. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  445. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  446. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  447. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  448. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  449. <option value="motor">馬達</option>
  450. <option value="heater1">加熱器1</option>
  451. <option value="heater2">加熱器2</option>
  452. <option value="Warning_Light"selected>警示燈</option>
  453. </select>
  454. {% else %}
  455. <select id="sensors">
  456. <option value="vacuum" selected>真空吸料機</option>
  457. <option value="threewayvalve_input">入料三通閥</option>
  458. <option value="diskvalve">蝴蝶閥</option>
  459. <option value="solenoid_tank_pump">逆洗幫浦電磁閥</option>
  460. <option value="solenoid_tank_disinfect">桶內消毒電磁閥</option>
  461. <option value="solenoid_outer_water">保溫夾層進水電磁閥</option>
  462. <option value="solenoid_tank_water_in">清水入水電磁閥</option>
  463. <option value="solenoid_tank_water_out">排水廢水電磁閥</option>
  464. <option value="pump_sensor">感測器抽水雙核隔膜泵</option>
  465. <option value="threewayvalve_outer_float">外桶浮選三通閥</option>
  466. <option value="motor">馬達</option>
  467. <option value="heater1">加熱器1</option>
  468. <option value="heater2">加熱器2</option>
  469. <option value="Warning_Light">警示燈</option>
  470. </select>
  471. {% endif %}
  472. </td>
  473. </tr>
  474. <tr>
  475. <td style="border:1px gray solid;">
  476. 時間間隔:
  477. <select name="time-interval" class="text-right">
  478. <option value="month">逐月</option>
  479. <option value="day">逐日</option>
  480. <option value="hour">逐時</option>
  481. </select>
  482. &nbsp;
  483. <!--
  484. 從&nbsp;
  485. <input type="datetime-local" name="sensor_starttime" id="sensor_starttime" value={{starttime}}>
  486. &nbsp;到&nbsp;
  487. <input type="datetime-local" name="sensor_endtime" id="sensor_endtime" value={{endtime}}>
  488. &nbsp;為止
  489. -->
  490. <span>從</span>
  491. <label for="querydate-start"></label><input id="querydate-start" type="date">
  492. <span>到</span>
  493. <label for="querydate-end"></label><input id="querydate-end" type="date">
  494. <span>為止</span>
  495. </td>
  496. </tr>
  497. <tr>
  498. <td style="border:1px gray solid;">
  499. 資料類型:
  500. <label><input type="checkbox" name="data-type" value="max">最大值</label>
  501. <label><input type="checkbox" name="data-type" value="avg">平均值</label>
  502. <label><input type="checkbox" name="data-type" value="min">最小值</label>
  503. <br>
  504. </td>
  505. </tr>
  506. <tr>
  507. <td style="border:1px gray solid;">
  508. <!--
  509. <button type="submit" name="charting">繪製圖表</button>
  510. <button type="submit" onclick="" id="btn_save_chart" style="display: none;">儲存圖表</button>
  511. -->
  512. <input type="button" class="btn btn-secondary" value="查詢" onclick="ShowInfo()">
  513. <input type="button" class="btn btn-secondary" value="匯出" onclick="downloadFile()">
  514. <script>
  515. function ShowInfo() {
  516. // 取得桶號、感測器名稱
  517. tid = document.getElementById("tank_num").value
  518. console.log('tid: ' + tid)
  519. sensor_name = document.getElementById("sensors").value
  520. console.log('sensor_name: ' + sensor_name)
  521. // 數據整理
  522. Echart(sensor_name, tid)
  523. // 顯示圖表
  524. };
  525. function downloadFile() {
  526. tid = document.getElementById("tank_num").value
  527. sensor_name = document.getElementById("sensors").value
  528. //藉型別陣列建構的 blob 來建立 URL
  529. let fileName = "ChartData_" + tid + "_" + sensor_name + ".csv";
  530. //"\ufeff"解決打開CSV中文亂碼問題
  531. const data = "\ufeff" + getData();
  532. let blob = new Blob([data], {
  533. type: 'text/csv,charset=UTF-8'
  534. });
  535. var href = URL.createObjectURL(blob);
  536. // 從 Blob 取出資料
  537. var link = document.createElement("a");
  538. document.body.appendChild(link);
  539. link.href = href;
  540. link.download = fileName;
  541. link.click();
  542. };
  543. //所有資料函數
  544. function getData() {
  545. var header = "日期," + data_name + "\n";
  546. var data = "";
  547. var length = all_datetime.length;
  548. for (var i = 0; i < length; i++) {
  549. data = data + all_datetime[i] + ',' + all_data[i] + '\n';
  550. };
  551. return header + data;
  552. };
  553. //最大最小平均資料函數
  554. function getData() {
  555. var header = data_name + "\n日期,";
  556. if (max_data) {
  557. console.log(max_data);
  558. header = header + "最大值,";
  559. };
  560. if (avg_data) {
  561. header = header + "平均值,";
  562. };
  563. if (min_data) {
  564. header = header + "最小值,";
  565. };
  566. header = header + "\n";
  567. var data = "";
  568. var length = xAxis_data.length;
  569. for (var i = 0; i < length; i++) {
  570. data = data + xAxis_data[i] + ',';
  571. if (max_data) {
  572. data = data + max_data[i] + ',';
  573. };
  574. if (avg_data) {
  575. data = data + avg_data[i] + ',';
  576. };
  577. if (min_data) {
  578. data = data + min_data[i] + ',';
  579. };
  580. data = data + '\n';
  581. };
  582. return header + data;
  583. };
  584. </script>
  585. </td>
  586. </tr>
  587. <tr>
  588. <td>
  589. <!--
  590. <img src={{ url }}>
  591. -->
  592. <div id="" class="show-info" style="text-align: center;">
  593. <center>
  594. <div class="show-chart" style="height: 420px; width: 100%; text-align: center;">
  595. 圖表
  596. </div>
  597. </center>
  598. </div>
  599. </td>
  600. </tr>
  601. </table>
  602. </div>
  603. </div>
  604. </div>
  605. </div>
  606. </div>
  607. </div>
  608. </div>
  609. {% endblock %}
  610. {% block script2 %}
  611. <script>
  612. var all_datetime = 0; // 所有資料時間 ?
  613. var all_data = 0; // 所有感測器數據 ?
  614. var data_name = 0; // 感測器名稱 // "溫溼度"
  615. var xAxis_data = 0; // x 軸資料
  616. var max_data = 0; //
  617. var min_data = 0; //
  618. var avg_data = 0; //
  619. function Echart(sensor_name, tid) {
  620. // Echart(sensor_name, tid)
  621. //將echarts圖形銷毀
  622. $(".show-chart").removeAttr("_echarts_instance_").empty();
  623. // Rita:sensor 與 data_name 重複
  624. // var sensor = evt.substring(2);
  625. if (!$("input[value=avg]").prop('checked') && !$("input[value=min]").prop('checked') && !$("input[value=max]").prop('checked')) {
  626. alert("請至少選擇一種資料類型!");
  627. return false;
  628. };
  629. if ($("#querydate-start").val() == '' || $("#querydate-end").val() == '') {
  630. alert("請選擇日期範圍!");
  631. return false;
  632. };
  633. //基於準備好的dom,初始化echarts例項
  634. var myChart = echarts.init(document.getElementsByClassName('show-chart')[0]); // class="col-10 show-chart"
  635. var date_start = $("#querydate-start").val();
  636. var date_end = $("#querydate-end").val();
  637. var avg = 0;
  638. var max = 0;
  639. var min = 0;
  640. var time_interval = $("select[name=time-interval]").val();
  641. var legend = new Array();
  642. var color = new Array();
  643. var series = new Array();
  644. if ($("input[value=max]").prop('checked')) {
  645. max = 1;
  646. legend.push("最大值");
  647. color.push("#1e88e5"); // 水藍色
  648. };
  649. if ($("input[value=avg]").prop('checked')) {
  650. avg = 1;
  651. legend.push("平均值");
  652. color.push("#43a047"); // 草綠色
  653. };
  654. if ($("input[value=min]").prop('checked')) {
  655. min = 1;
  656. legend.push("最小值");
  657. color.push("#e64a19"); // 橘紅色
  658. };
  659. var json = {
  660. 'tid': tid,
  661. 'sensor_name': sensor_name,
  662. 'avg': avg,
  663. 'max': max,
  664. 'min': min,
  665. 'time-interval': time_interval,
  666. 'date-start': date_start,
  667. 'date-end': date_end
  668. };
  669. console.log('json___' +
  670. 'tid: ' + tid +
  671. 'sensor_name: ' + sensor_name +
  672. 'avg: ' + avg +
  673. 'max: ' + max +
  674. 'min: ' + min +
  675. 'time-interval: ' + time_interval +
  676. 'date-start: ' + date_start +
  677. 'date-end: ' + date_end
  678. )
  679. $.get('/history_data_new', json, function (resText) {
  680. if (resText.max) {
  681. var max_series = {
  682. 'name': '最大值',
  683. 'type': 'scatter',
  684. 'data': resText.max.map(function (item) { return item[1]; }),
  685. 'itemStyle': { 'normal': { 'lineStyle': { 'color': '#1e88e5' } } },
  686. };
  687. series.push(max_series); // 把上面的 dict 加入 series array 內
  688. xAxis_data = resText.max.map(function (item) { return item[0]; });
  689. max_data = resText.max.map(function (item) { return item[1]; });
  690. };
  691. if (resText.avg) {
  692. var avg_series = { 'name': '平均值', 'type': 'scatter', 'data': resText.avg.map(function (item) { return item[1]; }), 'itemStyle': { 'normal': { 'lineStyle': { 'color': '#43a047' } } }, };
  693. series.push(avg_series);
  694. xAxis_data = resText.avg.map(function (item) { return item[0]; });
  695. console.log('xAxis_data: ' + xAxis_data) // 2021-07-09 10:00:00,2021-07-20 09:00:00,2021-07-22 15:00:00,2021-07-26 15:00:00,2021-07-26 16:00:00
  696. avg_data = resText.avg.map(function (item) { return item[1]; });
  697. console.log('avg_data: ' + avg_data) // 91.0,98.0,11.0,15.2,30.5
  698. };
  699. if (resText.min) {
  700. var min_series = { 'name': '最小值', 'type': 'scatter', 'data': resText.min.map(function (item) { return item[1]; }), 'itemStyle': { 'normal': { 'lineStyle': { 'color': '#e64a19' } } }, };
  701. series.push(min_series);
  702. xAxis_data = resText.min.map(function (item) { return item[0]; }); // all
  703. min_data = resText.min.map(function (item) { return item[1]; }); // min
  704. };
  705. //獲取日期內所有數據
  706. all_datetime = resText.all.map(function (item) { return item[0]; }); // all
  707. all_data = resText.all.map(function (item) { return item[1]; });
  708. //指定圖表的配置項和資料
  709. option = {
  710. title: {
  711. text: '', // 'Data History'
  712. left: '1%'
  713. },
  714. tooltip: {
  715. trigger: 'axis'
  716. },
  717. color: color,
  718. legend: {
  719. data: legend,
  720. },
  721. xAxis: {
  722. data: xAxis_data,
  723. },
  724. yAxis: {
  725. splitLine: {
  726. show: true,
  727. lineStyle: {
  728. color: ''
  729. }
  730. }
  731. },
  732. toolbox: {
  733. show: true,
  734. feature: {
  735. saveAsImage: {}
  736. }
  737. },
  738. dataZoom: [{
  739. startValue: '2021-01-01'
  740. }, {
  741. type: 'inside'
  742. }],
  743. series: series,
  744. /*
  745. series: [
  746. {
  747. name: '最大值',
  748. type: 'line',
  749. data: resText.max.map(function (item) {
  750. return item[1];
  751. }),
  752. itemStyle: {
  753. normal: {
  754. lineStyle: {
  755. color: '#1e88e5'
  756. }
  757. }
  758. },
  759. },
  760. {
  761. name: '平均值',
  762. type: 'line',
  763. data: [20.0, 20.0, 20.0, 20.0, 20.0, 20.0],
  764. itemStyle: {
  765. normal: {
  766. lineStyle: {
  767. color: '#43a047'
  768. }
  769. }
  770. },
  771. },
  772. {
  773. name: '最小值',
  774. type: 'line',
  775. data: [15.0, 15.0, 15.0, 15.0, 15.0, 15.0],
  776. itemStyle: {
  777. normal: {
  778. lineStyle: {
  779. color: '#e64a19'
  780. }
  781. }
  782. }
  783. },
  784. ]
  785. */
  786. };
  787. console.log('SHOW myChart')
  788. //使用剛指定的配置項和資料顯示圖表
  789. myChart.setOption(option);
  790. window.addEventListener('resize', myChart.resize);
  791. }, 'json');
  792. } // Echart(sensor_name, tid)
  793. </script>
  794. {% endblock %}