LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVi needs to accept an array of clusters, clusters can have different size

Hello all,

 

I want to use the same subVi for different projects. The subVi takes data from an array of clusters. Sometimes the cluster contains 2 numbers and one text string sometimes the cluster contains 3 or 4 numbers and a 2 text strings etc.

I did make a testproject. It seems I am able to use the same code to copy clusters of different sizes. So far so good. If I use property nodes I can loop trough the cluster elements. However I am not able to loop trough an array take one cluster, starting at the first row and ending at the latest. And then loop trough the cluster, like a for loop in a for loop. When using property nodes I am not able to loopt trough the array. When I try to copy a cluster I get the data from the latest row I did edit. I can use "IndexVals", this seems to add an offset to the last row I did select e.g if I did change data in row 2 and make the "IndexVals" 1 will get data from row 3. It should be easy right? Could some please tell me how to solve this? I Think I have been missing the point for the last hours.

 

 

 

Its_Me_0-1715868208136.png

 

 

I did ad a screenshot and a zip with the testcode. Hope someone can help me out. Thanx!

 

 

 

 

0 Kudos
Message 1 of 10
(543 Views)

Hi,

 

I hope this would help you.

 

GetDataFromDifferentClusters.png

0 Kudos
Message 2 of 10
(519 Views)

You must set the indices before you read the value, a Property node always goes through the properties from top to bottom.

I did some change and suggestions to your VI.

 

I see Pingu did much of the same changes. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 10
(507 Views)

@~Its_Me~ wrote:

Hello all,

 

I want to use the same subVi for different projects. The subVi takes data from an array of clusters. Sometimes the cluster contains 2 numbers and one text string sometimes the cluster contains 3 or 4 numbers and a 2 text strings etc.


 

Since you seem have a limited number of well defined possible clusters, you could just turn it into a malleable VI.

 

(What are the possibilities? 2, 3 or 4 numeric and 1 or 2 text strings? Can there be any other differences, such as in the datatype?)

0 Kudos
Message 4 of 10
(495 Views)

@altenbach wrote:
, you could just turn it into a malleable VI.

 

(What are the possibilities? 2, 3 or 4 numeric and 1 or 2 text strings? Can there be any other differences, such as in the datatype?)


Here's a quick draft. It will accept arrays of A or B and return empty array otherwise. All you need is a specialization case for each valid cluster typedef.

 

 

altenbach_0-1715878101564.png

 

 

0 Kudos
Message 5 of 10
(479 Views)

You don't need a malleable VI for this, and it can be general. (You should do error checking for unhandled cluster types)

 

Make a subVI whose input is a Variant. @PinguX already did most of the work. Attach your array to the subVI.

 

This is the subVIThis is the subVI

 

Use it with either of your arrays like below

mcduff_0-1715878524297.png

 

0 Kudos
Message 6 of 10
(465 Views)

@mcduff wrote:

You don't need a malleable VI for this, and it can be general.


(Note that the OP posted in LabVIEW 2018, so your 2021 snipped might not be useful)

 

Except that the malleable subVI designed to handle a few well defined typedef clusters is much higher performance, because the adaptation of the inlined vim is done at compile time.

 

While your subVI is more general, it juggles a lot of data into different data structures and does several type detections at runtime. This is significantly more expensive.

 

For a general solution, we should probably switch to OOP here instead.

0 Kudos
Message 7 of 10
(439 Views)

@altenbach wrote:

While your subVI is more general, it juggles a lot of data into different data structures and does several type detections at runtime. This is significantly more expensive.


True. But how many elements is the OP processing to warrant the performance increase over the generality? If the cluster changes names, then the malleable VI needs to be updated. Which costs more, programmer time or CPU time?

 


@altenbach wrote:

For a general solution, we should probably switch to OOP here instead.


Variant parsing, in my opinion, is an extremely useful and somewhat overlooked part of LabVIEW. Not sure if it always needs to be in an object though.

0 Kudos
Message 8 of 10
(424 Views)

Thank you guys, your answer is more than I had hoped for! I get 2 times a valid answer for asking 1 question.

 

Some background

The function will be used to safe a array of settings. The array will never be extremely large if there are 40 rows then its a lot for these tests. When the test runs the test will run for a few hours. There are however 3 testmachines and in the future there will be more. Every testmachine is using a different cluster width. There will also be some other code in the subvi. The main reason for my question was I did not want to change the subvi 3 times. At this time I will use the solution from pinguX.

 

To be honest I did never hear of the malleable VI. Now I do and I can see some situation where I can use it! As you guys describe it depends on the situation which one to choose.

 

There is one other question that pups up, do I need to use a close reference in the subvi? like this:

Its_Me_0-1716301923352.png

 

Thank you all for  the help!

 

0 Kudos
Message 9 of 10
(367 Views)

@~Its_Me~ wrote:

There is one other question that pups up, do I need to use a close reference in the subvi? like this:

Its_Me_0-1716301923352.png

 

Thank you all for  the help!


I do not believe it needs to be closed; but closing it will not harm anything.

 

I suggest you use @pinguX's solution with the modification I suggested. Make a Variant input to the subVI, then you have no references, no boolean, and in the future it will automatically adapt to any new cluster.

Message 10 of 10
(359 Views)