LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer/Consumer architecture: Optimize Queues

Hi

 

I am using producer/consumer architecture with an event structure. I am using queues. I would like to optimize my work with queues. At the begining my code looks like:

 

Scan4.jpg

After the optimization my code is:

 

Snap3.jpg

 

The application starts normally but I have to push a lot of times my buttons related with the optimized queues to launch the corresponding event. Before this optimization everything was OK. Could somebody help me?

 

Regards

 

 

0 Kudos
Message 1 of 35
(3,440 Views)

That's way too much spagetti. I don't think many people will be interested in digging into that mess.

Since you have an earlier ('unoptimized') version in which "everythin was OK", just go back to that.

Other than that, my suggesttion would be to start over; this time without pasta.

"If you weren't supposed to push it, it wouldn't be a button."
Message 2 of 35
(3,410 Views)

I have to agree with Paul.

 

Looking at both of these images, it's hard to find the willingness to use the word "optimisation" at all.

 

You really need to clean things up, maybe then your problem will be much more apparent to you.

Message 3 of 35
(3,399 Views)

Yes you are right!

 

Therefore I would like to optimize my code. My first step was to optimize my queues. I have started with two of them (Microscope and PositioningStage). At this stage the other queues are not important.

 

Regards 

0 Kudos
Message 4 of 35
(3,382 Views)
The first thing is that you are wanting to use events: a Very Good Thing. However given the difficulty involved in getting events and queues to play nice together, perhaps you need to ask yourself whether you really need the queue operations -- after all, events have queues too.

Also, you need to get past the idea that both loops need to be on the same block diagram. Not only do they not need to be, I have shown that there are a lot of really good reasons for them to not be in the same VI.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 5 of 35
(3,373 Views)

@tiho wrote:

Yes you are right!

 

Therefore I would like to optimize my code. My first step was to optimize my queues. I have started with two of them (Microscope and PositioningStage). At this stage the other queues are not important.

 

Regards 


Your first step should be cleaning up your wires so that you can even see what is going on.

Message 6 of 35
(3,361 Views)

tiho wrote:

Therefore I would like to optimize my code. My first step was to optimize my queues. I have started with two of them (Microscope and PositioningStage). At this stage the other queues are not important.


What do you mean here by "optimize"? What are you optimizing for - performance, usability, readability, something else?

0 Kudos
Message 7 of 35
(3,327 Views)

I'm confused by your Block Diagram.  You seem to have 4 Queues

Message 8 of 35
(3,289 Views)

I'm confused by your Block Diagram.  You seem to have 4 Queues, and in the Event structure, you put something on each of them.  That seems strange (but, then, I don't know what you are trying to do).  I've (almost) never written a loop with multiple error lines coming in to it; either there is an Error when you enter the loop or there is not!  If you want to do several things in parallel, each on its own Error line, you can branch the single Error In, and collect them with Merge Errors so that you have a single Error line going out.  [If you are concerned that you won't know "who caused the error", the Error Message usually gives you a clue, and you can also put a Simple Error Handler inside, if you are nervous).

 

I also notice that your Queues seem to come out of the Enqueue loop.  Why?  The only reason I bring mine out is to immediately wire them to Release Queue (because if I exit the Enqueuing loop, I'm probably done with the Queue).

 

Someone else asked what you meant by "optimize".  When I look at your two examples, it looks like the "optimized" Queue just has additional Stuff inside it.  Care to explain?

 

Bob Schor

 

P.S. -- I suggest about writing a short essay called "This is What I Want to Do -- are Queues Helpful in this Context?".  If we know what you are trying to accomplish, I'm sure you can get helpful "design" suggestions.

Message 9 of 35
(3,284 Views)

Thank you for your answer. I 

Yes, I have 4 queues. Each of them is related with a different hardware control device (camera, manipulator, microscope, positioning stage, image processing). I have corrected the error line and now I have a single error line going out from the loop (the screenshot below). My Queues come out of the enqueue loop because they wire to Release Queue. I have a lot of wires comming out of my queues. I would like to reduce them (queues lines). Therefore I think that I have to bundle them in a cluster. 

Snap5.jpg

 

0 Kudos
Message 10 of 35
(3,248 Views)