本文整理汇总了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);
}
}
示例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))
{
}
示例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))
{
}
示例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))
{
}
示例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))
{
}