Exemplo n.º 1
0
 public ROCAlarm(int id, string souce, string comment, float deadBand = 0f, int delay = 0) :
     base(id, ConditionType.Percent, souce, comment, 0, deadBand, delay)
 {
     _subConditions = new SubCondition[2] {
         new SubCondition(SubAlarmType.MajROC), new SubCondition(SubAlarmType.MinROC)
     };
 }
Exemplo n.º 2
0
        public Action SetFunction(Delegate tagChanged)
        {
            var _func = tagChanged as Func <bool>;

            if (_func != null)
            {
                return(delegate
                {
                    if (_enable)
                    {
                        SubCondition condition = _subConditions[0];
                        if (condition.IsEnabled)
                        {
                            if (_func())
                            {
                                OnActive(condition, Storage.Empty, DateTime.Now);
                                return;
                            }
                        }
                        OnInActive(Storage.Empty);
                    }
                });
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
 protected override void CheckAlarm(object sender, ValueChangingEventArgs <Storage> e)
 {
     if (_enable)
     {
         short newvalue = e.NewValue.Int16;
         short oldvlaue = e.OldValue.Int16;
         if (newvalue == 0 && oldvlaue != 0)
         {
             OnInActive(e.NewValue);
             return;
         }
         for (short i = 0; i < _subConditions.Length; i++)
         {
             SubCondition condition = _subConditions[i];
             if (condition.IsEnabled)
             {
                 int mask   = 1 << i;
                 int newval = mask & newvalue;
                 int oldval = mask & oldvlaue;
                 if (newval != 0 && oldval == 0)
                 {
                     OnActive(condition, new Storage {
                         Int16 = i
                     }, e.NewTimeStamp);
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 protected override void OnActive(SubCondition condition, Storage value, DateTime timeStamp)
 {
     if (condition.SubAlarmType != ActiveSubCondition)
     {
         if (condition.SubAlarmType != _tempType)
         {
             _timeStamp = timeStamp;
             _tempType  = condition.SubAlarmType;
         }
         if (_delay == 0 || (timeStamp - _timeStamp).TotalMilliseconds > _delay)
         {
             if (ActiveSubCondition == SubAlarmType.None)
             {
                 _active         = true;
                 _condLastActive = timeStamp;
             }
             _ack = false;
             ActiveSubCondition = condition.SubAlarmType;
             _current.Duration  = timeStamp - SubCondLastActive;
             _current           = new AlarmItem(timeStamp, condition.Message, _tag.GetValue(value), ActiveSubCondition, condition.Severity, _id, _source);
             if (AlarmActive != null)
             {
                 foreach (AlarmEventHandler deleg in AlarmActive.GetInvocationList())
                 {
                     deleg.BeginInvoke(this, _current, null, null);
                 }
             }
             RaiseChanged("Value");
         }
     }
     else
     {
         RaiseChanged("Value");
     }
 }
Exemplo n.º 5
0
 public QualitiesAlarm(int id, string source, string comment, int delay = 0) :
     base(id, ConditionType.Absolute, source, comment, 0, 0f, delay)
 {
     _subConditions = new SubCondition[1] {
         new SubCondition(SubAlarmType.BadPV)
     };
 }
Exemplo n.º 6
0
 public DigitAlarm(int id, string source = null, string comment = null, int delay = 0) :
     base(id, ConditionType.Absolute, source, comment, 0, 0f, delay)
 {
     _subConditions = new SubCondition[1] {
         new SubCondition(SubAlarmType.Dsc)
     };
 }
Exemplo n.º 7
0
 public ComplexCondition(int id, string source, string comment, float deadBand, int delay) :
     base(id, ConditionType.Absolute, source, comment, 0f, deadBand, delay)
 {
     _subConditions = new SubCondition[1] {
         new SubCondition(SubAlarmType.Dsc)
     };
 }
Exemplo n.º 8
0
 public LevelAlarm(int id, string source, string comment, float deadBand = 0f, int delay = 0) :
     base(id, ConditionType.Absolute, source, comment, 0, deadBand, delay)
 {
     _subConditions = new SubCondition[4] {
         new SubCondition(SubAlarmType.HiHi), new SubCondition(SubAlarmType.High),
         new SubCondition(SubAlarmType.LoLo), new SubCondition(SubAlarmType.Low)
     };
 }
Exemplo n.º 9
0
 public DevAlarm(int id, ConditionType conditionType, string source, string comment, float para,
                 float deadBand = 0f, int delay = 0) :
     base(id, conditionType, source, comment, para, deadBand, delay)
 {
     _subConditions = new SubCondition[2] {
         new SubCondition(SubAlarmType.MajDev), new SubCondition(SubAlarmType.MinDev)
     };
 }
Exemplo n.º 10
0
 public WordDigitAlarm(int id, string source = null, string comment = null, int delay = 0) :
     base(id, ConditionType.Absolute, source, comment, 0, 0f, delay)
 {
     _subConditions = new SubCondition[16];
     for (int i = 0; i < 16; i++)
     {
         _subConditions[i].SubAlarmType = SubAlarmType.Dsc;
         _subConditions[i].Threshold    = i;
     }
     ;
 }
Exemplo n.º 11
0
        public override bool RemoveSubCondition(SubCondition condition)
        {
            switch (condition.SubAlarmType)
            {
            case SubAlarmType.Dsc:
                _subConditions[0] = SubCondition.Empty;
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 12
0
        public override bool AddSubCondition(SubCondition condition)
        {
            switch (condition.SubAlarmType)
            {
            case SubAlarmType.BadPV:
                _subConditions[0] = condition;
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 13
0
        public override bool RemoveSubCondition(SubCondition condition)
        {
            switch (condition.SubAlarmType)
            {
            case SubAlarmType.Dsc:
                int index = (int)condition.Threshold;
                if (index >= 0 && index < 16)
                {
                    _subConditions[index] = SubCondition.Empty;
                }
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 14
0
 protected override void CheckAlarm(object sender, ValueChangingEventArgs <Storage> e)
 {
     if (_enable)
     {
         SubCondition condition = _subConditions[0];
         if (condition.IsEnabled)
         {
             if (e.Quality != QUALITIES.QUALITY_GOOD)
             {
                 OnActive(condition, e.NewValue, e.NewTimeStamp);
             }
             return;
         }
         OnInActive(e.NewValue);
     }
 }
Exemplo n.º 15
0
 protected override void CheckAlarm(object sender, ValueChangingEventArgs <Storage> e)
 {
     if (_enable)
     {
         SubCondition condition = _subConditions[0];
         if (condition.IsEnabled)
         {
             if (e.NewValue.Boolean == condition.Threshold > 0)
             {
                 OnActive(condition, e.NewValue, e.NewTimeStamp);
                 return;
             }
         }
         OnInActive(e.NewValue);
     }
 }
Exemplo n.º 16
0
        public static SubCondition FindSubConditon(this IAlarmServer server, string sourceName, SubAlarmType alarmType)
        {
            var conds = server.QueryConditions(sourceName);

            if (conds == null)
            {
                return(SubCondition.Empty);
            }
            foreach (ICondition cond in conds)
            {
                SubCondition sub = cond.FindSubConditon(alarmType);
                if (sub.SubAlarmType == alarmType)
                {
                    return(sub);
                }
            }
            return(SubCondition.Empty);
        }
Exemplo n.º 17
0
 protected override void OnActive(SubCondition condition, Storage value, DateTime timeStamp)
 {
     if (ActiveSubCondition == SubAlarmType.None)
     {
         _active         = true;
         _condLastActive = timeStamp;
     }
     _ack = false;
     ActiveSubCondition = condition.SubAlarmType;
     _current           = new AlarmItem(timeStamp, condition.Message, value.Int16, ActiveSubCondition, condition.Severity, _id, _source);
     if (AlarmActive != null)
     {
         foreach (AlarmEventHandler deleg in AlarmActive.GetInvocationList())
         {
             deleg.BeginInvoke(this, _current, null, null);
         }
     }
     RaiseChanged("Value");
 }
Exemplo n.º 18
0
        public override bool RemoveSubCondition(SubCondition condition)
        {
            switch (condition.SubAlarmType)
            {
            case SubAlarmType.HiHi:
                _subConditions[0] = SubCondition.Empty;
                return(true);

            case SubAlarmType.High:
                _subConditions[1] = SubCondition.Empty;
                return(true);

            case SubAlarmType.LoLo:
                _subConditions[2] = SubCondition.Empty;
                return(true);

            case SubAlarmType.Low:
                _subConditions[3] = SubCondition.Empty;
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 19
0
 public abstract bool RemoveSubCondition(SubCondition condition);
Exemplo n.º 20
0
 public abstract bool AddSubCondition(SubCondition condition);
Exemplo n.º 21
0
 protected abstract void OnActive(SubCondition condition, Storage value, DateTime timeStamp);
Exemplo n.º 22
0
 public override bool RemoveSubCondition(SubCondition condition)
 {
     return(true);
 }