08-06-2018 09:19 AM
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.
08-06-2018 09:59 AM
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
08-06-2018 10:22 AM
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.
08-07-2018 07:43 AM
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.
08-07-2018 07:43 AM
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.
08-07-2018 08:43 AM
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.
08-07-2018 01:08 PM
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.
08-07-2018 01:38 PM
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.