events.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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
  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_switch():
  20. _PROJECT_ID = 'Pj1101020002'
  21. async with AsyncClient() as client:
  22. platform = DataPlatformService(client, _PROJECT_ID)
  23. ahu_list = await platform.get_items_by_category('ATAH')
  24. for ahu in ahu_list:
  25. await ahu_switch_control(_PROJECT_ID, ahu)
  26. @repeat_every(seconds=60 * 15)
  27. async def regulate_pau_switch():
  28. _PROJECT_ID = 'Pj1101020002'
  29. async with AsyncClient() as client:
  30. platform = DataPlatformService(client, _PROJECT_ID)
  31. pau_list = await platform.get_items_by_category('ATFU')
  32. for pau in pau_list:
  33. await pau_switch_control(_PROJECT_ID, pau)
  34. @repeat_every(seconds=60 * 15)
  35. async def regulate_ventilation_fan_switch():
  36. _PROJECT_ID = 'Pj1101020002'
  37. async with AsyncClient() as client:
  38. platform = DataPlatformService(client, _PROJECT_ID)
  39. eq_list = await platform.get_items_by_category('VTSF')
  40. for eq in eq_list:
  41. await ventilation_fan_switch_control(_PROJECT_ID, eq)