|
@@ -2,23 +2,35 @@
|
|
|
|
|
|
from fastapi import APIRouter, Query
|
|
|
|
|
|
+from app.controllers.equipment.fcu.q_learning import QLearningCommandBuilder
|
|
|
from app.models.domain.space import SpaceControlResponse
|
|
|
+from app.services.transfer import Season
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
|
|
|
-@router.get('/control', response_model=SpaceControlResponse, tags=['space'])
|
|
|
+@router.get('/control', response_model=SpaceControlResponse)
|
|
|
async def get_space_command(
|
|
|
- projectId: str = Query(..., max_length=50, regex='^Pj'),
|
|
|
- roomId: str = Query(..., max_length=50, regex='^Sp'),
|
|
|
- time: str = Query(None, min_length=14, max_length=14),
|
|
|
+ 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 = {
|
|
|
- 'projectId': projectId,
|
|
|
- 'roomId': roomId,
|
|
|
+ 'projectId': project_id,
|
|
|
+ 'roomId': space_id,
|
|
|
'flag': 1,
|
|
|
- 'time': time,
|
|
|
+ 'time': timestamp,
|
|
|
'method': method,
|
|
|
}
|
|
|
return response
|
|
|
+
|
|
|
+
|
|
|
+@router.get('/test')
|
|
|
+async def get_test_result(current: float, pre: float, target: float):
|
|
|
+ path = ('/Users/highing/code/sagacloud/python_server/sagacloud-python/pythonserver'
|
|
|
+ '/pythonserver/room_control_modularization/net_mat/net_1_summer.mat')
|
|
|
+ builder = QLearningCommandBuilder(path, Season('Cooling'))
|
|
|
+ command = await builder.get_command(current, pre, target)
|
|
|
+
|
|
|
+ return command
|