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.

Alarms and Events

More
20 Feb 2024 17:46 #12574 by support
Replied by support on topic Alarms and Events
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:26 #12388 by support
Replied by support on topic Alarms and Events
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
29 Sep 2021 16:59 #10240 by support
Replied by support on topic Alarms and Events
Hello,
here is an example. I hope it helps.
# This example shows how to obtain current state information for the condition instance corresponding to a Source and 
# certain ConditionName.
 
import time
import win32com.client
 
serverDescriptor = win32com.client.Dispatch('OpcLabs.EasyOpc.ServerDescriptor')
serverDescriptor.UrlString = 'opcae://localhost/OPCLabs.KitEventServer.2'
 
sourceDescriptor = win32com.client.Dispatch('OpcLabs.EasyOpc.AlarmsAndEvents.AENodeDescriptor')
sourceDescriptor.QualifiedName = "Simulation.ConditionState1"
 
# Instantiate the client object
client = win32com.client.Dispatch('OpcLabs.EasyOpc.AlarmsAndEvents.EasyAEClient') 
 
print('Getting condition state...')
conditionState = client.GetConditionState(serverDescriptor, sourceDescriptor, 'Simulated', [])
 
print('ConditionState:')
print('    .ActiveSubcondition: ', conditionState.ActiveSubcondition)
print('    .Enabled: ', conditionState.Enabled)
print('    .Active: ', conditionState.Active)
print('    .Acknowledged: ', conditionState.Acknowledged)
print('    .Quality: ', conditionState.Quality)
# Note that IAEConditionState has many more properties
 
print()
print('Finished.')
Best regards
The following user(s) said Thank You: K-R IKE

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

More
29 Sep 2021 10:27 #10238 by K-R IKE
Replied by K-R IKE on topic Alarms and Events
Hello.

I don't know how to use GetConditionState of AEClient in Python.

teach me please.

Kind regards,

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

More
07 Sep 2021 10:14 #10188 by support
Replied by support on topic Alarms and Events
Hello,
thank you for your interest in our products.

We could not get COM events work in Python either.

We therefore suggest to use the "event pull" mechanism supported by QuickOPC: opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...#Event%20Pull%20Mechanism.html .

And, here is an example (with the event pull) that works:
# This example shows how to subscribe to events and obtain the notification events by pulling them.
 
import time
import win32com.client
 
serverDescriptor = win32com.client.Dispatch('OpcLabs.EasyOpc.ServerDescriptor')
serverDescriptor.ServerClass = 'OPCLabs.KitEventServer.2'
 
# Instantiate the client object
client = win32com.client.Dispatch('OpcLabs.EasyOpc.AlarmsAndEvents.EasyAEClient') 
# In order to use event pull, you must set a non-zero queue capacity upfront.
client.PullNotificationQueueCapacity = 1000
 
print('Subscribing events...')
subscriptionParameters = win32com.client.Dispatch('OpcLabs.EasyOpc.AlarmsAndEvents.AESubscriptionParameters')
subscriptionParameters.NotificationRate = 1000
hanle = client.SubscribeEvents(serverDescriptor, subscriptionParameters, True, None)
 
print('Processing event notifications for 1 minute...')
endTime = time.time() + 60
while time.time() < endTime:
    eventArgs = client.PullNotification(2*1000)
    if eventArgs is not None:
        # Handle the notification event
        print(eventArgs)
 
print('Unsubscribing events...')
client.UnsubscribeAllItems()
 
print('Finished.')
I hope this helps
Best regards

ZZ
The following user(s) said Thank You: K-R IKE

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

More
07 Sep 2021 07:19 - 07 Sep 2021 08:56 #10187 by K-R IKE
Alarms and Events was created by K-R IKE
Hello.

We are considering purchasing your product and are using your free trial version at the moment.
We would like to see how OPC Alarms & Events operate, but OnNotification doesn't execute with the following code below.
Is there any point we are missing?
Or is this something to do with OPC Kit Server side which needs us to do some extra work to make it work?

Code:
import win32com.client
import win32com.client.connect
import time
# import pythoncom
 
 
class EventHandler:
    def OnEventingFailure(self, sender0, eventArgs):
        print(sender0)
        print(eventArgs)
 
    def OnNotification(self, sender0, eventArgs):
        print(sender0)
        if eventArgs.Succeeded is not None:
            print(eventArgs.Message)
 
 
daclient = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.EasyDAClient')
client = win32com.client.Dispatch('OpcLabs.EasyOpc.AlarmsAndEvents.EasyAEClient')
serverDescriptor = win32com.client.Dispatch('OpcLabs.EasyOpc.ServerDescriptor')
subscriptionParameters = win32com.client.Dispatch('OpcLabs.EasyOpc.AlarmsAndEvents.AESubscriptionParameters')
serverDescriptor.Host = 'localhost'
serverDescriptor.ServerClass = 'OPCLabs.KitEventServer.2'
subscriptionParameters.notificationRate = 1000
handler = win32com.client.WithEvents(client, EventHandler)
print("Subscribing events...")
 
handle = client.SubscribeEvents(serverDescriptor, subscriptionParameters, True, None)
 
time.sleep(10)
 
daclient.WriteItemValue('localhost', 'OPCLabs.KitServer.2', 'SimulateEvents.ConditionState1.Activate', True)
time.sleep(10)
 
client.RefreshEventSubscription(handle)
 
print("Processing event notifications for 1 minute...")
time.sleep(60)
 
print("Unsubscribing events...")
if handle is not None:
    client.UnsubscribeEvents(handle)
 
print("Finished.")



Environment:
- OPC Server: OPC Kit Server
- QuickOPC: 5.61
- Programming language: Python 3.9.2
- OS: Windows 10 Pro (Ver.2004) 64bit

Please let us know how to make it work.

Kind regards,
Last edit: 07 Sep 2021 08:56 by support.

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

Moderators: support
Time to create page: 0.057 seconds