LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I instantiate data?

Hi guys,

I have created a set of components for managing a communications connection and its protocol.  I have a structure that stores information for a connection, which I have to pass in and out of each component.  This structure include buffers, which are changed continuously and have to be fast.

I would like to avoid using this method of feeding a local connection information variable on through the program, as everything will go wrong if I forget shift registers, access the connection in parallel or such.  I would like to use something like the queue "references" instead.  I created a class with all the comms components, which use the class datatype to store the connection information (my first class).  This did not help as I still had to circulate the class through the program, unlike the queues.  One option is to have a registry that stores all the connection information (as array of (connection information) ) and keep only the reference into the registry in the class datatype, but I reckon this would be rather slow, inefficient and unnecessarily complex.  Alternatively I could store the connection information as a class global, but then the data is shared by all instances of the class.

Another option would be to dynamically create an instance of the connection information and store a reference to it in the class datatype.  Is there a way of instantiating data dynamically and getting a reference to it?

Does anyone know how the queues are programmed or of any efficient way of doing what I want to do?

Thanks
Christie
0 Kudos
Message 1 of 5
(2,810 Views)
Hi Christie,
 
Are you using LabVIEW? If yes, you can either use queues or notifiers depending on your application. Launch LabVIEW and Choose
 
New>>More>> VI >> From Template>> Frameworks>>Design Patterns
 
and look at the Master/Slave and the Producer/Consumer Design Pattern.
 
If you are not using LabVIEW , what software are you using?
 
KostasB
 
NIUK Applications Engineering 
Message 2 of 5
(2,778 Views)
Hi.

Yes, I use Labview 8.5.  I have considered using queues or notifiers, but I don't believe they are the right solution.  If I read, unbundle, modify, bundle and write back to the queue/notifier, I imagine that Labview will replace the entire cluster, where I only wanted to change a few bytes in a few kilobyte cluster.  Ideally I want to get references to the cluster directly, to optimize efficiency, but I want to be able to create any number of clusters and their references dynamically.

Christie
0 Kudos
Message 3 of 5
(2,765 Views)

Can you predetermine an upper bound on the number of clusters you are going to need? If yes, you can initialise an array of clusters and then use the Replace Array Subset which is a very efficient function and LabVIEW

will not replace all the clusters within the array. You can then use notifiers to make the data global, you just need to make sure that you can process the data at the rate it is produced, otherwise you may need to use queues.

You could potentially use local variables instead of notifiers but you need to protect your code from race conditions, possibly by using semaphores.

KostasB

NIUK Applications Engineering

 



Message Edited by KostasB on 05-23-2008 04:34 AM
Message 4 of 5
(2,742 Views)
Thanks

I'll see if it solves my problem.
0 Kudos
Message 5 of 5
(2,710 Views)