LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the difference between VI Template and vi that is reenterant?

What is the difference between VI Template and vi that is reenterant?

From what little info I can find about them, they seem to basically do the same thing....

What are the difference?
What are the pros and cons of each?

Thanks alot for the help.....
0 Kudos
Message 1 of 10
(4,475 Views)

A VI Template is just a VI that you can use a starting point to build other VIs in the same way you can have a Word or Excel Template. When you open a VI Template from the 'New... menu selection, LabVIEW gives it a new name so the template does not get overwritten.

A Reentrant VI will force LabVIEW to create a new instance of that particular VI in memory for each place it is used on a block diagram. This really only useful for subVIs. This lets you have a single VI that can be used in several places without them blocking each other or sharing data.

If that doesn't clear it up, let us know and we'll explain a  bit more.

Ed



Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 2 of 10
(4,463 Views)
You can check the Example Finder (Help->Find Examples..., click on the "Search" tab, and enter "reentrancy" or "templates") to find an example of each to see how they work. The reentrant example is called "Timed loops in reentrant VIs". The template example is called "Subpanel Templates".
Message 3 of 10
(4,457 Views)
I inherited an app that uses .vit for the purpose of having multipe separate instances.
It works fine in the development enviornment but when I compile the code, when the .vit is called it crashes straight to the finder.
By the way, I am running on a Mac in OSX and apparently this is a known problem.

When I change the vi to a regular .vi, when I compile it, it runs like it should but I loose the ability to have multiple instances of it.

I was hopping that I could just change the .vits to .vis and then make then reenterant to acheive what I need.

I was just trying to figure out why they specifically used .vit instead of reenterant vis.

By the way, the .vit are being called by the "call by refernece vi". Not sure if that is going to make a differnece to this conversation.

Thanks,
0 Kudos
Message 4 of 10
(4,453 Views)
I seem to remember trying exactly that once on some version of LV6 on Windows (what can I say, it was a slow day at work...) and as I recall it did work - in theory it should. The easiest thing would be to build a quick prototype with a plugin that does something simple like increment a counter once a second, and see if it works.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 10
(4,441 Views)
Duplicate (well, not exactly, but the topic is close enough so that people might try to answer it there).

___________________
Try to take over the world!
Message 6 of 10
(4,427 Views)

The answer to the question "what is the difference... really depends on the context and the version of LV being used.

Lets start with pre-LV 8

Ed mentioned how templates operates while editing.

When running they are similar in that each time you open a template, a new VI is cloned from the template. If you whatch the hiearchy screen you will see new instances being created for each open.

Each template has its own diagram and front panel because they are different VI.

VI's that are not re-entrant share the front panel but have unique data and code spaces. Since the FP are shared and each instance of the VI in a diagram is unique, the only way to view the FP of a particular instance, was to find that instance in one of the diagrams and double-clicking it to tell LV which version you are are looking at.

So one big difference is you can use a template to open a dozen idenitcle FP's and have them run at the same time. You can not do this with re-entrant VI's.

OK I am not going to have time to address all of the other things.

RE: the issue you are having with crashing.

Since templates requires crating a clone, make sure the path to the template is correct, and monitor the error cluster coming for the "Open".

Have fun,

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 7 of 10
(4,406 Views)


@Tarek316 wrote:
I inherited an app that uses .vit for the purpose of having multipe separate instances.

Thanks,


OK, here's what happens when you call a VI Template using Call by Reference or using Invoke and Property Nodes.

Since the VI you are calling is a template, LabVIEW creates a new instance of that VI by creating a copy of it and giving a new name. Notice in the title bar of the instantiated VI the VI name is the same as the template VI plus a number. This is the same thing you see when you open a template from the "New..." menu. So if you call the template VI 3 times, you'd end up with 5 newly instantiated VIs named, "VI Name 1.vi", "VI Name 2.vi" and "VI Name 3.vi". This is how you end up with multiple instances.

Reentrancy only works on subVIs when they are used as a normal subVI in a top level application. Using Call by Reference or Invoke and Property Nodes to open and run a reentrant VI results in the VI only being opened once because LabVIEW will not automatically give it a new name. The new name is only generated when calling templates. Since LabVIEW can only a have a single instance of VI name in memory at a time, you'll not end up with multiple instances.

Not sure if I can help with the know issue on OSX. If it's specific to using the Call by Reference function, you could try calling the templates using Invoke and Property nodes.

Ed



Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 8 of 10
(4,394 Views)
There's no known issue with dynamically calling VIT in OSX.  From reading your other thread, it seems like the problem comes down to what's in the VIT you are calling, and what's in the code in your main VI.  I will do some tests on our test machines here and see if calling VIT in an executable will cause it to crash.  However, I doubt that it's the case.
0 Kudos
Message 9 of 10
(4,332 Views)
VI templates and reentrant VIs are different and used differently in LabVIEW 8.2 and 7.1
Here's an article about the difference between the two in 7.1. Differences Between Reentrant VIs, VI Templates, and Dynamic VIs.
If you have further questions on specific details, feel free to ask.
0 Kudos
Message 10 of 10
(4,308 Views)