11-01-2012 10:17 PM
I attached a Producer Consumer example that reads from a file and pass the 2 D array down to the consumer loop. I need help with notifiers. I never used them before. When my producer loop reads in my data from a file and passes it to the consumer loop. I need to implement Notifiers to notify the data is available and i can proform a my calculations. Can someone help me modify this example?
11-01-2012 11:24 PM
*E*,
There are a few things.
1. I dont mean to be a stickler, but the producer/consumer design patter uses queues instead of notifiers.
2. Im wondering why you are reading the file every iteration in the top loop? That case never goes to false since you have wired the boolean value from the tunnel. (Since while loops reads the tunnel once before the loop runs and since that value is true, that value will always be true every iteration).
3.Also why are you using the all rows local variable instead of wiring directly? That is a possible race condition as you have no control whenever that local variable is read.
4. Additionally, I dont see how your consumer loop stops since it always will be in the "Acquire State".
Can you give me some more information what this application is supposed to do, so I can provide some more help?
11-01-2012 11:26 PM
Ideally you would want to read the file just once. But does the file change? May I ask why did you decide to use the producer/consumer design pattern?
Im not asking these questions to be condescending, Im just asking questions because Im always curious about design decisions
11-01-2012 11:53 PM
Thanks for the reply. Yes i know it uses queues instead of notifiers but i was trying to say is it a either or case meaning do i use queues or notifiers or can i add in notifier to this loop to notify me when it reads in the data. Breaking it down reading each number seperately was just something i added in to try to undertstand it a little more.
11-01-2012 11:56 PM
Thanks for the reply. A 3rd party program is constantly writing to the file that the labview program is trying to read. So there will always be new data every __ amount of seconds and labview is going to read the data in all at once then pass it down to the consumer loop. then i would like to have some type of notification system or maybe time stamp to let me know when the data has been updated and i have new data to do my calculation with.
11-02-2012 12:03 AM
Ok, Im able to put the pieces together now. To be honest, I personally do not like the producer/consumer design pattern. I used to be in love with it, and used it in all of my applications. Then the pain (trying to synchronize data and timing, etc between them) started and I ran away from them.....sad but happy day. However, if you want to use it I can still guide you.
You say the data in the file changes every _ seconds, is the data timestamped? Also how long do the calculations take?
11-02-2012 05:54 AM
11-02-2012 07:33 AM - edited 11-02-2012 07:34 AM
You could probably just use the File/Directory Info function to see if and when the file was last modified. You can then read the file and pass the data on only when the file was updated.
11-02-2012 10:48 AM
Ok. Im just trying to figure out if you need to perform calculatations on every single time the file gets updated, or is it "okay" to miss an update?
11-02-2012 03:59 PM