10-03-2012 07:13 AM
I'm trying to constantly read data from a file every 30 seconds for example. then use the data being read to update all of my indicators and LEDs on my front panel. Is Producer Consumer architecture the best one to use? does anyone have an example to follow?
Solved! Go to Solution.
10-03-2012 07:23 AM
THe Producer/Consumer design pattern is definitely one way to do what you are attempting. Depending on which version of LabVIEW you are using (I only have 2011 installed here to look at) if you start LabVIEW and select "file", "New..." it should display a list of design pattern templates. The one for Producer/Consumer should give you a starting point.
Doing searches of these forums, and the NI site as a whole, will give more insight into the producer/consumer concept.
10-03-2012 07:25 AM
Thanks for your reply.
10-03-2012 07:33 AM
Greetings,
If your goal is to read a file every 30 seconds then update your FP LEDs maybe a state machine is the way to go. That is of course if what I interpretted from your statement is true. You pretty much outlined the necessary states in your post.
State 1: Wait 30 seconds
State 2: Read in File
State 3: Update FP Indicators
I agree with previous post though, a producer/consumer architecture will work. This forum should supply plenty of information regarding them.
Best of luck!
Chazzzmd
10-03-2012 07:35 AM
Thanks also for your reply!
10-03-2012 07:43 AM
One more question i was looking at the producer consumer loop and they are a few different options. With the Producer loop there are while loop with event structure loop, while loop with a case structure, and a while loop by itself. Do I use the option of the while loop by itself to read the data from the excel file or would the case structure option work better in this case?
10-03-2012 07:49 AM - edited 10-03-2012 07:50 AM
Without looking at the actual examples it is hard to say, but it sounds like the "case structure" version of the producer may be a simple state machine. If that is the case, it would probably be the way to go, having a set of "states" : open, file for reading, read data from file, update consumer, wait, repeat ad nauseum until the UI (consumer loop) sends the signal that the process is to stop, then an exit case (state) to nicely close the file and anything else. The file close can also be after exiting the loops, but make sure that upstream errors don't prevent the file close (I'm assuming that the error cluster is being used)
10-03-2012 07:52 AM
Ok Thanks again LV_Pro!
10-04-2012 05:06 PM
Here is an example i tried. Can anyone help? I needed the producer aquire the data from the file and the consumer loop process the data and do the calculations
10-04-2012 05:07 PM
Here is the VI