|
@@ -57,7 +57,6 @@ class QLearningCommandBuilder:
|
|
|
|
|
|
return int(speed)
|
|
|
|
|
|
- @logger.catch()
|
|
|
async def get_command(self, current_temperature: float, pre_temperature: float, actual_target: float) -> Dict:
|
|
|
# actual_target = np.mean(np.array(target))
|
|
|
input_value = np.array([
|
|
@@ -65,6 +64,9 @@ class QLearningCommandBuilder:
|
|
|
[(current_temperature - pre_temperature) / 5]
|
|
|
])
|
|
|
speed = self.predict_speed(input_value)
|
|
|
+ if np.isnan(current_temperature) or np.isnan(pre_temperature):
|
|
|
+ speed = 2
|
|
|
+
|
|
|
if speed == 0:
|
|
|
on_off = 0
|
|
|
water_on_off = 0
|
|
@@ -96,13 +98,17 @@ async def get_fcu_q_learning_control_result(project_id: str, equipment_id: str)
|
|
|
platform = DataPlatformService(client, project_id)
|
|
|
|
|
|
spaces = await duo_duo.get_space_by_equipment(equipment_id)
|
|
|
- if len(spaces) > 1:
|
|
|
- logger.error(f'FCU {equipment_id} control more than one spaces!')
|
|
|
- transfer = SpaceInfoService(client, project_id, spaces[0].get('id'))
|
|
|
- season = await transfer.get_season()
|
|
|
- current_target = await transfer.get_current_temperature_target()
|
|
|
- realtime_temperature = await platform.get_realtime_temperature(spaces[0].get('id'))
|
|
|
- past_temperature = await platform.get_past_temperature(spaces[0].get('id'), 15 * 60)
|
|
|
+ if not spaces:
|
|
|
+ logger.error(f'FCU {equipment_id} does not have space')
|
|
|
+ return {}
|
|
|
+ else:
|
|
|
+ if len(spaces) > 1:
|
|
|
+ logger.error(f'FCU {equipment_id} control more than one spaces!')
|
|
|
+ transfer = SpaceInfoService(client, project_id, spaces[0].get('id'))
|
|
|
+ season = await transfer.get_season()
|
|
|
+ current_target = await transfer.get_current_temperature_target()
|
|
|
+ realtime_temperature = await platform.get_realtime_temperature(spaces[0].get('id'))
|
|
|
+ past_temperature = await platform.get_past_temperature(spaces[0].get('id'), 15 * 60)
|
|
|
|
|
|
logger.debug(
|
|
|
f'{spaces[0]["id"]} - {equipment_id} - '
|