LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unexpected behaviour of functional global with notifiers

Solved!
Go to solution

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?

 

 

0 Kudos
Message 1 of 9
(3,386 Views)

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,


0 Kudos
Message 2 of 9
(3,370 Views)

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.

0 Kudos
Message 3 of 9
(3,353 Views)
Solution
Accepted by topic author sqrt(-1)

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.

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 9
(3,347 Views)

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

0 Kudos
Message 5 of 9
(3,345 Views)

@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.

 

notifier FG.pngBen64

Message 6 of 9
(3,341 Views)

@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.

 

notifier FG.pngBen64


Exactly! Name them notifiers.

 

Of course, then you can really go back and DELETE the element name list Smiley Surprised and throw the whole vi out the window as well

Spoiler
Just use obtain notifier-  All the FGV functions, including the variant lookup method suggested, are done under the hood-  LabVIEW is just like that sometimes, Smarter than we are

"Should be" isn't "Is" -Jay
Message 7 of 9
(3,333 Views)

Er- yes. of course.  Its a shame the same is not true of Events, DVR's... any more?

0 Kudos
Message 8 of 9
(3,328 Views)

@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)

DES Message Queue.lvlib_Queues.png

 

 

The example is missing dependencies.  (I have to hold something back in my pocket)

What a way to find my bugSmiley Embarassed Right there for everyone to see.


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 9
(3,307 Views)