Przeglądaj źródła

config switch logic

chenhaiyang 4 lat temu
rodzic
commit
25ecf14fb9

+ 1 - 0
app/controllers/equipment/ahu/switch.py

@@ -16,4 +16,5 @@ class AHUSwitch(Switch):
 async def ahu_switch_control(project_id: str, equipment_id: str) -> None:
     equip_params, day_type = await fetch_data(project_id, equipment_id)
     action = await AHUSwitch(AHU(**equip_params)).build_next_action(day_type.get('day_type'))
+    logger.debug(f'AHU-{equipment_id}: {action}')
     await send_switch_command(project_id, equipment_id, action)

+ 1 - 0
app/controllers/equipment/pau/switch.py

@@ -16,4 +16,5 @@ class PAUSwitch(Switch):
 async def pau_switch_control(project_id: str, equipment_id: str) -> None:
     equip_params, day_type = await fetch_data(project_id, equipment_id)
     action = await PAUSwitch(PAU(**equip_params)).build_next_action(day_type.get('day_type'))
+    logger.debug(f'PAU-{equipment_id}: {action}')
     await send_switch_command(project_id, equipment_id, action)

+ 1 - 0
app/controllers/equipment/switch.py

@@ -51,6 +51,7 @@ async def fetch_data(project_id: str, equipment_id: str) -> Tuple[Dict, Dict]:
         on_time, off_time = await platform.get_schedule(equipment_id)
 
     equip_params = {
+        'id': equipment_id,
         'running_status': running_status,
         'in_cloud_status': True if cloud_status == 1.0 else False,
         'on_time': on_time,

+ 1 - 0
app/controllers/equipment/ventilation_fan/switch.py

@@ -16,4 +16,5 @@ class VentilationFanSwitch(Switch):
 async def ventilation_fan_switch_control(project_id: str, equipment_id: str) -> None:
     equip_params, day_type = await fetch_data(project_id, equipment_id)
     action = await VentilationFanSwitch(VentilationFan(**equip_params)).build_next_action(day_type.get('day_type'))
+    logger.debug(f'VTSF-{equipment_id}: {action}')
     await send_switch_command(project_id, equipment_id, action)

+ 10 - 1
app/core/events.py

@@ -4,8 +4,14 @@ from typing import Callable, Optional
 
 from fastapi import FastAPI
 
+from app.controllers.equipment.events import (
+    regulate_ahu_freq,
+    regulate_ahu_supply_air_temperature,
+    regulate_ahu_switch,
+    regulate_pau_switch,
+    regulate_ventilation_fan_switch
+)
 from app.controllers.events import load_q_learning_model
-from app.controllers.equipment.events import regulate_ahu_freq, regulate_ahu_supply_air_temperature
 
 
 def create_start_app_handler(app: Optional[FastAPI] = None) -> Callable:
@@ -13,5 +19,8 @@ def create_start_app_handler(app: Optional[FastAPI] = None) -> Callable:
         await load_q_learning_model()
         await regulate_ahu_supply_air_temperature()
         await regulate_ahu_freq()
+        await regulate_ahu_switch()
+        await regulate_pau_switch()
+        await regulate_ventilation_fan_switch()
 
     return start_app