public void Above() { AlarmRegex re = new AlarmRegex("above 4198.20"); Assert.IsFalse(re.IsAlarm(1.0)); Assert.IsFalse(re.IsAlarm(4198.20)); Assert.IsTrue(re.IsAlarm(5000.1)); }
public void Rising() { AlarmRegex re = new AlarmRegex("rising 1"); // TO DO. Assert.IsTrue(re.IsAlarm(1.0,2.0)); }
public void Dropping() { AlarmRegex re = new AlarmRegex("dropping 0.25"); // TO DO. Assert.IsTrue(re.IsAlarm(1.0,2.0)); }
public void Below() { AlarmRegex re = new AlarmRegex("below 4198.20"); // Assert.IsTrue( re.IsAlarm( 1.0)); }
/// <summary> /// Check each point in the series for an alarm /// </summary> /// <param name="s"></param> internal void Check(Series s) { Logger.WriteLine("Check for alarms " + s.SiteID + " " + s.Parameter); var alarm = GetAlarmDefinition(s.SiteID.ToLower(), s.Parameter.ToLower()); // is alarm defined if (alarm.Rows.Count == 0) return; if (alarm.Rows.Count > 1) throw new Exception("bad... alarm_definition constraint not working (siteid,parameter)"); Logger.WriteLine("found alarm definition " + s.SiteID + " " + s.Parameter); AlarmDataSet.alarm_definitionRow row = alarm[0]; // check alarm_condition for each value AlarmRegex alarmEx = new AlarmRegex(row.alarm_condition); if (alarmEx.IsMatch()) { foreach (var c in alarmEx.AlarmConditions()) { if (c.Condition == AlarmType.Above) { foreach (Point p in s) { if (!p.IsMissing && p.Value > c.Value) { Logger.WriteLine("alarm_condition: "+row.alarm_condition); Logger.WriteLine("Alarm above found: "+p.Value); CreateAlarm(row, p); return; } } } if (c.Condition == AlarmType.Below) { foreach (Point p in s) { if (!p.IsMissing && p.Value < c.Value) { Console.WriteLine("Alarm below found"); CreateAlarm(row, p); return; } } } if (c.Condition == AlarmType.Dropping) { double num_a = s[0].Value; double num_b = s[1].Value; double num_c = s[2].Value; double num_d = s[3].Value; if ((num_a - num_b) > c.Value | (num_b - num_c) > c.Value | (num_c - num_d) > c.Value) { Console.WriteLine("Alarm dropping found"); CreateAlarm(row, s[0]); return; } } if (c.Condition == AlarmType.Rising) { double num_a = s[0].Value; double num_b = s[1].Value; double num_c = s[2].Value; double num_d = s[3].Value; if ((num_b - num_a) > c.Value | (num_c - num_b) > c.Value | (num_d - num_c) > c.Value) { Console.WriteLine("Alarm dropping found"); CreateAlarm(row, s[0]); return; } } } } // TO DO clear alarms if clear_condition }