|
@@ -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
|