LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best practice for calling LLB VI's programmatically AND in a SubPanel

I am new to LabView programming and trying to avoid the corners I have painted myself into with textual programming in the past.  I know pretty much what I want (but open to advice), just not sure if I know the best way to get there.

 

I have a library file with a VI in it that connects to a physical device and provides a panel to configure communication.  I want this panel in my application (as a SubPanel I assume) but I also want to be able to programmatically access the VI when the panel isn't in use.  So I did "Select a VI" on the block diagram and dropped it in, in addition to doing an Invoke Node and "Insert VI" to put it in the SubPanel.  This feels kind of wrong though.  Is there a way to just have one "instance" of the VI and access it both programmatically and in the SubPanel?  Or is that asking for more headache?

 

 

0 Kudos
Message 1 of 7
(1,134 Views)

Hi Brian,

 


@BrianOSullivan wrote:

Is there a way to just have one "instance" of the VI and access it both programmatically and in the SubPanel?


In a Subpanel you only show the front panel of a subVI. It is your decision to show that frontpanel - or not to show it…

Conclusion: there is only one instance of that subVI running and you can decide, if/when to show its frontpanel in a Subpanel container.

 

You don't even need subpanels, you can also open/close the frontpanel of that subVI as a separate window…

Best regards,
GerdW


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

@GerdW wrote:

In a Subpanel you only show the front panel of a subVI. It is your decision to show that frontpanel - or not to show it…

Conclusion: there is only one instance of that subVI running and you can decide, if/when to show its frontpanel in a Subpanel container.


Thanks for the reply Gerd.  I should probably reframe the question.  Showing/hiding the subpanel sounds great, but if I do the InsertVI function I don't think I have a way to programmatically access the VI.  I want to replicate the user interacting with the Subpanel (clicking buttons, typing strings, selecting VISA resources, etc) programmatically, that's where my confusion is.  I don't know the best way to programmatically interact with the VI AND let the user interact with it.

 

Thanks!

0 Kudos
Message 3 of 7
(1,082 Views)

Hi Brian,

 


@BrianOSullivan wrote:

I want to replicate the user interacting with the Subpanel (clicking buttons, typing strings, selecting VISA resources, etc) programmatically, that's where my confusion is.  I don't know the best way to programmatically interact with the VI AND let the user interact with it.


To "programmatically interact with the VI" you can:

  • use references of the FP element to write/read values
  • implement an algorithm to send commands to your VI and receive the responses: something like a QMH…
Best regards,
GerdW


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

@GerdW wrote:

Hi Brian,

 


@BrianOSullivan wrote:

I want to replicate the user interacting with the Subpanel (clicking buttons, typing strings, selecting VISA resources, etc) programmatically, that's where my confusion is.  I don't know the best way to programmatically interact with the VI AND let the user interact with it.


To "programmatically interact with the VI" you can:

  • use references of the FP element to write/read values
  • implement an algorithm to send commands to your VI and receive the responses: something like a QMH…

I highly recommend looking into User Events.  They work with the Event Structure, making it so you only need 1 loop in the called VI.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 7
(1,069 Views)

@GerdW wrote:

To "programmatically interact with the VI" you can:

  • use references of the FP element to write/read values
  • implement an algorithm to send commands to your VI and receive the responses: something like a QMH…

I think I interpreted this correctly (sorry, my green-ness might be showing).  I used a Call By Reference to attempt to read/write values, but reading this thread it looks like I have to use a strictly-typed call to do that, and I can't use a strictly-typed call to insert the VI into the SubPanel.  If I try to create two references (like the OP of that thread did) I get the error "The VI is not in a state compatible with this operation."

 

BrianOSullivan_0-1607966745318.png

I'm not sure if part of my problem might be because the VI waits for user interaction, so calling it By Reference don't ever return any values, I think execution hangs inside because the VI is looping waiting for user input.  I was thinking that reading/writing to the reference that is in the SubPanel would avoid that issue, but is that not possible?

0 Kudos
Message 6 of 7
(1,052 Views)

@crossrulz wrote:

I highly recommend looking into User Events.  They work with the Event Structure, making it so you only need 1 loop in the called VI.


My called VI already has a couple of loops that needs to run.  But I'm curious, could a called VI trigger user events that the calling VI responds to?  One thing I need to work around is the fact that my called VI waits for user input so when I call it I think execution hangs inside of it.  Actually communicating to and from it isn't as easy as I thought.

0 Kudos
Message 7 of 7
(1,048 Views)