|
@@ -6,7 +6,6 @@ from fastapi import APIRouter, Depends, HTTPException, Query
|
|
from sqlalchemy.orm import Session
|
|
from sqlalchemy.orm import Session
|
|
|
|
|
|
from app.api.dependencies.db import get_db
|
|
from app.api.dependencies.db import get_db
|
|
-from app.controllers.equipment.fcu.q_learning import QLearningCommandBuilder
|
|
|
|
from app.crud.space.weight import (
|
|
from app.crud.space.weight import (
|
|
get_weights_by_space,
|
|
get_weights_by_space,
|
|
get_weights_by_vav,
|
|
get_weights_by_vav,
|
|
@@ -15,17 +14,16 @@ from app.crud.space.weight import (
|
|
)
|
|
)
|
|
from app.models.domain.space import SpaceControlResponse
|
|
from app.models.domain.space import SpaceControlResponse
|
|
from app.schemas.sapce_weight import SpaceWeight, SpaceWeightCreate, SpaceWeightUpdate
|
|
from app.schemas.sapce_weight import SpaceWeight, SpaceWeightCreate, SpaceWeightUpdate
|
|
-from app.services.transfer import Season
|
|
|
|
|
|
|
|
router = APIRouter()
|
|
router = APIRouter()
|
|
|
|
|
|
|
|
|
|
@router.get("/control", response_model=SpaceControlResponse)
|
|
@router.get("/control", response_model=SpaceControlResponse)
|
|
async def get_space_command(
|
|
async def get_space_command(
|
|
- project_id: str = Query(..., max_length=50, regex="^Pj", alias="projectId"),
|
|
|
|
- space_id: str = Query(..., max_length=50, regex="^Sp", alias="roomId"),
|
|
|
|
- timestamp: str = Query(None, min_length=14, max_length=14, alias="time"),
|
|
|
|
- method: int = Query(3),
|
|
|
|
|
|
+ project_id: str = Query(..., max_length=50, regex="^Pj", alias="projectId"),
|
|
|
|
+ space_id: str = Query(..., max_length=50, regex="^Sp", alias="roomId"),
|
|
|
|
+ timestamp: str = Query(None, min_length=14, max_length=14, alias="time"),
|
|
|
|
+ method: int = Query(3),
|
|
):
|
|
):
|
|
response = {
|
|
response = {
|
|
"projectId": project_id,
|
|
"projectId": project_id,
|
|
@@ -37,14 +35,6 @@ async def get_space_command(
|
|
return response
|
|
return response
|
|
|
|
|
|
|
|
|
|
-@router.get("/test")
|
|
|
|
-async def get_test_result(current: float, pre: float, target: float):
|
|
|
|
- builder = QLearningCommandBuilder(Season("Cooling"))
|
|
|
|
- command = await builder.get_command(current, pre, target)
|
|
|
|
-
|
|
|
|
- return command
|
|
|
|
-
|
|
|
|
-
|
|
|
|
@router.post("/weight", response_model=SpaceWeight)
|
|
@router.post("/weight", response_model=SpaceWeight)
|
|
async def create_space_weight(weight: SpaceWeightCreate, db: Session = Depends(get_db)):
|
|
async def create_space_weight(weight: SpaceWeightCreate, db: Session = Depends(get_db)):
|
|
return create_weight(db=db, weight=weight)
|
|
return create_weight(db=db, weight=weight)
|
|
@@ -64,10 +54,10 @@ async def read_weight_by_vav(vav_id: str, db: Session = Depends(get_db)):
|
|
|
|
|
|
@router.put("/weight/{space_id}/{vav_id}", response_model=SpaceWeight)
|
|
@router.put("/weight/{space_id}/{vav_id}", response_model=SpaceWeight)
|
|
async def update_weight_by_space(
|
|
async def update_weight_by_space(
|
|
- space_id: str,
|
|
|
|
- vav_id: str,
|
|
|
|
- weight_in: SpaceWeightUpdate,
|
|
|
|
- db: Session = Depends(get_db),
|
|
|
|
|
|
+ space_id: str,
|
|
|
|
+ vav_id: str,
|
|
|
|
+ weight_in: SpaceWeightUpdate,
|
|
|
|
+ db: Session = Depends(get_db),
|
|
):
|
|
):
|
|
weights = get_weights_by_space(db, space_id=space_id)
|
|
weights = get_weights_by_space(db, space_id=space_id)
|
|
new_weight = None
|
|
new_weight = None
|