models.py 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. # coding: utf-8
  2. from datetime import datetime
  3. from sqlalchemy import Column, Date, DateTime, Float, Index, Integer, String, Text
  4. from sqlalchemy.schema import FetchedValue
  5. from flask_sqlalchemy import SQLAlchemy
  6. # db = SQLAlchemy()
  7. #與當前項目相關的模型文件,即所有的實體類在此編寫
  8. from coffee_manage import db
  9. from werkzeug.utils import send_file
  10. #用戶表
  11. class User(db.Model):
  12. __tablename__ = 'user'
  13. userID = db.Column(db.Integer, primary_key=True)
  14. firstname = db.Column(db.String(30), nullable=False)
  15. lastname = db.Column(db.String(30), nullable=False)
  16. mail = db.Column(db.String(50), nullable=False)
  17. phone = db.Column(db.String(20), nullable=False)
  18. username = db.Column(db.String(30), nullable=False, unique=True)
  19. password = db.Column(db.String(40), nullable=False)
  20. status = db.Column(db.Integer, nullable=False, info='0:admin;1:new;9:disable')
  21. # ////////////////////////////////////////////////////////////////////////////////
  22. # 乾燥槽
  23. # 乾燥桶入料_感測器_超音波感測器
  24. class dry_input_sensor(db.Model):
  25. __tablename__ = 'dry_input_sensor'
  26. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  27. tank_num = db.Column(db.Text, nullable=False)
  28. UltraSonic = db.Column(db.Text, nullable=False)
  29. # 乾燥桶_感測器_SHT11
  30. class dry_tank_SHT11(db.Model):
  31. __tablename__ = 'dry_tank_SHT11'
  32. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  33. tank_num = db.Column(db.Text, nullable=False)
  34. SHT11_Temp = db.Column(db.Text, nullable=False)
  35. SHT11_Humidity = db.Column(db.Text, nullable=False)
  36. # 乾燥桶_感測器_土壤三合一感測器
  37. class dry_tank_Soil(db.Model):
  38. __tablename__ = 'dry_tank_Soil'
  39. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  40. tank_num = db.Column(db.Text, nullable=False)
  41. soil_Temp = db.Column(db.Text, nullable=False)
  42. soil_Humidity = db.Column(db.Text, nullable=False)
  43. soil_EC = db.Column(db.Text, nullable=False)
  44. # 乾燥桶_感測器_超音波感測器
  45. class dry_tank_PA(db.Model):
  46. __tablename__ = 'dry_tank_PA'
  47. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  48. tank_num = db.Column(db.Text, nullable=False)
  49. PA = db.Column(db.Text, nullable=False)
  50. # 乾燥桶_感測器_超音波感測器
  51. class dry_tank_UltraSonic(db.Model):
  52. __tablename__ = 'dry_tank_UltraSonic'
  53. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  54. tank_num = db.Column(db.Text, nullable=False)
  55. UltraSonic = db.Column(db.Text, nullable=False)
  56. # 乾燥桶出料_感測器_超音波感測器
  57. class dry_output_sensor(db.Model):
  58. __tablename__ = 'dry_output_sensor'
  59. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  60. tank_num = db.Column(db.Text, nullable=False)
  61. UltraSonic = db.Column(db.Text, nullable=False)
  62. # 乾燥桶入料_排程設定
  63. class set_dry_input(db.Model):
  64. __tablename__ = 'set_dry_input'
  65. # sn
  66. sn = db.Column(db.Integer, primary_key=True)
  67. # 存入時間
  68. datetime = db.Column(db.DateTime, nullable=False)
  69. # 入料儲豆槽_咖啡豆高度
  70. input_height = db.Column(db.Text, nullable=False)
  71. # 乾燥桶_吸料時間
  72. input_entertime = db.Column(db.Text, nullable=False)
  73. # 乾燥桶_放料時間
  74. input_exittime = db.Column(db.Text, nullable=False)
  75. # 乾燥桶_咖啡豆高度
  76. tank_height = db.Column(db.Text, nullable=False)
  77. # 乾燥桶入料_致動器_真空吸料機
  78. class dry_input_brake(db.Model):
  79. __tablename__ = 'dry_input_brake'
  80. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  81. tank_num = db.Column(db.Text, nullable=False)
  82. vacuum = db.Column(db.Integer, nullable=False)
  83. #乾燥桶_致動器_ALL
  84. class dry_tank_brake(db.Model):
  85. __tablename__ = 'dry_tank_brake'
  86. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  87. tank_num = db.Column(db.Text, nullable=False)
  88. vacuum = db.Column(db.Integer, nullable=False)
  89. threewayvalve_input = db.Column(db.Integer, nullable=False)
  90. threewayvalve_bean = db.Column(db.Integer, nullable=False)
  91. diskvalve = db.Column(db.Integer, nullable=False)
  92. solenoid_disinfect = db.Column(db.Integer, nullable=False)
  93. solenoid_water = db.Column(db.Integer, nullable=False)
  94. solenoid_outer_water = db.Column(db.Integer, nullable=False)
  95. motor = db.Column(db.Integer, nullable=False)
  96. blower = db.Column(db.Integer, nullable=False)
  97. heater1 = db.Column(db.Integer, nullable=False)
  98. heater2 = db.Column(db.Integer, nullable=False)
  99. temp1_enable = db.Column(db.Integer, nullable=False)
  100. temp1 = db.Column(db.Float, nullable=False)
  101. # 乾燥桶出料_致動器_真空吸料機
  102. class dry_output_brake(db.Model):
  103. __tablename__ = 'dry_output_brake'
  104. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  105. tank_num = db.Column(db.Text, nullable=False)
  106. vacuum = db.Column(db.Integer, nullable=False)
  107. # ////////////////////////////////////////////////////////////////////////////////
  108. # 發酵槽
  109. # 發酵槽_發酵貨櫃入料儲豆槽_超音波感測器
  110. class ferment_input_UltraSonic(db.Model):
  111. __tablename__ = 'ferment_input_UltraSonic'
  112. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  113. tank_num = db.Column(db.Text, nullable=False)
  114. UltraSonic = db.Column(db.Text, nullable=False)
  115. # 發酵槽_發酵貨櫃入料儲豆槽_致動器
  116. class ferment_input_actuator(db.Model):
  117. __tablename__ = 'ferment_input_actuator'
  118. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  119. tank_num = db.Column(db.Text, nullable=False)
  120. vacuum = db.Column(db.Integer, nullable=False)
  121. # 發酵槽_感測器_SHT11
  122. class ferment_tank_SHT11(db.Model):
  123. __tablename__ = 'ferment_tank_SHT11'
  124. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  125. tank_num = db.Column(db.Text, nullable=False)
  126. SHT11_Temp = db.Column(db.Text, nullable=False)
  127. SHT11_Humidity = db.Column(db.Text, nullable=False)
  128. # 發酵槽_感測器_二氧化碳
  129. class ferment_tank_CO2(db.Model):
  130. __tablename__ = 'ferment_tank_CO2'
  131. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  132. tank_num = db.Column(db.Text, nullable=False)
  133. CO2 = db.Column(db.Text, nullable=False)
  134. # 發酵槽_感測器_PH
  135. class ferment_tank_PH(db.Model):
  136. __tablename__ = 'ferment_tank_PH'
  137. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  138. tank_num = db.Column(db.Text, nullable=False)
  139. PH = db.Column(db.Text, nullable=False)
  140. # 發酵槽_感測器_ORP
  141. class ferment_tank_ORP(db.Model):
  142. __tablename__ = 'ferment_tank_ORP'
  143. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  144. tank_num = db.Column(db.Text, nullable=False)
  145. ORP = db.Column(db.Text, nullable=False)
  146. # 發酵槽_感測器_DO
  147. class ferment_tank_DO(db.Model):
  148. __tablename__ = 'ferment_tank_DO'
  149. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  150. tank_num = db.Column(db.Text, nullable=False)
  151. DO = db.Column(db.Text, nullable=False)
  152. # 發酵槽_感測器_EC
  153. class ferment_tank_EC(db.Model):
  154. __tablename__ = 'ferment_tank_EC'
  155. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  156. tank_num = db.Column(db.Text, nullable=False)
  157. EC = db.Column(db.Text, nullable=False)
  158. # 發酵槽_感測器_PA
  159. class ferment_tank_PA(db.Model):
  160. __tablename__ = 'ferment_tank_PA'
  161. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  162. tank_num = db.Column(db.Text, nullable=False)
  163. PA = db.Column(db.Text, nullable=False)
  164. # 發酵槽保溫夾層_感測器_保溫夾層水位計
  165. class ferment_tank_WaterLevel(db.Model):
  166. __tablename__ = 'ferment_tank_WaterLevel'
  167. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  168. tank_num = db.Column(db.Text, nullable=False)
  169. WaterLevel = db.Column(db.Text, nullable=False)
  170. # 發酵槽_感測器_超音波感測器
  171. class ferment_tank_UltraSonic(db.Model):
  172. __tablename__ = 'ferment_tank_UltraSonic'
  173. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  174. tank_num = db.Column(db.Text, nullable=False)
  175. UltraSonic = db.Column(db.Text, nullable=False)
  176. # 發酵槽_感測器_咖啡生豆高度
  177. class ferment_tank_LiDAR(db.Model):
  178. __tablename__ = 'ferment_tank_LiDAR'
  179. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  180. tank_num = db.Column(db.Text, nullable=False)
  181. LiDAR = db.Column(db.Text, nullable=False)
  182. # 發酵槽_感測器_水位高度
  183. class ferment_tank_PressureWaterLevel(db.Model):
  184. __tablename__ = 'ferment_tank_PressureWaterLevel'
  185. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  186. tank_num = db.Column(db.Text, nullable=False)
  187. PressureWaterLevel = db.Column(db.Text, nullable=False)
  188. # 發酵槽_感測器_馬達編碼器
  189. class ferment_tank_motorEncoder(db.Model):
  190. __tablename__ = 'ferment_tank_motorEncoder'
  191. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  192. tank_num = db.Column(db.Text, nullable=False)
  193. motorEncoder = db.Column(db.Text, nullable=False)
  194. # 發酵槽_致動器
  195. class ferment_tank_actuator(db.Model):
  196. __tablename__ = 'ferment_tank_actuator'
  197. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  198. tank_num = db.Column(db.Text, nullable=False)
  199. vacuum = db.Column(db.Integer, nullable=False)
  200. threewayvalve_input = db.Column(db.Integer, nullable=False)
  201. diskvalve = db.Column(db.Integer, nullable=False)
  202. solenoid_tank_pump = db.Column(db.Integer, nullable=False)
  203. solenoid_tank_disinfect = db.Column(db.Integer, nullable=False)
  204. solenoid_outer_water = db.Column(db.Integer, nullable=False)
  205. solenoid_tank_water_in = db.Column(db.Integer, nullable=False)
  206. solenoid_tank_water_out = db.Column(db.Integer, nullable=False)
  207. pump_sensor = db.Column(db.Integer, nullable=False)
  208. threewayvalve_outer_float = db.Column(db.Integer, nullable=False)
  209. motor = db.Column(db.Integer, nullable=False)
  210. heater1 = db.Column(db.Integer, nullable=False)
  211. heater2 = db.Column(db.Integer, nullable=False)
  212. temp_enable = db.Column(db.Integer, nullable=False)
  213. temp = db.Column(db.Integer, nullable=False)
  214. # 發酵槽_發酵貨櫃出料儲豆槽_感測器
  215. class ferment_output_UltraSonic(db.Model):
  216. __tablename__ = 'ferment_output_UltraSonic'
  217. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  218. tank_num = db.Column(db.Text, nullable=False)
  219. UltraSonic = db.Column(db.Text, nullable=False)
  220. # 發酵槽_發酵貨櫃出料儲豆槽_致動器
  221. class ferment_output_actuator(db.Model):
  222. __tablename__ = 'ferment_output_actuator'
  223. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  224. tank_num = db.Column(db.Text, nullable=False)
  225. vacuum = db.Column(db.Integer, nullable=False)
  226. # 發酵槽_發酵貨櫃自動化狀態判斷
  227. class ferment_container_status(db.Model):
  228. __tablename__ = 'ferment_container_status'
  229. sn = db.Column(db.Integer, primary_key=True)
  230. datetime = db.Column(db.DateTime, nullable=False)
  231. Ferment_Input_1 = db.Column(db.Text, nullable=False)
  232. Ferment_Input_2 = db.Column(db.Text, nullable=False)
  233. Ferment_Tank_1 = db.Column(db.Text, nullable=False)
  234. Ferment_Tank_2 = db.Column(db.Text, nullable=False)
  235. Ferment_Tank_3 = db.Column(db.Text, nullable=False)
  236. Ferment_Tank_4 = db.Column(db.Text, nullable=False)
  237. Ferment_Tank_5 = db.Column(db.Text, nullable=False)
  238. Ferment_Tank_6 = db.Column(db.Text, nullable=False)
  239. Ferment_Tank_7 = db.Column(db.Text, nullable=False)
  240. Ferment_Tank_8 = db.Column(db.Text, nullable=False)
  241. Ferment_Tank_9 = db.Column(db.Text, nullable=False)
  242. Ferment_Tank_10 = db.Column(db.Text, nullable=False)
  243. Ferment_Tank_11 = db.Column(db.Text, nullable=False)
  244. Ferment_Tank_12 = db.Column(db.Text, nullable=False)
  245. Ferment_Output_1 = db.Column(db.Text, nullable=False)
  246. Ferment_Output_2 = db.Column(db.Text, nullable=False)
  247. # 乾燥槽_乾燥貨櫃自動化狀態判斷
  248. class dry_container_status(db.Model):
  249. __tablename__ = 'dry_container_status'
  250. sn = db.Column(db.Integer, primary_key=True)
  251. datetime = db.Column(db.DateTime, nullable=False)
  252. Dry_Input_1 = db.Column(db.Text, nullable=False)
  253. Dry_Input_2 = db.Column(db.Text, nullable=False)
  254. Dry_Tank_1 = db.Column(db.Text, nullable=False)
  255. Dry_Tank_2 = db.Column(db.Text, nullable=False)
  256. Dry_Tank_3 = db.Column(db.Text, nullable=False)
  257. Dry_Tank_4 = db.Column(db.Text, nullable=False)
  258. Dry_Tank_5 = db.Column(db.Text, nullable=False)
  259. Dry_Tank_6 = db.Column(db.Text, nullable=False)
  260. Dry_Tank_7 = db.Column(db.Text, nullable=False)
  261. Dry_Tank_8 = db.Column(db.Text, nullable=False)
  262. Dry_Tank_9 = db.Column(db.Text, nullable=False)
  263. Dry_Tank_10 = db.Column(db.Text, nullable=False)
  264. Dry_Tank_11 = db.Column(db.Text, nullable=False)
  265. Dry_Tank_12 = db.Column(db.Text, nullable=False)
  266. Dry_Output_1 = db.Column(db.Text, nullable=False)
  267. Dry_Output_2 = db.Column(db.Text, nullable=False)
  268. # 乾燥槽_乾燥貨櫃自動化狀態判斷
  269. class clean_container_status(db.Model):
  270. __tablename__ = 'clean_container_status'
  271. sn = db.Column(db.Integer, primary_key=True)
  272. datetime = db.Column(db.DateTime, nullable=False)
  273. Clean_Input_1 = db.Column(db.Text, nullable=False)
  274. Clean_Input_2 = db.Column(db.Text, nullable=False)
  275. Clean_Tank_1 = db.Column(db.Text, nullable=False)
  276. Clean_Tank_2 = db.Column(db.Text, nullable=False)
  277. Clean_Tank_3 = db.Column(db.Text, nullable=False)
  278. Clean_Tank_4 = db.Column(db.Text, nullable=False)
  279. ColorSelect_Input_1 = db.Column(db.Text, nullable=False)
  280. ColorSelect_Input_2 = db.Column(db.Text, nullable=False)
  281. ColorSelect_Tank_1 = db.Column(db.Text, nullable=False)
  282. ColorSelect_Tank_2 = db.Column(db.Text, nullable=False)
  283. ColorSelect_Output_g1 = db.Column(db.Text, nullable=False)
  284. ColorSelect_Output_b1 = db.Column(db.Text, nullable=False)
  285. ColorSelect_Output_g2 = db.Column(db.Text, nullable=False)
  286. ColorSelect_Output_b2 = db.Column(db.Text, nullable=False)
  287. Peel_Tank_1 = db.Column(db.Text, nullable=False)
  288. Peel_Tank_2 = db.Column(db.Text, nullable=False)
  289. Peel_Output_1 = db.Column(db.Text, nullable=False)
  290. Peel_Output_2 = db.Column(db.Text, nullable=False)
  291. Peel_Output_b1 = db.Column(db.Text, nullable=False)
  292. # ////////////////////////////////////////////////////////////////////////////////
  293. # 清洗貨櫃
  294. # 清洗浮選槽_清洗貨櫃入料儲豆槽_致動器
  295. class clean_input_actuator(db.Model):
  296. __tablename__ = 'clean_input_actuator'
  297. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  298. tank_num = db.Column(db.Text, nullable=False)
  299. vacuum = db.Column(db.Integer, nullable=False)
  300. # 清洗浮選槽_致動器 (old)
  301. class clean_tank_actuator(db.Model):
  302. __tablename__ = 'clean_tank_actuator'
  303. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  304. tank_num = db.Column(db.Text, nullable=False)
  305. vacuum = db.Column(db.Integer, nullable=False)
  306. pump_waterInput = db.Column(db.Integer, nullable=False)
  307. pump_waterL2L3 = db.Column(db.Integer, nullable=False)
  308. pump_waterL4L5 = db.Column(db.Integer, nullable=False)
  309. solenoid_waterL2L3 = db.Column(db.Integer, nullable=False)
  310. solenoid_waterL4L5 = db.Column(db.Integer, nullable=False)
  311. stepping_motor = db.Column(db.Text, nullable=False)
  312. # 清洗浮選槽_致動器 (new)
  313. class cleann_tank_actuator(db.Model):
  314. __tablename__ = 'cleann_tank_actuator'
  315. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  316. tank_num = db.Column(db.Text, nullable=False)
  317. vacuum = db.Column(db.Integer, nullable=False)
  318. threewayvalve_input = db.Column(db.Integer, nullable=False)
  319. motor = db.Column(db.Integer, nullable=False)
  320. solenoid_reclaimed_in = db.Column(db.Integer, nullable=False)
  321. solenoid_water_in = db.Column(db.Integer, nullable=False)
  322. pump_water_in = db.Column(db.Integer, nullable=False)
  323. solenoid_water_out = db.Column(db.Integer, nullable=False)
  324. solenoid_reclaimed_out = db.Column(db.Integer, nullable=False)
  325. solenoid_disinfect = db.Column(db.Integer, nullable=False)
  326. pump_disinfect = db.Column(db.Integer, nullable=False)
  327. diskvalve = db.Column(db.Integer, nullable=False)
  328. # 清洗浮選槽_清洗貨櫃出料儲豆槽_致動器
  329. class clean_output_actuator(db.Model):
  330. __tablename__ = 'clean_output_actuator'
  331. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  332. tank_num = db.Column(db.Text, nullable=False)
  333. vacuum = db.Column(db.Integer, nullable=False)
  334. # 清洗浮選槽_感測器
  335. class clean_tank_UltraSonic(db.Model):
  336. __tablename__ = 'clean_tank_UltraSonic'
  337. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  338. tank_num = db.Column(db.Text, nullable=False)
  339. UltraSonic = db.Column(db.Text, nullable=False)
  340. class clean_tank_Encoder(db.Model):
  341. __tablename__ = 'clean_tank_Encoder'
  342. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  343. tank_num = db.Column(db.Text, nullable=False)
  344. Encoder = db.Column(db.Text, nullable=False)
  345. class clean_tank_Turbidity(db.Model):
  346. __tablename__ = 'clean_tank_Turbidity'
  347. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  348. tank_num = db.Column(db.Text, nullable=False)
  349. tankTurbidity = db.Column(db.Text, nullable=False)
  350. class clean_filter_Turbidity(db.Model):
  351. __tablename__ = 'clean_filter_Turbidity'
  352. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  353. tank_num = db.Column(db.Text, nullable=False)
  354. filterTurbidity = db.Column(db.Text, nullable=False)
  355. # 脫皮機_清洗貨櫃入料儲豆槽_致動器
  356. class peel_input_actuator(db.Model):
  357. __tablename__ = 'peel_input_actuator'
  358. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  359. tank_num = db.Column(db.Text, nullable=False)
  360. vacuum = db.Column(db.Integer, nullable=False)
  361. # 脫皮機_致動器
  362. class peel_tank_actuator(db.Model):
  363. __tablename__ = 'peel_tank_actuator'
  364. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  365. tank_num = db.Column(db.Text, nullable=False)
  366. vacuum = db.Column(db.Integer, nullable=False)
  367. motor = db.Column(db.Integer, nullable=False)
  368. # 脫皮機_感測器
  369. class peel_output_UltraSonic(db.Model):
  370. __tablename__ = 'peel_output_UltraSonic'
  371. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  372. tank_num = db.Column(db.Text, nullable=False)
  373. UltraSonic = db.Column(db.Text, nullable=False)
  374. class peel_output_motorEncoder(db.Model):
  375. __tablename__ = 'peel_output_motorEncoder'
  376. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  377. tank_num = db.Column(db.Text, nullable=False)
  378. motorEncoder = db.Column(db.Text, nullable=False)
  379. # 脫皮機_清洗貨櫃出料儲豆槽_致動器
  380. class peel_output_actuator(db.Model):
  381. __tablename__ = 'peel_output_actuator'
  382. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  383. tank_num = db.Column(db.Text, nullable=False)
  384. vacuum = db.Column(db.Integer, nullable=False)
  385. # 色選機_清洗貨櫃出料儲豆槽_致動器
  386. class colorselect_output_actuator(db.Model):
  387. __tablename__ = 'colorselect_output_actuator'
  388. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  389. tank_num = db.Column(db.Text, nullable=False)
  390. vacuum = db.Column(db.Integer, nullable=False)
  391. class colorselect_tank_actuator(db.Model):
  392. __tablename__ = 'colorselect_tank_actuator'
  393. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  394. tank_num = db.Column(db.Text, nullable=False)
  395. vacuum = db.Column(db.Integer, nullable=False)
  396. motor = db.Column(db.Integer, nullable=False)
  397. nozzle = db.Column(db.Integer, nullable=False)
  398. class colorselect_tank_color(db.Model):
  399. __tablename__ = 'colorselect_tank_color'
  400. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  401. tank_num = db.Column(db.Text, nullable=False)
  402. color = db.Column(db.Integer, nullable=False)
  403. class colorselect_tank_UltraSonic(db.Model):
  404. __tablename__ = 'colorselect_tank_UltraSonic'
  405. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  406. tank_num = db.Column(db.Text, nullable=False)
  407. UltraSonic = db.Column(db.Integer, nullable=False)
  408. # 中水桶_致動器
  409. class reclaimed_tank_actuator(db.Model):
  410. __tablename__ = 'reclaimed_tank_actuator'
  411. datetime = db.Column(db.DateTime, nullable=False, primary_key=True)
  412. tank_num = db.Column(db.Text, nullable=False)
  413. solenoid_water_in = db.Column(db.Integer, nullable=False)
  414. solenoid_water_out = db.Column(db.Integer, nullable=False)
  415. solenoid_reclaimed_out = db.Column(db.Integer, nullable=False)
  416. pump_reclaimed_out = db.Column(db.Integer, nullable=False)
  417. # ////////////////////////////////////////////////////////////////////////////////
  418. #發酵槽溫度感測器表
  419. class TankTemSensor(db.Model):
  420. __tablename__ = 'tank_tem_sensor'
  421. sn = db.Column(db.Integer, primary_key=True)
  422. datetime = db.Column(db.DateTime, nullable=False)
  423. tank_num = db.Column(db.Integer, nullable=False)
  424. tem = db.Column(db.Text, nullable=False)
  425. #發酵槽二氧化碳感測器表
  426. class TankCO2Sensor(db.Model):
  427. __tablename__ = 'tank_co2_sensor'
  428. sn = db.Column(db.Integer, primary_key=True)
  429. datetime = db.Column(db.DateTime, nullable=False)
  430. tank_num = db.Column(db.Integer, nullable=False)
  431. co2 = db.Column(db.Text, nullable=False)
  432. #發酵槽酸鹼值感測器表
  433. class TankPHSensor(db.Model):
  434. __tablename__ = 'tank_ph_sensor'
  435. sn = db.Column(db.Integer, primary_key=True)
  436. datetime = db.Column(db.DateTime, nullable=False)
  437. tank_num = db.Column(db.Integer, nullable=False)
  438. ph = db.Column(db.Text, nullable=False)
  439. #發酵槽酸鹼值感測器表
  440. class TankECSensor(db.Model):
  441. __tablename__ = 'tank_ec_sensor'
  442. sn = db.Column(db.Integer, primary_key=True)
  443. datetime = db.Column(db.DateTime, nullable=False)
  444. tank_num = db.Column(db.Integer, nullable=False)
  445. ec = db.Column(db.Text, nullable=False)
  446. #發酵槽超音波感測器表
  447. class TankSonicSensor(db.Model):
  448. __tablename__ = 'tank_sonic_sensor'
  449. sn = db.Column(db.Integer, primary_key=True)
  450. datetime = db.Column(db.DateTime, nullable=False)
  451. tank_num = db.Column(db.Integer, nullable=False)
  452. sonic = db.Column(db.Text, nullable=False)
  453. class BeanValve(db.Model):
  454. __tablename__ = 'bean_valve'
  455. sn = db.Column(db.Integer, primary_key=True)
  456. datetime = db.Column(db.DateTime, nullable=False)
  457. duration = db.Column(db.Text, nullable=False)
  458. start = db.Column(db.Text, nullable=False)
  459. end = db.Column(db.Text, nullable=False)
  460. class WashMachine(db.Model):
  461. __tablename__ = 'wash_machine'
  462. sn = db.Column(db.Integer, primary_key=True)
  463. datetime = db.Column(db.DateTime, nullable=False)
  464. duration = db.Column(db.Text, nullable=False)
  465. start = db.Column(db.Text, nullable=False)
  466. end = db.Column(db.Text, nullable=False)
  467. class ConveyorBelt1(db.Model):
  468. __tablename__ = 'conveyor_belt1'
  469. sn = db.Column(db.Integer, primary_key=True)
  470. datetime = db.Column(db.DateTime, nullable=False)
  471. duration = db.Column(db.Text, nullable=False)
  472. start = db.Column(db.Text, nullable=False)
  473. end = db.Column(db.Text, nullable=False)
  474. class Cargo1Disinfect(db.Model):
  475. __tablename__ = 'cargo1_disinfect'
  476. sn = db.Column(db.Integer, primary_key=True)
  477. datetime = db.Column(db.DateTime, nullable=False)
  478. duration = db.Column(db.Text, nullable=False)
  479. start = db.Column(db.Text, nullable=False)
  480. end = db.Column(db.Text, nullable=False)
  481. class ColorMachine(db.Model):
  482. __tablename__ = 'color_machine'
  483. sn = db.Column(db.Integer, primary_key=True)
  484. datetime = db.Column(db.DateTime, nullable=False)
  485. duration = db.Column(db.Text, nullable=False)
  486. start = db.Column(db.Text, nullable=False)
  487. end = db.Column(db.Text, nullable=False)
  488. class ConveyorBelt2(db.Model):
  489. __tablename__ = 'conveyor_belt2'
  490. sn = db.Column(db.Integer, primary_key=True)
  491. datetime = db.Column(db.DateTime, nullable=False)
  492. duration = db.Column(db.Text, nullable=False)
  493. start = db.Column(db.Text, nullable=False)
  494. end = db.Column(db.Text, nullable=False)
  495. class PeelingMachine(db.Model):
  496. __tablename__ = 'peeling_machine'
  497. sn = db.Column(db.Integer, primary_key=True)
  498. datetime = db.Column(db.DateTime, nullable=False)
  499. duration = db.Column(db.Text, nullable=False)
  500. start = db.Column(db.Text, nullable=False)
  501. end = db.Column(db.Text, nullable=False)
  502. class ConveyorBelt3(db.Model):
  503. __tablename__ = 'conveyor_belt3'
  504. sn = db.Column(db.Integer, primary_key=True)
  505. datetime = db.Column(db.DateTime, nullable=False)
  506. duration = db.Column(db.Text, nullable=False)
  507. start = db.Column(db.Text, nullable=False)
  508. end = db.Column(db.Text, nullable=False)
  509. class Bacteria(db.Model):
  510. __tablename__ = 'bacteria'
  511. sn = db.Column(db.Integer, primary_key=True)
  512. datetime = db.Column(db.DateTime, nullable=False)
  513. tank_num = db.Column(db.Integer, nullable=False)
  514. duration = db.Column(db.Text, nullable=False)
  515. start = db.Column(db.Text, nullable=False)
  516. end = db.Column(db.Text, nullable=False)
  517. class Cargo2Disinfect(db.Model):
  518. __tablename__ = 'cargo2_disinfect'
  519. sn = db.Column(db.Integer, primary_key=True)
  520. datetime = db.Column(db.DateTime, nullable=False)
  521. tank_num = db.Column(db.Integer, nullable=False)
  522. duration = db.Column(db.Text, nullable=False)
  523. start = db.Column(db.Text, nullable=False)
  524. end = db.Column(db.Text, nullable=False)
  525. class Heating(db.Model):
  526. __tablename__ = 'heating'
  527. sn = db.Column(db.Integer, primary_key=True)
  528. datetime = db.Column(db.DateTime, nullable=False)
  529. tank_num = db.Column(db.Integer, nullable=False)
  530. duration = db.Column(db.Text, nullable=False)
  531. start = db.Column(db.Text, nullable=False)
  532. end = db.Column(db.Text, nullable=False)
  533. class Stir(db.Model):
  534. __tablename__ = 'stir'
  535. sn = db.Column(db.Integer, primary_key=True)
  536. datetime = db.Column(db.DateTime, nullable=False)
  537. tank_num = db.Column(db.Integer, nullable=False)
  538. duration = db.Column(db.Text, nullable=False)
  539. start = db.Column(db.Text, nullable=False)
  540. end = db.Column(db.Text, nullable=False)
  541. class WaterInjection(db.Model):
  542. __tablename__ = 'water_injection'
  543. sn = db.Column(db.Integer, primary_key=True)
  544. datetime = db.Column(db.DateTime, nullable=False)
  545. tank_num = db.Column(db.Integer, nullable=False)
  546. duration = db.Column(db.Text, nullable=False)
  547. start = db.Column(db.Text, nullable=False)
  548. end = db.Column(db.Text, nullable=False)
  549. class TopValve(db.Model):
  550. __tablename__ = 'top_valve'
  551. sn = db.Column(db.Integer, primary_key=True)
  552. datetime = db.Column(db.DateTime, nullable=False)
  553. tank_num = db.Column(db.Integer, nullable=False)
  554. duration = db.Column(db.Text, nullable=False)
  555. start = db.Column(db.Text, nullable=False)
  556. end = db.Column(db.Text, nullable=False)
  557. class BottomValve(db.Model):
  558. __tablename__ = 'bottom_valve'
  559. sn = db.Column(db.Integer, primary_key=True)
  560. datetime = db.Column(db.DateTime, nullable=False)
  561. tank_num = db.Column(db.Integer, nullable=False)
  562. duration = db.Column(db.Text, nullable=False)
  563. start = db.Column(db.Text, nullable=False)
  564. end = db.Column(db.Text, nullable=False)
  565. class Temperature(db.Model):
  566. __tablename__ = 'temperature'
  567. sn = db.Column(db.Integer, primary_key=True)
  568. datetime = db.Column(db.DateTime, nullable=False)
  569. tank_num = db.Column(db.Integer, nullable=False)
  570. duration = db.Column(db.Text, nullable=False)
  571. start = db.Column(db.Text, nullable=False)
  572. end = db.Column(db.Text, nullable=False)
  573. class Hoist(db.Model):
  574. __tablename__ = 'hoist'
  575. sn = db.Column(db.Integer, primary_key=True)
  576. datetime = db.Column(db.DateTime, nullable=False)
  577. duration = db.Column(db.Text, nullable=False)
  578. start = db.Column(db.Text, nullable=False)
  579. end = db.Column(db.Text, nullable=False)
  580. class Dryer(db.Model):
  581. __tablename__ = 'dryer'
  582. sn = db.Column(db.Integer, primary_key=True)
  583. datetime = db.Column(db.DateTime, nullable=False)
  584. duration = db.Column(db.Text, nullable=False)
  585. start = db.Column(db.Text, nullable=False)
  586. end = db.Column(db.Text, nullable=False)
  587. class Relay(db.Model):
  588. __tablename__ = 'relay'
  589. sn = db.Column(db.Integer, primary_key=True)
  590. datetime = db.Column(db.DateTime, nullable=False)
  591. tank_num = db.Column(db.Integer, nullable=False)
  592. status= db.Column(db.Text, nullable=False)
  593. class PeelingMachineRPM(db.Model):
  594. __tablename__ = 'peeling_machine_rpm'
  595. sn = db.Column(db.Integer, primary_key=True)
  596. datetime = db.Column(db.DateTime, nullable=False)
  597. tank_num = db.Column(db.Integer, nullable=False)
  598. rpm = db.Column(db.Text, nullable=False)
  599. class StirRPM(db.Model):
  600. __tablename__ = 'stir_rpm'
  601. sn = db.Column(db.Integer, primary_key=True)
  602. datetime = db.Column(db.DateTime, nullable=False)
  603. tank_num = db.Column(db.Integer, nullable=False)
  604. rpm = db.Column(db.Text, nullable=False)
  605. db.create_all()