hs4000.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from hub import methods, Global
  2. async def code_4001(**sources):
  3. """
  4. 获取全部渣包状态数据接口
  5. """
  6. # --- fill d1 ---
  7. d1 = Global.enfei_api.get_pot_list()
  8. # --- check ----
  9. if type(d1) != list:
  10. reason, detail = d1
  11. return dict(code=1, data=[], reason=reason, detail=detail)
  12. # --- fill d2 ---
  13. d2 = list()
  14. d3 = list(reversed(d1))
  15. d4 = list(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N']) # 排
  16. d5 = list(range(31)) # 罐数
  17. count = 0
  18. for i in d4:
  19. for j in d5:
  20. # --- define ---
  21. data = {
  22. 'pot_name': f"{i}.{j + 1}", # 渣罐别称
  23. 'pot_status': 0, # 渣罐状态 1 空位 2 就绪 3 缓冷(空冷) 4 水冷 5 自冷(水冷) 6 待倒 7 故障
  24. 'pot_number': '', # 渣罐编号
  25. }
  26. # --- update ---
  27. # methods.debug_log('hs4000.code_4001.48:', f"#count: {count}")
  28. data['pot_status'] = d3[count].get('packageStatus')
  29. data['pot_number'] = d3[count].get('localNumber')
  30. d2.append(data)
  31. # methods.debug_log('hs4000.code_4001.52:', f"#data: {data}")
  32. count += 1
  33. return dict(code=0, data=d2)