LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple FGV Controllers but minimize duplicate code.

I typically develop a FGV Controller for functions or instrument controls.  These controllers usually perform functions such as:  Initialization (Open), Setup or Configuration,  Write, Read, Close.  Examples:  Power Supply control or Timing control (or like Logging, see attache example).

 

What happens whens when you need multiple instances of your FGV controller?  Since it is non-reEntrant, you may want to copy it for each usage.   This leads to duplicate code, which is something I'd like to avoid.

 

Here is a method that I welcome critique and alternative solutions as feed back....

If you make your core function a ReEntrant VI, (as I did on the attached Example), you can reuse it without code duplication.

            This would require you to pass info (that was stored in the FGV shift register) into the reEntrant VI each time it is used.

  One solution is to create a FGV_WrapAround that maintains the FGV properties, but allows you to use the clone VI internally.

 

I know that there are many other solutions out there...

  NI Community, What have you found is a good method to handle encapsulated functions while allowing multiple use (without duplicating code)?

 

 

0 Kudos
Message 1 of 3
(3,345 Views)

As you said: Make it reentrant and then provide a non-reeentrant wrapper VI for each desired caller. That avoids the duplicate code and instantiates it uniquely.

That's the correct solution to me.

Message 2 of 3
(3,343 Views)

AristosQueue,

              This is exactly the approach I am planning to use unless I get feedback that there is a better method I should be considering. 

Thank you for the validation.

0 Kudos
Message 3 of 3
(3,338 Views)