LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic creation of LV2 global

Hello,
 
I have searched the forums for this particular topic, and although there is a lot of info on multithreading, reentrant vis, and LV2 globals, I can't seem to find the answer I'm looking for (yet :).
 
I am using an LV2 global to implement a message queue in order to manage the flow of serial communications to DUT.  It works great so far; now I want to implement this concept with multiple DUTs in parallel, each with it's own message queue.  Can this be done without hardcoding separate LV2 globals for each device (E.g. DUT1 -> Queue1.vi, DUT2 -> Queue2.vi, ...)?  Instead, I would like to dynamically create a new queue (LV2 global) for each DUT.
 
Any help would be appreciated.
0 Kudos
Message 1 of 19
(3,754 Views)
When you say you have a message queue, are you actually using a queue object or is this your own custom implementation, like a string array, or something?

You could get away with just modifying your functional global to work on an array of queues, with an element for each of your DUTs. When you need to access a queue, you just need to specify which index you want, which corresponds to which DUT you want.

Another approach is to go object-oriented, and implement your message queue as a class. Then, you instantiate an object of that class for each of your DUTs.

Depends on your skill level and how robust/long-term/level of work you want.


Message 2 of 19
(3,733 Views)
Thanks for the quick reply.  I'm using the LabVIEW queue object.  I've thought about using an array with index that corresponds to DUT, but I need the separate DUT processes to be independent of one another.  E.g. if I have 8 DUTs all accessing the same LV2 global, that becomes a bottleneck.  I'm not sure what you mean by 'going object-oriented'...  It would certainly be an option, but I'm sticking to a pure LabVIEW solution.  I'd prefer to stick with the design I already have, whether it is to hardcode separate LV2 globals or a more elegant solution of dynamically creating the LV2 globals if this is possible.
0 Kudos
Message 3 of 19
(3,728 Views)

I have used a number of different methods of dynamically creating LV2's but before I get into the details of those or mention scripting (oops), have you concidered using named queues to pass the data?

Have each of your cloned widgets interact with a queues based on their name.

That way the widgets each get their own queue and the controlling software can open up reference to as many queues as required.

Trying to help,

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 19
(3,713 Views)
Clearly, you have two separate requirements for your application: (1) implement a message queue for 8 DUTs, and (2) don't implement the message queue to create a bottleneck. Yes, it would be a bit of a bottleneck having a single functional global, whether you implement an array or named queues, since all 8 DUTs would need to access the same functional global, and whether or not that's an issue only you can really answer. However, my inkling based on your statements is that this is not acceptable to you. The object-oriented approach can be a pure LabVIEW solution. Your application actually has object-oriented written all over it. It seems, though, that you're not familiar with object-oriented design, so perhaps you don't really want to jump into that lake for this app. Given that, you can dynamically create LV2 globals. If you wish to pursue the dynamic creation of LV2 globals perhaps Ben may have some VIs he can upload to give you a start. Note that this involves scripting, as Ben mentioned, and whether or not that's more complicated than an object-oriented approach for you - I can't say for sure without knowing your level of expertise.
Message 5 of 19
(3,704 Views)
Yes, I like the idea of using named queues as an alternative to multiple copies of LV2 globals...  Thanks for the suggestion.  I still would be interested in how to dynamically create LV2 globals, if you have a link...  Thanks. 
0 Kudos
Message 6 of 19
(3,696 Views)

smercurio_fc - thanks for your reply also.  To answer your question, I have experience with object oriented design in a few languages, including VB, VC++, perl, php, java...  Could you give me a quick idea of how you would approach this in LabVIEW?  Very high level, please - I don't want to waste your time in the details... 😉 

0 Kudos
Message 7 of 19
(3,690 Views)
Sorry, don't mean to keep spamming you with short responses...  I think the named queue and the single functional global are two different animals.  I believe if I create multiple named queues, they can be accessed independently, e.g. DUT1/Queue1 are independent of DUT2/Queue2 such that DUT1 accessing Queue1 won't have to wait on DUT2 accessing Queue2 (maybe at the OS level, but not at the application level).  With the functional global approach, only one DUT can access it's Queue at a given instant, during which time no other DUT would have access... If I understand correctly.
0 Kudos
Message 8 of 19
(3,688 Views)

For scripting see the LAVA forum

http://forums.lavag.org/index.php?showforum=29

For a non-scripting approach you can do it with dynamic calls and stategic saving. The following is an outline.

0) The DUT tets should be called dynamically

1) Open the top level DUT VI then oen a ref to the LV2

2) Save the LV2 as a unique name

3) Save the top level DUT VI and all of the callers from the bottom up.

Note at this point the DUT VI has unique name and is linked to the new name of the LV2.

4) Repeat 1-3 for each DUT test.

5) load all of the saved DUT VI's dynamically.

Note: Since each DUT VI was saved pointing at a unique name LV2 they will not share LV2's

6) In the main app open each of the LV2's and use a call by reference nodes to interact in the same way you would use the normal LV2.

No scripitng involved.

I would still urge the named queue appraoch.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 9 of 19
(3,687 Views)
Thanks for the info, Ben.  This is along the lines of what I was thinking for the 'hardcode LV2' approach.  I'm already off an running with the named queue approach - much simpler and seems to me more scale-able.
0 Kudos
Message 10 of 19
(3,674 Views)