// This example shows how to completely turn off interaction in a console application. using System; using OpcLabs.EasyOpc.UA; using OpcLabs.EasyOpc.UA.Engine; using OpcLabs.EasyOpc.UA.OperationModel; namespace UADocExamples.Interaction { partial class ConsoleInteraction { public static void TurnOff() { // Do not implicitly trust any endpoint URLs. EasyUAClient.SharedParameters.EngineParameters.CertificateAcceptancePolicy.TrustedEndpointUrlStrings.Clear(); // Completely disable the console interaction. EasyUAClient.SharedParameters.PluginSetups.FindName("UAConsoleInteraction").Enabled = false; // Define which server we will work with. UAEndpointDescriptor endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; // Require secure connection, in order to enforce the certificate check. endpointDescriptor.EndpointSelectionPolicy = UAMessageSecurityModes.Secure; // Instantiate the client object. var client = new EasyUAClient(); UAAttributeData attributeData; try { // Obtain attribute data. // The operation will fail, unless you set up mutual trust using certificate stores. attributeData = client.Read(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853"); } catch (UAException uaException) { Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message); return; } // Display results. Console.WriteLine("Value: {0}", attributeData.Value); Console.WriteLine("ServerTimestamp: {0}", attributeData.ServerTimestamp); Console.WriteLine("SourceTimestamp: {0}", attributeData.SourceTimestamp); Console.WriteLine("StatusCode: {0}", attributeData.StatusCode); } } }
# This example shows how to completely turn off interaction in a console application. # 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.Engine import * from OpcLabs.EasyOpc.UA.OperationModel import * # Do not implicitly trust any endpoint URLs. We want the user be asked explicitly. EasyUAClient.SharedParameters.EngineParameters.CertificateAcceptancePolicy.TrustedEndpointUrlStrings.Clear() # Completely disable the console interaction. EasyUAClient.SharedParameters.PluginSetups.FindName('UAConsoleInteraction').Enabled = False # Define which server we will work with. endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer') # Require secure connection, in order to enforce the certificate check. endpointDescriptor.EndpointSelectionPolicy = UAEndpointSelectionPolicy(UAMessageSecurityModes.Secure) # Instantiate the client object. client = EasyUAClient() try: # Obtain attribute data. # The operation will fail, unless you set up mutual trust using certificate stores. attributeData = IEasyUAClientExtension.Read(client, endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10853')) except UAException as uaException: print('*** Failure: ' + uaException.GetBaseException().Message) exit() # Display results. print('Value: ', attributeData.Value) print('ServerTimestamp: ', attributeData.ServerTimestamp) print('SourceTimestamp: ', attributeData.SourceTimestamp) print('StatusCode: ', attributeData.StatusCode) print() print('Finished.')
Copyright © 2004-2023 CODE Consulting and Development, s.r.o., Plzen. All rights reserved. Web page: www.opclabs.com
Send Documentation Feedback. Resources: Knowledge Base. Technical support: Online Forums, FAQ.