LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Start/end a sub-vi with vi-reference in a Build (*.exe)

Dear All,

 

I have a sub-vi I need to open, run and end from a main vi. For safety reasons the sub-vi needs to be closed from the main vi and not by the user. There is a drive that is operated through OPC, and should the user end the sub-vi by himself/herself the drive doesn't stop, but keeps running a spindle.

With the solution attached (picture) this works well in the development envionment. However, after the application builder the referenced sub-vi isn't where the reference points to. Well, it's an *.exe with no vi's.

Does anyone have a work-around to start AND END a sub-vi from a main vi within an application (*.exe)?

 

Thanks for your help.

 

Best Regards

 

Ralf

0 Kudos
Message 1 of 26
(1,470 Views)

Hi Ralf "knuckle of pork",

 


@Eisbein wrote:

I have a sub-vi I need to open, run and end from a main vi. For safety reasons the sub-vi needs to be closed from the main vi and not by the user. … should the user end the sub-vi by himself/herself the drive doesn't stop, but keeps running a spindle.


How should the user be even able to "end" your subVI when you (as the programmer) don't allow that action?

Why do you need to use VIServer functions for this purpose at all?

Why do you need to call the "abort" method on your subVI? This is not safer then stopping the subVI by an user action!

 


@Eisbein wrote:

However, after the application builder the referenced sub-vi isn't where the reference points to. Well, it's an *.exe with no vi's.

Does anyone have a work-around to start AND END a sub-vi from a main vi within an application (*.exe)?


This happens because you determine the subVI reference the wrong way!

Why not use a static VI reference? (Again: why use VIServer functions at all?)

 

There are still VIs in your executable! You "just" need to reference them correctly: inside the executable you have one more "virtual" folder by the executable filename! Your subVI is (usually) found at "AppDir\EXE-filename\module\...\Profinet.vi"…

 

Suggestion: Start the subVI running parallel to your main VI and set a notification to signal the stop condition…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 26
(1,454 Views)

Gerd,

 

// How should the user be even able to "end" your subVI when you (as the programmer) don't allow that action?

>> Because this is only to be determined by the main-vi and conditions within (and not by the user whatsoever).

 

The sub-vi needs to stop at some point (better: this point) to avoid that exactly this sub-vi is called again in another vi. And the main vi is basically also a sub-vi in this case.

Okay, here is what I really tried to do: I call the sub-vi when the user switches to a manual mode. The user can use it to control a drive. When the user switches back to auto mode an exit button in the sub-vi should be activated that also ends it (and only then). Of course, I can open and run it, but how can I send a "T" to a running sub-vi from the main vi? That's all I would need. Any suggestions for this?

 

I would use a static VI reference, but also here I don't know how to end it (where the conditions and the command to end comes from the main-vi).

 

Ralf

0 Kudos
Message 3 of 26
(1,446 Views)

Hi Ralf,

 


@Eisbein wrote:

The sub-vi needs to stop at some point (better: this point) to avoid that exactly this sub-vi is called again in another vi.


Again I have to ask: why use VIServer function to accomplish this task?

 

As long as that subVI is NOT set as reentrant it CANNOT be called from a different VI!

In this case it can only be called/exeuted once at the same time!

 


@Eisbein wrote:

// How should the user be even able to "end" your subVI when you (as the programmer) don't allow that action?

>> Because this is only to be determined by the main-vi and conditions within (and not by the user whatsoever).


Again: why not use a notifier to send a flag to your subVI instead of trying to abort it using VIServer methods?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 26
(1,438 Views)

I'll try the static reference type tomorrow.

 

But to send a flag/notifier to a running sub-vi (front panel opened) to set one of the sub-vi's connections to "T" (in the best case) would be what I am looking for.

The only I have found was for strict type references and only in combination with calling the reference (see picture).

 

Ralf

0 Kudos
Message 5 of 26
(1,424 Views)

Hi Ralf,

 


@Eisbein wrote:

But to send a flag/notifier to a running sub-vi (front panel opened)


Why don't you use notifier functions to access a notifier in your mainVI (to set its value) and in the subVI (to read its value)?

Again: Why do you focus (only) on VIServer functions?

 


@Eisbein wrote:

to set one of the sub-vi's connections to "T" (in the best case) would be what I am looking for.


What is a "subVI connection"? Why do you want to set that to the char "T"? What are other, but "non best" cases?

 

Did you even look up the example VIs on notifiers?

 

Very much simplified example:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 26
(1,403 Views)

Hi Ralf,

 

this is a very similar problem to the Splash-Win question. Have a look at the examples in this post:

Splash-Loading-Screen-stacked-on-mainvi-and-not-exiting-properly 

Greets, Dave
0 Kudos
Message 7 of 26
(1,396 Views)

Gerd,

 

tried with static reference (strict/non-strict), made no difference whatsoever. With the *.exe in the path for the build the build at least finds the sub-vi. Means, I can only use the *.exe version from the ap-builder.

 

Looking at your notifier-solution I run into the same issue. The sub-vi is too large and is used at several point so that I can't put it inline into the main-vi.

 

Eisbein_0-1629291518831.png

and when calling the sub-vi as a file with the notifiers it runs forever or until it gets properly aborted from its own FP or when I just abort it from the sub-vi as shown. I assume it runs the sub-vi and ignores any notifier values after this.

Any solution for this?

Regards

Ralf

0 Kudos
Message 8 of 26
(1,379 Views)

Thanks for your help, Dave.

 

Interesting, and yes this would work if I put the sub-vi code into the main-vi. The sub-vi is just too large and is used several times so that I have to use it as a file.

But when I call a sub-vi as a file it ignores all notifiers after the sub-vi is running. See the picture I put into my reply to Gerd's notifier-solution.

 

If I only would know how to get a flag into a called sub-vi (file).

 

Best Regards

 

Ralf

 

0 Kudos
Message 9 of 26
(1,378 Views)

Hi Ralf,

 


@Eisbein wrote:

If I only would know how to get a flag into a called sub-vi (file).


How/when do you read the notifier in your subvi?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 26
(1,350 Views)