LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pass cluster to subVI

 

In my application I need to pass cluster to many different subVIs. What is the best practice for memory allocations.

Data cluster is of strict typedef

1. Pass the reference of the data cluster and use property node and varaint to data?

2. Pass the cluster to subVIs? This needs the data cluster as output terminal also if the data is modified.

 

When using show buffer allocation with both #1 and #2 the allocation seems to be same. What is the best practice to pass data cluster with many elements to subVis and have less memory allocation? Should the data cluster be of strict typedef or typedef, when to use typedef versus strict typedef?

The data cluster is also passed to different threads using queue(reference of data cluster is used).

 

Thanks.

 

0 Kudos
Message 1 of 11
(4,709 Views)

Just pass the cluster data in.  You will always be slower when using property nodes since those force a thread swap to the UI.  Another alternative may be to use a Data Value Reference to pass a reference of the data around instead of the data itself.  This is of course assuming you need everybody to use the same cluster data.


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 2 of 11
(4,705 Views)

Generally we use to have FGV to read and write cluster data. You can read and write to the FGV in the sub vis so that you don't have any memory space used in any of the sub vi.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 3 of 11
(4,701 Views)

Thanks,to pass the data cluster is it better to pass only the elements required by a subVI or the complete cluster to subVIs?

 

Never used data value reference. Looks like if complete cluster is passed to all subVIs then data value reference can be used. Is the new data value reference to be created once at the start of application and then use this reference throuhout by unbundle and bundle functions?

 

0 Kudos
Message 4 of 11
(4,689 Views)

How big is your clsuter? Do you really need to be worried about the memory usage? If you do you might want to use the DVR or FGV suggested earlier. If this is running on a PC and the cluster is not massive just pass it and don't worry about the memory copies. LabVIEW is pretty good at minimzing data copies.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 11
(4,688 Views)

Are there any example to look at for FGV to read and write values of cluster?

Cluster has arrays that grow dynamically until the application is stopped. Hence the cluster data can grow overtime.

Thanks.

0 Kudos
Message 6 of 11
(4,659 Views)

Yes. I am glad to share Ben's Nugget which has the FGV concept inside.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 7 of 11
(4,656 Views)

thanks for the FGV concept. Can FGV be used to pass the data between different loops which are in diferent subVIs?

Main VI has producer-consumer and a parallel DAQ and parallel File VIs.

The cluster data is of complex type (array of cluster which contains more cluster and arrays).

The cluster data can be read and written from any of the threads or loops. 


Reading FGV it seems to sequentially perform based on action. Can the FGV be used to send across loops which can write or read the data?

Thanks.

0 Kudos
Message 8 of 11
(4,630 Views)

Yes you can use it pass data between different loops but be sure about the flow when you use multiple writing otherwise it may endup in race condition.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 9 of 11
(4,626 Views)

No one wants to answer your question about the typedef apparently. Strict typedef is no different then a type def except that the appearance remains the same. Most often, strict type def clusters are used for front panel controls; the programmer wants to force the way the typedef looks in the control editor to be the way it looks everywhere else in the program. From a programming standpoint, it is no different than a regular typedef. It's purely a visual thing.

 

You want to use a typedef or strict typedef when you want all instances of a control to update everywhere if a change is made. You're essentially defining a custom datatype. This is most often done with clusters because with clusters you may add or remove elements as your program changes. If you do this, would you want to go through every subVI updating the cluster! Nope. So you make a typedef and when you add or remove something from the typedef cluster, that change will be propogated everywhere throughout your program. Write one program without using typedefs, and you will quickly understand why they are important. Smiley Wink Does that help clear it up?

Message 10 of 11
(4,617 Views)