LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Queue from consumer to producer?

At this time I am not able to post my code, but I have what what I think should be a somewhat simple question about producer /consumer loops. I am going to do my best to explain the how the code needs to work. 

 

I start off with my producer loop, send a queue down to the consumer loop, and am able to pass through and get that to work. Once I complete two of my commands in the consumer loop, I then need to save some data that I am passing, while still continuing with some of the cases in my consumer loop through queues. The user needs to be able to hit a save data button on the front panel. Is it possible for the user to hit the save data button in the consumer loop and continue there with further queues? Or does the save data need to be placed in the producer loop? If that is the case, is it proper to go from producer to consumer to producer back to consumer continuously? I believe my code should work once I get this save data issue figured out.

0 Kudos
Message 1 of 8
(2,700 Views)

Yes.

 

Design/patterns are just a starting point and there are no rules against letting the Consumer handle the button mashing provided issues with creating opening closing files will stall your Consumer to much.

 

You could also introduce yet another process that handle the data log independently.

 

In general I find the more I limit the functionality any single module in an application, the easier it is to support and enhance. If you end up rolling your own architecture, throw an image together and embed it in the diagram of your VI so that you will be able to remember "what was I thinking?"

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 8
(2,685 Views)

I would also put your logging into a separate loop and use another queue for sending messages to it.  This turns more into a Queued Message Handler (QMH).  But the UI loop can send a message to the logging loop to start recording the data (open/create the log file) while the original consumer loop always sends data to the logging loop.  The logging loop will only save the data when there is a valid file reference.


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 3 of 8
(2,680 Views)

Here are small screenshots of my code. I am trying to trigger "Save Data Point" in the event structure in my producer loop from "Wait for Next Step" in the consumer loop. I don't think data logging is my issue (at least not yet). My issue right now is sending a command from the consumer to trigger the event in the producer. Any help would be appreciated. I have tried using notifiers, adjusting the queues... not sure if an FGV would be a necessary option. Any help would be appreciated.

Download All
0 Kudos
Message 4 of 8
(2,651 Views)

Here are small screenshots of my code. I am trying to trigger "Save Data Point" in the event structure in my producer loop from "Wait for Next Step" in the consumer loop. I don't think data logging is my issue (at least not yet). My issue right now is sending a command from the consumer to trigger the event in the producer. Any help would be appreciated. I have tried using notifiers, adjusting the queues... not sure if an FGV would be a necessary option. Any help would be appreciated.

0 Kudos
Message 5 of 8
(2,634 Views)

Why do you need a "Wait For Next Step" state?  The Dequeue does that for you (sleeps until a message is in the queue).  Furthermore, the producer should in no way care about what is in the consumer's queue.  So get rid of that Preview Queue and just send the message.  The consumer will process it when it comes out of the Dequeue Element.


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 6 of 8
(2,642 Views)

Before "wait for next step" I collect data in another state. In "Wait for Next Step", I am enabling a button to click to save the data, but the code to process that data and save it is above in the producer loop. I am trying to process the data in the producer loop coming from the consumer loop. The data is getting stuck in the "Wait for Next Step" state, and is not able to be passed above to the producer loop. By eliminating preview queue, are you saying to use enqueue instead? If I delete the "wait for next step" state, which I realize is not doing much, the consumer doesn't seem to want to pass my data in the way it needs passed.

0 Kudos
Message 7 of 8
(2,626 Views)

As we stated before, make another loop for logging the data.  You should not be passing this data back up to the producer loop except for maybe GUI updates, and use an User Event for that.  In your case, you should just send a message telling the consumer loop to save the data.  It can then pass that data down to a logging loop.

 

And if you really want help, post your VIs.  It is really hard to figure out what you are trying to do with just pictures.


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 8
(2,620 Views)