// 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 . using System; using OpcLabs.EasyOpc.UA; using OpcLabs.EasyOpc.UA.OperationModel; namespace UADocExamples._EasyUAClient { partial class WriteValue { public static void Main1() { 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); } 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. # # 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 { $client.WriteValue($endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10221", 12345) } 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. # # 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 OpcLabs.EasyOpc.UA import * from OpcLabs.EasyOpc.UA.OperationModel import * # Instantiate the client object. client = EasyUAClient() # Perform the operation. try: IEasyUAClientExtension.WriteValue(client, UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer'), UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10221'), 12345) except UAException as uaException: print('*** Failure: ' + uaException.GetBaseException().Message) exit() print('Finished.')
' 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 . Imports OpcLabs.EasyOpc.UA Imports OpcLabs.EasyOpc.UA.OperationModel Namespace _EasyUAClient Partial Friend Class WriteValue Public Shared Sub Main1() ' 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) Catch uaException As UAException Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message) Exit Sub End Try End Sub End Class End Namespace
// 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 . #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 . 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 . 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 . // 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 . 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 . 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 an ever-incrementing value to an OPC UA variable. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . using System; using System.Threading; using OpcLabs.EasyOpc.UA; using OpcLabs.EasyOpc.UA.AddressSpace; using OpcLabs.EasyOpc.UA.OperationModel; namespace UADocExamples._EasyUAClient { partial class WriteValue { public static void Incrementing() { 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/" UANodeId nodeId = "nsu=http://test.org/UA/Data/ ;i=10221"; // Example settings with Softing dataFEED OPC Suite: //UAEndpointDescriptor endpointDescriptor = // "opc.tcp://localhost:4980/Softing_dataFEED_OPC_Suite_Configuration1"; //UANodeId nodeId = "nsu=Local%20Items ;s=Local Items.EAK_Test1.EAK_Testwert1_I4"; // Instantiate the client object var client = new EasyUAClient(); // int i = 0; do { Console.WriteLine($"@{DateTime.Now}: Writing {i}"); try { client.WriteValue(endpointDescriptor, nodeId, i); } catch (UAException uaException) { Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message); return; } i = unchecked((i + 1) & 0x7FFFFFFF); Thread.Sleep(2 * 1000); } while (!Console.KeyAvailable); } } }
' This example shows how to write an ever-incrementing value to an OPC UA variable. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Imports System.Threading Imports Opc.Ua Imports OpcLabs.EasyOpc.UA Imports OpcLabs.EasyOpc.UA.AddressSpace Imports OpcLabs.EasyOpc.UA.OperationModel Namespace _EasyUAClient Partial Friend Class WriteValue Public Shared Sub Incrementing() ' 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/" Dim nodeId As UANodeId = "nsu=http://test.org/UA/Data/ ;i=10221" ' Example settings with Softing dataFEED OPC Suite: 'Dim endpointDescriptor As UAEndpointDescriptor = ' "opc.tcp://localhost:4980/Softing_dataFEED_OPC_Suite_Configuration1" 'Dim nodeId As UANodeId = "nsu=Local%20Items ;s=Local Items.EAK_Test1.EAK_Testwert1_I4" ' Instantiate the client object Dim client = New EasyUAClient() ' Dim i As Integer = 0 Do Console.WriteLine($"@{DateTime.Now}: Writing {i}") Try client.WriteValue(endpointDescriptor, nodeId, i) Catch uaException As UAException Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message) Exit Sub End Try i = CInt((CLng(i) + 1) And &H7FFFFFFF) Thread.Sleep(2 * 1000) Loop Until Console.KeyAvailable End Sub End Class End Namespace
Rem This example shows how to write an ever-incrementing value to an OPC UA variable. Rem Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Option Explicit Const endpointDescriptorUrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" Const nodeIdExpandedText = "nsu=http://test.org/UA/Data/ ;i=10221" ' Example settings with Softing dataFEED OPC Suite: 'Const endpointDescriptorUrlString = "opc.tcp://localhost:4980/Softing_dataFEED_OPC_Suite_Configuration1" 'Const nodeIdExpandedText = "nsu=Local%20Items ;s=Local Items.EAK_Test1.EAK_Testwert1_I4" ' Instantiate the client object Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient") ' Dim i: i = 0 Do While True WScript.Echo "@" & Time & ": Writing " & i On Error Resume Next Client.WriteValue endpointDescriptorUrlString, nodeIdExpandedText, i If Err.Number <> 0 Then WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description WScript.Quit End If On Error Goto 0 i = (i + 1) And &H7FFFFFFF WScript.Sleep 2*1000 Loop
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved. Web page: www.opclabs.com
Send Documentation Feedback. Resources: Knowledge Base, Product Downloads. Technical support: Online Forums, FAQ.Missing some example? Ask us for it on our Online Forums! You do not have to own a commercial license in order to use Online Forums, and we reply to every post.