|
@@ -1,18 +1,21 @@
|
|
|
from fastapi import APIRouter, BackgroundTasks, Depends, Query
|
|
|
+from loguru import logger
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
|
|
import app.models.domain.devices as domain_devices
|
|
|
from app.api.dependencies.db import get_db
|
|
|
from app.controllers.equipment.ahu.supply_air_temperature_set import get_next_supply_air_temperature_set
|
|
|
from app.controllers.equipment.ahu.thermal_mode import get_thermal_mode
|
|
|
+from app.controllers.equipment.ahu.basic import build_acatah_freq_set
|
|
|
+from app.controllers.equipment.ahu.switch import build_acatah_switch_set
|
|
|
from app.controllers.equipment.fcu.basic import build_acatfc_instructions
|
|
|
from app.controllers.equipment.fcu.early_start import get_recommended_early_start_time
|
|
|
-from app.controllers.equipment.fcu.on_ratio import start_on_ratio_mode
|
|
|
from app.controllers.equipment.pau.freq_set import get_next_acatfu_freq_set
|
|
|
from app.controllers.equipment.pau.supply_air_temperature_set import get_next_acatfu_supply_air_temperature_set
|
|
|
from app.controllers.equipment.pau.switch import get_switch_action
|
|
|
from app.controllers.equipment.vav import build_acatva_instructions
|
|
|
from app.controllers.equipment.vrf.basic import build_acatvi_instructions
|
|
|
+from app.controllers.equipment.ventilation_fan.switch import build_acvtsf_switch_set
|
|
|
from app.models.domain.devices import DevicesInstructionsBaseResponse, DevicesEarlyStartTime
|
|
|
|
|
|
router = APIRouter()
|
|
@@ -50,14 +53,44 @@ async def get_acatah_supply_air_temperature_set(
|
|
|
}
|
|
|
|
|
|
|
|
|
-@router.post('/on-ratio-experiment/fcu/{fcu_id}/target/{target}/period/{period}')
|
|
|
-async def run_on_ratio_experiment(fcu_id: str, target: float, period: int, background_tasks: BackgroundTasks):
|
|
|
- background_tasks.add_task(start_on_ratio_mode, fcu_id, target, period)
|
|
|
- return {
|
|
|
- 'fcu': fcu_id,
|
|
|
- 'target': target,
|
|
|
- 'period': period
|
|
|
- }
|
|
|
+@router.post('/instructions/acatah/freq-set', response_model=domain_devices.ACATAHFreqSetResponse)
|
|
|
+async def get_acatah_freq_set(params: domain_devices.ACATAHFreqSetRequest):
|
|
|
+ freq_set = build_acatah_freq_set(params)
|
|
|
+
|
|
|
+ logger.info(params)
|
|
|
+ logger.info(f'{params.device_id}: freq set - {freq_set}')
|
|
|
+
|
|
|
+ return freq_set
|
|
|
+
|
|
|
+
|
|
|
+@router.post('/instructions/acatah/switch-set', response_model=domain_devices.ACATAHSwitchSetResponse)
|
|
|
+async def get_acatah_switch_set(params: domain_devices.ACATAHSwitchSetRequest):
|
|
|
+ switch_set = build_acatah_switch_set(params)
|
|
|
+
|
|
|
+ logger.info(params)
|
|
|
+ logger.info(f'{params.device_id}: switch set - {switch_set}')
|
|
|
+
|
|
|
+ return switch_set
|
|
|
+
|
|
|
+
|
|
|
+@router.post('/instructions/acvtsf/switch-set', response_model=domain_devices.ACVTSFSwitchSetResponse)
|
|
|
+async def get_acvtsf_switch_set(params: domain_devices.ACVTSFSwitchSetRequest):
|
|
|
+ switch_set = build_acvtsf_switch_set(params)
|
|
|
+
|
|
|
+ logger.info(params)
|
|
|
+ logger.info(f'{params.device_id}: switch set - {switch_set}')
|
|
|
+
|
|
|
+ return switch_set
|
|
|
+
|
|
|
+
|
|
|
+# @router.post('/on-ratio-experiment/fcu/{fcu_id}/target/{target}/period/{period}')
|
|
|
+# async def run_on_ratio_experiment(fcu_id: str, target: float, period: int, background_tasks: BackgroundTasks):
|
|
|
+# background_tasks.add_task(start_on_ratio_mode, fcu_id, target, period)
|
|
|
+# return {
|
|
|
+# 'fcu': fcu_id,
|
|
|
+# 'target': target,
|
|
|
+# 'period': period
|
|
|
+# }
|
|
|
|
|
|
|
|
|
@router.get('/instructions/acatfu/equip-switch-set', response_model=DevicesInstructionsBaseResponse)
|
|
@@ -126,6 +159,9 @@ async def get_acatfc_early_start_time(
|
|
|
async def get_acatvi_instructions(params: domain_devices.ACATVIInstructionsRequest):
|
|
|
instructions = await build_acatvi_instructions(params)
|
|
|
|
|
|
+ logger.info(params)
|
|
|
+ logger.info(f'{params.device_id} - {instructions}')
|
|
|
+
|
|
|
return instructions
|
|
|
|
|
|
|
|
@@ -133,6 +169,9 @@ async def get_acatvi_instructions(params: domain_devices.ACATVIInstructionsReque
|
|
|
async def get_acatfc_instructions(params: domain_devices.ACATFCInstructionsRequest):
|
|
|
instructions = await build_acatfc_instructions(params)
|
|
|
|
|
|
+ logger.info(params)
|
|
|
+ logger.info(f'{params.device_id} - {instructions}')
|
|
|
+
|
|
|
response = domain_devices.ACATFCInstructionsResponse(
|
|
|
onOff=instructions.switch_set,
|
|
|
speed=instructions.speed_set,
|
|
@@ -148,6 +187,9 @@ async def get_acatfc_instructions(params: domain_devices.ACATFCInstructionsReque
|
|
|
async def get_acatva_instructions(params: domain_devices.ACATVAInstructionsRequest):
|
|
|
instructions = await build_acatva_instructions(params)
|
|
|
|
|
|
+ logger.info(params)
|
|
|
+ logger.info(f'{params.device_id} - {instructions}')
|
|
|
+
|
|
|
response = domain_devices.ACATVAInstructionsResponse(
|
|
|
SupplyAirFlowSet=instructions.supply_air_flow_set,
|
|
|
VirtualRealtimeTemperature=instructions.virtual_realtime_temperature,
|