01-30-2024 03:32 AM
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
01-30-2024 04:02 AM - edited 01-30-2024 04:04 AM
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?
01-30-2024 04:25 AM
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:
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.
01-31-2024 01:33 AM
@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.
01-31-2024 04:52 AM
@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.
01-31-2024 07:30 AM - edited 01-31-2024 07:33 AM
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.