LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create Queue Reference and Data Value Reference.

Solved!
Go to solution

Hi,

 

I would like to know how to create a queue reference and a data value reference. I know how to create queue using obtain queue. Then gives this queue a name and use enqueue element and dequeue element by using the obtain queue again and giving it the name we first assigned. But what I want is how can i create a queue reference. That is  I did the obtain queue and then i dont have to use the obtain queue again, only once to create it. I got the reference from the obtain queue and I can use it in anywhere in the project by connecting it to enqueue or dequeue. Same thing for DVRs. I want to create a DVR by using the new data value reference and then creating the reference. I only know how to create indicators from obtain queue and new data value reference. Also I tried searching for any online material that will help me learn how to use queues and dvrs as class objects, but I cant find any. If anyone knows any online material, kindly do help me. 

0 Kudos
Message 1 of 8
(6,481 Views)

Hi govind,

 

I know how to create queue using obtain queue. … But what I want is how can i create a queue reference.

So you know how to create a queue (reference), but then you want to learn how to do that???

 

Note: you can obtain several references for the very same queue when you provide the same name for each ObtainQueue instance!

 

(Data value reference need to be transported using wires, here you don't have that name feature… [LV2017])

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(6,470 Views)

that is what I said I know how to use obtain queue again. I have already did a small project like that where in one vi I use obtain queue with a name and connect it to enqueue element and in another vi obtain queue again with same name and use dequeue element. I know this, my doubt is how to use obtain vi only once and then use the reference in different parts of the project meaning different vis. If this is the only way to do it then what is meant by using queues in objects of classes and same with DVRs. I started oop recently, I thought you just create classes and it will work just like that. But I found out by help in these forums that if u branch an object it will create a second object, so to do what i want to do i need to create a reference to the object and everyone advices me to use queues or dvrs etc. The suggested DVRs more, but if I cant access DVRs with name then what good is it. What is what is a control which is a reference maybe queue reference or DVR which I can use anywhere. Is that possible?

0 Kudos
Message 3 of 8
(6,446 Views)

The proper way is to pass the reference into your subVIs that need access to the DVR via the connector pane.


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 4 of 8
(6,434 Views)

The function "Obtain Queue" will output a *reference* to the queue.  If you branch that wire, you might indeed make a copy.  But *what* you make a copy of is the *reference* (which used to be a 32-bit integer and maybe still is).  You are *not* copying or making a separate instance of the queue itself.  You are copying the datatype that's on the wire -- and that data type is a Queue reference.   Making multiple copies of this reference is fine because each one *still refers back* to the one original queue.

 

Same thing with a DVR.  Create it once, and then share access to it by branching (copying) the wire containing a *reference* to the data.  That's what's on the output wire, a *reference* to a data value.

 

Different thing with an object because LabVIEW objects are by-value.  Thus the data on the wire is the object itself, *not* a reference to it.  Branching an object wire will copy the data on the wire, i.e., it will make a distinct copy of the object itself.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 5 of 8
(6,432 Views)
Solution
Accepted by topic author govindsankar

When you drop the Obtain Queue function into your block diagram, you see the 'queue out' output terminal:

Untitled1.png

Right click on 'queue out' and create a control. 

Untitled2.png

You can rename it whatever you want. Then you can include it in a cluster to pass around in a VI to reference the queue.

Message 6 of 8
(6,428 Views)
Solution
Accepted by topic author govindsankar

It seems like you want to be able to just drop a method down anywhere in your code and have it refer to a specific instance of that object, regardless of whether or not the calling code has been passed that object or a reference to that object. If this is the behavior you want, you could initialize a DVR of the object, then store it in a FGV. In your public class methods, you call the FGV to get the DVR reference, then call your actual class method inside the In-Place Element structure. You could also get rid of the DVR and just use an action engine too. 

 

 

Message 7 of 8
(6,426 Views)

"It seems like you want to be able to just drop a method down anywhere in your code and have it refer to a specific instance of that object, regardless of whether or not the calling code has been passed that object or a reference to that object"

 

Exactly this is what I want. Thank you. 

0 Kudos
Message 8 of 8
(6,408 Views)