Browse Source

fix a bug

chenhaiyang 4 years ago
parent
commit
5c92937d55
1 changed files with 12 additions and 9 deletions
  1. 12 9
      app/controllers/equipment/fcu/on_ratio.py

+ 12 - 9
app/controllers/equipment/fcu/on_ratio.py

@@ -62,14 +62,14 @@ class OnRatioController:
     def calculate_on_ratio(self, period_time: float, delta_on: float, delta_off: float, last_mode: str) -> float:
         if self.period_num == 0:
             if last_mode == 'normal':
-                ratio = 0.9
+                ratio = 0.8
             elif last_mode == 'off':
-                ratio = 0.1
+                ratio = 0.2
             else:
                 if self.return_air > self.target - 0.75:
-                    ratio = 0.1
+                    ratio = 0.2
                 else:
-                    ratio = 0.9
+                    ratio = 0.8
         else:
             if delta_on <= 0:
                 ratio = 0.9
@@ -78,11 +78,14 @@ class OnRatioController:
                     if delta_off >= 0:
                         delta_off = 0.0
                     ratio = (0.5 * (self.target - self.return_air) / period_time - delta_off) / (delta_on - delta_off)
+                    if ratio > 0.9:
+                        ratio = 0.9
+                    if ratio < 0.1:
+                        ratio = 0.1
+
                     if delta_on <= 0:
                         ratio = 0.5
                     logger.debug(f'delta target: {0.5 * (self.target - self.return_air)}')
-                    if ratio > 0.9:
-                        ratio = 0.9
                 except ZeroDivisionError:
                     ratio = 0.1
 
@@ -139,7 +142,7 @@ async def start_on_ratio_mode(device_id: str, target: float, period_time: int):
     _DAILY_OFF_TIME = '220000'
 
     period_num = 0
-    last_on_ratio = 0.9
+    last_on_ratio = 1.0
     last_mode = 'default'
     life_count = 0
     while life_count < 2000:
@@ -176,7 +179,7 @@ async def start_on_ratio_mode(device_id: str, target: float, period_time: int):
                     await asyncio.sleep(period_time)
 
                     period_num = 0
-                    last_on_ratio = 0.9
+                    last_on_ratio = 1.0
                     last_mode = mode
 
                 life_count += 1
@@ -184,7 +187,7 @@ async def start_on_ratio_mode(device_id: str, target: float, period_time: int):
             else:
                 await send_instructions(device_id, False, 'off', False)
                 period_num = 0
-                last_on_ratio = 0.1
+                last_on_ratio = 0.0
                 last_mode = 'off'
                 await asyncio.sleep(period_time)
         except (KeyError, IndexError, TypeError, HTTPException):