06-07-2017 08:47 AM
Hi all,
I created a functional global to manage a list of notifiers (see attachment). It returns a notifier reference according to the element name specified as input.
If a new element name is specified, a new unnamed notifer is created (Obtain notifer). If an existing element name is specified, the notifier reference (previouslty initialized) is returned.
This structure is used to manage notifier for classes. Different classes use different notifiers.
The first time I call the FG, the notifier is initalized and a valid refnum is returned. The second time I call it, Invalid Refnum is returned.
Why this?
Solved! Go to Solution.
06-07-2017 09:06 AM - edited 06-07-2017 09:09 AM
It may be because you have no Initialise case. The arrays may not be empty when you start, and so the names and values may not match, or the references may be invalid. IN your initialise case, empty the arrays. It is also worth mentioning that this is a prefect use case of a Variant Lookup Table, which will perform faster and with less coding than the search 1d array method you are using. There are many examples of variant lookup tables on these forums.
Regards,
06-07-2017 09:24 AM
I've added the initalization case that empty arrays but this strange behaviour remains,
I'm looking at Variant Lookup Table now. I didn't know it. Thanks for your suggestion.
06-07-2017 09:25 AM - edited 06-07-2017 09:26 AM
Between the first and second call, does your VI go idle?
If so, the notifiers are being destroyed when LV clean runs.
Ben
PS: I like the Variant lookup as well.
06-07-2017 09:26 AM
please make a simple test VI which gives you the strange behaviour. I tried your VI and it works as far as i can see
06-07-2017 09:32 AM
@sqrt(-1) wrote:
Hi all,
I created a functional global to manage a list of notifiers (see attachment). It returns a notifier reference according to the element name specified as input.
If a new element name is specified, a new unnamed notifer is created (Obtain notifer). If an existing element name is specified, the notifier reference (previouslty initialized) is returned.
This structure is used to manage notifier for classes. Different classes use different notifiers.
The first time I call the FG, the notifier is initalized and a valid refnum is returned. The second time I call it, Invalid Refnum is returned.
Why this?
You should wire the new element name to the Obtain Notifier name input in the not found case.
Ben64
06-07-2017 09:40 AM
@ben64 wrote:
@sqrt(-1) wrote:
Hi all,
I created a functional global to manage a list of notifiers (see attachment). It returns a notifier reference according to the element name specified as input.
If a new element name is specified, a new unnamed notifer is created (Obtain notifer). If an existing element name is specified, the notifier reference (previouslty initialized) is returned.
This structure is used to manage notifier for classes. Different classes use different notifiers.
The first time I call the FG, the notifier is initalized and a valid refnum is returned. The second time I call it, Invalid Refnum is returned.
Why this?
You should wire the new element name to the Obtain Notifier name input in the not found case.
Ben64
Exactly! Name them notifiers.
Of course, then you can really go back and DELETE the element name list and throw the whole vi out the window as well
06-07-2017 09:43 AM
Er- yes. of course. Its a shame the same is not true of Events, DVR's... any more?
06-07-2017 10:13 AM - edited 06-07-2017 10:35 AM
@Michael_78 wrote:
Er- yes. of course. Its a shame the same is not true of Events, DVR's... any more?
In all fairness, There are reasons to do exactly what was suggested. To Wit: there is no method to return the names of all notifiers in this application instance. This could aid a developer trying to figure out just where they typoed a name and got a new notifier rather than a reference to the notifier they wanted.
Attached in 2017
I just recently modified an lvlib that can be found in some shipping template projects to add a feature like this for Queues. (And disconnect a cluster typedef that I didn't like)
The example is missing dependencies. (I have to hold something back in my pocket)
What a way to find my bug Right there for everyone to see.