当前位置: 首页>>代码示例>>C#>>正文


C# MonitoredItem.GetEventType方法代码示例

本文整理汇总了C#中Opc.Ua.Client.MonitoredItem.GetEventType方法的典型用法代码示例。如果您正苦于以下问题:C# MonitoredItem.GetEventType方法的具体用法?C# MonitoredItem.GetEventType怎么用?C# MonitoredItem.GetEventType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Opc.Ua.Client.MonitoredItem的用法示例。


在下文中一共展示了MonitoredItem.GetEventType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddressSpaceChange_Notification

        /// <summary>
        /// Processes a Publish response from the UA server for AddressSpace changes.
        /// </summary>
        /// <param name="monitoredItem"></param>
        /// <param name="e"></param>
        void AddressSpaceChange_Notification(MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs e)
        {
            try
            {
                EventFieldList eventFields = e.NotificationValue as EventFieldList;

                if (eventFields == null)
                {
                    return;
                }
                if (monitoredItem != null)
                {
                    if (monitoredItem.ClientHandle != eventFields.ClientHandle)
                    {
                        return;
                    }
                }
                INode eventUA = monitoredItem.GetEventType(eventFields);
                if (eventUA.NodeId == new NodeId(Opc.Ua.ObjectTypes.BaseModelChangeEventType))
                {
                    //TODO:if we get this event we know a change was made, but we do not know what so we will beed to get all EventTypes and compare and update our config data
                }
                else if (eventUA.NodeId != new NodeId(Opc.Ua.ObjectTypes.GeneralModelChangeEventType))
                {
                    //We are not interested in any other event, so we will return.
                    //If we can set the where clause on the filter for this item, this else clause can be removed.
                    return;
                }
                else
                {
                    object v = monitoredItem.GetFieldValue(eventFields, Opc.Ua.ObjectTypes.GeneralModelChangeEventType, new QualifiedName(Opc.Ua.BrowseNames.Changes));

                    //ChangeStructureDataTypeCollection changes = (ChangeStructureDataTypeCollection) monitoredItem.GetFieldValue(eventFields, ObjectTypes.GeneralModelChangeEventType, new QualifiedName(GeneralModelChangeEvent.Names.Changes));



                }

            }
            catch (Exception ex)
            {
                Utils.Trace(ex, "Unexpected error in AddressSpaceChange_Notification");
            }
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:49,代码来源:ComAeProxy.cs

示例2: MonitoredItem_Notification

        /// <summary>
        /// Processes a Publish response from the UA server.
        /// </summary>
        /// <param name="monitoredItem"></param>
        /// <param name="e"></param>
        void MonitoredItem_Notification(MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs e)
        {
            try
            {
                EventFieldList eventFields = e.NotificationValue as EventFieldList;

                if (eventFields == null)
                {
                    return;
                }
                if (monitoredItem != null)
                {
                    if (monitoredItem.ClientHandle != eventFields.ClientHandle)
                    {
                        return;
                    }
                }
                INode eventUA = monitoredItem.GetEventType(eventFields);
                EventCategory cat = FindEventCatInfo(eventUA.BrowseName.ToString());

                if (cat == null) return; // The event is not of a category that we recognize.
           
                if (cat.EventType == OpcRcw.Ae.Constants.CONDITION_EVENT)
                {
                    NodeId branchId = monitoredItem.GetFieldValue(eventFields, Opc.Ua.ObjectTypes.ConditionType, Opc.Ua.BrowseNames.BranchId) as NodeId;
                    if (!NodeId.IsNull(branchId)) return; // We don't support condition branches in the COM Proxy
                }

                EventNotification ev = new EventNotification();

                ev.EventId = monitoredItem.GetFieldValue(eventFields, Opc.Ua.ObjectTypes.BaseEventType, new QualifiedName(Opc.Ua.BrowseNames.EventId)) as byte[];
                ev.SourceID = System.Convert.ToString(monitoredItem.GetFieldValue(eventFields, Opc.Ua.ObjectTypes.BaseEventType, new QualifiedName(Opc.Ua.BrowseNames.SourceName)));
                ev.Time = System.Convert.ToDateTime(monitoredItem.GetFieldValue(eventFields, Opc.Ua.ObjectTypes.BaseEventType, new QualifiedName(Opc.Ua.BrowseNames.Time)));
                ev.Message = System.Convert.ToString(monitoredItem.GetFieldValue(eventFields, Opc.Ua.ObjectTypes.BaseEventType, new QualifiedName(Opc.Ua.BrowseNames.Message)));
                ev.EventType = cat.EventType;
                ev.EventCategory = cat.CategoryID;
                ev.Severity = System.Convert.ToInt32(monitoredItem.GetFieldValue(eventFields, Opc.Ua.ObjectTypes.BaseEventType, new QualifiedName(Opc.Ua.BrowseNames.Severity)));

                List<EventAttribute> Attrs = GetEventAttributes(cat.CategoryID);
                UniqueList<string> strEventNodeIds = new UniqueList<string>();
                foreach (EventAttribute attr in Attrs)
                    if (attr.strEventNodeId != "")
                        strEventNodeIds.AddUnique(attr.strEventNodeId);

                ev.EventAttributes = new Dictionary<int, object>();
                foreach (EventAttribute attr in m_configFile.Attributes)
                {
                    foreach (string strEventNodeId in strEventNodeIds)
                    {
                        if (attr.strEventNodeId == strEventNodeId)
                        {
                            object value = monitoredItem.GetFieldValue(eventFields, (NodeId)attr.strEventNodeId, new QualifiedName(attr.BrowseName, attr.BrowseNameNSIndex));
                            if (value == null)
                            {
                                ev.EventAttributes.Add(attr.AttributeID, "");
                            }
                            else if ((value.GetType() != null) & (short)ComUtils.GetVarType(value) != 0)
                            {
                                ev.EventAttributes.Add(attr.AttributeID, value);
                            }
                            else
                            {
                                // any value with a UA type that does not have a corresponding COM type will be returned as a string 
                                ev.EventAttributes.Add(attr.AttributeID, value.ToString());
                            }
                        }
                    }
                }

                //Condition-Related Event properties
                ev.ConditionName = "";
                ev.SubConditionName = "";
                ev.ChangeMask = 0;
                ev.NewState = OpcRcw.Ae.Constants.CONDITION_ENABLED | OpcRcw.Ae.Constants.CONDITION_ACKED;
                ev.Quality = OpcRcw.Da.Qualities.OPC_QUALITY_GOOD;
                ev.AckRequired = false;
                ev.ActiveTime = DateTime.Now;
                ev.Cookie = 0;

                if (ev.EventType == OpcRcw.Ae.Constants.CONDITION_EVENT)
                    SetConditionEventFields(monitoredItem, eventFields, ev, cat);

                //Tracking Events and for Condition-Related Events which are acknowledgment notifications
                if (cat.EventType == OpcRcw.Ae.Constants.TRACKING_EVENT)
                    ev.ActorID = System.Convert.ToString(monitoredItem.GetFieldValue(eventFields, (NodeId)eventUA.NodeId, new QualifiedName(Opc.Ua.BrowseNames.ClientUserId)));

                IncomingEventHandler eventHandler = new IncomingEventHandler();
                
                //extract the area associated with this event.
                AreaNode areaNode;
                string[] areas = null;
                if (m_notifiers.TryGetValue(monitoredItem.ClientHandle, out areaNode))
                {
                    areas = new string[] { areaNode.AreaName };
                }
//.........这里部分代码省略.........
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:101,代码来源:ComAeProxy.cs


注:本文中的Opc.Ua.Client.MonitoredItem.GetEventType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。