From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

connector reference without types defined

Hi

 

  I want to build a subVI that contains an Enqueue function to adapt any kind of Queues. However to make that I need to make a control to the Enqueue function and then link the control in the connector pane, so that I can call this VI and feed the real queue I want to call into this subVI. 

 

  My problem is I want not to define the type of data the queue contains in the stage of this subVI since I want this subVI to be adapting to data type I feed into it. Is it impossible to do that?

 

  Actually I want to make my own version of Enqueue, Obtain queue and dequeue so that i can easily manage all the queues used in my program.

 

Thanks,

Raymond

0 Kudos
Message 1 of 11
(2,870 Views)
You can't easily do exactly what you want. Say a bit more of what it is that you are trying to accomplish. Why do you need your own version of the queue functions?
Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
0 Kudos
Message 2 of 11
(2,863 Views)

Hi Mike,

 

  It looks to me impossible to do. I wish every time I obtain a queue I can record the name of queue, time I obtain it, the ref. of that queue so that I can manage them at any time. Also it would be easy for me to build some codes to easily monitor how many elements are in each queue, and is it easy for me to kill any queue I need to, and I can record the time I enqueue an element or when I dequeue an element.

 

  Since I am largely using queue to pass information from vi to vi so it would be better for me build up some tools to manage that.

 

  So far I find queue very useful to pass data within a project, However ref. of queue cause memory and can be obtained new ones for unlimited times, though I can manage to avoid the problem but sometimes it's easier to deal with it with some well established tools, when I am building up a large program.

 

  I tried to build up a tables that store all names of my queue, however only names are not enough-- I need the type also to obtain back that queue, and it's not trival to me to build up a table I can store all the types I may use. 

 

Raymond

0 Kudos
Message 3 of 11
(2,860 Views)

It seems like you should be able to do what you want by passing the names of the queues to the subVIs.  If you read the detailed help for Obtain Queue, it points out the a new reference to the same queue is created each time it is called and that Release Queue needs to be called to avoid a memory leak.  You need to make sure that the names are unique and that you know when queues have been created and destroyed, but that kind of bookeeping is probably necessary for a program like yours anyway.

 

I would recommend arranging your program so that the creation of queues is handled in one place and make sure that the creation takes place before any parallel calls to Obtain/Dequeue/Release can occur.

 

Lynn

0 Kudos
Message 4 of 11
(2,849 Views)

Hi Lynn,

 

  The obtain queue requires me to input the data type as well. It would be much easier if all I need to keep is the name, then I can establish an array to put all names in. However if I need to put also the data type, I have to define cluster that contain every queue's data type prototype, which is still do-able, but less simple as only the names which are always strings. If I can make data type into things like a number and then convert back to data type easily, that might be a way out, however I have never succeeded.

 

Raymond

0 Kudos
Message 5 of 11
(2,837 Views)

That'd also be easier for me to handle errors related to queue.

0 Kudos
Message 6 of 11
(2,836 Views)

OK.  I had not noticed that the element data type is a required input on Obtain Queue.

 

That seems rather strange given that dropping a second Obtain Queue with the same name on the diagram produces a reference output which knows the datatype for the named queue!  If the named queue exists and the "create if not found" input is wired to a False constant, the data type input should not be required.

 

Perhaps someone from NI R&D can explain why?  The documentation should also be clarified to make it clear that what you were trying to do won't work.

 

Lynn

0 Kudos
Message 7 of 11
(2,832 Views)

Forgot to attach image.

 

Lynn

 

Obtain named queue.png

0 Kudos
Message 8 of 11
(2,830 Views)

I agree with you.. Obviously the Obtain queue checks the data type with the queue's name provided.

0 Kudos
Message 9 of 11
(2,827 Views)

johnsold wrote:

...dropping a second Obtain Queue with the same name on the diagram produces a reference output which knows the datatype for the named queue!


That is probably an accident and something no one touched BECAUSE the data type is required, so it doesn't matter that this happens.

 

Examples where this would break if you didn't have to wire in the data type:

 

  1. If the name input is not a constant.
  2. If the queue reference is obtained in a dynamic VI. It's not in memory at edit time, so you can't analyze it to determine the data type.

 

As for the original request, vote for this idea to have this implemented at some point - http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Provide-a-better-way-to-implement-a-polymorphic-VI/idi...  and look at this - http://forums.ni.com/t5/LabVIEW-Developers-Feature/Now-available-for-download-quot-Randomize-1D-Arra...

 

 

You could also try creating wrappers if you only have a few data types or you could try using the desktop execution trace toolkit which I believe should show this info, but I don't think it will allow you to create orderly debug logs, just to see what's happening now.


___________________
Try to take over the world!
0 Kudos
Message 10 of 11
(2,816 Views)