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


C# Session.ReadValue方法代码示例

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


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

示例1: Server_ConnectComplete

        /// <summary>
        /// Updates the application after connecting to or disconnecting from the server.
        /// </summary>
        private void Server_ConnectComplete(object sender, EventArgs e)
        {
            try
            {
                m_session = ConnectServerCTRL.Session;

                if (m_session == null)
                {
                    return;
                }

                // set a suitable initial state.
                if (m_session != null && !m_connectedOnce)
                {
                    m_connectedOnce = true;

                    EventsLV.IsSubscribed = false;
                    EventsLV.DisplayConditions = true;
                    EventsLV.ChangeArea(Opc.Ua.ObjectIds.Server, false);

                    FilterDeclaration filter = new FilterDeclaration();

                    ushort namespaceIndex = (ushort)m_session.NamespaceUris.GetIndex(DsatsDemo.Namespaces.DsatsDemo);

                    filter.EventTypeId = ExpandedNodeId.ToNodeId(DsatsDemo.ObjectTypeIds.LockConditionType, m_session.NamespaceUris);

                    filter.AddSimpleField(String.Empty, BuiltInType.NodeId, false);
                    filter.AddSimpleField(Opc.Ua.BrowseNames.EventId, BuiltInType.ByteString, false);
                    filter.AddSimpleField(Opc.Ua.BrowseNames.EventType, BuiltInType.NodeId, false);
                    filter.AddSimpleField(Opc.Ua.BrowseNames.ConditionName, BuiltInType.String, true);
       
                    filter.AddSimpleField(new QualifiedName[] { 
                        new QualifiedName(DsatsDemo.BrowseNames.LockState, namespaceIndex),
                        new QualifiedName(Opc.Ua.BrowseNames.CurrentState) },
                        BuiltInType.String,
                        ValueRanks.Scalar,
                        true);

                    filter.AddSimpleField(new QualifiedName(DsatsDemo.BrowseNames.ClientUserId, namespaceIndex), BuiltInType.String, true);
                    filter.AddSimpleField(new QualifiedName(DsatsDemo.BrowseNames.SubjectName, namespaceIndex), BuiltInType.String, true);
                    filter.AddSimpleField(new QualifiedName(DsatsDemo.BrowseNames.SessionId, namespaceIndex), BuiltInType.NodeId, true);

                    EventsLV.ChangeFilter(filter, true);
                    
                    m_filter = filter;

                    PhaseCB.Items.Clear();

                    BrowseDescription nodeToBrowse = new BrowseDescription();
                    nodeToBrowse.NodeId = new NodeId(DsatsDemo.Objects.Rig_Phases, namespaceIndex);
                    nodeToBrowse.ReferenceTypeId = Opc.Ua.ReferenceTypeIds.HierarchicalReferences;
                    nodeToBrowse.IncludeSubtypes = true;
                    nodeToBrowse.BrowseDirection = BrowseDirection.Forward;
                    nodeToBrowse.ResultMask = (uint)BrowseResultMask.All;

                    DataValue value = m_session.ReadValue(new NodeId(DsatsDemo.Variables.Rig_CurrentPhase, namespaceIndex));
                    NodeId currentPhase = value.GetValue<NodeId>(null);

                    ReferenceDescriptionCollection references = ClientUtils.Browse(m_session, nodeToBrowse, false);

                    if (references != null)
                    {
                        for (int ii = 0; ii < references.Count; ii++)
                        {
                            PhaseCB.Items.Add(references[ii]);

                            if (currentPhase == references[ii].NodeId)
                            {
                                PhaseCB.SelectedIndex = ii;
                            }
                        }
                    }

                    m_connectedOnce = true;
                }

                EventsLV.IsSubscribed = true;
                EventsLV.ChangeSession(m_session, true);
                EventsLV.ConditionRefresh();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:88,代码来源:MainForm.cs

示例2: ShowDialog

        /// <summary>
        /// Displays the available areas in a tree view.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <returns></returns>
        public string ShowDialog(Session session)
        {
            m_session = session;

            LocaleCB.Items.Clear();

            // get the locales from the server.
            DataValue value = m_session.ReadValue(VariableIds.Server_ServerCapabilities_LocaleIdArray);

            if (value != null)
            {
                string[] availableLocales = value.GetValue<string[]>(null);

                if (availableLocales != null)
                {
                    for (int ii = 0; ii < availableLocales.Length; ii++)
                    {
                        LocaleCB.Items.Add(availableLocales[ii]);
                    }
                }
            }

            // select the current locale.
            if (LocaleCB.Items.Count > 0)
            {
                LocaleCB.SelectedIndex = 0;
            }

            // display the dialog.
            if (ShowDialog() != DialogResult.OK)
            {
                return null;
            }

            return LocaleCB.SelectedItem as string;
        }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:41,代码来源:SelectLocaleDlg.cs

示例3: Update

        /// <summary>
        /// Sets the nodes in the control.
        /// </summary>
        public bool Update(Session session, NodeId methodId, bool inputArgs)
        {
            if (session == null)  throw new ArgumentNullException("session");
            if (methodId == null) throw new ArgumentNullException("methodId");
            
            Clear();
            
            m_session = session;

            // find the method.
            MethodNode method = session.NodeCache.Find(methodId) as MethodNode;

            if (method == null)
            {
                return false;
            }

            // select the property to find.
            QualifiedName browseName = null;
                    
            if (inputArgs)
            {
                browseName = Opc.Ua.BrowseNames.InputArguments;
            }
            else
            {
                browseName = Opc.Ua.BrowseNames.OutputArguments;
            }

            // fetch the argument list.
            VariableNode argumentsNode = session.NodeCache.Find(methodId, ReferenceTypeIds.HasProperty, false, true, browseName) as VariableNode;

            if (argumentsNode == null)
            {
                return false;
            }

            // read the value from the server.
            DataValue value = m_session.ReadValue(argumentsNode.NodeId);

            ExtensionObject[] argumentsList = value.Value as ExtensionObject[];

            if (argumentsList != null)
            {
                for (int ii = 0; ii < argumentsList.Length; ii++)
                {
                    AddItem(argumentsList[ii].Body as Argument);
                }
            }

            AdjustColumns();

            return ItemsLV.Items.Count > 0;
        }        
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:57,代码来源:ArgumentListCtrl.cs


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