11-24-2012 06:19 AM
Hi everyone,
I am trying to use producer/consumer architecture where the producer loop reads the data in from my DAQ device and where multple consumer loops analyse and/or display the data, and write the data to file... The vi has a number of FP controls that are used to start/stop DAQ, start/stop write to file, modify graph settings (e.g. x-axis length, etc), change file paths, trigger AO commands, add/remove arrays, etc... I would like to put all FP controls into an event stucture and have this as a separate "UI loop"... However, I am nor sure to to send these commands to the appropriate loop, or have the appropriate case structure in the loop, for example, execute... I would assume that a queue or notifer would need to be needed..?
Can anyone possibly help?
Regards,
Jack
11-24-2012 07:17 AM - edited 11-24-2012 07:19 AM
Hi Mr Brewe,
Thanks for the reply... I am capable of writing the execuion code using queues and the multiple, parallel while loops... I am basically trying to avoid all the "polling" from the FP controls... I probably should have just said this in my original post...
So my main question is related to the most appropriate basic design pattern to use in this instance, and perhaps a very simple example of how the queues or notifers (never used notifiers as I don't want to run the risk of data loss; as some control changes are written to file) can be used to send data from an Event Structure in one loop to numerous other parallel loops..
In the past I have received must more detailed assistance from the forum community... Hopefully, some members can help again...?
Regards,
Jack
11-24-2012 07:23 AM - edited 11-24-2012 07:25 AM
I'm not sure his answer was really serious. At least his other 4 posts, all in the last hour or so, are somewhat unrelated to the actual topic with sometimes quite a hostile tone. Maybe a spammer trying to get past a certain post limit to end up spamming the board with pill messages once his account has accumulated enough posts to not trigger the newbie spam alert when posting several messages in short order.
11-24-2012 08:23 AM
I have attached a vi that I have started coding that demonstrates my problem... I have used to STOP button and the READ button as the example.
Thanks,
Jack
11-24-2012 09:09 AM
@rolfk wrote:
I'm not sure his answer was really serious. At least his other 4 posts, all in the last hour or so, are somewhat unrelated to the actual topic with sometimes quite a hostile tone. Maybe a spammer trying to get past a certain post limit to end up spamming the board with pill messages once his account has accumulated enough posts to not trigger the newbie spam alert when posting several messages in short order.
hmmmm...... sorry for the hijack?
back to the matter...you can control each individual process using the event structure, but you use a dedicated queue operation for each loop to communicate the data .
11-24-2012 10:18 AM
Jack,
The Producer/Consumer architecture is probably a good starting point. You will also want to learn about State Machines.
Follow apok's suggestion of separate queues for each loop pair which needs to communicate. Suppose you have UI loop, DAQ loop, file loop, and signal processing loop. You might then have queues for UI -> DAQ, UI -> File, UI to Signal, DAQ -> UI, DAQ -> Signal, and Signal -> File. Dependign on how you decide to stop all the loops, you might have additional queues or notifiers. In Multi-loop systems I prefer to send a stop command (usually via the UI -> xxx queue) and then a Status = Stopped message by the return queue. The master loop only stops after it has received "Stopped" status messages from all the other loops.
Remember that it is OK to write (enqueue) to a queue in more than one place but generally you should only dequeue or read in one place.
All the DAQ configuration stuff in your VI would go into an intialization state inside the DAQ loop and the Stop and Clear Task VIs would go into the shutdown state in that loop. I think Clear Task will stop the task so it is not necessary to use both together. Check the help to be sure.
Lynn
11-24-2012 02:12 PM
11-24-2012 02:48 PM
Jack,
I am not sure I understand your question.
Let's talk about two loops, the UI loop and a File loop. The commands might include Open <file path>, Write <data>, Read, Close, and Shutdown. Note that some of the commands include additional information shown as < >. What I do for this situation is to create a typedefed enum for the commands. The datatype for the queue is a cluster containing the enum and one or more data controls. You can use a variant and only have one or you could have a path control and an array of numeric for the data. When the File loop dequeues the cluster, unbundle the enum and use it to select a case froma case structure. Each case processes a different command and can use different data as needed.
Does that begin to answer the question you were asking?
Lynn
11-24-2012 02:55 PM
11-24-2012 08:20 PM - edited 11-24-2012 08:24 PM
here's an example and by no means a standard practice, just for sh+ts and giggles..