LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

using first call? in LVOOP

Solved!
Go to solution

LVOOP experts,

 

I am quite green when in comes to LV classes, but am striving to understand them better.

 

Is there any way to use the First Call? primitive inside a static dispatch method VI? It seems to work fine when I have one instance of my class, but does not work if I create several instances (which was my goal in the first place). The First Call only returns true for the very first instance, all the others it returns false all the time.

 

It is quite easy for me to add an initialise method to the class, but was wondering if its possible to do it with the First Call?

 

Thanks

Neil

0 Kudos
Message 1 of 3
(2,936 Views)

First things first:

 

I am not a LVOOP expert but I am trying!

 

You can use the fFirst Call but it wil only be true the first time the containing VI runs. It could be used to develop a Singlton design pattern so that if multiple threads try to init the class using a VI with First Call could enusre that only a single instance it created.

 

I think you should go with the "Init" or "Create" method for each instance.

 

like i said, I am no expert. Please reply if I am not making sense!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 3
(2,928 Views)
Solution
Accepted by topic author Neil.Pate

Thanks for the comments Ben,

 

I figured out the problem after a bit of head-scratching. The VI needed to be set to re-entrant (clone).  I only figured this out when the class was behaving really badly with more than one instance (but no first call being used), this was eventually tracked down to a feedback node inside the class (again solved by making re-entrant and cloned).

 

Now, I figured that having the VI as reentrant and clone made the design a bit ugly, so I reworked the class to not use the feedback node, and an init method (as you also suggested).

 

Now it works! 🙂

 

I am trying to slowly get to grips with classes, and winning one step at a time I think.

 

0 Kudos
Message 3 of 3
(2,902 Views)