// This example shows how to write a value into a single node, specifying a type explicitly.
//
// Reasons for specifying the type explicitly might be:
// - The data type in the server has subtypes, and the client therefore needs to pick the subtype to be written.
// - The data type that the server reports is incorrect.
// - Writing with an explicitly specified type is more efficient.
//
// For a selected subset of most common types, you can also use a different overload of the WriteValue method, and specify
// a value from the TypeCode enumeration instead.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.OperationModel;
namespace UADocExamples._EasyUAClient
{
partial class WriteValue
{
public static void Type()
{
UAEndpointDescriptor endpointDescriptor =
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
// or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
// or "https://opcua.demo-this.com:51212/UA/SampleServer/"
// Instantiate the client object
var client = new EasyUAClient();
// Modify value of a node
try
{
client.WriteValue(
endpointDescriptor,
"nsu=http://test.org/UA/Data/ ;i=10221",
12345,
typeof(Int32));
}
catch (UAException uaException)
{
Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message);
}
}
}
}
' This example shows how to write a value into a single node, specifying a type explicitly.
'
' Reasons for specifying the type explicitly might be:
' - The data type in the server has subtypes, and the client therefore needs to pick the subtype to be written.
' - The data type that the server reports is incorrect.
' - Writing with an explicitly specified type is more efficient.
'
' For a selected subset of most common types, you can also use a different overload of the WriteValue method, and specify
' a value from the TypeCode enumeration instead.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Imports System
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.OperationModel
Namespace _EasyUAClient
Partial Friend Class WriteValue
Public Shared Sub Type()
' Define which server we will work with.
Dim endpointDescriptor As UAEndpointDescriptor =
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
' or "https://opcua.demo-this.com:51212/UA/SampleServer/"
' Instantiate the client object
Dim client = New EasyUAClient()
' Modify value of a node
Try
client.WriteValue( _
endpointDescriptor, _
"nsu=http://test.org/UA/Data/ ;i=10221", _
12345, _
GetType(Int32))
Catch uaException As UAException
Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message)
Exit Sub
End Try
End Sub
End Class
End Namespace