LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to get the element data type of a Queue from itself?

Solved!
Go to solution

Hi everyone,

 

i have a Q that has a cluster as element data type.

now when i want to enqueue

i'll use bundle-by-name

and for that i'd have to have my data-type present

(long cable from whereever (possibly from where i obtained the Q).

 

my question is,

whether there is a method/property-node/something that allows me to

wire the Queue Refnum into it and receive the element-data-type,

so i can then input into the top of bundle-by-name?

(i really dont want to have that cable all over the place)

 

the reason i ask here is that

the help for the outgoing Queue Refnum from the Obtain Queue method,

shows the element-data-type and so i hope there might be a solution.

 

thx for your time

and cheers

j


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 1 of 30
(4,990 Views)

I don't know of any properties and whatnot.  There are some possible workarounds, but they would not be worth it.  The simplest solution to your problem is to make the cluster a Type Def.  Then you can just use a constant of that type def for your Bundle By Name.


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 2 of 30
(4,969 Views)

thx for the quick reply,

i was hoping there is another way.

 

regards j


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 3 of 30
(4,960 Views)

There is no queue function (property/method/primitive) exposing the data type.

There is, however, a way to get at least the toplevel datatype from your queue.

 

You might have seen that if you create a control or indicator for the queue reference, it has some datatype display in the lower right corner.

Creating a reference to this control/indicator, you can use a property node on that queue reference. Using the property "Element.ClassID" or "Element.ClassName", you get the information about the top-most datatype in the queue (e.g. Numeric, Bool, Cluster).

But as it is only the top-most information, you will not be able to look into e.g. the cluster and check against a cluster type you might want to use.....

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 30
(4,955 Views)

Hm, ok, playing around is fun. Here is something which could help:

GetQueueElementInformation.PNG

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 30
(4,949 Views)
Solution
Accepted by topic author jwscs

Get Queue Status should have an output with the data type (more accurately an array of the data type and an array of clusters if the data is itself an array). If you don't set the return elements input to T, this shouldn't even cost anything.

 

That said, I would agree with the others that making it a typedef is better.


___________________
Try to take over the world!
Message 6 of 30
(4,940 Views)

Hm, my bad not looking at Queue Status before 😞

Was thinking about "dynamic data types" in LV overall and how to handle this. But honestly, it is not worth it as implementation is totally blown out of scope and there is no real use-case for it. Not to speak about runtime performance impact of such implementations.....

 

So bottom line is: Keep data structures as simple and basic as possible and design your application to handle all kind of data structures which will occur.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 7 of 30
(4,934 Views)

If I understand your question correctly, the answer is "Yes, it's very easy ..."

Preview Queue.png

The answer is "Preview Queue".  Here I create a Queue of some mysterious type (it's a cluster having a Thing and a Center, but you don't know that yet).  I take the Queue reference from whereever I can find it and pass it into Preview Queue Element.  I take the output and use it to define my cluster in Bundle by Name.

 

Two caveats.  This copies the first element of the Queue into the cluster, so you probably need to be sure to define all of the elements of your cluster.  But what if the Queue is empty (as mine is, above, as I just Obtained it) -- well, that's why 0 is wired into the TimeOut input, since I do not want to wait "forever" (-1) for the empty Queue to have an element!  Turns out that even in this case, you still get the correct Cluster elements!

 

Neat, huh?

 

Bob Schor

Message 8 of 30
(4,905 Views)

@Bob_Schor wrote:

Two caveats.


Which is why I suggested the get status prim, which doesn't have these caveats and can also avoid the performance issue of making a copy of the first element.


___________________
Try to take over the world!
0 Kudos
Message 9 of 30
(4,860 Views)

tst, that's really clever!  I never thought about using the Get Status "elements" output when I asked it to not return elements, but that seems to work, too.  One of the fun aspects of sticking your neck out in these forums is learning from folks like you ...

 

BS

0 Kudos
Message 10 of 30
(4,850 Views)