02-23-2017 02:34 PM
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?
Solved! Go to Solution.
02-23-2017 02:46 PM
Sounds like a state machine architecture.
02-23-2017 02:50 PM
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?
02-23-2017 03:00 PM
@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?
02-23-2017 03:16 PM
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).
02-23-2017 03:39 PM
Just wire a case structure into your tab control in a loop.
02-23-2017 03:44 PM
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.
02-23-2017 04:23 PM
@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?