Exemplo n.º 1
0
            public override bool Equals(object obj)
            {
                SourceAndEventTypeKey other = obj as SourceAndEventTypeKey;

                if (other != null)
                {
                    return(SourceNode.Equals(other.SourceNode) && EventType.Equals(other.EventType));
                }
                return(base.Equals(obj));
            }
Exemplo n.º 2
0
        private void MonitorItem_Notification(MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs e)
        {
            try
            {
                EventFieldList notification = e.NotificationValue as EventFieldList;

                if (notification == null)
                {
                    return;
                }
                var filter = monitoredItem.Filter as Opc.Ua.EventFilter;

                if (filter != null)
                {
                    var values = GetEventFilterValues(monitoredItem.StartNodeId, filter);
                    if (values != null)
                    {
                        var eventType  = (NodeId)notification.EventFields[notification.EventFields.Count - 1].Value;
                        var sourceNode = (NodeId)notification.EventFields[notification.EventFields.Count - 2].Value;
                        var key        = new SourceAndEventTypeKey(sourceNode, eventType);
                        lock (_eventData)
                        {
                            List <EventFilterValues> eventFilterValuesList;
                            if (_eventData.TryGetValue(monitoredItem.StartNodeId, out eventFilterValuesList))
                            {
                                var eventFilterValues = eventFilterValuesList.FirstOrDefault(a => a.Filter.IsEqual(filter));
                                if (eventFilterValues != null)
                                {
                                    eventFilterValues.Values[key] = notification.EventFields;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                _log.LogError(exception, "Error in monitor notification");
            }
        }