LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Swapping between VIs that have focus

Within my Main VI, I have a subVI that is running in a tight loop.  it sniffs some outputs from yet another VI that is monitoring some control signals read from a PXI-chassis I/O card.  From the main VI, I want to click on a button (i.e. DisplaySniffer) that brings the sniffer VI to the forefront (it's a small window with a few things on it) - the Main VI is quite large, so it's always visible behind the sniffer VI, and that is by design.  When I click the DisplaySniffer, the front panel displays (due to the code in the attached, First_VI.png).  I want it to display until the operator clicks STOP.  At that point, I want DisplaySniffer to continue running, but I want Main to come to the forefront.  In the event handler of sniffer, I thought I could duplicate the code (in the attached) but point, instead, to the main VI, but when I do that, Sniffer stays in front.  I realize that this is probably not the best way to do this, as eventually Main is going to be built into an EXE, and will have a different path.  With all of this in mind (if I've made sense up till now) does anyone have a recommendation on a good way to ping-pong between which VI front panel is in the forefront?

0 Kudos
Message 1 of 8
(2,832 Views)

For DisplaySniffer - use VI Properties to customize Window Appearance to Window Behavior:Floating.

This will keep it on top of your main (assuming main is set to default).

 

Then provide a way (queue, user event, FG, etc) to open and close DisplaySniffer's front panel.

This avoids messing with focus.

 

steve

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 8
(2,793 Views)

I am not having success with this.  I think the fundamental problem i'm having is getting the true reference to this VI (sniffer) at runtime.  A little more clarification.  The sniffer VI is first called, not by main, but by a VI called by Main.  so it's running pretty shortly after main starts.  Then, when I click on a button on main, I want the sniffer vi to come to the front.  This seems to work with the code I originally attached.  If I run the sniffer VI standalone, the event handler seems to work (I only have one event - for the stop button).  I have it display the name of the VI.  The problem, however, is that the event handler does NOT work at runtime.  So I think I need to solve THAT mystery first.  How do I get a reference to the running sniffer VI?  Simply pointing to where it lives in my file structure doesn't seem to be working.

0 Kudos
Message 3 of 8
(2,762 Views)

In the development mode where "This seems to work ..." - when you click on main - does DisplaySniffer.vi get hidden?

 

For paths to work in both development mode and an application follow these steps:

1) Use the Application Directory vi to set your path

Absolute path.png

2) In the app Build Specification under Source Files - put "Subvi folder" in the Always Included box.

3) Verify in Preview that your path exists as you expect

 

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 8
(2,749 Views)

I know you're not seeing my code, so it has to be hard to help me.  However, I am struggling with what you're saying.  I am not entirely sure what I'm supposed to do with the output string generated by the code in your snippet (item 1)?  Also, I have not yet created a build, which is where I think your items 2 and 3 come into play, right?  I am clicking 'run' on main, but it's not an EXE just yet, I am just in the development mode.  

 

To clarify, I attached two more images.  The first shows the code called from Main to display the front panel of the RFD_Control_Lines VI (this is the sniffer in my earlier (generic) description).  The second attachment are my attempts within a event handler to push the RFD_Control_Lines front panel behind that of Main.  The code in the disable block WAS in the event handler, but I tried to implement the code from you earlier solution, and it displays a "Not a Path" when I run.  I'm sure I didn't do what you were intending.

Download All
0 Kudos
Message 5 of 8
(2,723 Views)

ok, so I didn't explain one of my problems tremendously well earlier, so I'll try again.  I believe that I am looking at two instantiations of the same VI.  The one is kicked off in the routine that is monitoring my PXI Chassis I/O card and the second is an additional copy of the VI.  This explains why, when I run the VI stand alone, the event handlers seem to function, but they don't when I have Main running.  SOOOO, my question, how do I get a reference to the VI that I kicked off from the original (PXI) monitor that I can use elsewhere to ensure i'm pointing to the one and only version of the VI?

0 Kudos
Message 6 of 8
(2,719 Views)

@mrbean wrote:

 my question, how do I get a reference to the VI that I kicked off from the original (PXI) monitor that I can use elsewhere ...?


Isn't that your reference right there?

Frozen_0-1587421711590.png

Put that into a functional global maybe? So it is accessible from your second instance?

 

---------------------------------------------
Certified LabVIEW Developer (CLD)
0 Kudos
Message 7 of 8
(2,707 Views)

path issue.png

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 8 of 8
(2,706 Views)