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


C# Session.Read方法代码示例

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


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

示例1: Read

        /// <summary>
        /// Reads the values for a set of variables.
        /// </summary>
        static void Read(Session session)
        {
            IList<NodeOfInterest> results = GetNodeIds(session, Opc.Ua.Objects.ObjectsFolder,
                VariableBrowsePaths.ToArray());
            // build list of nodes to read.
            ReadValueIdCollection nodesToRead = new ReadValueIdCollection();

            for (int ii = 0; ii < results.Count; ii++)
            {
                ReadValueId nodeToRead = new ReadValueId();

                nodeToRead.NodeId = results[ii].NodeId;
                nodeToRead.AttributeId = Attributes.Value;
                
                nodesToRead.Add(nodeToRead);
            }

            // read values.
            DataValueCollection values;
            DiagnosticInfoCollection diagnosticInfos;

            ResponseHeader responseHeader = session.Read(
                null,
                0,
                TimestampsToReturn.Both,
                nodesToRead,
                out values,
                out diagnosticInfos);

            // verify that the server returned the correct number of results.
            Session.ValidateResponse(values, nodesToRead);
            Session.ValidateDiagnosticInfos(diagnosticInfos, nodesToRead);
                          
            // process results.
            for (int ii = 0; ii < values.Count; ii++)
            {

                // check for error.
                if (StatusCode.IsBad(values[ii].StatusCode))
                {
                    ServiceResult result = Session.GetResult(values[ii].StatusCode, ii, diagnosticInfos, responseHeader);
                    Console.WriteLine("Read result for {0}: {1}", VariableBrowsePaths[ii], result.ToLongString());
                    continue;
                }
                
                // write value.
                Console.WriteLine( "{0}: V={1}, Q={2}, SrvT={3}, SrcT={4}",nodesToRead[ii].NodeId, values[ii].Value.ToString(),
                    values[ii].StatusCode.ToString(), values[ii].ServerTimestamp, values[ii].SourceTimestamp);
            }
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:53,代码来源:Program.cs

示例2: ProcessDefinitionAssociation

 /// <summary>
 /// Initializes a new instance of the <see cref="ProcessDefinitionAssociation"/> class.
 /// </summary>
 /// <param name="session"><see cref="T:TcmCoreService.Session" /></param>
 /// <param name="uri"><see cref="T:TcmCoreService.Misc.TcmUri" /></param>
 internal ProcessDefinitionAssociation(Session session, TcmUri uri)
     : this(session, session.Read<ProcessDefinitionAssociationData>(uri))
 {
 }
开发者ID:TcmExtensions,项目名称:TcmCoreService,代码行数:9,代码来源:ProcessDefinitionAssociation.cs

示例3: BluePrintNode

 /// <summary>
 /// Initializes a new instance of the <see cref="BluePrintNode"/> class.
 /// </summary>
 /// <param name="session"><see cref="T:TcmCoreService.Session" /></param>
 /// <param name="uri"><see cref="T:TcmCoreService.Misc.TcmUri" /></param>
 internal BluePrintNode(Session session, TcmUri uri)
     : this(session, session.Read<BluePrintNodeData>(uri))
 {
 }
开发者ID:TcmExtensions,项目名称:TcmCoreService,代码行数:9,代码来源:BluePrintNode.cs

示例4: VersionedItem

 /// <summary>
 /// Initializes a new instance of the <see cref="VersionedItem" /> class.
 /// </summary>
 /// <param name="session"><see cref="T:TcmCoreService.Session" /></param>
 /// <param name="uri"><see cref="T:TcmCoreService.Misc.TcmUri" /></param>
 internal VersionedItem(Session session, TcmUri uri)
     : this(session, session.Read<VersionedItemData>(uri))
 {
 }
开发者ID:TcmExtensions,项目名称:TcmCoreService,代码行数:9,代码来源:VersionedItem.cs

示例5: WorkflowObject

 /// <summary>
 /// Initializes a new instance of the <see cref="WorkflowObject"/> class.
 /// </summary>
 /// <param name="session"><see cref="T:TcmCoreService.Session" /></param>
 /// <param name="uri"><see cref="T:TcmCoreService.Misc.TcmUri" /></param>
 internal WorkflowObject(Session session, TcmUri uri)
     : this(session, session.Read<WorkflowObjectData>(uri))
 {
 }
开发者ID:TcmExtensions,项目名称:TcmCoreService,代码行数:9,代码来源:WorkflowObject.cs


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