10-06-2008 05:45 AM
Hello all,
I have a question about dynamic user events. I have 6 different users events which I create, and would like to put into an array. (Such that I can use them in a For loop laters, taking off one event per loop and assigning it to a control of a vi) So far I haven't found a way of doing that since if I just wire the user events refnums to an array I get broken wires. (Similarly if I wire them to a build cluster structure.)
I think that you'll understand what I am trying to do if you look at my labview code in the attached vi.
In the vi I create some user events, and then wire them to the control of two vi's which will communicate to each other using these events. In the code you will see 6 Invoke Node structures where I use the "Ctrl Val.set" to pass the events to the two vi's. Obviously this is the wrong why of doing things. Since if instead of having 6 events I had 100, then I would need to put 100 Invoke Node structures on the block diagram (making it very large compared to the size of my computer screen!).
So what I would like to do, is put the user events refnums into a array, then put the one Invoke node structure into a For loop, and index the array to assign the events to the vi's programmatically.
Is there anyway of doing this? Or is there an alternative (/ better way) to what I have done?
(Baisically I have 2 vi's that run in parallel and communicate to each other using user events. I need to pass the events to both vi's, how do I do it in the minimum of mouse clicks, and minimum of screen space.)
Thank you!
Paul.
Solved! Go to Solution.
10-06-2008 06:57 AM
Paul,
there should be no problem putting user events in an array (for the same event data type) or a cluster (For same or different types).
I don't know why you're getting broken wires when you try to do this, it works fine for me.
Shane.
10-06-2008 07:31 AM
10-06-2008 07:32 AM
The problem you have is related to the fact that your user event have different data types.
Two ways (maybe more) to solve:
1. Convert to variant and then into an array, you would have to convert vback inside your dynamic VI
2. Use a different approach:
Take a single event data type consisting of a cluster containing an enum and a variant. The enum contains all the event type you would like to have. The variant conatins the data corresponding to the event type.
Now when sending you can add the event data to the variant and when receiving the enum with event type tells you how the event data should be converted back. In that case you don't need an array of user events, because you only have one.
10-06-2008 07:41 AM
Fantastic André! Thats what I am going to do (option 2).
thanks for all your replies.
paul.
10-06-2008 08:37 AM
10-06-2008 08:49 AM
10-06-2008 09:03 AM
You are completely right, it wasn't my solution that I accepted.
But I clicked it by mistake, then wasn't sure how to change it.
(how do I change it?)
I think it is quite clear that André's solution is the accepted one from my reply though.
Also his solution works great (I just tried it)! Initially I was casting the event refnums as variants, then putting them into an array (exactly as André's first option was). But I didn't like that so much, and I hadn't thought of just using one generic event type (as André's second option was).
Anyway, quite right! Zero kudos to me, and Max kudos to André.
paul
p.s. Also like the new system, though isn't the "kudos" just the same as the old stars (just sound cooler)?
10-06-2008 09:14 AM - edited 10-06-2008 09:15 AM
I haven't created any new messages since the forum changed over, so I'm not sure. But check on the menu under Options on the upper right. I think there is a way to undo your choice and put it on another.
Kudo's have replaced the stars. Anything that was 4 or 5 stars is now equivalent to a Kudo. But with the old system, anything less than 5 stars was essentially a negative opinion in the ratings. So to simplify the multiple shades of gray (1 through 4 stars essentially being some degree of a negative) and to just eliminate the negative aspect altogether, the Kudo system was born.
I don't know if the "Accepted Solution" designation does anything to help the person whose solution was accepted, but having that designation helps people searching the forum because they have the same problem find the answer quicker.
10-06-2008 09:19 AM
yeap,
options: "unmark accepted solution" .
thanks.