06-24-2014 02:33 PM
I want to be able to start the VI, then be able to start and stop each "video" graph independently, after the VI is initialized. Right now, I just have two while loops run when I start the VI and a seperate event structure nested in another while loop, which gives me access to the other buttons. However, this setup does not allow me to start and stop the "video" graphs whenever or play one, but not the other. Could someone help me?
Any help would be appreciated!
06-24-2014 02:36 PM
I think I would need to see some code to be sure, but is sounds like you are doing too much in your event loop. How are you sending information to your graph loops?
06-24-2014 02:53 PM
At the most basic level, I have three while loops: the first runs one of the graphs, the second runs the other graph, and the third contains the event structure. The event cases allow me to save both of the arrays in the video as text files, to access in Python if we need to analyze something further. The third event case performs a numerical calculation.
To send information to my graphs, I pull an intensity array from each of the cameras, then send that information to the graph. Since that is in a while loop, it just runs until I stop the program.
06-25-2014 03:46 AM
You did not tell anything new in your Message 3 compared to the original Message 1.
As far as I can imaging your three loop and your wish to execute the cameras separately, this calls for case structures in your camera-WHILE-loops. You place the "pull an intensity array" within the CASE structures (case1). Case2 can be outputting and empty array, without stopping the camera. I would avoid stopping the camera(s) (if stopping them happens repeatedly during the program run) -- just to save overhead of starting the camera(s) again.
Any touchable example, please?
06-25-2014 07:11 AM
Do you have any waits on those three loops? are you sharing information between loops?
I suggest that you take a look to this . since what you might need is to run 3 vis in parallels or something like that exchanging information from the controls in a main front panel. you could find this information under Queued message handler state machine
06-25-2014 10:44 AM
@sagittariusA wrote:
At the most basic level, I have three while loops: the first runs one of the graphs, the second runs the other graph, and the third contains the event structure. The event cases allow me to save both of the arrays in the video as text files, to access in Python if we need to analyze something further. The third event case performs a numerical calculation.
To send information to my graphs, I pull an intensity array from each of the cameras, then send that information to the graph. Since that is in a while loop, it just runs until I stop the program.
Here's how I read this:
I do everything except the graphs in the Event Structure loop. That is your problem. You can only be running one event case at a time. So when you go to poll one camera, you can't do anything else until that task is complete.
What you need to do is make additional loops for your camera reads, does some calculations, access Python. You will want a different loop for each interface you have. Your Event Structure then just sends the commands to these loops to do what they need to do. In this way, the Event Structure can just send a command and then send the next command on the next iteration. This should happen fast enough that it will look simultaneous to you.
06-25-2014 01:48 PM
Okay, so here is my code. At start up, I want nothing to happen. Then, when one of the start buttons is pressed, the corresponding graph will run until the stop button is pressed. I want to be able to turn them both on and be able to turn each one of them on and off at my leisure. In addition, I would like the save button for each to work while the graphs are running, which is how it is functioning now. The Python commands don't take any time at all. I had just planned on adding them to the event structure.
06-25-2014 01:58 PM
Learn queues. You will want to use queues to send commands to your loops. So have the first loop wait for a command with the Dequeue Element. If you get the "start" command, have it start running. You should also use a shift register so that you can set the wait for the Dequeue Element to 0. This way it can just keep executing the start command. When you get the "stop" command, you perform your stop task and set your timeout to -1 (wait forever). You should also have an "exit" command that will tell that loop to stop. No need to have a separate stop button for each of your loops when you can send commands to make them stop.
You should have a good look at the Producer/Consumer.
06-25-2014 03:44 PM
Could this also be accomplished by state machines? I am relatively new to LabVIEW, with my previous experience being simple datasaving procedures. I have never see producer/consumer before and just the basics of state machines, so I have no idea where to start.
Thanks!
06-25-2014 04:39 PM
You can make each of the separate loops state machines. But you need to be able to look for commands coming from other locations. Learn the Producer/Consumer. That will teach you how to use queues to send commands.