LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to build workable exe when subvi is opened by reference

Hi,

 

I wrote a program where subVI is opened via Open VI Reference where I introduce the subVI path. The program and packed exe works fine on my local development environment but the exe would not open subVI panel on other machine. I made the main VI with several buttons in event structure and I want to open each subVI panel when click each button, but it show no response on other machine and I suppose the build exe action did not embed subVIs which leads to the exe find no such VI. I also tried to use static VI reference and this time the exe could pop up subVI panel but there was an error says "Error 1198 occurred at invoke node". Not quite sure how to make the exe build work 😞 Is there anyone knows that how to build the exe when subVI is opend by reference? Really appreciate it.

MarkXL_0-1737112034238.png

 

0 Kudos
Message 1 of 9
(241 Views)

I haven't looked at (or used) the code for a while (almost a decade), but I have used Open VI Reference to start (numerous) Asynchronous Clones running.  The Clone VI was called "Station", and was passed a Named Queue of type S-Msg (this was a Messenger Channel going to run a Channel Message Handler loop, with the Queue being used to send "Now Do This" messages to the Clone(s).  Here's a picture (sorry, but almost everything should be self-evident by the entity names, and if I attached the "naked" sub-VI, it would have a lot of blank square boxes) --

Create Station Clone.png

 

Needless to say, this worked.  A typical running of the main routine would have 6 to 20 of these clones running simultaneously.

 

Bob Schor

0 Kudos
Message 2 of 9
(213 Views)

@MarkXL wrote:

Hi,

 

I wrote a program where subVI is opened via Open VI Reference where I introduce the subVI path. The program and packed exe works fine on my local development environment but the exe would not open subVI panel on other machine. I made the main VI with several buttons in event structure and I want to open each subVI panel when click each button, but it show no response on other machine and I suppose the build exe action did not embed subVIs which leads to the exe find no such VI. I also tried to use static VI reference and this time the exe could pop up subVI panel but there was an error says "Error 1198 occurred at invoke node". Not quite sure how to make the exe build work 😞 Is there anyone knows that how to build the exe when subVI is opend by reference? Really appreciate it.

MarkXL_0-1737112034238.png

 


First, a static Vi reference is indeed a (much) better way to do this.

 

Is that error from the code you show, or does the event structure also use run methods?

 

We can't tell from just the screenshot.

 

LabVIEW will include VIs that are linked with static VI references, but if those VIs contain static VI references, I've found those VIs are not (always?) included automatically.

 

So, make sure all VIs are build in the executable.

 

There are several ways to do this.

 

1) Prevent dynamic references all together (several way to do this too).

2) Add files (.VI, .lvclass)  to a VI that is guaranteed to be included. They don't have to execute, ever, but make sure the dead code elimination doesn't clean them up.

3) Always include files in the build spec..

 

0 Kudos
Message 3 of 9
(163 Views)

Hi Bob, thanks for reply. I see and it should work, no question. My problem is that it seems LabVIEW would not make it work after I pack it into exe application with Open VI Reference using. No issue to run source code in development environment.

0 Kudos
Message 4 of 9
(136 Views)

Hi wiebe, the interesting thing is that static VI reference could make main.exe work and could open the corresponding VIs' panel. It's just would give such error when debugging which is annoying. I know that I did not use it right (definitely) but I just could not find the answer to resolve it although it would not affect exe application work. So my question is like:

 

1) If I use Open VI Reference to open and run subVI, how to build a workable exe? Currently it just couldn't.

2) Static VI Reference works fine in exe but report error in debugging, how to use it right?

 

Thank you anyway for answering this. Currently I am just go with Static VI Reference 🙂

0 Kudos
Message 5 of 9
(130 Views)

Well, I see the error here means that the RUN VI could not handle the VI which is already running top level, it can't run the running VI again. So I add a method ABORT VI before opening it and this time no error like before. But my purpose is user can open the subVI panel freshly everytime clicking the event button while Reinit All could not clear content like multicolumn listbox. Open VI Reference and Close VI reference sets could give fresh subVI panel everytime but that would cause exe problem 😞

MarkXL_0-1737452507968.png

 

0 Kudos
Message 6 of 9
(110 Views)

Sounds maybe like a stop strategy (the lack of it) is the real problem.

 

If you can't run the VI because it's already running, there are numerous solutions.

 

For instance:

  • If the user closes the panel, make sure the VI stops running.
  • If the VI is already running, ignore the error (it's running). Doesn't always work of course.
  • Test the state, don't run if it's running or running top level.
  • Make the VI always run (as a real subVI), and in stead of running it when needed, show it's front panel. No dynamic VIs can be a real relief.

 

Is this sub VI supposed to be reentrant? A static reference can still be used, but you have to explicitly open a clone from the static reference. Before LV24, get the VI's name or path, in 24> the open VI reference accepts a reference.

 

Except for loading plug ins that are added to the exe after the build, there's nothing a a open VI reference by name or path can do that a static VI reference can't. A static VI reference is always preferred, as searching and building becomes a lot easier.

0 Kudos
Message 7 of 9
(79 Views)

Thank you wiebe, good suggestion! The current solution is that execute FPopen and Run VI for the first time calling this subVI using static VI reference but only initialize and FPOpen if the VI is running top level. Of cause for the objects which could not be initialized or cleared I may assign null value or call property node to see if this could be done or not.

The sub VI is supposed to be reentrant and I am not so familiar with clone from static reference and I need to do some research about it. The best way for this is that when subVI is closed it would be released from memory so I can call a total fresh subVI panel next time and no need to do initialization manually.

0 Kudos
Message 8 of 9
(57 Views)

@MarkXL wrote:

The sub VI is supposed to be reentrant and I am not so familiar with clone from static reference and I need to do some research about it. 


A static VI reference is never a clone. It's always a reference to the actual VI.

 

But you can still benefit from the static VI reference:

wiebeCARYA_0-1737626675440.png

The VI is automatically included in builds and you don't have to worry about the path changing in a build (and handling the errors, etc.). A big relief.

 

If you right click the static VI reference, and change it to a Strictly Typed VI Reference, you can use Call By Reference, Call and Forget, Call and Forget. The latter two needs the 0x8 to be changed (to 0x88 and 0x108, read the help):

wiebeCARYA_1-1737627150104.png

 

This is helpful if (when) the VI needs inputs and\or outputs (way better than using (functional) globals or other global resources).

Message 9 of 9
(40 Views)