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.

Python examples

More
20 Feb 2024 17:40 #12562 by support
Replied by support on topic Python examples
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:39 #12401 by support
Replied by support on topic Python examples
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
30 May 2018 06:10 #6381 by support
Replied by support on topic Python examples
Hello,

QuickOPC is exposed to Python via COM, and consuming COM events from Python has turned out to be quite problematic. It might be possible, but you are on your own, currently.

Instead, we suggest to use the "event pull mechanism" - see opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...#Event%20Pull%20Mechanism.html . Semantically, it gets you precisely the same notifications as you would get with events or callbacks, but the coding is different and the activity to obtain the data comes from your side.

There is a Python example right on that documentation page. It looks like this:
# This example shows how to subscribe to item changes and obtain the events by pulling them.
 
import time
import win32com.client
 
# Instantiate the client object
client = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.EasyDAClient') 
# In order to use event pull, you must set a non-zero queue capacity upfront.
client.PullItemChangedQueueCapacity = 1000
 
print('Subscribing item changes...')
client.SubscribeItem('', 'OPCLabs.KitServer.2', 'Simulation.Random', 1000)
 
print('Processing item changes for 1 minute...')
endTime = time.time() + 60
while time.time() < endTime:
    eventArgs = client.PullItemChanged(2*1000)
    if eventArgs is not None:
        # Handle the notification event
        print(eventArgs)
 
print('Unsubscribing item changes...')
client.UnsubscribeAllItems()
 
print('Finished.')
Best regards

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

More
29 May 2018 13:54 #6370 by filin
Python examples was created by filin
Hello!

I have a small question. How I can register callback for subscribtion (i mean smth like ItemChanged)?
Do you have any examples for it?

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

Moderators: support
Time to create page: 0.045 seconds