04-23-2010 09:19 AM
All,
I'm curious to get your opinion on the use of occurrences vs. notifiers.
Clearly the following are true:
- notifiers have more functionality
- notifiers can pass data
These are good reasons to use notifiers; but they are not in and of themselves reasons to avoid the use of occurrences.
Does anyone have any thoughts on why NI recommends against the use of occurrences?
http://zone.ni.com/reference/en-XX/help/371361F-01/glang/generate_occurrence/
"Generate Occurrence Function
Owning Palette: Occurrences Functions
Requires: Base Package
Generates an occurrence that you can pass to the Wait on Occurrence and Set Occurrence functions.
Note National Instruments encourages you to use the Notifier Operations functions in place of occurrences for most operations."
Please post your thoughts and opinions!
-Evan
04-23-2010 09:26 AM
Have you ever tried to create an array of unique Occurences?
Its easy with Notifiers but try to do it with Occurences.
See this Nugget for my Nugget on generating Occurences.
Ben
04-23-2010 09:47 AM
In my programming I've had few occasions where I've had a need to use either, but the few situations where I have, I've always used notifiers. Notifiers just seem more flexible. If in the future you decide you need to pass data the infrastructure is already there. I'm sure there is less overhead with an occurence and I'm sure that is probably a consideration but unless you're running on an FPG or RT system it probably won't make much difference.
I've never really seen occurences used by others too often. Although if you look on Lava there is an Active Object Example in the code repository that uses occurences.
The thing that stuck out to me on the link Evan posted was this:
"For example, if you place a Generate Occurrence function inside of a loop, the value produced by the Generate Occurrence function is the same for every iteration of the loop."
I haven't had a chance to read Ben's post yet, but I will in minute. My guess his post has a lot to do with what I quoted above.
04-26-2010 03:10 PM
Hi Everyone,
I've compiled the information you have responded with, and talked to some folks in R&D. Essentially you're both right. To be sure, there is nothing wrong inherently with occurrences, but to new LV programmers, the use of Notifiers will prevent possibly difficult situations in future revisions of a program (refer to #3 below).
1. Notifiers carry information.
- Even though you don't think you'll need to pass information about an event today, you may want to in the future. Using notifiers from the outset will protect you in the future.
2. Notifiers have more functionality.
- There is a notifier palette which gives you access to capabilities like wait on multiple notifications, get status, among others.
3. Generating occurences within a loop only returns a single occurrence.
- Creating multiple occurrences must be done either manually (by placing multiple generate occurences on the block diagram) or through VI server which significantly complicates the problem.
4. Notifiers can do absolutely everything that occurrences can do.
Thanks for your input!
Evan
09-01-2011 02:40 PM
What was Tomi referring to here?
In my own experiment, the notifier appears to be faster.
That said, I created a simple "continue_Execution" framework (basically "Wait for Flag" and "Set Flag") based on occurrences because I wasn't sure what problem Tomi was referring to since the link he referenced is dead (see my link above). Before I release it to the community, I'd like confirmation that there are not performance or reentrancy considerations. For my case, I do not need to pass data.
Thanks,
Jason
03-13-2012 02:00 PM
Aforementioned Wait for Flag / Set Flag now available for download.