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) }; }
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); } }
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); } } } } }
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"); } }
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) }; }
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) }; }
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) }; }
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) }; }
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) }; }
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; } ; }
public override bool RemoveSubCondition(SubCondition condition) { switch (condition.SubAlarmType) { case SubAlarmType.Dsc: _subConditions[0] = SubCondition.Empty; return(true); default: return(false); } }
public override bool AddSubCondition(SubCondition condition) { switch (condition.SubAlarmType) { case SubAlarmType.BadPV: _subConditions[0] = condition; return(true); default: return(false); } }
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); } }
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); } }
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); } }
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); }
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"); }
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); } }
public abstract bool RemoveSubCondition(SubCondition condition);
public abstract bool AddSubCondition(SubCondition condition);
protected abstract void OnActive(SubCondition condition, Storage value, DateTime timeStamp);
public override bool RemoveSubCondition(SubCondition condition) { return(true); }