LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Making an array of different user events refnums?

Solved!
Go to solution

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.

0 Kudos
Message 1 of 15
(4,260 Views)

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.

0 Kudos
Message 2 of 15
(4,245 Views)
User event refnums are typed, so you can only build them into an array if they have the same type. If you want to see an example for this type of architecture, try searching the LAVA forums for "LVx".

___________________
Try to take over the world!
Message 3 of 15
(4,234 Views)
Solution
Accepted by topic author labJunky

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.

Regards,
André (CLA, CLED)
Message 4 of 15
(4,233 Views)

Fantastic André! Thats what I am going to do (option 2).

 

thanks for all your replies. 

paul.

0 Kudos
Message 5 of 15
(4,227 Views)
How can your own reply be an "accepted solution?"Smiley Surprised  Shouldn't you give that designation to one of the people who replied to you and gave you the answer such as Andrei!Smiley Wink
0 Kudos
Message 6 of 15
(4,199 Views)
This new forum system is pretty cool but there will be some confusion at first.  At least he didn't give himself Kudos!
LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 7 of 15
(4,188 Views)

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)?

 

0 Kudos
Message 8 of 15
(4,181 Views)

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.

 

Message Edited by Ravens Fan on 10-06-2008 10:15 AM
0 Kudos
Message 9 of 15
(4,175 Views)

yeap,

 

options: "unmark accepted solution" .

 

thanks.

0 Kudos
Message 10 of 15
(4,170 Views)