LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer Consumer Loop with Notifiers

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?

0 Kudos
Message 1 of 12
(3,432 Views)

*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?

 

 

 

Certified LabVIEW Architect
Certified Professional Instructor
0 Kudos
Message 2 of 12
(3,423 Views)

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

Certified LabVIEW Architect
Certified Professional Instructor
0 Kudos
Message 3 of 12
(3,422 Views)

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.

0 Kudos
Message 4 of 12
(3,418 Views)

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.

0 Kudos
Message 5 of 12
(3,416 Views)

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?

Certified LabVIEW Architect
Certified Professional Instructor
0 Kudos
Message 6 of 12
(3,413 Views)
Yes not exactly sure how often i will choose for the time to be updated. But everytime the labview program reads i would like for it to have the most updated data... It may or may not have a time stamp. But i think the work around is that it may over write the last data so its the only data in the file to be read... As far as calculations im not exact sure of how long each would take but i figure if u. It reads from the file every 30 second to a min. That should be enough time to get every calculation that needs to be done...
0 Kudos
Message 7 of 12
(3,381 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 12
(3,364 Views)

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?

Certified LabVIEW Architect
Certified Professional Instructor
0 Kudos
Message 9 of 12
(3,337 Views)
Yes the file may update every second for example but labview may be set to read every 30 seconds for example but everytime labview reads i need calculations to be preformed
0 Kudos
Message 10 of 12
(3,316 Views)