10-22-2015 09:41 AM
I have a top-level vi that has strictrly typed static reference to another vi having x-control inside. This x-control runs special thread when it switches to run-mode and stops this thread after switching back to idle. Opening the top-level vi switches x-control to run-mode thus causing it to run this special thread so when I try to close the project, Labview asks to stop the currently running vis. This doesn't seem to be a real problem but just leave me feeling the stuff is not very clean.
The strictly typed static reference is used only as a mean for future open vi reference and async call. I can replace the static reference along with "Path" property by the Path constant solving the problem. The only reason I don't do this is that I'm going to build this program as an executable so I don't know how to build a path for future vi open properly.
Is there any way to make things clean? I don't want to have my x-control to be in run-mode just when I open top-level vi and want to be able to build an executable. If it's possible to do without static reference - it's perfect.
10-22-2015 01:22 PM
This is a "feature" (that I confess I do not understand) of the Strictly Typed Reference. Wiring a non-Strict Static Reference to a VI that has not been started gives an execution state of "Idle", but just change the Static Reference to Strictly Typed and you get Running (even if you never "run" the sub-VI).
I may have found a work-around. I'm hoping the attached Snippet illustrates the point. The Dummy Sub-VI is nothing more than a While Loop with a 5 second wait inside it, that is, "Run for 5 seconds and stop". Key points:
Bob Schor
10-22-2015 01:24 PM
Oops, forgot to include the Snippet ...
BS
10-22-2015 01:30 PM
I also found some way to get rid of these strictly typed static references: actually their main purpose was to get path name, so now I just use path relative to current vi (not too elegant solution but works in particular cases).
10-23-2015 08:26 AM
Your method works in Development Mode, but will fail if you use the same code in an Executable, whereas the Static VI Reference method will work under both conditions.
Bob Schor
10-23-2015 08:35 AM
I also read somewhere that you should use the VI Name rather than path unless you're dynamically loading a VI because VI Path always looks on disk and uses the root loop.
10-23-2015 08:37 AM
I tested it in both modes, it works: the reason is because vi path can be relative to .exe file (like "c:\temp\something.exe\something.vi"). So vi path gives you "c:\temp\something.exe\parent.vi", then path strip leads to "c:\temp\something.exe" and build path finally gets "c:\temp\something.exe\child.vi".
10-23-2015 08:40 AM
In my previous projects I used "Name" property but I don't remember why. For this project I just got rid of these static references: I don't like my x-controls running when I don't want it (and this would result in performance issue).