private async Task SendAlarm(LimitAlarmDesc limitAlarmDesc, DataQualityTimestamp dtq) { if (limitAlarmDesc == null) { return; } ILimitAlarm alarmProcessor = GetlimitAlarmActorPoxy("AlarmProcessor"); await alarmProcessor.ProcessEventAsync(this.context, limitAlarmDesc, dtq); }
private async Task ProcessLimitAlarms(DataQualityTimestamp dtq) { double value = dtq.Value; bool isAlarm = false; LimitAlarmDesc limitAlarmDesc = null; foreach (var limit in this.limitAlarmData.LimitAlarms) { switch (limit.Key) { case AlarmCategoty.Lo: { if (value <= limit.Value.Value) { limitAlarmDesc = limit.Value; isAlarm = true; } } break; case AlarmCategoty.Lolo: { if (value <= limit.Value.Value) { limitAlarmDesc = limit.Value; isAlarm = true; } } break; case AlarmCategoty.Hi: { if (value >= limit.Value.Value) { limitAlarmDesc = limit.Value; isAlarm = true; } } break; case AlarmCategoty.HiHi: { if (value >= limit.Value.Value) { limitAlarmDesc = limit.Value; isAlarm = true; } } break; } } if (isAlarm) { await SendAlarm(limitAlarmDesc, dtq); } }
public async Task ProcessEventAsync(string context, LimitAlarmDesc limitAlarm, DataQualityTimestamp dtq) { await Task.Run(() => { var alarm = new AlarmMessage(context, limitAlarm, dtq); var body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(alarm)); channel.BasicPublish(exchange: "", routingKey: "Alarm", basicProperties: null, body: body); }); }
private static List <LimitAlarmDesc> CreatePresureLimitData() { List <LimitAlarmDesc> limitAlarms = new List <LimitAlarmDesc>(4); //5,10,90,95 LimitAlarmDesc lolo = new LimitAlarmDesc() { AlarmCategoty = AlarmCategoty.Lolo, Value = 110, Message = "Humidity lolo alarm ", Piority = 100, }; limitAlarms.Add(lolo); LimitAlarmDesc lo = new LimitAlarmDesc() { AlarmCategoty = AlarmCategoty.Lo, Value = 120, Message = "Humidity lo alarm ", Piority = 200, }; limitAlarms.Add(lo); LimitAlarmDesc hi = new LimitAlarmDesc() { AlarmCategoty = AlarmCategoty.Hi, Value = 260, Message = "Humidity hi alarm ", Piority = 200, }; limitAlarms.Add(hi); LimitAlarmDesc hihi = new LimitAlarmDesc() { AlarmCategoty = AlarmCategoty.HiHi, Value = 280, Message = "Humidity hihi alarm ", Piority = 100, }; limitAlarms.Add(hihi); return(limitAlarms); }
private static List <LimitAlarmDesc> CreateTempLimitData() { List <LimitAlarmDesc> limitAlarms = new List <LimitAlarmDesc>(4); //5,10,90,95 LimitAlarmDesc lolo = new LimitAlarmDesc() { AlarmCategoty = AlarmCategoty.Lolo, Value = 5, Message = "temp lolo alarm ", Piority = 100, }; limitAlarms.Add(lolo); LimitAlarmDesc lo = new LimitAlarmDesc() { AlarmCategoty = AlarmCategoty.Lo, Value = 10, Message = "temp lo alarm ", Piority = 200, }; limitAlarms.Add(lo); LimitAlarmDesc hi = new LimitAlarmDesc() { AlarmCategoty = AlarmCategoty.Hi, Value = 80, Message = "temp hi alarm ", Piority = 200, }; limitAlarms.Add(hi); LimitAlarmDesc hihi = new LimitAlarmDesc() { AlarmCategoty = AlarmCategoty.HiHi, Value = 85, Message = "temp hihi alarm ", Piority = 100, }; limitAlarms.Add(hihi); return(limitAlarms); }