events.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. ahu_id_list = [item['id'] for item in ahu_list]
  26. for ahu in ahu_id_list:
  27. await ahu_switch_control(_PROJECT_ID, ahu)
  28. @repeat_every(seconds=60 * 15)
  29. async def regulate_pau_switch():
  30. _PROJECT_ID = 'Pj1101020002'
  31. async with AsyncClient() as client:
  32. platform = DataPlatformService(client, _PROJECT_ID)
  33. pau_list = await platform.get_items_by_category('ATFU')
  34. pau_id_list = [item['id'] for item in pau_list]
  35. for pau in pau_id_list:
  36. await pau_switch_control(_PROJECT_ID, pau)
  37. @repeat_every(seconds=60 * 15)
  38. async def regulate_ventilation_fan_switch():
  39. _PROJECT_ID = 'Pj1101020002'
  40. async with AsyncClient() as client:
  41. platform = DataPlatformService(client, _PROJECT_ID)
  42. eq_list = await platform.get_items_by_category('VTSF')
  43. eq_id_list = [item['id'] for item in eq_list]
  44. for eq in eq_id_list:
  45. await ventilation_fan_switch_control(_PROJECT_ID, eq)
  46. @repeat_every(seconds=60 * 15)
  47. async def run_control_group():
  48. await start_control_group_mode('Eq1101080259d666795232564546ac19b7042f1f52b9', 27.0)
  49. await start_control_group_mode('Eq11010802598449efe230f444cca826e840dbf67f41', 27.0)
  50. await start_control_group_mode('Eq1101080259ea519ed43678481c8a8c108fa85e5aa3', 27.0)