events.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # -*- coding: utf-8 -*-
  2. from fastapi_utils.tasks import repeat_every
  3. from httpx import AsyncClient
  4. from app.controllers.equipment.ahu.basic import get_freq_controlled, get_supply_air_temperature_controlled
  5. from app.controllers.equipment.ahu.switch import ahu_switch_control
  6. from app.controllers.equipment.pau.switch import pau_switch_control
  7. from app.controllers.equipment.ventilation_fan.switch import ventilation_fan_switch_control
  8. from app.services.platform import DataPlatformService
  9. @repeat_every(seconds=60 * 5)
  10. async def regulate_ahu_freq():
  11. _PROJECT_ID = 'Pj1101050030'
  12. _AHU_LIST = [
  13. 'Eq1101050030b6b2f1db3d6944afa71e213e0d45d565',
  14. 'Eq1101050030846e0a94670842109f7c8d8db0d44cf5'
  15. ]
  16. for ahu in _AHU_LIST:
  17. await get_freq_controlled(_PROJECT_ID, ahu)
  18. @repeat_every(seconds=60 * 15)
  19. async def regulate_ahu_supply_air_temperature():
  20. _PROJECT_ID = 'Pj1101050030'
  21. _AHU_LIST = [
  22. 'Eq1101050030b6b2f1db3d6944afa71e213e0d45d565',
  23. 'Eq1101050030846e0a94670842109f7c8d8db0d44cf5'
  24. ]
  25. for ahu in _AHU_LIST:
  26. await get_supply_air_temperature_controlled(_PROJECT_ID, ahu)
  27. @repeat_every(seconds=60 * 15)
  28. async def regulate_ahu_switch():
  29. _PROJECT_ID = 'Pj1101020002'
  30. async with AsyncClient() as client:
  31. platform = DataPlatformService(client, _PROJECT_ID)
  32. ahu_list = await platform.get_items_by_category('ATAH')
  33. for ahu in ahu_list:
  34. await ahu_switch_control(_PROJECT_ID, ahu)
  35. @repeat_every(seconds=60 * 15)
  36. async def regulate_pau_switch():
  37. _PROJECT_ID = 'Pj1101020002'
  38. async with AsyncClient() as client:
  39. platform = DataPlatformService(client, _PROJECT_ID)
  40. pau_list = await platform.get_items_by_category('ATFU')
  41. for pau in pau_list:
  42. await pau_switch_control(_PROJECT_ID, pau)
  43. @repeat_every(seconds=60 * 15)
  44. async def regulate_ventilation_fan_switch():
  45. _PROJECT_ID = 'Pj1101020002'
  46. async with AsyncClient() as client:
  47. platform = DataPlatformService(client, _PROJECT_ID)
  48. eq_list = await platform.get_items_by_category('VTSF')
  49. for eq in eq_list:
  50. await ventilation_fan_switch_control(_PROJECT_ID, eq)