def main_motor_temperature_detect(self, df, para): """ 主电机系统温度异常判断规则 """ if not df.empty: df = df.resample('T').mean() dT = df['temp_out'] - df['temp_in'] # 进出口温升小于*,同时三项温度大于* => 冷却系统效果不好 if np.any((dT < para[0]) & ((df['A'] > para[1]) | (df['B'] > para[1]) | (df['C'] > para[1]))): event = Event({ 'assetid': self.graph.deviceid, 'meastime': df.index[0], 'level': 1, 'info': '冷却系统进出口温度异常!' }) self.graph.events.append(event) # 三项温度温差大于*,且绝对温度大于* => 定子温度异常 if np.any((((df['A'] - df['B']) > para[2]) & ( (df['A'] > para[1]) & (df['B'] > para[1]))) | (((df['A'] - df['C']) > para[3]) & ( (df['A'] > para[1]) & (df['C'] > para[1]))) | (((df['B'] - df['C']) > para[4]) & ( (df['B'] > para[1]) & (df['C'] > para[1])))): event = Event({ 'assetid': self.graph.deviceid, 'meastime': df.index[0], 'level': 1, 'info': '电子定子温度异常!' }) self.graph.events.append(event) # 三相温度大于* => 定子温度异常 if np.any((df['A'] > para[5]) | (df['B'] > para[5]) | (df['C'] > para[5])): event = Event({ 'assetid': self.graph.deviceid, 'meastime': df.index[0], 'level': 1, 'info': '电机定子温度异常!' }) self.graph.events.append(event) # 轴承绝对温度大于* => 轴承温度异常 if np.any((df['temp_bearing_front'] > para[6]) | (df['temp_bearing_rear'] > para[6])): event = Event({ 'assetid': self.graph.deviceid, 'meastime': df.index[0], 'level': 1, 'info': '电机轴承温度异常!' }) self.graph.events.append(event)
def test_initializer(self): node = Node(Event(3, title=u"title", summary=u"summary")) self.assertEquals(node.title, u"title") self.assertEquals(node._id, 3) self.assertEquals(node.summary, u"summary") self.assertTrue(node.speaker is None) self.assertRaises(AttributeError, Event, 3, t=u"title")
def get_alarm_logical(self, p4, p5): """ 0-1型信号 """ df = self.graph.get_data_from_api(['signal1', 'signal2']) if not df.empty: n = np.sum(np.abs(df['signal1'] - df['signal2'])) t = n * df.dt if t > p4 or n > p5: event = Event({ 'assetid': self.graph.deviceid, 'meastime': df.index[0], 'level': 1, 'info': '双仪表数值不匹配' }) self.graph.events.append(event)
def get_alarm_analogs(self, p2, p3): """ 模拟量信号 """ df = self.graph.get_data_from_api(['signal1', 'signal2']) if not df.empty: df = df.resample(f'{p2}S').mean() r = (np.abs(df['signal1'] - df['signal2']) / np.mean(df['signal1'] + df['signal2'])) * 100 # 双仪表相对偏差(%) if np.any(r) > p3: event = Event({ 'assetid': self.graph.deviceid, 'meastime': df.index[0], 'level': 1, 'info': '双仪表数值不匹配' }) self.graph.events.append(event)
def get_alarm(self): df = self.graph.get_data_from_api(['sv_ref', 'sv_act']) if df.empty: return algparas = self.graph.parameter rolling = df['sv_ref'].rolling(algparas[0] * df.dt) roll_cv = np.abs(rolling.std() / rolling.mean()) # 计算窗口变异系数 min_cv = roll_cv.max() if min_cv > algparas[1]: # 数据包不包含稳态工况 return stidx = roll_cv.argmin() - np.floor(algparas[0] * df.dt / 2) edidx = roll_cv.argmin() + np.ceil(algparas[0] * df.dt / 2) n = (edidx - stidx) // 5 # 对稳态段切头切尾 avg_ref = np.mean(df['sv_ref'][stidx + n:edidx - n]) avg_act = np.mean(df['sv_act'][stidx + n:edidx - n]) r = np.abs(avg_ref - avg_act) / avg_ref * 100 # 计算稳态工况设定值与实际值偏差 index = Index({ 'assetid': self.graph.deviceid, 'meastime1st': df.index[0], 'feid1st': "16000", 'value1st': r, 'indices2nd': [] }) self.graph.indices.append(index) if r > algparas[2]: event = Event({ 'assetid': self.graph.deviceid, 'meastime': df.index[0], 'level': 1, 'info': '伺服阀零偏报警' }) self.graph.events.append(event)
def setUp(self): self.node = Node(Event(3)) self.attrs = self.node._wraps._attrs.iterkeys()
def test_add_conflicts(self): e = Node(Event(5)) self.node.add_conflict_with_node(e) self.assertTrue(e.get_id() in self.node.conflicts_with)