events.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.fcu.on_ratio import start_control_group_mode
  7. from app.controllers.equipment.pau.switch import pau_switch_control
  8. from app.controllers.equipment.ventilation_fan.switch import ventilation_fan_switch_control
  9. from app.services.platform import DataPlatformService
  10. @repeat_every(seconds=60 * 5)
  11. async def regulate_ahu_freq():
  12. _PROJECT_ID = 'Pj1101050030'
  13. _AHU_LIST = [
  14. 'Eq1101050030b6b2f1db3d6944afa71e213e0d45d565',
  15. 'Eq1101050030846e0a94670842109f7c8d8db0d44cf5'
  16. ]
  17. for ahu in _AHU_LIST:
  18. await get_freq_controlled(_PROJECT_ID, ahu)
  19. @repeat_every(seconds=60 * 15)
  20. async def regulate_ahu_switch():
  21. _PROJECT_ID = 'Pj1101020002'
  22. async with AsyncClient() as client:
  23. platform = DataPlatformService(client, _PROJECT_ID)
  24. ahu_list = await platform.get_items_by_category('ATAH')
  25. for ahu in ahu_list:
  26. await ahu_switch_control(_PROJECT_ID, ahu)
  27. @repeat_every(seconds=60 * 15)
  28. async def regulate_pau_switch():
  29. _PROJECT_ID = 'Pj1101020002'
  30. async with AsyncClient() as client:
  31. platform = DataPlatformService(client, _PROJECT_ID)
  32. pau_list = await platform.get_items_by_category('ATFU')
  33. for pau in pau_list:
  34. await pau_switch_control(_PROJECT_ID, pau)
  35. @repeat_every(seconds=60 * 15)
  36. async def regulate_ventilation_fan_switch():
  37. _PROJECT_ID = 'Pj1101020002'
  38. async with AsyncClient() as client:
  39. platform = DataPlatformService(client, _PROJECT_ID)
  40. eq_list = await platform.get_items_by_category('VTSF')
  41. for eq in eq_list:
  42. await ventilation_fan_switch_control(_PROJECT_ID, eq)
  43. @repeat_every(seconds=60 * 15)
  44. async def run_control_group():
  45. await start_control_group_mode('Eq1101080259ea519ed43678481c8a8c108fa85e5aa3', 25.0)
  46. await start_control_group_mode('Eq11010802598449efe230f444cca826e840dbf67f41', 25.0)