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] Notification Event

More
28 Aug 2011 10:02 #468 by support
R.,

yes, you are right, and the ‘if…then..else’ is an appropriate way. In fact, the “Concepts” document contains this guidance, too:

Pseudo-code for the full Notification event handler may look similar to this:
if notificationEventArgs.Exception is not null then
An error occurred and the subscription is disconnected, handle it (or ignore)
else if notificationEventArgs.RefreshComplete then
A “refresh” is complete; handle it (only needed if you are invoking a refresh explicitly)
else if notificationEventArgs.Event is null then
Subscription has been successfully connected or re-connected, handle it (or ignore)
else
Handle the OPC event, details are in notificationEventArgs.Event. You may use notificationEventArgs.Refresh flag for distinguishing refreshes from original notifications.

We need some notification about the successful connection because, as opposed to OPC Data Access, there may be no OPC-A&E event shipped to the client after a successful connection (with simple event or tracking, or with condition events if Refresh is turned off).

On possible improvement for future versions of the API is to have something like “event kind” in the event arguments, so that a ‘switch’ statement can be used instead of series of ‘if…then…else’ as above.

Best regards,

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

More
27 Aug 2011 11:36 #467 by support
From: R.
Sent: Friday, August 26, 2011 11:01 PM
To: Zbynek Zahradnik
Subject: FW: Notification Event

Zbynek,

I think I answered my main question here: I found the part in the concepts document that says: You receive the Notification when a successful connection (or re-connection) is made. In this case, the Exception and Event properties of the event arguments are null references.

So the question that remains then, is what is the best practice to handle this scenario in the event notification so I do not receive the nullreference exception? Is adding the If…then like I did in my application an appropriate way to handle this?

R.

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

More
27 Aug 2011 11:34 #466 by support
From: R.
Sent: Friday, August 26, 2011 8:48 PM
To: Zbynek Zahradnik
Subject: Notification Event


Zbynek,


I have attached a [...] program I have been working on [... in] version 5.1.

I have a question about the notification event.

If I subscribe to the kit server for events, I receive a notification event that has a null value for both the e.event and also the e.exception. I had to add the extra If…then statement at Line 235 to catch this.

Can you explain to me why I am receiving a callback that neither has event information, or an exception? What is the purpose of this? Is there something wrong with the way I have this set up that is causing this, or is it expected behavior?


Steps to reproduce:
1. Click browse servers button.
2. Select the server prog id. (tested with both kit server and TOP Server)
3. Click the Subscribe button
4. Notification event is fired.


Thanks,
R.

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

Moderators: support
Time to create page: 0.052 seconds