소스 검색

add build_acatvi_early_start_prediction

chenhaiyang 1 년 전
부모
커밋
65d9bebaa4
3개의 변경된 파일38개의 추가작업 그리고 0개의 파일을 삭제
  1. 16 0
      app/api/routers/devices.py
  2. 14 0
      app/controllers/equipment/vrf/early_start.py
  3. 8 0
      app/models/domain/devices.py

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

@@ -35,6 +35,7 @@ from app.controllers.equipment.vav import (
 )
 from app.controllers.equipment.ventilation_fan.switch import build_acvtsf_switch_set
 from app.controllers.equipment.vrf.basic import build_acatvi_instructions, build_acatvi_instructions_v2
+from app.controllers.equipment.vrf.early_start import build_acatvi_early_start_prediction
 from app.controllers.equipment.vrf.mode import build_acatvi_mode
 
 router = APIRouter()
@@ -242,6 +243,21 @@ async def get_acatvi_mode(params: domain_devices.ACATVIModeRequest):
     return {"mode": new_mode}
 
 
+@router.post("/instructions/acatvi/early-start", response_model=domain_devices.ACATVIEarlyStartPredictionResponse)
+async def get_acatvi_early_start_prediction(
+        params: domain_devices.ACATVIEarlyStartPredictionRequest,
+        db: Session = Depends(get_db)
+):
+    minutes = build_acatvi_early_start_prediction(params, db)
+
+    logger.info(params)
+    logger.info(f"{params.space_id} - {minutes}")
+
+    resp = {"minutes": minutes}
+
+    return resp
+
+
 @router.post(
     "/instructions/acatfc", response_model=domain_devices.ACATFCInstructionsResponse
 )

+ 14 - 0
app/controllers/equipment/vrf/early_start.py

@@ -0,0 +1,14 @@
+from sqlalchemy.orm import Session
+
+from app.controllers.equipment.fcu.early_start import EarlyStartTimeDTRBuilder
+from app.crud.model_path.early_start import model_path_early_start_dtr
+from app.models.domain.devices import ACATVIEarlyStartPredictionRequest
+
+
+async def build_acatvi_early_start_prediction(params: ACATVIEarlyStartPredictionRequest, db: Session) -> float:
+    model_path = model_path_early_start_dtr.get_path_by_device(db, params.device_id)
+
+    builder = EarlyStartTimeDTRBuilder(model_path, params.season)
+    hour = await builder.get_prediction(params.space_realtime_temperature, params.outdoor_realtime_temperature)
+
+    return hour * 60

+ 8 - 0
app/models/domain/devices.py

@@ -104,6 +104,14 @@ class ACATFCEarlyStartPredictionResponse(BaseModel):
     minutes: float
 
 
+class ACATVIEarlyStartPredictionRequest(ACATFCEarlyStartPredictionRequest):
+    pass
+
+
+class ACATVIEarlyStartPredictionResponse(ACATFCEarlyStartPredictionResponse):
+    pass
+
+
 class Space(BaseModel):
     realtime_temperature: float | None