LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I send commands from a single UI loop to different while loops?

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

0 Kudos
Message 1 of 29
(3,306 Views)

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

0 Kudos
Message 2 of 29
(3,292 Views)

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.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 29
(3,289 Views)

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

0 Kudos
Message 4 of 29
(3,281 Views)

@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......Smiley Indifferent 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 .

0 Kudos
Message 5 of 29
(3,272 Views)

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

0 Kudos
Message 6 of 29
(3,260 Views)
Hi Lyn,

Thanks for the reply.... If I use a separate queue between the UI and each loop, how are different commands sent to the same loop distinguished when they both come from the same dequeue? Or does individual command needs its own queue?

Thanks,
Jack
0 Kudos
Message 7 of 29
(3,248 Views)

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

0 Kudos
Message 8 of 29
(3,240 Views)
User events can also give a one to many architecture without managing all the queues yourself. I would look into those also.
0 Kudos
Message 9 of 29
(3,236 Views)

here's an example and by no means a standard practice, just for sh+ts and giggles..

Spoiler
queue.png
0 Kudos
Message 10 of 29
(3,225 Views)