02-04-2024 08:18 AM
Hello,
I would like to swap between 2 Front panels and I found a solution but I bet there's a better one I couldn't think of.
Here just the thought behind it. I would have to do this with more Indicators and controls to swap some parts of the UI. I got 2 options in the Ring and if one is changed the front end should adept.
Is there a way to build 2 separate Vis with a separate front end and just call them with the corresponding UI. I don't want them to run simultaneously.
Best regards
02-04-2024 09:28 AM
The answer is "Yes" (as opposed to the children's song "And the Word is No"). There is something called a Sub-Panel in LabVIEW (on the Front Panel screen, it in in the "Layout" menu).
Let's say you have two VIs, call them "One" and "Two", and a third VI, call it "Master" with a switch that says which VI you want to be "visible" and "controllable".
Ideally, you configure "One" and "Two" so that their Front Panels are the same size. [The way I do this is to put a Decoration like a Flat Box under my sub-VIs Controls and Indicators, and make it the same size for both "One" and "Two". I also arrange the Run-Time Window of both so it "fits" the identically-sized VIs.]
On Master, you create a sub-Panel that's the size of the (now identical) Front Panel of One and Two. When you create the sub-Panel (and name it), you'll find an Invoke Node (which you can name "Master") called "Insert VI" that you can put a reference to the VI you want to run in the sub-Panel Window.
There's a good example that ships with LabVIEW showing three identically-sized sub-Panels all actively running, and letting you view their Front Panels by choosing which one you want to observe. The Example notes that you can't "pass values" (easily) to these sub-Panels, but you can give them their own "Front Panel" controls (for example, if they plot a Graph, you can have controls to change the Y scale). You can also make the sub-VIs get data asynchronously (via a Queue or Channel Wire) so that they continually update whether or not you are viewing them.
Bob Schor
02-04-2024 09:30 AM
Sometimes I use the "Visible" property on a specific control. (Note that you don't need to disable a hidden control.)
Often I'll use a tab control.
02-04-2024 09:33 AM
Thats what i wanted thank you very much! I will see if i can run this like you said.
Best regards.
02-04-2024 09:37 AM
So if i hide a control its also disabled or is it running in the background?
02-04-2024 11:15 AM
If you left it running, it is still running. About 8 years ago, I wrote a Behavior Monitoring program that (in priniciple) monitored up to 24 Stations (we usually used around 10 at a time). Each had a Video camera and an "Event Detector", and when the Event Detector fired, we wanted to save a video from 1 second before the event to 4 seconds after. Events occurred irregularly, about 4-5/hour.
We wrote a "Station" routine for one Camera, one Event Detector, and one Video out, cloned it as many times as we had Stations, and had an array of Clones that we could put into a sub-Panel if we wanted to "look at the Video" over the 2-hour period we were monitoring. When we pushed the button for "Station 17", we released the Station that was using the sub-Panel and put Station 17's Reference in, and we were watching the feed from Station 17's camera. Of course, at the end, we had to shut down all the running Stations (and their Event Detectors, Cameras, and Videos).
Bob Schor
03-04-2024 09:29 AM
Hello i got the Vi´s Done now and want to build the master but im not getting it done right:
This error occures when i put the Ring and run vi inside the loop.
When i put it outside i got the problem that I cannot change the vi.
It did not swap
Any idea how to fix this? Best regards
03-04-2024 09:59 AM
There are multiple things you need to do with subPanels, which may not be shown in your images.
You need to decide how you want your system to run. When you select the VI starts and is inserted into the subPanel, when finished does the subPanel VI close, or does it keep running. Do you want to insert VI's that are always running into the subPanel? All of this will affect how you call your VI's.
03-04-2024 10:05 AM
Hello,
Thanks for the fast reply. I want to start the master Vi from the desktop. After that the Vi selected by the Ring should be visible i the sub panel and be running until i press stop or swap to the other vi with the ring. Both Vis are using similar output and inputs, just wanted to mention if this effects something.
Where do i have to place the Call and Forget mode. Inside or outside the loop? Same with the Remove Vi
03-04-2024 10:27 AM
So Everythig is working except for switching the Vis....
They are both loadinh running and working.
So i need a solution for exchanging them while the programm is running.
I also need to know how to align them to the subpanel automatically. Now i need to use the scroll bar to align them. The vis have the same size as the Subpanel but i dont get it how i can align them automatically. Also any ideas on this? I read the post i marked as solution and i understand the concept but i dont know how i do the last step. One of the Vis is placed very good but i still can use the scrollbar. the other one is misplaced havily.