02-27-2006 12:51 PM
02-28-2006 08:51 AM
Anthony,
Can one have multiple producer/consumer design patterns in the same application...something like nested for/while loops. Assume I have a producer/consumer design pattern 'A'. Can the consumer 'A' be the producer for another producer/consumer design pattern, let's say 'B'? Also could you explain a little bit more about queue being enumerate and using a case structure in the loop.
02-28-2006 09:39 AM
03-02-2006 08:43 AM
03-03-2006 03:30 AM
03-03-2006 08:19 AM
03-08-2006 08:20 AM
I've looked a bit at the code... First question: Why do you use a seperate producer A and producer B loop? Seems to me that you could combine them into one loop.
Second: From the description of the problem, and your code, it seems that you're creating a racing condition. Your frequency event will be converted into a command on the consumer B queue.. So, it will wait untill that part is ready.
The question is wether you are allowed to change the frequency while the consumer is still busy. If you aren't, then there's two obvious approaches. One is to have the first loop wait untill the consumer is ready. (using a indicator, semaphore or whatever)
More logical would be, to have the first loop continuing reading the file. However, the actual changing of the frequency should be done in the consumer. Thus, the loop that reads the frequencies will put a 'set frequency' command (and it's value) on the queue, followed by the arm command. That way you can synchronize your actions very easily.
03-10-2006 01:51 PM
Anthony,
Here's the modified version of my application. It works perfectly fine right now, except that the following don't function as they are supposed to: when I connect probes or indicators to read from the local variables for distance and frequency, only the first value is read and then they remain constant, although the actual indicators (distance & frequency) update their respective values as their corresponding events are generated. I will need this information as part of a comment statement when I write data to file.
Also, I tried various options for implementing a STOP control for my program including stop value change events in the event structure, but none of them worked. The only way I can stop the program is by clicking the ABORT EXECUTE button, which is not recommended. Any ideas on this front will be great. Finally, if time permits can you look into my code and suggest ways of improving it (code efficiency) and any redundant code that can be eliminated.
Will look forward to your reply.
03-13-2006 08:38 AM
Reading the local variables... You must realize that a property node, local variable, or whatever, only produce data once. If you want to read an indicator multiple times via a property node or local variable, then you need to put them multiple times on the diagram, in the corresponding places. (That could also means that they are in a loop)
An 'update value (signaling)' property node will ONLY cause an 'value changed' event. But it will not cause the 'value out' property nodes that 'belong' to the indicator to do anything. If you want a local variable to be read after such an event, you should place a 'read value' property node within that event.
Do I make sense? Otherwise, try to do what you want in a small test program. When I get stuck, I regulary make such small test program, to see if what I'm doing is at all possible.
As for ending the program. If it doesn't end like it should, I suggest to 'step' through the program, and check wether your comparisons that control the ending of the loops are correct. Probably, there's a +1 or -1 missing somewhere, causing a loop to run forever. Ending the program shouldn't be a big problem.
You might (should!) want to try to clean up the code a little bit, by making more use of sub-vi's. That will also help you to better visualize what your program is doing, and where there are mistakes in the code.
I see that you need many flat sequences to control data flow. Seems that controlling the device is using subvi's without error lines. You might consider encapsuling those vi's by your own, so to simply include an error line. Very simple: use the 'sub-vi with error handling template'; put the device vi into the no-error part; make controls/indicator for the device vi input and output in your subvi. That will clean up the diagram immensly.
03-21-2006 02:42 PM
Anthony,
Can u look into the code now...when the program is run, I am prompting the user for saving data to a file (which is the first task of the program). When the user clicks 'yes', a file dialog box pops-up and the selected path is passed as a local variable to the 'write to measurement file vi'. The problem is this...when this is done another file dialog box pops-up. I am not sure how to resolve this problem.
Also, I could not figure out a way to STOP the program. Checked all the loops and they are working fine. And I did not quite understand the last part of ur previous reply. Will look forward to ur reply.
Thanks!