Stores the metadata for an AE event attribute.
コード例 #1
0
        /// <summary>
        /// Fetches the attributes for the category from the AE server.
        /// </summary>
        private List <EventAttribute> LoadEventAttributes(ComAeClient client, int eventTypeId, int categoryId)
        {
            List <EventAttribute> attributes = new List <EventAttribute>();

            int[]    ids          = null;
            string[] descriptions = null;
            short[]  dataTypes    = null;

            try
            {
                client.GetEventAttributes(categoryId, out ids, out descriptions, out dataTypes);
            }
            catch (Exception e)
            {
                Utils.Trace(e, "Unexpected error fetching event attributes.");
                ids = null;
            }

            if (ids != null)
            {
                for (int ii = 0; ii < ids.Length; ii++)
                {
                    EventAttribute attribute = new EventAttribute();
                    attribute.Id          = ids[ii];
                    attribute.Description = descriptions[ii];
                    attribute.VarType     = dataTypes[ii];
                    attributes.Add(attribute);
                }
            }

            return(attributes);
        }
コード例 #2
0
ファイル: AeTypeCache.cs プロジェクト: OPCFoundation/UA-.NET
        /// <summary>
        /// Fetches the attributes for the category from the AE server.
        /// </summary>
        private List<EventAttribute> LoadEventAttributes(ComAeClient client, int eventTypeId, int categoryId)
        {
            List<EventAttribute> attributes = new List<EventAttribute>();

            int[] ids = null;
            string[] descriptions = null;
            short[] dataTypes = null;

            try
            {
                client.GetEventAttributes(categoryId, out ids, out descriptions, out dataTypes);
            }
            catch (Exception e)
            {
                Utils.Trace(e, "Unexpected error fetching event attributes.");
                ids = null;
            }

            if (ids != null)
            {
                for (int ii = 0; ii < ids.Length; ii++)
                {
                    EventAttribute attribute = new EventAttribute();
                    attribute.Id = ids[ii];
                    attribute.Description = descriptions[ii];
                    attribute.VarType = dataTypes[ii];
                    attributes.Add(attribute);
                }
            }

            return attributes;
        }
コード例 #3
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);
        }