Procházet zdrojové kódy

get vav's flow set limit from platform

chenhaiyang před 4 roky
rodič
revize
c4b31c6fc2

+ 5 - 2
app/controllers/equipment/vav.py

@@ -39,7 +39,6 @@ class VAVController(EquipmentController):
                 realtime_list.append(space.realtime_temperature)
                 if strategy == 'Plan B':
                     for eq in space.equipment:
-                        logger.info(eq)
                         if isinstance(eq, FCU):
                             buffer = (4 - eq.air_valve_speed) / 4
                             buffer_list.append(buffer)
@@ -72,7 +71,8 @@ class VAVController(EquipmentController):
             logger.info(f'realtime temperature: {temperature_realtime}')
             supply_air_flow_set = self._equipment.supply_air_flow * ((temperature_supply - temperature_realtime)
                                                                      / (temperature_supply - temperature_set))
-        supply_air_flow_set = max(150.0, supply_air_flow_set)
+        supply_air_flow_set = max(self._equipment.supply_air_flow_lower_limit, supply_air_flow_set)
+        supply_air_flow_set = min(self._equipment.supply_air_flow_upper_limit, supply_air_flow_set)
         self._equipment.supply_air_flow_set = supply_air_flow_set
 
         return supply_air_flow_set
@@ -100,6 +100,7 @@ async def get_vav_control_result(project_id: str, equipment_id: str) -> VAVBox:
             realtime_supply_air_temperature_list.append(await platform.get_realtime_supply_air_temperature(eq))
         realtime_supply_air_temperature = np.array(realtime_supply_air_temperature_list).mean()
         realtime_supply_air_flow = await platform.get_realtime_supply_air_flow(equipment_id)
+        lower_limit, upper_limit = await platform.get_air_flow_limit(equipment_id)
 
         served_spaces = await duo_duo.get_space_by_equipment(equipment_id)
         space_objects = []
@@ -131,6 +132,8 @@ async def get_vav_control_result(project_id: str, equipment_id: str) -> VAVBox:
             'spaces': space_objects,
             'supply_air_temperature': realtime_supply_air_temperature,
             'supply_air_flow': realtime_supply_air_flow,
+            'supply_air_flow_lower_limit': lower_limit,
+            'supply_air_flow_upper_limit': upper_limit,
         }
         vav = VAVBox(**temp_vav_params)
 

+ 2 - 0
app/models/domain/equipment.py

@@ -32,3 +32,5 @@ class VAVBox(BaseEquipment):
     supply_air_temperature: Optional[float]
     supply_air_flow: Optional[float]
     supply_air_flow_set: Optional[float]
+    supply_air_flow_lower_limit: Optional[float]
+    supply_air_flow_upper_limit: Optional[float]

+ 32 - 1
app/services/platform.py

@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 from enum import Enum
-from typing import Dict
+from typing import Dict, Tuple
 
 import arrow
 import numpy as np
@@ -93,3 +93,34 @@ class DataPlatformService(Service):
 
     async def get_fan_speed(self, equipment_id: str) -> float:
         return await self.get_realtime_data(InfoCode.fan_speed, equipment_id)
+
+    async def get_static_info(self, code: str, object_id: str):
+        url = self._base_url.join('data-platform-3/object/batch_query')
+        params = self._common_parameters()
+        payload = {
+            'customInfo': True,
+            'criterias': [
+                {
+                    'id': object_id
+                }
+            ]
+        }
+        raw_info = await self._post(url, params, payload)
+
+        try:
+            info = raw_info['Content'][0]['infos'][code]
+        except KeyError as e:
+            logger.error(f'id: {object_id}, details: {e}')
+            info = None
+
+        return info
+
+    async def get_air_flow_limit(self, equipment_id: str) -> Tuple[float, float]:
+        lower = await self.get_static_info('MinAirFlow', equipment_id)
+        upper = await self.get_static_info('MaxAirFlow', equipment_id)
+        if not lower:
+            lower = 150.0
+        if not upper:
+            upper = 2000.0
+
+        return lower, upper