1
0

peel_container_tank.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>{{ title }}</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7. <!-- 新 Bootstrap4 核心 CSS 文件 -->
  8. <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
  9. <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
  10. <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  11. <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
  12. <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
  13. <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
  14. <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  15. <!--可用來建立使用者小圖示-->
  16. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  17. <script language="JavaScript">
  18. var ptid = '{{tid}}';
  19. $(document).ready(function(){
  20. $("#coffee_title_pc").text('P' + ptid + ' 脫皮機操作介面');
  21. $("#coffee_title_phone").text('P' + ptid + ' 操作介面');
  22. });
  23. </script>
  24. <script>
  25. // 清洗浮選 致動器開關
  26. var tank_num = '{{tid}}';
  27. // 入料 真空吸料機
  28. function inputVacuum(params) {
  29. if (params == '1') {
  30. var data = { "tank_num": "P" + tank_num, "command": "input_vacuum_status", "value": "on" };
  31. } else if (params == '0') {
  32. var data = { "tank_num": "P" + tank_num, "command": "input_vacuum_status", "value": "off" };
  33. } else {
  34. var status = "off";
  35. var check = $("input[name=input_vacuum_status]:checked"); // 這裡面是 jQuery 撈取資料的方法, jQuery 常使用到 $ 錢字號
  36. console.log('check:', check);
  37. //大於0代表有被選中, 如果有多個可以呈現勾取的項目數量
  38. if (check.length > 0) {
  39. status = "on";
  40. $("#cmn-toggle-62").prop('checked', false); // 確認是否勾選
  41. if (!confirm("你確定要開啟入料儲豆槽真空吸料機嗎?")) {
  42. return false;
  43. };
  44. } else {
  45. $("#cmn-toggle-62").prop('checked', true);
  46. if (!confirm("你確定要關閉入料儲豆槽真空吸料機嗎?")) {
  47. return false;
  48. };
  49. };
  50. var data = { "tank_num": "P" + tank_num, "command": "input_vacuum_status", "value": status };
  51. }
  52. $.post('/mqtt/{{tid}}', data, function (res) {
  53. console.log('data:', data)
  54. if (res == 'on') {
  55. $("#cmn-toggle-62").prop('checked', true);
  56. } else if (res == 'off') {
  57. $("#cmn-toggle-62").prop('checked', false);
  58. } else {
  59. };
  60. }, 'text')
  61. }
  62. // 桶內 真空吸料機
  63. function tankVacuum(params) {
  64. if (params == '1') {
  65. var data = { "tank_num": "P" + tank_num, "command": "tank_vacuum_status", "value": "on" };
  66. } else if (params == '0') {
  67. var data = { "tank_num": "P" + tank_num, "command": "tank_vacuum_status", "value": "off" };
  68. } else {
  69. var status = "off";
  70. var check = $("input[name=tank_vacuum_status]:checked");
  71. console.log('check:', check);
  72. //大於0代表有被選中
  73. if (check.length > 0) {
  74. status = "on";
  75. $("#cmn-toggle-65").prop('checked', false);
  76. if (!confirm("你確定要開啟真空吸料機嗎?")) {
  77. return false;
  78. };
  79. } else {
  80. $("#cmn-toggle-65").prop('checked', true);
  81. if (!confirm("你確定要關閉真空吸料機嗎?")) {
  82. return false;
  83. };
  84. };
  85. var data = { "tank_num": "P" + tank_num, "command": "tank_vacuum_status", "value": status };
  86. }
  87. $.post('/mqtt/{{tid}}', data, function (res) {
  88. console.log('data:', data)
  89. if (res == 'on') {
  90. $("#cmn-toggle-65").prop('checked', true);
  91. } else if (res == 'off') {
  92. $("#cmn-toggle-65").prop('checked', false);
  93. } else {
  94. };
  95. }, 'text')
  96. }
  97. // 馬達
  98. function tankMotor_set() {
  99. var motor_data = $("#motor_rpm_data").val();
  100. console.log("motor_data: " + motor_data)
  101. if (motor_data == '') {
  102. //$("#cmn-toggle-20").prop('checked', false);
  103. alert("請先輸入要運轉的值!");
  104. return false;
  105. } else if (motor_data == 0) {
  106. alert("轉速 0 為關閉馬達");
  107. } else if (Number(motor_data) < -50 || Number(motor_data) > 50 || !Number(motor_data)) {
  108. //
  109. //$("#cmn-toggle-20").prop('checked', false);
  110. alert("您輸入的值已超過範圍,請重新輸入!" + !Number(motor_data));
  111. return false;
  112. };
  113. var value = "off";
  114. //var check = $("input[name=peeling-machine-on]:checked");
  115. if (motor_data != 0) {
  116. value = motor_data;
  117. //$("#cmn-toggle-20").prop('checked', false);
  118. if (!confirm("你確定要開啟攪拌馬達,運轉速度為 " + motor_data + " RPM 嗎?")) {
  119. return false;
  120. };
  121. } else {
  122. //$("#cmn-toggle-20").prop('checked', true);
  123. if (!confirm("你確定要關閉攪拌馬達嗎?")) {
  124. return false;
  125. };
  126. };
  127. var data = { "tank_num": "P" + tank_num, "command": "tank_motor_status", "value": motor_data };
  128. $.post('/mqtt/{{tid}}', data, function (res) {
  129. console.log('data:', data)
  130. if (res == 'on') {
  131. //$("#cmn-toggle-14").prop('checked', true); // prop 設置元素屬型與元素值, 設定 checked 屬性為 true
  132. setTimeout("alert('攪拌馬達_開啟成功!')", 500); // 設定時間執行函式 delay(500), 只執行一次
  133. var timer = setInterval(Rotate, 60000); // 啟動後會在 60000 毫秒(更新時間一分鐘)內不斷執行 (原因須配合更新時間?)
  134. } else if (res == 'off') {
  135. //$("#cmn-toggle-14").prop('checked', false);
  136. setTimeout("alert('攪拌馬達_關閉成功!')", 500);
  137. clearInterval(timer); // 取消 timer 的不斷執行
  138. $("#motor_rpm_status").text(''); // 設置 #motor_rpm_status 的文字為空, #井字號
  139. } else {
  140. alert(res);
  141. };
  142. }, 'text')
  143. };
  144. function tankMotor(params) {
  145. var data = { "tank_num": "P" + tank_num, "command": "tank_motor_status", "value": params };
  146. $.post('/mqtt/{{tid}}', data, function (res) {
  147. console.log('data:', data)
  148. if (res == 'on') {
  149. var timer = setInterval(Rotate, 60000);
  150. } else if (res == 'off') {
  151. clearInterval(timer);
  152. $("#motor_rpm_status").text('');
  153. } else {
  154. };
  155. }, 'text')
  156. };
  157. function Rotate() {
  158. $.get('/peel', '', function (res) {
  159. //console.log(res.peeling);
  160. $("#motor_rpm_status").text(res.peeling + ' rpm(每1分鐘更新一次)');
  161. }, 'json');
  162. setTimeout(function () { location.reload(); }, 500);
  163. };
  164. // 馬達 反轉
  165. function tankMotor_Reverse() {
  166. $("#input").attr('placeholder');
  167. var tankMotor_now = ($('#motor_rpm_data').attr('placeholder'))*-1
  168. console.log('tankMotor_now: ' + tankMotor_now)
  169. tankMotor(String(tankMotor_now))
  170. setTimeout(function () { location.reload(); }, 3*1000);
  171. }
  172. // 出料 真空吸料機
  173. function outputVacuum(params) {
  174. if (params == '1') {
  175. var data = { "tank_num": "P" + tank_num, "command": "output_vacuum_status", "value": "on" };
  176. } else if (params == '0') {
  177. var data = { "tank_num": "P" + tank_num, "command": "output_vacuum_status", "value": "off" };
  178. } else {
  179. var status = "off";
  180. var check = $("input[name=output_vacuum_status]:checked");
  181. //大於0代表有被選中
  182. if (check.length > 0) {
  183. status = "on";
  184. $("#cmn-toggle-71").prop('checked', false);
  185. if (!confirm("你確定要開啟出料儲豆槽真空吸料機嗎?")) {
  186. return false;
  187. };
  188. } else {
  189. $("#cmn-toggle-71").prop('checked', true);
  190. if (!confirm("你確定要關閉出料儲豆槽真空吸料機嗎?")) {
  191. return false;
  192. };
  193. };
  194. var data = { "tank_num": "P" + tank_num, "command": "output_vacuum_status", "value": status };
  195. }
  196. $.post('/mqtt/{{tid}}', data, function (res) {
  197. if (res == 'on') {
  198. $("#cmn-toggle-71").prop('checked', true);
  199. } else if (res == 'off') {
  200. $("#cmn-toggle-71").prop('checked', false);
  201. } else {
  202. };
  203. }, 'text')
  204. }
  205. </script>
  206. <script language="JavaScript">
  207. function changeUpdate() {
  208. clearInterval(WebUpdate_set);
  209. var webupdate_time = $("input[name=webupdate_time]").val()
  210. console.log('webupdate_time' + webupdate_time)
  211. WebUpdate_set = setInterval(function(){WebUpdate(ptid)} , webupdate_time * 1000);
  212. }
  213. </script>
  214. </head>
  215. <body>
  216. <div id="wrapper">
  217. <div id="coffee_header">
  218. <!-- 匯入共同使用的 header.html 內容 -->
  219. {% include 'header.html' %}
  220. </div>
  221. <h4>致動器</h4>
  222. <table border="1" class="table-all" cellpadding="3" style="text-align: center;">
  223. <tr>
  224. <td style="color:red;">Valve</td>
  225. <td>真空吸料機</td>
  226. <td>馬達</td>
  227. </tr>
  228. <tr>
  229. <td>
  230. <span style="color:#C0C0C0;">off</span>
  231. <span style="color:#008CBA;">on</span>
  232. </td>
  233. <td>
  234. <div class="switch_div">
  235. <div class="switch">
  236. <input type="checkbox" class="cmn-toggle cmn-toggle-round" id="cmn-toggle-64">
  237. </div>
  238. <div class="switch text-center">
  239. {% if tank_vacuum== 1 %}
  240. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-65" checked
  241. name="tank_vacuum_status" value="ON" onclick="tankVacuum()">
  242. {% else %}
  243. <input type="checkbox" class="cmn-toggle cmn-toggle-round-flat" id="cmn-toggle-65"
  244. name="tank_vacuum_status" value="OFF" onclick="tankVacuum()">
  245. {% endif %}
  246. <label class="label_ActuatorStatus" for="cmn-toggle-65"></label>
  247. </div>
  248. <div class="switch">
  249. <input type="checkbox" class="cmn-toggle cmn-toggle-yes-no" id="cmn-toggle-66">
  250. </div>
  251. </div>
  252. </td>
  253. <td>
  254. <input type="text" class="input-text" id="motor_rpm_data" placeholder="{{tank_motor}}" value="">RPM<br>
  255. <input type="button" class="input-button" value="Confirm" name="tank_motor_status" onclick="tankMotor_set()">
  256. </td>
  257. </tr>
  258. <tr>
  259. <td><span style="color:#008CBA;"><b>ON</b></span></td>
  260. <td><input type="button" class="input-button-on" value="ON" onclick="tankVacuum('1')"></td>
  261. <td>
  262. <input type="button" class="input-button-on" value="40" onclick="tankMotor('40')">
  263. <input type="button" class="input-button-on" value="-40" onclick="tankMotor('-40')">
  264. <input type="button" class="input-button-on" value="20" onclick="tankMotor('20')">
  265. <input type="button" class="input-button-on" value="Rev." onclick="tankMotor_Reverse()">
  266. </td>
  267. </tr>
  268. <tr>
  269. <td><span style="color:#C0C0C0;"><b>OFF</b></span></td>
  270. <td><input type="button" class="input-button-off" value="OFF" onclick="tankVacuum('0')"></td>
  271. <td><input type="button" class="input-button-off" value="0" onclick="tankMotor('0')"></td>
  272. </tr>
  273. </table>
  274. <br>
  275. <h4>感測器</h4>
  276. <table border="1" class="table-all" cellpadding="3">
  277. <tr>
  278. <td style="background-color:#f3f3f3">
  279. 生豆高度
  280. </td>
  281. <td><span id="UltraSonic_t_status">{{tank_UltraSonic.UltraSonic}}</span> 公分</td>
  282. <td style="background-color:#f3f3f3">
  283. 馬達編碼器
  284. </td>
  285. <td><span id="motorEncoder_t_status">{{tank_motorEncoder.motorEncoder}}</span> RPM</td>
  286. </tr>
  287. </table>
  288. <br>
  289. <h4>排程測試</h4>
  290. <table border="1" class="table-all" cellpadding="3">
  291. <tr>
  292. <td>生豆高度
  293. <input type="text" class="input-text" name="Peel_Tank_bean_height" value="20">公分<br>
  294. 馬達轉速
  295. <input type="text" class="input-text" name="Peel_Tank_motor_rpm" value="30">rpm<br>
  296. 吸料
  297. <input type="text" class="input-text" name="Peel_Tank_vacuumON_time" value="10">秒,
  298. 放料
  299. <input type="text" class="input-text" name="Peel_Tank_vacuumOFF_time" value="10">秒<br>
  300. </td>
  301. </tr>
  302. <tr>
  303. <td>
  304. <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="peel_auto_status_testing()">
  305. <u>[測試] 脫皮自動化_狀態判斷</u></button>
  306. <button style="margin: 5px 10px 0px 10px;" type="submit" class="btn btn-primary" onclick="peel_auto_status_stop()">
  307. <u>狀態判斷_停止</u></button>
  308. <script>
  309. var peel_status_process = 0;
  310. var data;
  311. function getting_parameters_P(){
  312. var Peel_Tank_bean_height = $('input[name=Peel_Tank_bean_height]').val();
  313. var Peel_Tank_motor_rpm = $('input[name=Peel_Tank_motor_rpm]').val();
  314. var Peel_Tank_vacuumON_time = $('input[name=Peel_Tank_vacuumON_time]').val();
  315. var Peel_Tank_vacuumOFF_time = $('input[name=Peel_Tank_vacuumOFF_time]').val();
  316. data = {"Peel_Tank_bean_height":Peel_Tank_bean_height,
  317. "Peel_Tank_motor_rpm":Peel_Tank_motor_rpm,
  318. "Peel_Tank_vacuumON_time":Peel_Tank_vacuumON_time,
  319. "Peel_Tank_vacuumOFF_time":Peel_Tank_vacuumOFF_time
  320. }
  321. }
  322. function peel_auto_status_stop(){
  323. clearInterval(peel_status_interval)
  324. console.log("------- 狀態自動化判斷 停止 -------")
  325. }
  326. function peel_auto_status_testing(){
  327. console.log("------- 狀態自動化判斷 開始 -------")
  328. getting_parameters_P()
  329. // 更新桶槽狀態
  330. peel_status_interval = setInterval(peel_auto_status, 5*1000);
  331. function peel_auto_status(){
  332. if (peel_status_process == 1) { return }
  333. peel_status_process = 1;
  334. $.get('/peel_auto_status', data, function (res){
  335. P1 = res.Peel_Tank_1
  336. PO1 = res.Peel_Output_1
  337. console.log('P1: ' + P1)
  338. console.log('PO1: ' + PO1)
  339. peel_status_process = 0;
  340. }, 'json');
  341. }
  342. }
  343. </script>
  344. </td>
  345. </tr>
  346. </table>
  347. <div id="coffee_footer">
  348. <!-- 匯入共同使用的 footer.html 內容 -->
  349. {% include 'footer.html' %}
  350. </div>
  351. </div>
  352. </body>
  353. <script>
  354. // jQuery 更新感測器致動器狀態
  355. function WebUpdate(ptid) {
  356. $.get('/loading/P' + ptid, '', function (res) {
  357. if (res.tank_vacuum == 0) {
  358. $("#cmn-toggle-65").prop('checked', false);
  359. } else if (res.tank_vacuum == 1) {
  360. $("#cmn-toggle-65").prop('checked', true);
  361. }
  362. $("#motor_rpm_data").attr("placeholder", res.tank_motor);
  363. // console.log("res.tank_motor"+res.tank_motor)
  364. }, 'json');
  365. }
  366. </script>
  367. </html>