space.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. # -*- coding: utf-8 -*-
  2. from fastapi import APIRouter, Query
  3. from app.controllers.equipment.fcu.q_learning import QLearningCommandBuilder
  4. from app.models.domain.space import SpaceControlResponse
  5. from app.services.transfer import Season
  6. router = APIRouter()
  7. @router.get('/control', response_model=SpaceControlResponse)
  8. async def get_space_command(
  9. project_id: str = Query(..., max_length=50, regex='^Pj', alias='projectId'),
  10. space_id: str = Query(..., max_length=50, regex='^Sp', alias='roomId'),
  11. timestamp: str = Query(None, min_length=14, max_length=14, alias='time'),
  12. method: int = Query(3),
  13. ):
  14. response = {
  15. 'projectId': project_id,
  16. 'roomId': space_id,
  17. 'flag': 1,
  18. 'time': timestamp,
  19. 'method': method,
  20. }
  21. return response
  22. @router.get('/test')
  23. async def get_test_result(current: float, pre: float, target: float):
  24. builder = QLearningCommandBuilder(Season('Cooling'))
  25. command = await builder.get_command(current, pre, target)
  26. return command