10-23-2020 03:17 AM
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:
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
Solved! Go to Solution.
10-23-2020 03:42 AM - edited 10-23-2020 03:42 AM
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.
10-23-2020 03:51 AM
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 🙂
10-23-2020 04:04 AM
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?
10-23-2020 04:21 AM - edited 10-23-2020 05:00 AM
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:
2. Reading data from a certain cluster (from "DATE BATERIE 3" in this case):
3. Writing data into a certain cluster ("DATE BATERIE 3" for example):
- now this is what I don't know how to do.....
Regards,
Ovidiu
10-23-2020 04:45 AM
10-23-2020 04:53 AM
@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.
10-23-2020 05:29 AM
Hi,
I made a comment upper, could you take a look and reply at it pls? 🙂
10-23-2020 05:41 AM
@BalajO ha scritto:
3. Writing data into a certain cluster ("DATE BATERIE 3" for example):
- 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.
10-23-2020 06:17 AM - edited 10-23-2020 06:20 AM
1. Create array of clusters:
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.