The example below shows how to get OPC UA file properties (such as its size or writable status), using the file transfer client.
// Shows how to get OPC UA file properties (such as its size or writable status), using the file transfer client. // Note: Consider using a higher-level abstraction, OPC UA file provider, instead. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // 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. using System; using OpcLabs.EasyOpc.UA; using OpcLabs.EasyOpc.UA.FileTransfer; using OpcLabs.EasyOpc.UA.OperationModel; namespace UADocExamples.FileTransfer._EasyUAFileTransferClient { class GetFileProperties { public static void Main1() { // Unified Automation .NET based demo server (UaNETServer/UaServerNET.exe) UAEndpointDescriptor endpointDescriptor = "opc.tcp://localhost:48030"; // A node that represents an instance of OPC UA FileType object. UANodeDescriptor fileNodeDescriptor = "nsu=http://www.unifiedautomation.com/DemoServer/ ;s=Demo.Files.TextFile"; // Instantiate the file transfer client object var fileTransferClient = new EasyUAFileTransferClient(); // Get properties of a specified file. UAFileProperties fileProperties; Console.WriteLine("Getting file properties..."); try { fileProperties = fileTransferClient.GetFileProperties(endpointDescriptor, fileNodeDescriptor); } catch (UAException uaException) { Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message); return; } // Display result Console.WriteLine(); Console.WriteLine($"MimeType: {fileProperties.MimeType}"); Console.WriteLine($"OpenCount: {fileProperties.OpenCount}"); Console.WriteLine($"Size: {fileProperties.Size}"); Console.WriteLine($"UserWritable: {fileProperties.UserWritable}"); Console.WriteLine($"Writable: {fileProperties.Writable}"); Console.WriteLine($"Timestamp: {fileProperties.Timestamp}"); Console.WriteLine(); Console.WriteLine("Finished..."); } } }
' Shows how to get OPC UA file properties (such as its size or writable status), using the file transfer client. ' Note: Consider using a higher-level abstraction, OPC UA file provider, instead. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' 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. Imports OpcLabs.EasyOpc.UA Imports OpcLabs.EasyOpc.UA.FileTransfer Imports OpcLabs.EasyOpc.UA.OperationModel Namespace FileTransfer._EasyUAFileTransferClient Friend Class GetFileProperties Public Shared Sub Main1() ' Unified Automation .NET based demo server (UaNETServer/UaServerNET.exe) Dim endpointDescriptor As UAEndpointDescriptor = "opc.tcp://localhost:48030" ' A node that represents an instance of OPC UA FileType object. Dim fileNodeDescriptor As UANodeDescriptor = "nsu=http://www.unifiedautomation.com/DemoServer/ ;s=Demo.Files.TextFile" ' Instantiate the file transfer client object Dim fileTransferClient = New EasyUAFileTransferClient ' Get properties of a specified file. Dim fileProperties As UAFileProperties Console.WriteLine("Getting file properties...") Try fileProperties = fileTransferClient.GetFileProperties(endpointDescriptor, fileNodeDescriptor) Catch uaException As UAException Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message) Exit Sub End Try ' Display result Console.WriteLine() Console.WriteLine($"MimeType: {fileProperties.MimeType}") Console.WriteLine($"OpenCount: {fileProperties.OpenCount}") Console.WriteLine($"Size: {fileProperties.Size}") Console.WriteLine($"UserWritable: {fileProperties.UserWritable}") Console.WriteLine($"Writable: {fileProperties.Writable}") Console.WriteLine($"Timestamp: {fileProperties.Timestamp}") Console.WriteLine() Console.WriteLine("Finished...") End Sub End Class End Namespace
# Shows how to get OPC UA file properties (such as its size or writable status), using the file transfer client. # Note: Consider using a higher-level abstraction, OPC UA file provider, instead. # # 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 . # 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. # 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.FileTransfer import * from OpcLabs.EasyOpc.UA.OperationModel import * # Unified Automation .NET based demo server (UaNETServer/UaServerNET.exe). endpointDescriptor = UAEndpointDescriptor('opc.tcp://localhost:48030') # A node that represents an instance of OPC UA FileType object. fileNodeDescriptor = UANodeDescriptor('nsu=http://www.unifiedautomation.com/DemoServer/ ;s=Demo.Files.TextFile') # Instantiate the file transfer client object. fileTransferClient = EasyUAFileTransferClient() # Get properties of a specified file. try: print('Getting file properties...') fileProperties = IEasyUAFileTransferExtension.GetFileProperties(fileTransferClient, endpointDescriptor, fileNodeDescriptor) except UAException as uaException: print('*** Failure: ' + uaException.GetBaseException().Message) exit() # Display result. print() print('MimeType: ', fileProperties.MimeType, sep='') print('OpenCount: ', fileProperties.OpenCount, sep='') print('Size: ', fileProperties.Size, sep='') print('UserWritable: ', fileProperties.UserWritable, sep='') print('Writable: ', fileProperties.Writable, sep='') print('Timestamp: ', fileProperties.Timestamp, sep='') print() print('Finished.')
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
Documentation Home, Send Documentation Feedback. Technical Support