// This example shows how to write a value into a single node.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
#include "stdafx.h" // Includes "QuickOpc.h", and other commonly used files
#include "WriteValue.h"
namespace _EasyUAClient
{
void WriteValue::Main()
{
// Initialize the COM library
CoInitializeEx(NULL, COINIT_MULTITHREADED);
{
// Instantiate the client object
_EasyUAClientPtr ClientPtr(__uuidof(EasyUAClient));
// Perform the operation
ClientPtr->WriteValue(
//L"http://opcua.demo-this.com:51211/UA/SampleServer",
L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer",
L"nsu=http://test.org/UA/Data/ ;i=10221",
12345);
}
// Release all interface pointers BEFORE calling CoUninitialize()
CoUninitialize();
}
}
// This example shows how to write a value into a single node.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
class procedure WriteValue.Main;
var
Client: EasyUAClient;
begin
// Instantiate the client object
Client := CoEasyUAClient.Create;
// Perform the operation
Client.WriteValue(
//'http://opcua.demo-this.com:51211/UA/SampleServer',
'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer',
'nsu=http://test.org/UA/Data/ ;i=10221',
12345);
end;
// This example shows how to write a value into a single node.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
class procedure WriteValue.Main;
var
Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient;
begin
// Instantiate the client object
Client := CoEasyUAClient.Create;
// Perform the operation
try
Client.WriteValue(
//'http://opcua.demo-this.com:51211/UA/SampleServer',
//'https://opcua.demo-this.com:51212/UA/SampleServer/',
'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer',
'nsu=http://test.org/UA/Data/ ;i=10221',
12345);
except
on E: EOleException do
begin
WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
Exit;
end;
end;
end;
// This example shows how to write a value into a single node.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PHP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
// Instantiate the client object
$Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient");
// Perform the operation
try
{
$Client->WriteValue(
//"http://opcua.demo-this.com:51211/UA/SampleServer",
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer",
"nsu=http://test.org/UA/Data/ ;i=10221",
12345);
}
catch (com_exception $e)
{
printf("*** Failure: %s\n", $e->getMessage());
}
// This example shows how to write a value into a single node.
mle_outputtext.Text = ""
// Instantiate the client object
OLEObject client
client = CREATE OLEObject
client.ConnectToNewObject("OpcLabs.EasyOpc.UA.EasyUAClient")
// Modify value of a node
TRY
client.WriteValue("http://opcua.demo-this.com:51211/UA/SampleServer", "nsu=http://test.org/UA/Data/ ;i=10221", 12345)
CATCH (OLERuntimeError oleRuntimeError)
mle_outputtext.Text = mle_outputtext.Text + "*** Failure: " + oleRuntimeError.Description + "~r~n"
RETURN
END TRY
mle_outputtext.Text = mle_outputtext.Text + "~r~n"
mle_outputtext.Text = mle_outputtext.Text + "Finished." + "~r~n"
# This example shows how to write a value into a single node.
#
# The Python for Windows (pywin32) extensions package is needed. Install it using "pip install pypiwin32".
# CAUTION: We now recommend using Python.NET package instead. Full set of examples with Python.NET is available!
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
import win32com.client
from pywintypes import com_error
# Instantiate the client object
client = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.EasyUAClient')
# Perform the operation
try:
client.WriteValue(
'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer',
'nsu=http://test.org/UA/Data/ ;i=10221',
12345)
except com_error as e:
print('*** Failure: ' + e.args[2][1] + ': ' + e.args[2][2])
exit()
REM This example shows how to write a value into a single node.
REM
REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB .
REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
REM a commercial license in order to use Online Forums, and we reply to every post.
Public Sub WriteValue_Main_Command_Click()
OutputText = ""
' Instantiate the client object
Dim Client As New EasyUAClient
' Perform the operation
On Error Resume Next
Call Client.WriteValue("opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", "nsu=http://test.org/UA/Data/ ;i=10221", 12345)
If Err.Number <> 0 Then
OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf
Exit Sub
End If
On Error GoTo 0
End Sub
Rem This example shows how to write a value into a single node.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.
Option Explicit
' Instantiate the client object
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")
' Perform the operation
On Error Resume Next
Client.WriteValue "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", "nsu=http://test.org/UA/Data/ ;i=10221", 12345
If Err.Number <> 0 Then
WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
WScript.Quit
End If
On Error Goto 0
// This example shows how to write a value into a single node that is of type ByteString.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
#include "stdafx.h" // Includes "QuickOpc.h", and other commonly used files
#include <atlcom.h>
#include <atlsafe.h>
#include "WriteValue.h"
namespace _EasyUAClient
{
void WriteValue::ByteString()
{
// Initialize the COM library
CoInitializeEx(NULL, COINIT_MULTITHREADED);
{
// Instantiate the client object
_EasyUAClientPtr ClientPtr(__uuidof(EasyUAClient));
// Prepare the value to be written
CComSafeArray<BYTE> array(5);
array.SetAt(0, 11);
array.SetAt(1, 22);
array.SetAt(2, 33);
array.SetAt(3, 44);
array.SetAt(4, 55);
const CComVariant value(array);
// Perform the operation
ClientPtr->WriteValue(
//L"http://opcua.demo-this.com:51211/UA/SampleServer",
L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer",
L"nsu=http://test.org/UA/Data/ ;i=10230",
value);
}
// Release all interface pointers BEFORE calling CoUninitialize()
CoUninitialize();
}
}
// This example shows how to write a value into a single node that is of type ByteString.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
class procedure WriteValue.ByteString;
var
Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient;
Values: OleVariant;
begin
Values := VarArrayCreate([0, 4], varByte);
Values[0] := 11;
Values[1] := 22;
Values[2] := 33;
Values[3] := 44;
Values[4] := 55;
// Instantiate the client object
Client := CoEasyUAClient.Create;
// Modify value of a node
try
Client.WriteValue(
//'http://opcua.demo-this.com:51211/UA/SampleServer',
//'https://opcua.demo-this.com:51212/UA/SampleServer/',
'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer',
'nsu=http://test.org/UA/Data/ ;i=10230', Values);
except
on E: EOleException do
begin
WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
Exit;
end;
end;
VarClear(Values);
end;
// This example shows how to write a value into a single node that is of type ByteString.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PHP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
$Values[0] = 11;
$Values[1] = 22;
$Values[2] = 33;
$Values[3] = 44;
$Values[4] = 55;
// Instantiate the client object
$Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient");
// Modify value of a node
try
{
$Client->WriteValue(
//"http://opcua.demo-this.com:51211/UA/SampleServer",
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer",
"nsu=http://test.org/UA/Data/ ;i=10230",
$Values);
}
catch (com_exception $e)
{
printf("*** Failure: %s\n", $e->getMessage());
}