1
0

coffee_tanks_comm.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. #%%
  2. # 取得各網頁桶槽出料、入料優先順序
  3. while True:
  4. # DB 取得桶槽狀態
  5. # 將 優先順序 轉換成 桶槽狀態
  6. # 桶槽狀態轉換
  7. # 桶槽狀態存回 DB
  8. # 若有改變狀態, 更新優先順序
  9. break
  10. #%%
  11. # 測試 : 乾燥出料 對應 乾燥桶槽桶槽, 以利傳值到網頁, 供使用者排序
  12. import pymysql
  13. db = pymysql.connect(host='127.0.0.1', port=3306, user='root', password='Gold@53743001', database='CoffeeManage', charset='utf8')
  14. c = db.cursor()
  15. # # 1. 先找到乾燥出料儲豆槽編號, tank_type = 乾燥出料:DO1、DO2
  16. c.execute("SELECT `tank_id` FROM `dry_tank_relation` WHERE `tank_type`='dry_out'")
  17. Dry_Out_Items = c.fetchall()
  18. for i in range(len(Dry_Out_Items)):
  19. print("===== ", Dry_Out_Items[i][0], " ==========") # DO1
  20. c.execute("SELECT `tank_id` FROM `dry_tank_relation` WHERE `tank_type` = 'dry_tank' AND `tank_export` = '" + Dry_Out_Items[i][0] + "'")
  21. result = c.fetchall()
  22. print(Dry_Out_Items[i][0], "_result:", result)
  23. exec(Dry_Out_Items[i][0] + "_DryOut_Order = []")
  24. # # 2. 找到出料為 DO1 且 tank_type = 乾燥桶槽 之桶槽號:D1、D2、D3;以此類推
  25. for x in range(len(result)):
  26. eval(Dry_Out_Items[i][0] + "_DryOut_Order.append(result[x][0])")
  27. # eval("print('" + Dry_Out_Items[i][0] + "_DryOut_Order: ', DI1_DryOut_Order)")
  28. print(Dry_Out_Items[i][0] + "_DryOut_Order:", eval(Dry_Out_Items[i][0] + "_DryOut_Order"))
  29. # # 3. 請使用者分別排序 DO1 對應桶槽、DO2 對應桶槽
  30. # print("-----------------------------------------------------------")
  31. db.commit()
  32. db.close()
  33. #%%
  34. #%%
  35. #%%
  36. # # === 乾燥出豆 1/2 ======================================================
  37. # # === 網頁取值 ===========================
  38. DryOut_item = [
  39. 'DO1',
  40. 'DO2'
  41. ]
  42. DryOut_item_status = []
  43. DryOut_order = [
  44. ['D1', 'D2', 'D3'],
  45. ['D4', 'D5', 'D6'],
  46. ]
  47. DryOut_order_status = []
  48. #%%
  49. # # === 乾燥出豆 2/2 ======================================================
  50. # # === DB 取得桶槽狀態 ===========================
  51. D1 = 'ReadyForOutputtingBean'
  52. D2 = 'Waiting'
  53. D3 = 'Waiting'
  54. D4 = 'Waiting'
  55. D5 = 'Waiting'
  56. D6 = 'Waiting'
  57. D7 = 'ReadyForOutputtingBean'
  58. D8 = 'OutputtingBean'
  59. DO1 = 'Waiting'
  60. DO2 = 'Waiting'
  61. print("D1:", D1)
  62. print("D2:", D2)
  63. print("D3:", D3)
  64. print("D4:", D4)
  65. print("D5:", D5)
  66. print("D6:", D6)
  67. print("DO1:", DO1)
  68. print("DO2:", DO2)
  69. # # === 將桶槽號碼整理成狀態 ===========================
  70. for i in range(len(DryOut_item)):
  71. DryOut_item_status.append(eval(DryOut_item[i]))
  72. # print(DryOut_item[i], eval(DryOut_item[i]))
  73. target_list = []
  74. for o in range(len(DryOut_order[i])):
  75. target_list.append(eval(DryOut_order[i][o]))
  76. # print(DryOut_order[i][o], eval(DryOut_order[i][o]))
  77. DryOut_order_status.append(target_list)
  78. # print("===================================")
  79. # # === 桶槽狀態轉換 ===========================
  80. for i in range(len(DryOut_item_status)):
  81. if DryOut_item_status[i] == "Waiting" \
  82. and DryOut_order_status[i].count('OutputtingBean') == 0 \
  83. and DryOut_order_status[i].count('ReadyForOutputtingBean') != 0:
  84. for o in range(len(DryOut_order_status[i])):
  85. # print("=== OutputtingBean ", DryOut_order[i][o], "===")
  86. if DryOut_order_status[i][o] == "ReadyForOutputtingBean":
  87. exec(DryOut_order[i][o] + " = 'OutputtingBean'")
  88. exec(DryOut_item[i] + " = 'InputtingBean'")
  89. finish_order = DryOut_order[i][o]
  90. # print(finish_order)
  91. DryOut_order[i].pop(o)
  92. DryOut_order[i].append(finish_order)
  93. break
  94. print("===== status update =====")
  95. print("D1:", D1)
  96. print("D2:", D2)
  97. print("D3:", D3)
  98. print("D4:", D4)
  99. print("D5:", D5)
  100. print("D6:", D6)
  101. print("DO1:", DO1)
  102. print("DO2:", DO2)
  103. #%%
  104. #%%
  105. # # === 乾燥入豆 1/2 ======================================================
  106. # # === 網頁取值 ===========================
  107. DryIn_item = [
  108. 'DI1',
  109. 'DI2'
  110. ]
  111. DryIn_item_status = []
  112. DryIn_order = [
  113. ['D1', 'D2', 'D3'],
  114. ['D4', 'D5', 'D6'],
  115. ]
  116. DryIn_order_status = []
  117. #%%
  118. # # === 乾燥入豆 2/2 ======================================================
  119. # # === DB 取得桶槽狀態 ===========================
  120. DI1 = 'OutputtingBean'
  121. DI2 = 'OutputtingBean'
  122. D1 = 'Drying'
  123. D2 = 'Waiting'
  124. D3 = 'Waiting'
  125. D4 = 'Drying'
  126. D5 = 'Waiting'
  127. D6 = 'Waiting'
  128. print("DI1:", DI1)
  129. print("DI2:", DI2)
  130. print("D1:", D1)
  131. print("D2:", D2)
  132. print("D3:", D3)
  133. print("D4:", D4)
  134. print("D5:", D5)
  135. print("D6:", D6)
  136. # # === 將桶槽號碼整理成狀態 ===========================
  137. for i in range(len(DryIn_item)):
  138. DryIn_item_status.append(eval(DryIn_item[i]))
  139. # print(DryIn_item[i], eval(DryIn_item[i]))
  140. target_list = []
  141. for o in range(len(DryIn_order[i])):
  142. target_list.append(eval(DryIn_order[i][o]))
  143. # print(DryIn_order[i][o], eval(DryIn_order[i][o]))
  144. DryIn_order_status.append(target_list)
  145. # print("===================================")
  146. # # === 桶槽狀態轉換 ===========================
  147. for i in range(len(DryIn_item)):
  148. if DryIn_item_status[i] == "OutputtingBean" \
  149. and DryIn_order_status[i].count('InputtingBean') == 0:
  150. if DryIn_order_status[i].count('InputtingBean_Pause') != 0:
  151. for o in range(len(DryIn_order_status[i])):
  152. # print("=== Waiting ", DryIn_order[i][o], " ===")
  153. if DryIn_order_status[i][o] == "InputtingBean_Pause":
  154. # print(DryIn_order[i][o] + "= 'InputtingBean'")
  155. exec(DryIn_order[i][o] + " = 'InputtingBean'")
  156. break
  157. elif DryIn_order_status[i].count('Waiting') != 0:
  158. for o in range(len(DryIn_order_status[i])):
  159. # print("=== Waiting ", DryIn_order[i][o], " ===")
  160. if DryIn_order_status[i][o] == 'Waiting':
  161. # print(DryIn_order[i][o] + "= 'InputtingBean'")
  162. exec(DryIn_order[i][o] + " = 'InputtingBean'")
  163. finish_order = DryIn_order[i][o]
  164. print(finish_order)
  165. DryIn_order[i].pop(o)
  166. DryIn_order[i].append(finish_order)
  167. print("NEW DryIn_order :", DryIn_order)
  168. break
  169. elif DryIn_item_status[i] == "Waiting" or DryIn_item_status[i] == "InputtingBean":
  170. if DryIn_order_status.count('InputtingBean') != 0:
  171. for o in range(len(DryIn_order_status)):
  172. if DryIn_order_status[i][o] == 'InputtingBean':
  173. exec(DryIn_order[i][o] + " = 'InputtingBean_Pause'")
  174. break
  175. print("===== status update =====")
  176. print("DI1:", DI1)
  177. print("DI2:", DI2)
  178. print("D1:", D1)
  179. print("D2:", D2)
  180. print("D3:", D3)
  181. print("D4:", D4)
  182. print("D5:", D5)
  183. print("D6:", D6)
  184. # %%
  185. #%%
  186. # # === 發酵出豆 1/2 ======================================================
  187. # # === 網頁取值 ===========================
  188. FermentOut_item = [
  189. 'FO1',
  190. 'FO2'
  191. ]
  192. FermentOut_item_status = []
  193. FermentOut_order = [
  194. ['F1', 'F2', 'F3'],
  195. ['F4', 'F5', 'F6'],
  196. ]
  197. FermentOut_order_status = []
  198. # # === 乾燥出豆 2/2 ======================================================
  199. # # === DB 取得桶槽狀態 ===========================
  200. F1 = 'Waiting'
  201. F2 = 'ReadyForOutputtingBean'
  202. F3 = 'Waiting'
  203. F4 = 'Waiting'
  204. F5 = 'Waiting'
  205. F6 = 'Waiting'
  206. F7 = 'ReadyForOutputtingBean'
  207. F8 = 'OutputtingBean'
  208. FO1 = 'Waiting'
  209. FO2 = 'Waiting'
  210. print("F1:", F1)
  211. print("F2:", F2)
  212. print("F3:", F3)
  213. print("F4:", F4)
  214. print("F5:", F5)
  215. print("F6:", F6)
  216. print("FO1:", FO1)
  217. print("FO2:", FO2)
  218. # # === 將桶槽號碼整理成狀態 ===========================
  219. for i in range(len(FermentOut_item)):
  220. FermentOut_item_status.append(eval(FermentOut_item[i]))
  221. # print(FermentOut_item[i], eval(FermentOut_item[i]))
  222. target_list = []
  223. for o in range(len(FermentOut_order[i])):
  224. target_list.append(eval(FermentOut_order[i][o]))
  225. # print(FermentOut_order[i][o], eval(FermentOut_order[i][o]))
  226. FermentOut_order_status.append(target_list)
  227. # print("===================================")
  228. # # === 桶槽狀態轉換 ===========================
  229. for i in range(len(FermentOut_item_status)):
  230. if FermentOut_item_status[i] == "Waiting" \
  231. and FermentOut_order_status[i].count('OutputtingBean') == 0 \
  232. and FermentOut_order_status[i].count('ReadyForOutputtingBean') != 0:
  233. for o in range(len(FermentOut_order_status[i])):
  234. # print("=== OutputtingBean ", FermentOut_order[i][o], "===")
  235. if FermentOut_order_status[i][o] == "ReadyForOutputtingBean":
  236. exec(FermentOut_order[i][o] + " = 'OutputtingBean'")
  237. exec(FermentOut_item[i] + " = 'InputtingBean'")
  238. finish_order = FermentOut_order[i][o]
  239. # print(finish_order)
  240. FermentOut_order[i].pop(o)
  241. FermentOut_order[i].append(finish_order)
  242. print("NEW FermentOut_order", FermentOut_order)
  243. break
  244. print("===== status update =====")
  245. print("F1:", F1)
  246. print("F2:", F2)
  247. print("F3:", F3)
  248. print("F4:", F4)
  249. print("F5:", F5)
  250. print("F6:", F6)
  251. print("FO1:", FO1)
  252. print("FO2:", FO2)
  253. #%%
  254. #%%
  255. # # === 發酵入豆 1/2 ======================================================
  256. # # === 網頁取值 ===========================
  257. FermentIn_item = [
  258. 'FI1',
  259. 'FI2'
  260. ]
  261. FermentIn_item_status = []
  262. FermentIn_order = [
  263. ['F1', 'F2', 'F3'],
  264. ['F4', 'F5', 'F6'],
  265. ]
  266. FermentIn_order_status = []
  267. #%%
  268. # # === 發酵入豆 2/2 ======================================================
  269. # # === DB 取得桶槽狀態 ===========================
  270. FI1 = 'OutputtingBean'
  271. FI2 = 'OutputtingBean'
  272. F1 = 'Fermenting'
  273. F2 = 'Waiting'
  274. F3 = 'Waiting'
  275. F4 = 'Fermenting'
  276. F5 = 'Waiting'
  277. F6 = 'Waiting'
  278. print("FI1:", FI1)
  279. print("FI2:", FI2)
  280. print("F1:", F1)
  281. print("F2:", F2)
  282. print("F3:", F3)
  283. print("F4:", F4)
  284. print("F5:", F5)
  285. print("F6:", F6)
  286. # # === 將桶槽號碼整理成狀態 ===========================
  287. for i in range(len(FermentIn_item)):
  288. FermentIn_item_status.append(eval(FermentIn_item[i]))
  289. # print(FermentIn_item[i], eval(FermentIn_item[i]))
  290. target_list = []
  291. for o in range(len(FermentIn_order[i])):
  292. target_list.append(eval(FermentIn_order[i][o]))
  293. # print(FermentIn_order[i][o], eval(FermentIn_order[i][o]))
  294. FermentIn_order_status.append(target_list)
  295. # print("===================================")
  296. # # === 桶槽狀態轉換 ===========================
  297. for i in range(len(FermentIn_item)):
  298. if FermentIn_item_status[i] == "OutputtingBean" \
  299. and FermentIn_order_status[i].count('InputtingBean') == 0:
  300. if FermentIn_order_status[i].count('InputtingBean_Pause') != 0:
  301. for o in range(len(FermentIn_order_status[i])):
  302. # print("=== Waiting ", FermentIn_order[i][o], " ===")
  303. if FermentIn_order_status[i][o] == "InputtingBean_Pause":
  304. # print(FermentIn_order[i][o] + "= 'InputtingBean'")
  305. exec(FermentIn_order[i][o] + " = 'InputtingBean'")
  306. break
  307. elif FermentIn_order_status[i].count('Waiting') != 0:
  308. for o in range(len(FermentIn_order_status[i])):
  309. # print("=== Waiting ", FermentIn_order[i][o], " ===")
  310. if FermentIn_order_status[i][o] == 'Waiting':
  311. # print(FermentIn_order[i][o] + "= 'InputtingBean'")
  312. exec(FermentIn_order[i][o] + " = 'InputtingBean'")
  313. finish_order = FermentIn_order[i][o]
  314. print(finish_order)
  315. FermentIn_order[i].pop(o)
  316. FermentIn_order[i].append(finish_order)
  317. print("NEW FermentIn_order :", FermentIn_order)
  318. break
  319. elif FermentIn_item_status[i] == "Waiting" or FermentIn_item_status[i] == "InputtingBean":
  320. if FermentIn_order_status.count('InputtingBean') != 0:
  321. for o in range(len(FermentIn_order_status)):
  322. if FermentIn_order_status[i][o] == 'InputtingBean':
  323. exec(FermentIn_order[i][o] + " = 'InputtingBean_Pause'")
  324. break
  325. print("===== status update =====")
  326. print("FI1:", FI1)
  327. print("FI2:", FI2)
  328. print("F1:", F1)
  329. print("F2:", F2)
  330. print("F3:", F3)
  331. print("F4:", F4)
  332. print("F5:", F5)
  333. print("F6:", F6)
  334. #%%
  335. # # === 發酵出料 to 乾燥入料 1/2 ======================================================
  336. # # === 網頁取值 ===========================
  337. FtoD_item = [
  338. 'FO1',
  339. 'FO2'
  340. ]
  341. FtoD_item_status = []
  342. FtoD_order = [
  343. ['DO1'],
  344. ['DO2']
  345. ]
  346. FtoD_order_status = []
  347. #%%
  348. # # === 發酵出料 to 乾燥入料 2/2 ======================================================
  349. # # === DB 取得桶槽狀態 ===========================
  350. FO1 = 'OutputtingBean'
  351. FO2 = 'OutputtingBean'
  352. DO1 = 'OutputtingBean'
  353. DO2 = 'Waiting'
  354. print("FO1:", FO1)
  355. print("FO2:", FO2)
  356. print("DO1:", DO1)
  357. print("DO2:", DO2)
  358. # # === 將桶槽號碼整理成狀態 ===========================
  359. for i in range(len(FtoD_item)):
  360. # print(FtoD_item[i], eval(FtoD_item[i]))
  361. FtoD_item_status.append(eval(FtoD_item[i]))
  362. target_list = []
  363. for o in range(len(FtoD_order[i])):
  364. # print(FtoD_order[i][o], eval(FtoD_order[i][o]))
  365. target_list.append(eval(FtoD_order[i][o]))
  366. FtoD_order_status.append(target_list)
  367. # print("===================================")
  368. # print("FtoD_item_status: ", FtoD_item_status)
  369. # print("FtoD_order_status: ", FtoD_order_status)
  370. # # === 桶槽狀態轉換 ===========================
  371. for i in range(len(FtoD_item_status)):
  372. if FtoD_item_status[i] == "OutputtingBean" \
  373. and FtoD_order_status[i].count('InputtingBean') == 0 \
  374. and FtoD_order_status[i].count('Waiting') != 0 :
  375. for o in range(len(FtoD_order_status[i])):
  376. print("=== InputtingBean ", FtoD_order[i][o], "===")
  377. if FtoD_order_status[i][o] == "Waiting":
  378. exec(FtoD_order[i][o] + " = 'InputtingBean'")
  379. finish_order = FtoD_order[i][o]
  380. print(finish_order)
  381. FtoD_order[i].pop(o)
  382. FtoD_order[i].append(finish_order)
  383. print("NEW FtoD_order :", FtoD_order)
  384. break
  385. print("===== status update =====")
  386. print("FO1:", FO1)
  387. print("FO2:", FO2)
  388. print("DO1:", DO1)
  389. print("DO2:", DO2)
  390. #%%
  391. #%%
  392. # # === 脫皮出料 1/2 ======================================================
  393. # # === 網頁取值 ===========================
  394. PeelOut_item = [
  395. 'P1',
  396. 'P2'
  397. ]
  398. PeelOut_item_status = []
  399. PeelOut_order = [
  400. ['FI1'],
  401. ['FI2'],
  402. ]
  403. PeelOut_order_status = []
  404. PeelFullHeight = 30.0
  405. #%%
  406. # # === 脫皮出料 2/2 ======================================================
  407. # # === DB 取得桶槽狀態 ===========================
  408. # !!!!! 請注意, 這邊的 item 還要增加 超音波數值 (儲豆槽內豆子高度)
  409. P1 = 'Peeling'
  410. P2 = 'Peeling'
  411. P1_UltraSonic = 30.5
  412. P2_UltraSonic = 40
  413. FI1 = 'Outputting'
  414. FI2 = 'Waiting'
  415. print("P1: ", P1)
  416. print("P2: ", P2)
  417. print("P1_UltraSonic: ", P1_UltraSonic)
  418. print("P2_UltraSonic: ", P2_UltraSonic)
  419. print("FI1: ", FI1)
  420. print("FI2: ", FI2)
  421. # # === 將桶槽號碼整理成狀態 ===========================
  422. for i in range(len(PeelOut_item)):
  423. PeelOut_item_status.append(eval(PeelOut_item[i]))
  424. # print(PeelOut_item[i], eval(PeelOut_item[i]))
  425. target_list = []
  426. for o in range(len(PeelOut_order[i])):
  427. target_list.append(eval(PeelOut_order[i][o]))
  428. # print(PeelOut_order[i][o], eval(PeelOut_order[i][o]))
  429. PeelOut_order_status.append(target_list)
  430. # # === 桶槽狀態轉換 ===========================
  431. for i in range(len(PeelOut_item)):
  432. if eval(PeelOut_item[i] + "_UltraSonic") >= PeelFullHeight \
  433. and PeelOut_order_status[i].count('InputtingBean') == 0:
  434. if PeelOut_order_status[i].count('InputtingBean_Pause') != 0:
  435. for o in range(len(PeelOut_order_status[i])):
  436. # print("=== Waiting ", PeelOut_order[i][o], " ===")
  437. if PeelOut_order_status[i][o] == "InputtingBean_Pause":
  438. # print(PeelOut_order[i][o] + "= 'InputtingBean'")
  439. break
  440. elif PeelOut_order_status[i].count('Waiting') != 0:
  441. for o in range(len(PeelOut_order_status[i])):
  442. # print("=== Waiting ", PeelOut_order[i][o], " ===")
  443. if PeelOut_order_status[i][o] == 'Waiting':
  444. # print(PeelOut_order[i][o] + "= 'InputtingBean'")
  445. exec(PeelOut_order[i][o] + " = 'InputtingBean'")
  446. finish_order = PeelOut_order[i][o]
  447. print(finish_order)
  448. PeelOut_order[i].pop(o)
  449. PeelOut_order[i].append(finish_order)
  450. print("NEW PeelOut_order :", PeelOut_order)
  451. break
  452. else:
  453. if PeelOut_order_status.count('InputtingBean') != 0:
  454. for o in range(len(PeelOut_order_status)):
  455. if PeelOut_order_status[i][o] == 'InputtingBean':
  456. exec(PeelOut_order[i][o] + " = 'InputtingBean_Pause'")
  457. break
  458. print("===== status update =====")
  459. print("P1: ", P1)
  460. print("P2: ", P2)
  461. print("F1: ", FI1)
  462. print("F2: ", FI2)
  463. #%%
  464. #%%
  465. # # === 清洗出料 ======================================================
  466. # # === 網頁取值 ===========================
  467. # # !!!!! 請注意, 因為此處 C1、C2(多) S1(少), 多對少的狀況, 所以 S 為 item, C 為 order
  468. CleanOut_item = [
  469. 'S1',
  470. 'S2'
  471. ]
  472. CleanOut_item_status = []
  473. CleanOut_order = [
  474. ['C1', 'C2'],
  475. ['C3', 'C4']
  476. ]
  477. CleanOut_order_status = []
  478. ColorSelectFullHeight = 50.0
  479. # # === DB 取得桶槽狀態 ===========================
  480. # !!!!! 請注意, 這邊的 item 還要增加 超音波數值 (儲豆槽內豆子高度)
  481. C1 = 'ReadyForOutputtingBean'
  482. C2 = 'Waiting'
  483. C3 = 'Waiting'
  484. C4 = 'OutputtingBean'
  485. S1 = 'Waiting'
  486. S2 = 'ColorSelecting'
  487. S1_UltraSonic = 30.5
  488. S2_UltraSonic = 40
  489. print("C1: ", C1)
  490. print("C2: ", C2)
  491. print("C3: ", C3)
  492. print("C4: ", C4)
  493. print("S1: ", S1)
  494. print("S2: ", S2)
  495. # # === 將桶槽號碼整理成狀態 ===========================
  496. for i in range(len(CleanOut_item)):
  497. CleanOut_item_status.append(eval(CleanOut_item[i]))
  498. # print(CleanOut_item[i], eval(CleanOut_item[i]))
  499. target_list = []
  500. for o in range(len(CleanOut_order[i])):
  501. target_list.append(eval(CleanOut_order[i][o]))
  502. # print(CleanOut_order[i][o], eval(CleanOut_order[i][o]))
  503. CleanOut_order_status.append(target_list)
  504. # # === 桶槽狀態轉換 ===========================
  505. for i in range(len(CleanOut_item)):
  506. # print(eval(CleanOut_item[i] + "_UltraSonic"))
  507. if CleanOut_order_status[i].count('OutputtingBean') == 0 \
  508. and CleanOut_order_status[i].count('ReadyForOutputtingBean') != 0:
  509. for o in range(len(CleanOut_order_status[i])):
  510. # print("=== OutputtingBean ", CleanOut_order[i][o], " ===")
  511. if CleanOut_order_status[i][o] == 'ReadyForOutputtingBean':
  512. # print(CleanOut_order[i][o] + "= 'OutputtingBean'")
  513. exec(CleanOut_order[i][o] + " = 'OutputtingBean'")
  514. finish_order = CleanOut_order[i][o]
  515. print(finish_order)
  516. CleanOut_order[i].pop(o)
  517. CleanOut_order[i].append(finish_order)
  518. print("NEW CleanOut_order :", CleanOut_order)
  519. break
  520. print("===== status update =====")
  521. print("C1: ", C1)
  522. print("C2: ", C2)
  523. print("C3: ", C3)
  524. print("C4: ", C4)
  525. print("S1: ", S1)
  526. print("S2: ", S2)
  527. # %%