// This example shows how to write a value into a single node, specifying a type code 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 reports is incorrect.
// - Writing with an explicitly specified type is more efficient.
//
// TypeCode is easy to use, but it does not cover all possible types. It is also possible to specify the .NET Type, using
// a different overload of the WriteValue method.
//
// 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 TypeCode()
{
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();
Console.WriteLine("Modifying value of a node...");
try
{
client.WriteValue(
endpointDescriptor,
"nsu=http://test.org/UA/Data/ ;i=10221",
12345,
System.TypeCode.Int32);
}
catch (UAException uaException)
{
Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}");
return;
}
Console.WriteLine("Finished.");
}
}
}
# This example shows how to write a value into a single node, specifying a type code 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 reports is incorrect.
# - Writing with an explicitly specified type is more efficient.
#
# TypeCode is easy to use, but it does not cover all possible types. It is also possible to specify the .NET Type, using
# a different overload of the WriteValue method.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
#requires -Version 5.1
using namespace OpcLabs.EasyOpc.UA
using namespace OpcLabs.EasyOpc.UA.OperationModel
# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUA.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUAComponents.dll"
[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.
$client = New-Object EasyUAClient
Write-Host "Modifying value of a node..."
try {
[IEasyUAClientExtension]::WriteValue($client,
$endpointDescriptor,
"nsu=http://test.org/UA/Data/ ;i=10221",
12345,
[System.TypeCode]::Int32)
}
catch [UAException] {
Write-Host "*** Failure: $($PSItem.Exception.GetBaseException().Message)"
return
}
Write-Host "Finished."
# This example shows how to write a value into a single node, specifying a type code 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 reports is incorrect.
# - Writing with an explicitly specified type is more efficient.
#
# TypeCode is easy to use, but it does not cover all possible types. It is also possible to specify the .NET Type, using
# a different overload of the WriteValue method.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc
# Import .NET namespaces.
from System import *
from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.OperationModel import *
endpointDescriptor = 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.
client = EasyUAClient()
print('Modifying value of a node...')
try:
IEasyUAClientExtension.WriteValue(client,
endpointDescriptor,
UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10221'),
12345,
TypeCode.Int32)
except UAException as uaException:
print('*** Failure: ' + uaException.GetBaseException().Message)
exit()
print('Finished.')
' This example shows how to write a value into a single node, specifying a type code 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 reports is incorrect.
' - Writing with an explicitly specified type is more efficient.
'
' TypeCode is easy to use, but it does not cover all possible types. It is also possible to specify the .NET Type, using
' a different overload of the WriteValue method.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.OperationModel
Namespace _EasyUAClient
Partial Friend Class WriteValue
Public Shared Sub TypeCode()
' 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, _
System.TypeCode.Int32)
Catch uaException As UAException
Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message)
Exit Sub
End Try
End Sub
End Class
End Namespace