|
@@ -1,21 +1,24 @@
|
|
|
-from fastapi import APIRouter, BackgroundTasks, Depends, Query
|
|
|
+from fastapi import APIRouter, 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.supply_air_temperature_set import get_next_supply_air_temperature_set
|
|
|
+from app.controllers.equipment.ahu.supply_air_temperature_set import build_acatah_supply_air_temperature_set
|
|
|
from app.controllers.equipment.ahu.switch import build_acatah_switch_set
|
|
|
+from app.controllers.equipment.ahu.thermal_mode import get_thermal_mode, build_acatah_thermal_mode_set
|
|
|
from app.controllers.equipment.fcu.basic import build_acatfc_instructions
|
|
|
+from app.controllers.equipment.fcu.early_start import build_acatfc_early_start_prediction
|
|
|
from app.controllers.equipment.fcu.early_start import get_recommended_early_start_time
|
|
|
-from app.controllers.equipment.pau.freq_set import get_next_acatfu_freq_set
|
|
|
+from app.controllers.equipment.pau.freq_set import get_next_acatfu_freq_set, build_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.pau.supply_air_temperature_set import build_acatfu_supply_air_temperature
|
|
|
+from app.controllers.equipment.pau.switch import get_switch_action, build_acatfu_switch_set
|
|
|
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.controllers.equipment.vrf.basic import build_acatvi_instructions
|
|
|
from app.models.domain.devices import DevicesInstructionsBaseResponse, DevicesEarlyStartTime
|
|
|
|
|
|
router = APIRouter()
|
|
@@ -37,6 +40,16 @@ async def get_acatah_thermal_mode_set(
|
|
|
}
|
|
|
|
|
|
|
|
|
+@router.post('/instructions/acatah/thermal-mode-set', response_model=domain_devices.ACATAHThermalModeSetResponse)
|
|
|
+async def get_acatah_thermal_mode_set_v2(params: domain_devices.ACATAHThermalModeSetRequest):
|
|
|
+ thermal_mode = build_acatah_thermal_mode_set(params)
|
|
|
+
|
|
|
+ logger.info(f'{params.device_id}: thermal mode set - {thermal_mode}')
|
|
|
+ resp = {'thermal_mode_set': thermal_mode}
|
|
|
+
|
|
|
+ return resp
|
|
|
+
|
|
|
+
|
|
|
@router.get('/instructions/acatah/supply-air-temperature-set', response_model=DevicesInstructionsBaseResponse)
|
|
|
async def get_acatah_supply_air_temperature_set(
|
|
|
project_id: str = Query(..., max_length=50, regex='^Pj', alias='projectId'),
|
|
@@ -53,6 +66,20 @@ async def get_acatah_supply_air_temperature_set(
|
|
|
}
|
|
|
|
|
|
|
|
|
+@router.post(
|
|
|
+ '/instructions/acatah/supply-air-temperature-set',
|
|
|
+ response_model=domain_devices.ACATAHSupplyAirTempSetResponse
|
|
|
+)
|
|
|
+async def get_acatah_supply_air_temperature_set_v2(params: domain_devices.ACATAHSupplyAirTempSetRequest):
|
|
|
+ supply_air_temperature_set = build_acatah_supply_air_temperature_set(params)
|
|
|
+
|
|
|
+ logger.info(supply_air_temperature_set)
|
|
|
+
|
|
|
+ resp = {'supply_air_temperature_set': supply_air_temperature_set}
|
|
|
+
|
|
|
+ return resp
|
|
|
+
|
|
|
+
|
|
|
@router.post('/instructions/acatah/freq-set', response_model=domain_devices.ACATAHFreqSetResponse)
|
|
|
async def get_acatah_freq_set(params: domain_devices.ACATAHFreqSetRequest):
|
|
|
freq_set = await build_acatah_freq_set(params)
|
|
@@ -60,7 +87,9 @@ async def get_acatah_freq_set(params: domain_devices.ACATAHFreqSetRequest):
|
|
|
logger.info(params)
|
|
|
logger.info(f'{params.device_id}: freq set - {freq_set}')
|
|
|
|
|
|
- return freq_set
|
|
|
+ resp = {'freq_set': freq_set}
|
|
|
+
|
|
|
+ return resp
|
|
|
|
|
|
|
|
|
@router.post('/instructions/acatah/switch-set', response_model=domain_devices.ACATAHSwitchSetResponse)
|
|
@@ -70,7 +99,9 @@ async def get_acatah_switch_set(params: domain_devices.ACATAHSwitchSetRequest):
|
|
|
logger.info(params)
|
|
|
logger.info(f'{params.device_id}: switch set - {switch_set}')
|
|
|
|
|
|
- return switch_set
|
|
|
+ resp = {'switch_set': switch_set}
|
|
|
+
|
|
|
+ return resp
|
|
|
|
|
|
|
|
|
@router.post('/instructions/acvtsf/switch-set', response_model=domain_devices.ACVTSFSwitchSetResponse)
|
|
@@ -80,17 +111,9 @@ async def get_acvtsf_switch_set(params: domain_devices.ACVTSFSwitchSetRequest):
|
|
|
logger.info(params)
|
|
|
logger.info(f'{params.device_id}: switch set - {switch_set}')
|
|
|
|
|
|
- return switch_set
|
|
|
-
|
|
|
+ resp = {'switch_set': 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
|
|
|
-# }
|
|
|
+ return resp
|
|
|
|
|
|
|
|
|
@router.get('/instructions/acatfu/equip-switch-set', response_model=DevicesInstructionsBaseResponse)
|
|
@@ -109,6 +132,18 @@ async def get_acatfu_equip_switch_set(
|
|
|
}
|
|
|
|
|
|
|
|
|
+@router.post('/instructions/acatfu/switch-set', response_model=domain_devices.ACATFUSwitchSetResponse)
|
|
|
+async def get_acatfu_switch_set(params: domain_devices.ACATFUSwitchSetRequest):
|
|
|
+ switch_set = await build_acatfu_switch_set(params)
|
|
|
+
|
|
|
+ logger.info(params)
|
|
|
+ logger.info(f'{params.device_id}: switch set - {switch_set}')
|
|
|
+
|
|
|
+ resp = {'switch_set': switch_set}
|
|
|
+
|
|
|
+ return resp
|
|
|
+
|
|
|
+
|
|
|
@router.get('/instructions/acatfu/supply-air-temperature-set', response_model=DevicesInstructionsBaseResponse)
|
|
|
async def get_acatfu_supply_air_temperature_set(
|
|
|
project_id: str = Query(..., max_length=50, regex='^Pj', alias='projectId'),
|
|
@@ -125,6 +160,20 @@ async def get_acatfu_supply_air_temperature_set(
|
|
|
}
|
|
|
|
|
|
|
|
|
+@router.post(
|
|
|
+ '/instructions/acatfu/supply-air-temperature-set',
|
|
|
+ response_model=domain_devices.ACATFUSupplyAirTempSetResponse
|
|
|
+)
|
|
|
+async def get_acatfu_supply_air_temperature_set_v2(params: domain_devices.ACATFUSupplyAirTempSetRequest):
|
|
|
+ supply_air_temperature_set = build_acatfu_supply_air_temperature(params)
|
|
|
+
|
|
|
+ logger.info(supply_air_temperature_set)
|
|
|
+
|
|
|
+ resp = {'supply_air_temperature_set': supply_air_temperature_set}
|
|
|
+
|
|
|
+ return resp
|
|
|
+
|
|
|
+
|
|
|
@router.get('/instructions/acatfu/freq-set', response_model=DevicesInstructionsBaseResponse)
|
|
|
async def get_acatfu_freq_set(
|
|
|
project_id: str = Query(..., max_length=50, regex='^Pj', alias='projectId'),
|
|
@@ -141,6 +190,17 @@ async def get_acatfu_freq_set(
|
|
|
}
|
|
|
|
|
|
|
|
|
+@router.post('/instruction/acatfu/freq-set', response_model=domain_devices.ACATFUFreqSetResponse)
|
|
|
+async def get_acatfu_freq_set(params: domain_devices.ACATFUFreqSetRequest):
|
|
|
+ freq_set = build_acatfu_freq_set(params)
|
|
|
+
|
|
|
+ logger.info(f'{params.device_id} - {freq_set}')
|
|
|
+
|
|
|
+ resp = {'freq_set': freq_set}
|
|
|
+
|
|
|
+ return resp
|
|
|
+
|
|
|
+
|
|
|
@router.get('/early-start/prediction/acatfc', response_model=DevicesEarlyStartTime)
|
|
|
async def get_acatfc_early_start_time(
|
|
|
project_id: str = Query(..., max_length=50, regex='^Pj', alias='projectId'),
|
|
@@ -155,6 +215,21 @@ async def get_acatfc_early_start_time(
|
|
|
}
|
|
|
|
|
|
|
|
|
+@router.post('/prediction/acatfc/early-start', response_model=domain_devices.ACATFCEarlyStartPredictionResponse)
|
|
|
+async def get_acatfc_early_start_prediction(
|
|
|
+ params: domain_devices.ACATFCEarlyStartPredictionRequest,
|
|
|
+ db: Session = Depends(get_db)
|
|
|
+):
|
|
|
+ minutes = await build_acatfc_early_start_prediction(params, db)
|
|
|
+
|
|
|
+ logger.info(params)
|
|
|
+ logger.info(f'{params.space_id} - {minutes}')
|
|
|
+
|
|
|
+ resp = {'minutes': minutes}
|
|
|
+
|
|
|
+ return resp
|
|
|
+
|
|
|
+
|
|
|
@router.post('/instructions/acatvi', response_model=domain_devices.ACATVIInstructionsResponse)
|
|
|
async def get_acatvi_instructions(params: domain_devices.ACATVIInstructionsRequest):
|
|
|
instructions = await build_acatvi_instructions(params)
|