Pārlūkot izejas kodu

run test with deepsaga2

chenhaiyang 4 gadi atpakaļ
vecāks
revīzija
2bc6ca1f32
3 mainītis faili ar 30 papildinājumiem un 36 dzēšanām
  1. 6 10
      alarm.py
  2. 2 3
      data_platform_api.py
  3. 22 23
      main.py

+ 6 - 10
alarm.py

@@ -33,16 +33,12 @@ class FanCoilUnitAlarm(Alarm):
         super().__init__(params)
 
     def procedure(self):
-        if self.get('water_valve_switch') == 1:
-            if 0 not in self.get('water_valve_history_status'):
-                return
+        if self.get('water_valve_switch') == 1 and 0 not in self.get('water_valve_history_status'):
+            if len(set(self.get('tap_history_status'))) == 1:
 
-        if len(set(self.get('tap_history_status'))) <= 1:
-            return
-
-        air_temp_diff = self.get('return_air_temp') - abs(self.get('supply_air_temp'))
-        water_temp_diff = self.get('water_out_temp') - abs(self.get('water_in_temp'))
-        if air_temp_diff > 12 and water_temp_diff < 5:
-            self.set_alarm(1)
+                air_temp_diff = self.get('return_air_temp') - abs(self.get('supply_air_temp'))
+                water_temp_diff = self.get('water_out_temp') - abs(self.get('water_in_temp'))
+                if air_temp_diff > 12 and water_temp_diff < 5:
+                    self.set_alarm(1)
 
         return

+ 2 - 3
data_platform_api.py

@@ -48,7 +48,6 @@ class PlatformRequest:
 
 
 def query_real_time_data(project_id, equip_id, code_list):
-    logger.info(project_id)
     url = 'parameter/batch_query_param'
     params = {
         'projectId': project_id,
@@ -99,7 +98,7 @@ def send_alarm(project_id, object_id, type_code, description):
         'status': 'alarm',
         'objects': [object_id],
         'ctime': time_stamp,
-        'level': 's',
+        'level': 'S',
         'type_code': type_code,
         'description': description
     }
@@ -107,7 +106,7 @@ def send_alarm(project_id, object_id, type_code, description):
     raw_result = porter.send_request()
     result = raw_result.get('id')
 
-    send_alarm(project_id, object_id, result, time_stamp)
+    save_alarm_info(project_id, object_id, result, time_stamp)
 
     return result
 

+ 22 - 23
main.py

@@ -7,6 +7,7 @@ main
 The module handles the main procedure of fan coil unit alarm test.
 """
 
+import json
 import logging.config
 from datetime import datetime
 
@@ -25,7 +26,7 @@ logger = logging.getLogger(__name__)
 
 def get_alarm_params(project_id, equip_id):
     real_time_params = [
-        'ctm-info008',
+        'WaterValveSwitchStatus',
         'ReturnAirTemp',
         'SupplyTemp',
         'WaterOutTemp',
@@ -34,29 +35,18 @@ def get_alarm_params(project_id, equip_id):
     real_time_data = data_platform_api.query_real_time_data(project_id, equip_id, real_time_params)
 
     history_params = [
-        'ctm-info008',
-        'ctm-info010',
-        'ctm-info011',
-        'ctm-info012'
+        'WaterValveSwitchStatus',
+        'FanGear'
     ]
     history_data = dict()
     for code in history_params:
         temp_data = data_platform_api.query_history_time_data(project_id, equip_id, code, 15)
         history_data.update({code: temp_data})
 
-    tap_history_status = []
-    for i in range(len(history_data.get('ctm-info010'))):
-        if history_data.get('ctm-info010')[i] == 1.0:
-            tap_history_status.append('low')
-        if history_data.get('ctm-info011')[i] == 1.0:
-            tap_history_status.append('mid')
-        if history_data.get('ctm-info012')[i] == 1.0:
-            tap_history_status.append('high')
-
     params_dic = {
-        'water_valve_switch': real_time_data.get('ctm-info008'),
-        'water_valve_history_status': history_data.get('ctm-info008'),
-        'tap_history_status': tap_history_status,
+        'water_valve_switch': real_time_data.get('WaterValveSwitchStatus'),
+        'water_valve_history_status': history_data.get('WaterValveSwitchStatus'),
+        'tap_history_status': history_data.get('FanGear'),
         'return_air_temp': real_time_data.get('ReturnAirTemp'),
         'supply_air_temp': real_time_data.get('SupplyTemp'),
         'water_out_temp': real_time_data.get('WaterOutTemp'),
@@ -67,8 +57,11 @@ def get_alarm_params(project_id, equip_id):
 
 
 def guard():
-    project_id = 'Pj1101080002'
-    devices = ['Eq1101080002001ACATFC032']
+    project_id = 'Pj3101150005'
+    devices = [
+        'Eq3101150005e8f64436c90b401ba63cf3cc5cdf5cc9',
+        'Eq3101150005d9111aa8ae5047548ee25f272a9833ea'
+    ]
 
     for device in devices:
         alarm_params = get_alarm_params(project_id, device)
@@ -81,24 +74,30 @@ def guard():
             if not data_platform_api.is_alarmed(project_id, device, type_code):
                 data_platform_api.send_alarm(project_id, device, type_code, '风量偏小')
 
+    return
+
 
 def recover():
-    project_id = 'Pj1101080002'
-    devices = ['Eq1101080002001ACATFC032']
+    project_id = 'Pj3101150005'
+    devices = [
+        'Eq3101150005e8f64436c90b401ba63cf3cc5cdf5cc9',
+        'Eq3101150005d9111aa8ae5047548ee25f272a9833ea'
+    ]
 
     for device in devices:
         alarm_info = data_platform_api.query_redis_alarm(project_id, device)
         for k, v in alarm_info.items():
-            if (datetime.now() - datetime.strptime(v, '%Y%m%d%H%M%S')).total_seconds() >= 30 * 60:
+            if (datetime.now() - datetime.strptime(v, '%Y%m%d%H%M%S')).total_seconds() >= 5 * 60:
                 data_platform_api.recover_alarm(project_id, k)
 
 
 if __name__ == '__main__':
     scheduler = BlockingScheduler()
     scheduler.add_job(guard, 'interval', seconds=5)
-    scheduler.add_job(recover, 'interval', seconds=10)
+    scheduler.add_job(recover, 'interval', seconds=150)
 
     try:
         scheduler.start()
+
     except (KeyboardInterrupt, SystemExit):
         pass