Stores information about an AE event type in the server address space.
Inheritance: Opc.Ua.BaseObjectTypeState
コード例 #1
0
        /// <summary>
        /// Creates an instance of an event.
        /// </summary>
        public BaseEventState CreateInstance(ServerSystemContext context, AeEventTypeState eventType)
        {
            BaseEventState instance = null;

            switch (eventType.EventType.EventTypeMapping)
            {
            case EventTypeMapping.AlarmConditionType: { instance = new AlarmConditionState(null); break; }

            case EventTypeMapping.AuditEventType: { instance = new AuditEventState(null); break; }

            case EventTypeMapping.BaseEventType: { instance = new BaseEventState(null); break; }

            case EventTypeMapping.DeviceFailureEventType: { instance = new DeviceFailureEventState(null); break; }

            case EventTypeMapping.DiscreteAlarmType: { instance = new DiscreteAlarmState(null); break; }

            case EventTypeMapping.NonExclusiveDeviationAlarmType: { instance = new NonExclusiveDeviationAlarmState(null); break; }

            case EventTypeMapping.ExclusiveLevelAlarmType: { instance = new ExclusiveLevelAlarmState(null); break; }

            case EventTypeMapping.LimitAlarmType: { instance = new LimitAlarmState(null); break; }

            case EventTypeMapping.NonExclusiveLevelAlarmType: { instance = new NonExclusiveLevelAlarmState(null); break; }

            case EventTypeMapping.OffNormalAlarmType: { instance = new OffNormalAlarmState(null); break; }

            case EventTypeMapping.SystemEventType: { instance = new SystemEventState(null); break; }

            case EventTypeMapping.TripAlarmType: { instance = new TripAlarmState(null); break; }
            }

            return(instance);
        }
コード例 #2
0
        /// <summary>
        /// Updates the event types in cache with the most recent info fetched from the AE server.
        /// </summary>
        public void UpdateCache(ServerSystemContext context, ushort namespaceIndex)
        {
            // clear the existing nodes.
            EventTypeNodes = new NodeIdDictionary <BaseObjectTypeState>();
            Attributes     = new Dictionary <int, int[]>();
            TypeTable typeTable = context.TypeTable as TypeTable;

            // rebuild from the recently fetched list.
            for (int ii = 0; ii < EventTypes.Count; ii++)
            {
                // save the attributes for use when creating filters.
                if (EventTypes[ii].EventTypeMapping != EventTypeMapping.ConditionClassType && !Attributes.ContainsKey(EventTypes[ii].CategoryId))
                {
                    EventType eventType = EventTypes[ii];

                    int[] attributeIds = new int[eventType.Attributes.Count];

                    for (int jj = 0; jj < attributeIds.Length; jj++)
                    {
                        attributeIds[jj] = eventType.Attributes[jj].Id;
                    }

                    Attributes.Add(EventTypes[ii].CategoryId, attributeIds);
                }

                AeEventTypeState node = new AeEventTypeState(EventTypes[ii], namespaceIndex);

                BaseObjectTypeState mappingNode = null;

                if (!EventTypeNodes.TryGetValue(node.SuperTypeId, out mappingNode))
                {
                    mappingNode = new AeEventTypeMappingState(node.EventType.EventTypeMapping, namespaceIndex);
                    EventTypeNodes.Add(mappingNode.NodeId, mappingNode);

                    // ensure the mapping node is in the type table.
                    if (typeTable != null)
                    {
                        if (!typeTable.IsKnown(mappingNode.NodeId))
                        {
                            typeTable.AddSubtype(mappingNode.NodeId, mappingNode.SuperTypeId);
                        }
                    }
                }

                EventTypeNodes.Add(node.NodeId, node);

                // ensure the type node is in the type table.
                if (typeTable != null)
                {
                    if (!typeTable.IsKnown(node.NodeId))
                    {
                        typeTable.AddSubtype(node.NodeId, mappingNode.NodeId);
                    }
                }
            }
        }
コード例 #3
0
ファイル: AeTypeCache.cs プロジェクト: OPCFoundation/UA-.NET
        /// <summary>
        /// Updates the event types in cache with the most recent info fetched from the AE server.
        /// </summary>
        public void UpdateCache(ServerSystemContext context, ushort namespaceIndex)
        {
            // clear the existing nodes.
            EventTypeNodes = new NodeIdDictionary<BaseObjectTypeState>();
            Attributes = new Dictionary<int,int[]>();
            TypeTable typeTable = context.TypeTable as TypeTable;

            // rebuild from the recently fetched list.
            for (int ii = 0; ii < EventTypes.Count; ii++)
            {
                // save the attributes for use when creating filters.
                if (EventTypes[ii].EventTypeMapping != EventTypeMapping.ConditionClassType && !Attributes.ContainsKey(EventTypes[ii].CategoryId))
                {
                    EventType eventType = EventTypes[ii];

                    int[] attributeIds = new int[eventType.Attributes.Count];

                    for (int jj = 0; jj < attributeIds.Length; jj++)
                    {
                        attributeIds[jj] = eventType.Attributes[jj].Id;
                    }

                    Attributes.Add(EventTypes[ii].CategoryId, attributeIds);
                }

                AeEventTypeState node = new AeEventTypeState(EventTypes[ii], namespaceIndex);

                BaseObjectTypeState mappingNode = null;

                if (!EventTypeNodes.TryGetValue(node.SuperTypeId, out mappingNode))
                {
                    mappingNode = new AeEventTypeMappingState(node.EventType.EventTypeMapping, namespaceIndex);
                    EventTypeNodes.Add(mappingNode.NodeId, mappingNode);

                    // ensure the mapping node is in the type table.
                    if (typeTable != null)
                    {
                        if (!typeTable.IsKnown(mappingNode.NodeId))
                        {
                            typeTable.AddSubtype(mappingNode.NodeId, mappingNode.SuperTypeId);
                        }
                    }
                }

                EventTypeNodes.Add(node.NodeId, node);

                // ensure the type node is in the type table.
                if (typeTable != null)
                {
                    if (!typeTable.IsKnown(node.NodeId))
                    {
                        typeTable.AddSubtype(node.NodeId, mappingNode.NodeId);
                    }
                }
            }
        }
コード例 #4
0
ファイル: AeTypeCache.cs プロジェクト: OPCFoundation/UA-.NET
        /// <summary>
        /// Creates an instance of an event.
        /// </summary>
        public BaseEventState CreateInstance(ServerSystemContext context, AeEventTypeState eventType)
        {
            BaseEventState instance = null;

            switch (eventType.EventType.EventTypeMapping)
            {
                case EventTypeMapping.AlarmConditionType: { instance = new AlarmConditionState(null); break; }
                case EventTypeMapping.AuditEventType: { instance = new AuditEventState(null); break; }
                case EventTypeMapping.BaseEventType: { instance = new BaseEventState(null); break; }
                case EventTypeMapping.DeviceFailureEventType: { instance = new DeviceFailureEventState(null); break; }
                case EventTypeMapping.DiscreteAlarmType: { instance = new DiscreteAlarmState(null); break; }
                case EventTypeMapping.NonExclusiveDeviationAlarmType: { instance = new NonExclusiveDeviationAlarmState(null); break; }
                case EventTypeMapping.ExclusiveLevelAlarmType: { instance = new ExclusiveLevelAlarmState(null); break; }
                case EventTypeMapping.LimitAlarmType: { instance = new LimitAlarmState(null); break; }
                case EventTypeMapping.NonExclusiveLevelAlarmType: { instance = new NonExclusiveLevelAlarmState(null); break; }
                case EventTypeMapping.OffNormalAlarmType: { instance = new OffNormalAlarmState(null); break; }
                case EventTypeMapping.SystemEventType: { instance = new SystemEventState(null); break; }
                case EventTypeMapping.TripAlarmType: { instance = new TripAlarmState(null); break; }
            }

            return instance;
        }
コード例 #5
0
        /// <summary>
        /// Updates the condition event.
        /// </summary>
        private void UpdateAlarm(AlarmConditionState instance, EventType eventType, ONEVENTSTRUCT e)
        {
            instance.NodeId = AeParsedNodeId.ConstructIdForCondition(e.szSource, e.dwEventCategory, e.szConditionName, m_namespaceIndex);

            // find the condition class.
            NodeId           classId            = AeParsedNodeId.Construct(e.dwEventType, e.dwEventCategory, null, m_namespaceIndex);
            AeEventTypeState conditionClassType = m_cache.FindType(m_defaultContext, classId);

            if (conditionClassType != null)
            {
                instance.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.ConditionClassId, classId, false);
                instance.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.ConditionClassName, conditionClassType.EventType.Description, false);
            }
            else
            {
                instance.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.ConditionClassId, Opc.Ua.ObjectTypeIds.BaseConditionClassType, false);
                instance.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.ConditionClassName, "BaseConditionClass", false);
            }

            instance.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.ConditionName, e.szConditionName, false);;
            instance.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.ClientUserId, e.szActorID, false);
            instance.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.Quality, ComUtils.GetQualityCode(e.wQuality), false);

            bool acknowledged = (e.wNewState & Constants.CONDITION_ACKED) != 0;
            bool active       = (e.wNewState & Constants.CONDITION_ACTIVE) != 0;
            bool enabled      = (e.wNewState & Constants.CONDITION_ENABLED) != 0;
            bool retain       = enabled & (active || !acknowledged);

            LocalizedText effectiveDisplayName = ConditionStateNames.Inactive;

            if (!enabled)
            {
                effectiveDisplayName = ConditionStateNames.Disabled;
            }
            else if (!acknowledged)
            {
                effectiveDisplayName = ConditionStateNames.Unacknowledged;
            }
            else if (active)
            {
                effectiveDisplayName = ConditionStateNames.Active;
            }

            instance.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.Retain, true, false);

            instance.EnabledState            = new TwoStateVariableState(instance);
            instance.EnabledState.BrowseName = Opc.Ua.BrowseNames.EnabledState;
            instance.EnabledState.Value      = new LocalizedText((enabled) ? ConditionStateNames.Enabled : ConditionStateNames.Disabled);
            instance.EnabledState.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.Id, enabled, false);
            instance.EnabledState.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.EffectiveDisplayName, effectiveDisplayName, false);

            instance.AckedState            = new TwoStateVariableState(instance);
            instance.AckedState.BrowseName = Opc.Ua.BrowseNames.AckedState;
            instance.AckedState.Value      = new LocalizedText((acknowledged) ? ConditionStateNames.Acknowledged : ConditionStateNames.Unacknowledged);
            instance.AckedState.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.Id, acknowledged, false);

            instance.ActiveState            = new TwoStateVariableState(instance);
            instance.ActiveState.BrowseName = Opc.Ua.BrowseNames.ActiveState;
            instance.ActiveState.Value      = new LocalizedText((active) ? ConditionStateNames.Active : ConditionStateNames.Inactive);
            instance.ActiveState.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.Id, active, false);
            instance.ActiveState.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.TransitionTime, ComUtils.GetDateTime(e.ftActiveTime), false);

            if (!String.IsNullOrEmpty(e.szSubconditionName))
            {
                instance.ActiveState.SetChildValue(m_defaultContext, Opc.Ua.BrowseNames.EffectiveDisplayName, e.szSubconditionName, false);
            }
        }
コード例 #6
0
        /// <summary>
        /// Dispatches the event.
        /// </summary>
        private BaseEventState DispatchEvent(ONEVENTSTRUCT e)
        {
            NodeId typeId = AeParsedNodeId.Construct(e.dwEventType, e.dwEventCategory, e.szConditionName, m_namespaceIndex);

            // find the type.
            AeEventTypeState eventType = m_cache.FindType(m_defaultContext, typeId);

            if (eventType == null)
            {
                return(null);
            }

            // create a new instance.
            BaseEventState instance = m_cache.CreateInstance(m_defaultContext, eventType);

            if (instance == null)
            {
                return(null);
            }

            // fill in fields.
            UpdateBaseEvent(instance, eventType.EventType, e);

            if (instance is AuditEventState)
            {
                UpdateAuditEvent((AuditEventState)instance, eventType.EventType, e);
            }

            if (instance is AlarmConditionState)
            {
                UpdateAlarm((AlarmConditionState)instance, eventType.EventType, e);
            }

            if (instance is ExclusiveLimitAlarmState)
            {
                UpdateExclusiveLimitAlarm((ExclusiveLimitAlarmState)instance, eventType.EventType, e);
            }

            else if (instance is NonExclusiveLimitAlarmState)
            {
                UpdateNonExclusiveLimitAlarm((NonExclusiveLimitAlarmState)instance, eventType.EventType, e);
            }

            // process attributes.
            bool ackCommentFound = false;

            object[] values = ComUtils.GetVARIANTs(ref e.pEventAttributes, e.dwNumEventAttrs, false);

            for (int ii = 0; ii < eventType.EventType.Attributes.Count; ii++)
            {
                EventAttribute attribute = eventType.EventType.Attributes[ii];

                if (ii >= e.dwNumEventAttrs)
                {
                    continue;
                }

                if (!ackCommentFound && AeTypeCache.IsKnownName(attribute.Description, "ACK COMMENT"))
                {
                    ConditionState condition = instance as ConditionState;

                    if (condition != null)
                    {
                        condition.Comment            = new ConditionVariableState <LocalizedText>(condition);
                        condition.Comment.BrowseName = Opc.Ua.BrowseNames.Comment;
                        condition.Comment.Value      = new LocalizedText(values[ii] as string);
                    }

                    ackCommentFound = true;
                    continue;
                }

                PropertyState property = new PropertyState(instance);

                property.SymbolicName = attribute.Description;
                property.BrowseName   = new QualifiedName(property.SymbolicName, m_namespaceIndex);
                property.Value        = values[ii];

                instance.AddChild(property);
            }

            return(instance);
        }