04-24-2018 10:27 AM
Bob,
I'm having a few errors where the queue will sometimes mess up the order of the signals and route them to different value, is this a common occurrence with using dynamic data with queues? Additionally, why is the DAQ assistant so bad? Wouldn't this be ideal for cases where there are several analog input signals? I've attached a screenshot of my producer and the start of my consumer loop.
04-24-2018 11:19 AM
Apologies the incorrect signal was a loose wire that gave a similar reading to another value, I've fixed that now. But now my program is running great.... Except when I try to record my data... You can visually see when I'm recording and not recording data that the indicators slow down or speed up.. Whenever I'm trying to save my data, I'm getting the original error of everything getting back logged. My producer loop is very fast and I believe a small part of the time, but I guess I'm confused how the queue knows when to tell the producer loop to send another set of data without the producer just constantly running.
04-24-2018 11:58 AM
@Poxford wrote:
Whenever I'm trying to save my data, I'm getting the original error of everything getting back logged. My producer loop is very fast and I believe a small part of the time, but I guess I'm confused how the queue knows when to tell the producer loop to send another set of data without the producer just constantly running.
The Queue doesn't know anything, it is just a "dumb conduit". Again, I haven't seen your code, but you should have created a Queue without specifying a size, which allows it to "grow as needed". Hmm, I don't recall (and it is easier and safer to just ask you here) how fast your Producer Loop runs and how much data it puts on the Queue each time it loops -- clearly if you are trying to put 1MByte of data every millisecond, you're going to have a problem ...
How fast does your Producer Loop run? How big is the Array of Dbl that you are putting on the Queue? Is your Queue of an unbounded size?
The reason for asking these questions is that a Queue can "expand" -- you can have multiple entries on the Queue. In some circumstances, you'll get better performance (because you won't need to constantly allocate memory) if you know, in advance, that (say) no more than 20 items will need to be enqueued, so you Obtain a Queue of fixed length, 20 items, you pre-fill the Queue with 20 items (note if you are using Arrays, fill it with Arrays of the correct size!) to get all the Memory allocated, then Flush the Queue (clearing the memory). Now the Memory is ready for use.
In most instances, one just uses an unbounded Queue, and there's no problem. But you seem to be having a problem. Maybe it's time to post another Zip file with the reworked code, showing the Producer/Consumer design. You do know, I hope, that the Consumer part of the code is in its own While Loop, completely separate (except being "connected" by the Queue coming into both loops) from the Producer, which I recall is embedded in a State Machine ...
Bob Schor
04-24-2018 12:38 PM
Yup that's what I had figured. I've been debugging for a bit and it seems my producer and consumer loops are both finishing in around 100 ms with the consumer loop varying a little below and at a max of 100 ms. So it does appear on average that the consumer loop is finishing faster. I'm not seeing that lag/delay anymore for some reason, but will continue to test. Also yes I do have my consumer loop in an entirely different while loop and the queue I've made has no size so it is able to fill up with whatever is necessary.
04-24-2018 01:59 PM
@Poxford wrote:
I'm not seeing that lag/delay anymore for some reason, but will continue to test
Wow! Does that mean that we've solved your problem? With apologies to Charles Dodgson, "O frabjous day!".
Bob Schor