Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

SubscribeMultiple Example using Python

More
20 Feb 2024 17:44 #12571 by support
Examples for OPC client and subscriber development in Python are now on GitHub: github.com/OPCLabs/Examples-QuickOPC-Python .

Please Log in or Create an account to join the conversation.

More
21 Nov 2023 13:25 #12386 by support
Note: QuickOPC now supports Python in much better way, cleaner syntax, and public packages (pypi.org/project/opclabs-quickopc/) on Python Package Index . See What's new in QuickOPC 2023.2 for more information. And, over 270 examples are available in the User's Guide!

Please Log in or Create an account to join the conversation.

More
10 Feb 2023 08:41 #11529 by support
Hello,

here it is:

 
# This example shows how to subscribe to changes of multiple monitored items, pull events, and display each change.
 
import time
import win32com.client
 
# Instantiate the client object
client = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.EasyUAClient')
# In order to use event pull, you must set a non-zero queue capacity upfront.
client.PullDataChangeNotificationQueueCapacity = 1000
 
print('Subscribing...')
monitoringParameters = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.UAMonitoringParameters')
monitoringParameters.SamplingInterval = 1000
monitoredItemArguments1 = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.OperationModel.EasyUAMonitoredItemArguments')
monitoredItemArguments1.EndpointDescriptor.UrlString = 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer'
monitoredItemArguments1.NodeDescriptor.NodeId.ExpandedText = 'nsu=http://test.org/UA/Data/ ;i=10845'
monitoredItemArguments1.MonitoringParameters = monitoringParameters
monitoredItemArguments2 = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.OperationModel.EasyUAMonitoredItemArguments')
monitoredItemArguments2.EndpointDescriptor.UrlString = 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer'
monitoredItemArguments2.NodeDescriptor.NodeId.ExpandedText = 'nsu=http://test.org/UA/Data/ ;i=10853'
monitoredItemArguments2.MonitoringParameters = monitoringParameters
monitoredItemArguments3 = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.OperationModel.EasyUAMonitoredItemArguments')
monitoredItemArguments3.EndpointDescriptor.UrlString = 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer'
monitoredItemArguments3.NodeDescriptor.NodeId.ExpandedText = 'nsu=http://test.org/UA/Data/ ;i=10855'
monitoredItemArguments3.MonitoringParameters = monitoringParameters
arguments = [
monitoredItemArguments1,
monitoredItemArguments2,
monitoredItemArguments3
]
client.SubscribeMultipleMonitoredItems(arguments)
 
print('Processing data change events for 1 minute...')
endTime = time.time() + 60
while time.time() < endTime:
eventArgs = client.PullDataChangeNotification(2*1000)
if eventArgs is not None:
# Handle the notification event
print(eventArgs)
 
 


Best regards

Please Log in or Create an account to join the conversation.

More
09 Feb 2023 20:09 #11528 by jgonzalez
Hello,

Thank you for getting back to me so Promptly. The customer is working on an OPC UA Client application. My apologies for not sharing this with you in my initial message.

Best regards,

John G.

Please Log in or Create an account to join the conversation.

More
09 Feb 2023 20:06 #11527 by support
Hi John,
is this meant for OPC UA, or for OPC Classic?

(I do not have either example, but will try to put it together tomorrow)

Best regards

Please Log in or Create an account to join the conversation.

More
09 Feb 2023 15:25 #11524 by jgonzalez
Hello,

I have a customer that is working on a client application using Python. The customer is requesting an example of "Subscribe to Multiple".

Our team's knowledge of the python language is very limited and from experience, we have not come across much use from customers.

Our question to you is, do you happen to have any example code for "Subscribe to Multiple" using python?

Your guidance is greatly appreciated.

Best regards,

John G.

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.133 seconds