Browse Source

amend response params

highing666 3 years ago
parent
commit
953041b052

+ 16 - 2
app/api/routers/devices.py

@@ -135,11 +135,25 @@ async def get_acatvi_instructions(params: domain_devices.ACATVIInstructionsReque
 async def get_acatfc_instructions(params: domain_devices.ACATFCInstructionsRequest):
 async def get_acatfc_instructions(params: domain_devices.ACATFCInstructionsRequest):
     instructions = await build_acatfc_instructions(params)
     instructions = await build_acatfc_instructions(params)
 
 
-    return instructions
+    response = domain_devices.ACATFCInstructionsResponse(
+        onOff=instructions.switch_set,
+        speed=instructions.speed_set,
+        temperature=instructions.temperature_set,
+        mode=instructions.switch_set,
+        water=instructions.water_valve_switch_set
+    )
+
+    return response
 
 
 
 
 @router.post('/instructions/acatva', response_model=domain_devices.ACATVAInstructionsResponse)
 @router.post('/instructions/acatva', response_model=domain_devices.ACATVAInstructionsResponse)
 async def get_acatva_instructions(params: domain_devices.ACATVAInstructionsRequest):
 async def get_acatva_instructions(params: domain_devices.ACATVAInstructionsRequest):
     instructions = await build_acatva_instructions(params)
     instructions = await build_acatva_instructions(params)
 
 
-    return instructions
+    response = domain_devices.ACATVAInstructionsResponse(
+        SupplyAirFlowSet=instructions.supply_air_flow_set,
+        VirtualRealtimeTemperature=instructions.virtual_realtime_temperature,
+        TargetTemperatureSet=instructions.virtual_temperature_target_set
+    )
+
+    return response

+ 9 - 8
app/controllers/equipment/fcu/basic.py

@@ -9,6 +9,7 @@ from loguru import logger
 from app.controllers.equipment.controller import EquipmentController
 from app.controllers.equipment.controller import EquipmentController
 from app.models.domain.devices import ACATFCInstructionsRequest
 from app.models.domain.devices import ACATFCInstructionsRequest
 from app.schemas.equipment import AirValveSpeed, FCU
 from app.schemas.equipment import AirValveSpeed, FCU
+from app.schemas.instructions import ACATFCInstructions
 from app.schemas.space import Space
 from app.schemas.space import Space
 from app.services.platform import DataPlatformService, InfoCode
 from app.services.platform import DataPlatformService, InfoCode
 from app.services.transfer import SpaceInfoService, Duoduo, Season
 from app.services.transfer import SpaceInfoService, Duoduo, Season
@@ -220,7 +221,7 @@ async def get_fcu_control_result(project_id: str, equipment_id: str) -> Dict:
 
 
 
 
 @logger.catch()
 @logger.catch()
-async def build_acatfc_instructions(params: ACATFCInstructionsRequest) -> Dict:
+async def build_acatfc_instructions(params: ACATFCInstructionsRequest) -> ACATFCInstructions:
     space = Space(
     space = Space(
         temperature_target=params.space_temperature_target,
         temperature_target=params.space_temperature_target,
         realtime_temperature=params.space_realtime_temperature
         realtime_temperature=params.space_realtime_temperature
@@ -235,12 +236,12 @@ async def build_acatfc_instructions(params: ACATFCInstructionsRequest) -> Dict:
     await controller.run()
     await controller.run()
     regulated_fcu = controller.get_results()
     regulated_fcu = controller.get_results()
 
 
-    instructions = {
-        'switch_set': 1 if regulated_fcu.running_status else 0,
-        'speed_set': regulated_fcu.air_valve_speed.value,
-        'temperature_set': float(round_half_up(regulated_fcu.setting_temperature, 1)),
-        'mode_set': regulated_fcu.work_mode,
-        'water_valve_switch_set': 1 if regulated_fcu.running_status else 0
-    }
+    instructions = ACATFCInstructions(
+        switch_set=1 if regulated_fcu.running_status else 0,
+        speed_set=regulated_fcu.air_valve_speed.value,
+        temperature_set=float(round_half_up(regulated_fcu.setting_temperature, 1)),
+        mode_set=regulated_fcu.work_mode,
+        water_valve_switch_set=1 if regulated_fcu.running_status else 0
+    )
 
 
     return instructions
     return instructions

+ 7 - 6
app/controllers/equipment/vav.py

@@ -13,6 +13,7 @@ from app.controllers.equipment.controller import EquipmentController
 from app.crud.space.weight import get_weights_by_vav
 from app.crud.space.weight import get_weights_by_vav
 from app.models.domain.devices import ACATVAInstructionsRequest
 from app.models.domain.devices import ACATVAInstructionsRequest
 from app.schemas.equipment import VAVBox, FCU
 from app.schemas.equipment import VAVBox, FCU
+from app.schemas.instructions import ACATVAInstructions
 from app.schemas.sapce_weight import SpaceWeight
 from app.schemas.sapce_weight import SpaceWeight
 from app.schemas.space import Space
 from app.schemas.space import Space
 from app.services.platform import DataPlatformService
 from app.services.platform import DataPlatformService
@@ -302,7 +303,7 @@ async def get_vav_control_v2(db: Session, project_id: str, equipment_id: str) ->
 
 
 
 
 @logger.catch()
 @logger.catch()
-async def build_acatva_instructions(params: ACATVAInstructionsRequest) -> Dict:
+async def build_acatva_instructions(params: ACATVAInstructionsRequest) -> ACATVAInstructions:
     vav_params = VAVBox(
     vav_params = VAVBox(
         spaces=params.spaces,
         spaces=params.spaces,
         supply_air_temperature=params.supply_air_temperature,
         supply_air_temperature=params.supply_air_temperature,
@@ -315,10 +316,10 @@ async def build_acatva_instructions(params: ACATVAInstructionsRequest) -> Dict:
     await controller.run()
     await controller.run()
     regulated_vav = controller.get_results()
     regulated_vav = controller.get_results()
 
 
-    instructions = {
-        'supply_air_flow_set': regulated_vav.supply_air_flow_set,
-        'virtual_temperature_target_set': regulated_vav.virtual_target_temperature,
-        'virtual_realtime_temperature': regulated_vav.virtual_realtime_temperature
-    }
+    instructions = ACATVAInstructions(
+        supply_air_flow_set=regulated_vav.supply_air_flow_set,
+        virtual_realtime_temperature=regulated_vav.virtual_realtime_temperature,
+        virtual_temperature_target_set=regulated_vav.virtual_target_temperature
+    )
 
 
     return instructions
     return instructions

+ 13 - 13
app/models/domain/devices.py

@@ -1,7 +1,7 @@
 from enum import Enum
 from enum import Enum
 from typing import Dict, List, Optional
 from typing import Dict, List, Optional
 
 
-from pydantic import BaseModel
+from pydantic import BaseModel, Field
 
 
 
 
 class ThermalMode(str, Enum):
 class ThermalMode(str, Enum):
@@ -11,14 +11,14 @@ class ThermalMode(str, Enum):
 
 
 
 
 class DevicesInstructionsBaseResponse(BaseModel):
 class DevicesInstructionsBaseResponse(BaseModel):
-    projectId: str
-    equipId: str
+    project_id: str = Field(None, alias='projectId')
+    device_id: str = Field(None, alias='equipId')
     output: Dict
     output: Dict
 
 
 
 
 class DevicesEarlyStartTime(BaseModel):
 class DevicesEarlyStartTime(BaseModel):
-    projectId: str
-    spaceId: str
+    project_id: str = Field(None, alias='projectId')
+    space_id: str = Field(None, alias='spaceId')
     minutes: float
     minutes: float
 
 
 
 
@@ -46,11 +46,11 @@ class ACATFCInstructionsRequest(BaseModel):
 
 
 
 
 class ACATFCInstructionsResponse(BaseModel):
 class ACATFCInstructionsResponse(BaseModel):
-    switch_set: int
-    speed_set: int
-    temperature_set: float
-    mode_set: int
-    water_valve_switch_set: int
+    switch_set: int = Field(None, alias='onOff')
+    speed_set: int = Field(None, alias='speed')
+    temperature_set: float = Field(None, alias='temperature')
+    mode_set: int = Field(None, alias='mode')
+    water_valve_switch_set: int = Field(None, alias='water')
 
 
 
 
 class Space(BaseModel):
 class Space(BaseModel):
@@ -71,6 +71,6 @@ class ACATVAInstructionsRequest(BaseModel):
 
 
 
 
 class ACATVAInstructionsResponse(BaseModel):
 class ACATVAInstructionsResponse(BaseModel):
-    supply_air_flow_set: float
-    virtual_temperature_target_set: float
-    virtual_realtime_temperature: float
+    supply_air_flow_set: float = Field(None, alias='SupplyAirFlowSet')
+    virtual_temperature_target_set: float = Field(None, alias='TargetTemperatureSet')
+    virtual_realtime_temperature: float = Field(None, alias='VirtualRealtimeTemperature')

+ 15 - 0
app/schemas/instructions.py

@@ -0,0 +1,15 @@
+from pydantic import BaseModel
+
+
+class ACATFCInstructions(BaseModel):
+    switch_set: int
+    speed_set: int
+    temperature_set: float
+    mode_set: int
+    water_valve_switch_set: int
+
+
+class ACATVAInstructions(BaseModel):
+    supply_air_flow_set: float
+    virtual_temperature_target_set: float
+    virtual_realtime_temperature: float