Beispiel #1
0
        private async Task OnAlarmOrEvent(AlarmOrEvent alarmOrEvent)
        {
            if (!running)
            {
                initBuffer.Add(alarmOrEvent);
                return;
            }

            AggregatedEvent?aggEvent = null;

            for (int i = aggregatedWarningsAndAlarms.Count - 1; i >= 0; i--)
            {
                var e = aggregatedWarningsAndAlarms[i];
                if (e.CanAggregateWith(alarmOrEvent))
                {
                    aggEvent = e;
                    break;
                }
            }

            if (aggEvent != null)
            {
                aggEvent.AggregateWith(alarmOrEvent);

                if (aggEvent.ReturnedToNormal && aggEvent.State == EventState.Ack)
                {
                    aggregatedWarningsAndAlarms.Remove(aggEvent);
                }

                DataValue data = DataValue.FromObject(aggEvent);
                VTQ       vtq  = new VTQ(aggEvent.TimeFirst, Quality.Good, data);
                await connection.HistorianModify(GetVar(), ModifyMode.Update, vtq);
            }
            else if (!alarmOrEvent.ReturnToNormal)
            {
                aggEvent = AggregatedEvent.FromEvent(alarmOrEvent);
                if (aggEvent.TimeFirst <= latestUsedTimestamp)
                {
                    Timestamp t = latestUsedTimestamp.AddMillis(1);
                    aggEvent.TimeFirst = t;
                    aggEvent.TimeLast  = t;
                }
                if (aggEvent.IsWarningOrAlarm())
                {
                    aggregatedWarningsAndAlarms.Add(aggEvent);
                }
                latestUsedTimestamp = aggEvent.TimeFirst;

                DataValue data = DataValue.FromObject(aggEvent);
                VTQ       vtq  = new VTQ(aggEvent.TimeFirst, Quality.Good, data);
                await connection.HistorianModify(GetVar(), ModifyMode.Insert, vtq);

                if (alarmOrEvent.Severity == Severity.Warning || alarmOrEvent.Severity == Severity.Alarm)
                {
                    NotifyAlarm(alarmOrEvent);
                }
            }
        }
Beispiel #2
0
        public async void OnAlarmOrEvent(AlarmOrEvent alarmOrEvent)
        {
            if (!running)
            {
                initBuffer.Add(alarmOrEvent);
                return;
            }

            AggregatedEvent aggEvent = null;

            for (int i = aggregatedWarningsAndAlarms.Count - 1; i >= 0; i--)
            {
                var e = aggregatedWarningsAndAlarms[i];
                if (e.CanAggregateWith(alarmOrEvent))
                {
                    aggEvent = e;
                    break;
                }
            }

            if (aggEvent != null)
            {
                aggEvent.AggreagteWith(alarmOrEvent);

                DataValue data = DataValue.FromObject(aggEvent);
                VTQ       vtq  = new VTQ(aggEvent.TimeFirst, Quality.Good, data);
                await connection.HistorianModify(GetVar(), ModifyMode.Update, vtq);
            }
            else
            {
                aggEvent = AggregatedEvent.FromEvent(alarmOrEvent);
                if (aggEvent.TimeFirst <= latestUsedTimestamp)
                {
                    Timestamp t = latestUsedTimestamp.AddMillis(1);
                    aggEvent.TimeFirst = t;
                    aggEvent.TimeLast  = t;
                }
                if (aggEvent.IsWarningOrAlarm())
                {
                    aggregatedWarningsAndAlarms.Add(aggEvent);
                }
                latestUsedTimestamp = aggEvent.TimeFirst;

                DataValue data = DataValue.FromObject(aggEvent);
                VTQ       vtq  = new VTQ(aggEvent.TimeFirst, Quality.Good, data);
                await connection.HistorianModify(GetVar(), ModifyMode.Insert, vtq);
            }
        }