LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tab Control: How to run program only when a specific Page is selected?

Solved!
Go to solution

So I have a Tab Control of about 8 pages. Each page has some specific code that goes along with it. On one page an array is read and a picture is displayed based upon what is found inside one of its elements. On another page it's just a basic slideshow that continually runs. On another there are more pictures that are shown based on data inside an array. Each page of 8 has something like that on it. 

 

But when I run the program, it runs slow. I asked a colleague about it and he says I have too much running at once. We checked out the Task Manager and confirmed by one program was taking up all the processing speed. 

 

So I was thinking of accomplishing this by wait of the Wait function, but that doesn't seem to do the job. The program still runs, but at intervals now. I want there to be no running code except the one for the specific page that has been selected. Any ideas?

0 Kudos
Message 1 of 8
(3,963 Views)

Sounds like a state machine architecture.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 8
(3,948 Views)

I thought things had to be one at a time for State Machines? I mean, I know that's the point, but how could that be implemented with a Tab Control?

0 Kudos
Message 3 of 8
(3,944 Views)

@ShogunOrta wrote:

I want there to be no running code except the one for the specific page that has been selected. Any ideas?


Isn't that what you asked for in your original post, one page at a time?  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 8
(3,942 Views)
Solution
Accepted by topic author ShogunOrta

I should be clear.  There is no code associated with the tab.  The tab control is a container object used to group items together on your front panel.  You have to define the block of code that gets executed when the tab control changes values. 

 

If tab control value equals Page 1, go to this state and execute.

If tab control value equals Page 2, go to this state and execute. 

 

You could also use subpanels if you are so inclined.  Each page (and its associated code) would be moved to its own separate VI, and you would load the respective VI into a sub-panel and run it.  I wouldn't necessarily mix this idea with a tab control, because you only need one sub-panel (not eight). 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 5 of 8
(3,935 Views)

Just wire a case structure into your tab control in a loop.

Tab Loop.png

0 Kudos
Message 6 of 8
(3,925 Views)

Ah, well as with the Tab Control the user can randomly select which Page they want to view. So it's not Page 1 then Page 2 then Page 3, etc. It could be Page 1 then Page 8 then Page 3 then Page 4, etc. But hey, if the State Machine can handle that, I'll definitely look into it.

0 Kudos
Message 7 of 8
(3,921 Views)

@ShogunOrta wrote:

 

But when I run the program, it runs slow. I asked a colleague about it and he says I have too much running at once. We checked out the Task Manager and confirmed by one program was taking up all the processing speed. 

 


I think you are looking in the wrong place. If code runs slow, uses all CPU, or causes a sluggish UI, it is not well written. Can you show us a simplified version of your code so we can give more specific advice? What is your current code architecture?

 

What is a "basic slideshow". Are the image sizes optimized for the display area. What are you using to display the images? What is the display rate? are the images constantly read from the disk or kept in memory? What is happening on the other tabs?

 

 

 

 

0 Kudos
Message 8 of 8
(3,906 Views)