LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to multiply a cluster and all actions connected to it

Solved!
Go to solution
Highlighted

Hello to everyone.

 

As a n00bie, I have a question for you.

I have created a cluster and I have all the manipulation that is done via this cluster.

Now, I'd like to have 8 clusters with their own manipulation. How can I do that?

 

I also attached some pictures below:

BalajO_0-1603440437009.png

BalajO_1-1603440483777.png

 

Actually what am I looking for is to get the cluster name dynamic some how, so that I can save everything in a subVI and then use that subVI 8 times. Is that possible?

 

Best of all,

Ovidiu

 

0 Kudos
Message 1 of 13
(361 Views)
Highlighted

One possibility is to work with references. As an example, the code below acts on cluster Parametri or Parametri 2 depending on which reference is wired to the property nodes.

 

example.png

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 2 of 13
(353 Views)
Highlighted

Hi,

 

This is an option I could use if I had to work only with one at a time, but I'd like to work with all 8 in parallel 🙂

0 Kudos
Message 3 of 13
(344 Views)
Highlighted

Hello!

 

@BalajO wrote:

Hello to everyone.

 

As a n00bie, I have a question for you.

I have created a cluster and I have all the manipulation that is done via this cluster.

Now, I'd like to have 8 clusters with their own manipulation. How can I do that?

Is there a reason why You cannot just use an array of these clusters?

 

Actually what am I looking for is to get the cluster name dynamic some how, so that I can save everything in a subVI and then use that subVI 8 times. Is that possible?

 

Best of all,

Ovidiu

 


You can get the cluster name by first casting it to a variant and then using Get Type Information.However, I would advise against using eight instances of the same thing and handling them according to their variable name. Depending on what You want to do with those clusters, there might be solutions that are easier to modify later on - e.g. an array of clusters. What do You plan on doing with the cluster name once You have it?

Message 4 of 13
(338 Views)
Highlighted

Hi there,

 

Yes, cluster arrays seems a good idea, and I tried it.

The problem is that I have to write (bundle) and read (unbundle) different information in a while, depending on the action for each of the 8. Some will read, others will write and others will do nothing. I implemented everything I need to do with 1 cluster that I made typedef.

I am trying to implement it as general and customizable as possible.

 

Could you show me how do I unbundle and bundle a cluster from an array of clusters so that I can read/write info? If I can do this, I think I'll be able to create that subVI and only use it for each cluster from the array accordingly.

 

I tried to do something meantime and I'd like to know also if this is ok.

1. Create array of clusters:

BalajO_0-1603445845476.png

2. Reading data from a certain cluster (from "DATE BATERIE 3" in this case):

BalajO_1-1603445898634.png

3. Writing data into a certain cluster ("DATE BATERIE 3" for example):

BalajO_2-1603447230799.png

 - now this is what I don't know how to do.....

 

 

Regards,

Ovidiu

0 Kudos
Message 5 of 13
(328 Views)
Highlighted

Hi Ovidiu,

 

there are array functions like IndexArray or ReplaceArrayElements to handle individual elements of an array. Or use the InplaceStructure...

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 6 of 13
(308 Views)
Highlighted

@BalajO wrote:

Hi there,

 

Yes, cluster arrays seems a good idea, and I tried it.

The problem is that I have to write (bundle) and read (unbundle) different information in a while, depending on the action for each of the 8. Some will read, others will write and others will do nothing. I implemented everything I need to do with 1 cluster that I made typedef.

I am trying to implement it as general and customizable as possible.

 

Could you show me how do I unbundle and bundle a cluster from an array of clusters so that I can read/write info? If I can do this, I think I'll be able to create that subVI and only use it for each cluster from the array accordingly.

 

Regards,

Ovidiu


If the action will be the same for all elements, then autoindexing might help (which is literally the "for all" of LabVIEW). If, in one pass through the array of batteries, You have different tasks, then You could have Your subvi accept one cluster and the type of task as an input. Then in the main VI, create an array of tasks corresponding to the elements in the array of batteries, and autoindex both.

0 Kudos
Message 7 of 13
(298 Views)
Highlighted

Hi,

 

I made a comment upper, could you take a look and reply at it pls? 🙂

0 Kudos
Message 8 of 13
(288 Views)
Highlighted

@BalajO  ha scritto:

 

3. Writing data into a certain cluster ("DATE BATERIE 3" for example):

BalajO_2-1603447230799.png

 - now this is what I don't know how to do.....

 

 

Regards,

Ovidiu


The cluster you are modifying here is contained into another cluster. Unbundle all other members and re-bundle them properly before replacing the array element.

Also, I suggest you to use Unbundle/Bundle by Name, unless you are operating on all members at once.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 9 of 13
(281 Views)
Highlighted

1. Create array of clusters:

BalajO_0-1603445845476.png

In Your example, You still have 3 distinct batteries. If You want to add a fourth one, You need to change the code. Also, I would recommend building an array of Your clusters. Right now, it is an array of size 1 containing an anonymous cluster that contains three elements (battery 2, 3 and 4), each containing the state of that battery.

This is a sketch of what I would do. The innermost structure is the in-place-structure @GerdW mentioned. If I need more or less batteries, I can change the "Number of Batteries" input or use Array Functions to add or remove them during runtime.

LLindenbauer_0-1603451176770.png

0 Kudos
Message 10 of 13
(264 Views)