Exemplo n.º 1
0
 private void CheckForBelowAlarm(Series s, alarm_definitionRow alarm, AlarmCondition c)
 {
     foreach (Point p in s)
     {
         if (!p.FlaggedBad && !p.IsMissing && p.Value < c.Value)
         {
             Console.WriteLine("Alarm below found");
             CreateAlarm(alarm, p);
             break;
         }
     }
 }
Exemplo n.º 2
0
 private void CheckForAboveAlarm(Series s, alarm_definitionRow alarm, AlarmCondition c)
 {
     foreach (Point p in s)
     {
         if (!p.FlaggedBad && !p.IsMissing && p.Value > c.Value)
         {
             Logger.WriteLine("alarm_condition: " + alarm.alarm_condition);
             Logger.WriteLine("Alarm above found: " + p.Value);
             CreateAlarm(alarm, p);
             break;
         }
     }
 }
Exemplo n.º 3
0
        private void CheckForRateOfChangeAlarm(Series s, alarm_definitionRow alarm, AlarmCondition c)
        {
            Logger.WriteLine("Checking Rate of Change: " + c.Condition + " " + c.Value);
            // need data one time step before.. read from database.

            if (s.TimeInterval == TimeInterval.Irregular)
            {
                s.Read(s.MinDateTime.AddMinutes(-20), s.MaxDateTime.AddMinutes(1));
            }
            else if (s.TimeInterval == TimeInterval.Daily)
            {
                s.Read(s.MinDateTime.AddDays(-1), s.MaxDateTime.AddMinutes(1));
            }

            for (int i = 1; i < s.Count; i++)
            {
                var pt   = s[i];
                var prev = s[i - 1];

                if (!pt.IsMissing && !pt.FlaggedBad
                    & !prev.IsMissing && !prev.FlaggedBad)
                {
                    double hrs    = pt.DateTime.Subtract(prev.DateTime).TotalHours;
                    double change = 0;
                    if (c.Condition == AlarmType.Rising)
                    {
                        change = (pt.Value - prev.Value) / hrs;
                    }
                    ;
                    if (c.Condition == AlarmType.Dropping)
                    {
                        change = (prev.Value - pt.Value) / hrs;
                    }

                    Logger.WriteLine(pt.ToString() + " Change per hour: " + change.ToString("F2"));
                    if (change > c.Value)
                    {
                        Console.WriteLine("Alarm " + c.Condition);
                        CreateAlarm(alarm, pt);
                        break;
                    }
                }
            }
        }