From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple queues management

Solved!
Go to solution

Hello!

 

I am an student and I am making project that requires me to go beyound 2 loops.

I want to make architecture that will allow to comunicate each loop to each without hard modifications.

I am wondering how to make code clean without queue references wires messing around and going from one loop to another.

 

- My first Idea was to remove all queue wires and connect to queue by its name like in frame 3:

 

1.jpg

 

But Desktop trace execution Toolkit shows that I have memory leak. Documentation says that new queue ref is created when I obtain queue that exists and adresses shows that is true.

 

 

 

-My secound Idea was to use variant atribute and global variable and create functions that will allow me to create, exit , enq and dequeue from whom and whenever I want. Schematic idea looks like this

 

create

2.jpg

enq

4.jpg

deq

3.jpg

exit

5.jpg

 

This time I didn't have leaks so may I assume this is correct way?

But people always tell to avoid global variables so I am not sure.

 

 

-My third idea was to bundle all queues into cluster and then bundle and unbundle by name whenever I want, There is openG function that allows me to get value from cluster by name so if I name queues it should be easy to do. So I will only have 1 wire for cluster and 1 wire for error for each loop. In this case data flow is keept because all stays with cluster.

 

-My forth ide was to create functional global to store all queues but it didn;t worked at all 🙂

 

If someone has done that before please give me a hint 🙂

Best regards

pawhan11

0 Kudos
Message 1 of 11
(3,907 Views)

Look at the Master/slave pattern (file/new/templates/master...), that's basically how it should be done.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 11
(3,892 Views)

But it is based on notifiers and It only allows to comunicate from master to multiple slaves at the same time...

Or am I looking at wrong example?

0 Kudos
Message 3 of 11
(3,887 Views)

That sounds like the wrong exaple. 🙂 It should be an event driven producer and a queue-consumer.

Your example ofc has a memory leak since you dont release the queue.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 11
(3,884 Views)

If this is example (only one that has events) you mention I don't know how it relates. Please explain and be patient if You can 🙂

 

7.jpg

 

It only allows me to talk from prod to consumer. I can create UE or another queue to talk backwards but thats ont my point. When I have many loops I have many queue wires comming from one loop to another and I want them gone. And Question is how to pass queues qithout wires without making memory leaks.

 

Best Regards 

pawhan11

 

0 Kudos
Message 5 of 11
(3,870 Views)

Ah. Hiding wires shouldn't be needed, and the general way of doing it is clumping them up in clusters. In this case we can solve both with an Action Engine.

Create an AE with a cluster of queues, then you need 3 states, Init, Get, Close.  (and error in and out)

In init create your queues and store the ref.

Get ofc gets the queues.

Close closes all queues.

 

Then it should be pretty self explainatory, Init at start of program, Get the queues inside loops, Close all when exiting.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 11
(3,860 Views)

I do this all the time with Action Engine.  You will want an Init, Send, and Close case.  My suggestion is initialize right before the loop that will do the reading.  Pass the queue reference out of the Action Engine to go to the Dequeue Element inside of the loop.  I have found it best to have a different Action Engine for each queue.  Now another thread can send a message to the reading loop by calling the Send case of the Action Engine.  Perform the close once the reading loop is complete.


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 7 of 11
(3,848 Views)

Sounds nice but I will have to create engine to handle 1 queue,

Can I create 1 engine that will handle many queues? 

Thanks for this nugget 🙂

 

Now I am thinking about wiring all queues into cluster like that:

2013-09-10 18-02-26.jpg

So I can easy dequeue from whom I want and enqueue to who I want

0 Kudos
Message 8 of 11
(3,838 Views)
Solution
Accepted by topic author pawhan11

@pawhan11 wrote:

Sounds nice but I will have to create engine to handle 1 queue,

Can I create 1 engine that will handle many queues?


You can.  My experience says that isn't a good idea.  You will have to manage data types, making sure the right queue is written to, and managing the cluster of queue references.

 

What I did was I made a template for the queue action engine.  I have a separate enum type def to manage the cases for the action engine.  Every engine you make should use that type def.  By making the template, you can quickly make new action engines by simply chaning the data type that is used.


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
Message 9 of 11
(3,831 Views)

Thanks.

It is solved now 🙂

0 Kudos
Message 10 of 11
(3,797 Views)