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
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
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.')
Please Log in or Create an account to join the conversation.
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.
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.')
Best regards
ZZ
Please Log in or Create an account to join the conversation.
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,
Please Log in or Create an account to join the conversation.