本文整理匯總了C#中Opc.Ua.Client.Session.Write方法的典型用法代碼示例。如果您正苦於以下問題:C# Session.Write方法的具體用法?C# Session.Write怎麽用?C# Session.Write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Opc.Ua.Client.Session
的用法示例。
在下文中一共展示了Session.Write方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: WriteValue
/// <summary>
/// Writes the value
/// </summary>
private Variant WriteValue(Session session, NodeId nodeId)
{
// cast the value to a string.
object value = TypeInfo.Cast(ValueTB.Text, TypeInfo.Scalars.String, m_sourceType.BuiltInType);
// build list of attributes to read.
WriteValueCollection nodesToWrite = new WriteValueCollection();
WriteValue nodeToWrite = new WriteValue();
nodeToWrite.NodeId = nodeId;
nodeToWrite.AttributeId = Attributes.Value;
// using the WrappedValue instead of the Value property because we know the TypeInfo.
// this makes the assignment more efficient by avoiding reflection to determine type.
nodeToWrite.Value.WrappedValue = new Variant(value, m_sourceType);
nodesToWrite.Add(nodeToWrite);
// override the diagnostic masks (other parameters are set to defaults).
RequestHeader requestHeader = new RequestHeader();
requestHeader.ReturnDiagnostics = (uint)DiagnosticsMasks.All;
// read the attributes.
StatusCodeCollection results = null;
DiagnosticInfoCollection diagnosticInfos = null;
ResponseHeader responseHeader = session.Write(
requestHeader,
nodesToWrite,
out results,
out diagnosticInfos);
ClientBase.ValidateResponse(results, nodesToWrite);
ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToWrite);
// check status.
if (StatusCode.IsBad(results[0]))
{
// embed the diagnostic information in a exception.
throw ServiceResultException.Create(results[0], 0, diagnosticInfos, responseHeader.StringTable);
}
// return valid value.
return nodeToWrite.Value.WrappedValue;
}