04-20-2012 11:26 PM
I have noticed recently that an event structure unbundles any cluster passed to it.
Does anyone know how to prevent this?
My workaround is to double wrap my cluster or re-bundle it before passing it into a vi.
My clusters have 20-30 elements.
Thanks in advance.
04-21-2012 08:07 AM
Why are you trying to prevent this? What is the issue that you believe exists? You can select what's shown there.
04-21-2012 12:52 PM
Also this could be quite useful to have this default behaviour. For instance, if your cluster contains numeric controls. You could use NewVal terminal to trigger the events at the new values of the numeric controls.
As mentioned, there is no issue with this behaviour. Event structure are only used to respond to the user events on the front panel unless there is some code in the timeout case. You could select which control you wish the event structure to respond to by choosing that control in the Edit Event window.
04-22-2012 02:31 PM
@AustinCann wrote:
Also this could be quite useful to have this default behaviour. For instance, if your cluster contains numeric controls. You could use NewVal terminal to trigger the events at the new values of the numeric controls.
As mentioned, there is no issue with this behaviour. Event structure are only used to respond to the user events on the front panel unless there is some code in the timeout case. You could select which control you wish the event structure to respond to by choosing that control in the Edit Event window.
I just want to correct you a bit. It is NOT true that Event structure only responds to front panel events.
Event Structures can respond to dynamically user events, that doesn't have to be connected to a front panel control. When having dynamically user events there will not be any NewVal terminal.
And for the OP, I can see the issue. If the data for the event is a cluster that contains many elements, and you would send the cluster to a sub-vi or further to other loops, you would need to bundle the cluster again in the event structure. It would be a good feature to be able to get the complete cluster or each element in the event structure.
04-22-2012 02:57 PM
You may want to kudo this Idea
Allow Dynamically Registered User Events to preserve Native Datatype in Event Structure
04-22-2012 03:31 PM
Note: While typing this up I see that others have provided good answers, but here is mine anyway ...
Although Timmar did not explicitly say it, I think the point that he is trying to make is that “User Event clusters” are handled differently than “front panel clusters” by the event structure. This variation in functionality requires that he make code changes that he would like to avoid.
For example, an “error in” cluster from the front panel, when used in a Value Change Event, goes in as a cluster and comes out as a cluster.
The same “error in” cluster from a User Event goes in as a cluster and comes out as an unbundled cluster. (See Timmar’s example.)
Issues that are caused by the functionality:
The work around is not too difficult.
When you create the User Event, pre-bundle your cluster by putting it in a cluster container with the same name.
When you generate the event, bundle the cluster.
I don’t think there is a way to prevent this behavior and this could be considered a feature. In the common use case where you are getting a User Event from a producer loop and want to send the data to several front panel indicators, the automatic unbundling saves you a step. Maybe that’s why NI did it this way.
My current project uses ~60 User Events. About half of them are “pre-bundled” as described here.
steve
04-22-2012 07:39 PM
Ravens Fan,
I will certainly Kudos your Idea Exchange,
Why is it that my searches never find these posts?
Tim L
04-22-2012 08:00 PM
Steve,
You hit the nail on the head, Your posting is my workaround.
Juck Dunnaway via Ravens Fan has clearly beaten me to the punch though (3 years ago!)
How come this one hasn't been done?
This one is a great one as well!
Expand Data Interface to Built-In Messaging Primitives
I think jgcode deserves credit for the initial idea in this thread