LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

question about Labview user event cluster argument handling

hello! Does anybody knows why, regarding data argument in user event, Labview doesn't behave the same way when the argument passed  is a cluster?

 

for example, below, regarding cluster ->it's not passed itself, but only its content, contrary to the other cases (boolean, int etc...). In case of producer-consumer structure, this force the developer to rebuild cluster inside the event structure, to be passed to the consumer loop.

 

Is there a reason for this Labview implementation? Is there an option to pass the whole cluster instead of its content?

 

regards

 

user event with cluster.png

Pierre FCentum TNS, Grenoble
Certified LabVIEW Associated Developer
0 Kudos
Message 1 of 6
(1,121 Views)

Hi Pierre,

 


@Pierre_F wrote:

Is there a reason for this Labview implementation? Is there an option to pass the whole cluster instead of its content? 


I don't see an option to get the whole cluster at once from the UserData.

Instead I would do this:

The cluster should be typedefined, so it's easy to build the cluster inside the event case.

 

How large would be the cluster you want to transfer by UserEvents?

Would there be an option to separate the cluster into its items?

Or can you flatten its data into a string and unflatten inside the event case?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(1,099 Views)

Hi Pierre,

 

This is the normal behavior, and I don't know why NI made this choice.

I guess this is to easily access elements for UI events, but is effectively less practical for user events.

 

What I usually do is just wrapping the cluster in another cluster like this:

raphschru_0-1706609986061.png

 

I would advise you to create a wrapper SubVI for generating events, so that you don't need to bundle your cluster in the other cluster every time.

 

Regards,

Raphaël.

Message 3 of 6
(1,078 Views)

@Pierre_F wrote:

 

Is there a reason for this Labview implementation?  


I don't know if that's the reason, but there's a guess here. Basically, if you want to handle events for different clusters in the same frame, then by unbundling for you, LV can give you elements which are common between the clusters.

 

I don't think I ever had use for this and I also occasionally run into the annoyance of "why can't I just take this typedef cluster and pass it into a subVI" or something else along those lines.


___________________
Try to take over the world!
0 Kudos
Message 4 of 6
(1,013 Views)

@GerdW wrote:

Hi Pierre,

 


@Pierre_F wrote:

Is there a reason for this Labview implementation? Is there an option to pass the whole cluster instead of its content? 


I don't see an option to get the whole cluster at once from the UserData.

Instead I would do this:

The cluster should be typedefined, so it's easy to build the cluster inside the event case.

 

How large would be the cluster you want to transfer by UserEvents?

Would there be an option to separate the cluster into its items?

Or can you flatten its data into a string and unflatten inside the event case?


When I do something like that, I use the same cluster constant for both defining the data type, and generating the event.

ui.png

0 Kudos
Message 5 of 6
(987 Views)

I like the default behaviour in general, but if you really want it as a cluster, wrap it in another cluster as mentioned or make it a Variant. With a Variant you can send anything as an event but you'll need to convert it to something useful with Variant to Data.

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 6
(962 Views)