LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Register event as sub vi

Solved!
Go to solution
Highlighted

Hi!

 

So, for beautification of the code Events get registered in a sub vi of it's own, and the ref is sent out as an Event Ref Indicator (ERI). Main program's event structure connects and all work well. (With a bunch of user events it's quite alot better looking this way)

 

One of the events use a type def for event types (which seems like a generally good idea).

If i change the type def, the Sub vi breaks and i need to recreate the ERI. Type def'ing the ERI doesn't help. I could send the commands as text with the error of spelling error (and possible miniscule performance loss with string comparison compared to type def).

 

Any suggestions?

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 1 of 4
(1,061 Views)
Highlighted
Solution
Accepted by Yamaeda

Embedded within the event reference type is all of the type info about the events.  When you change a registered event, the specific type of event reference changes.

There is no way to get an indicator to change to match the type of data feeding it; you just have to recreate the control.

0 Kudos
Message 2 of 4
(1,043 Views)
Highlighted

There really should be, but i'm sure you're right. 😞

Thanks.

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 4
(1,020 Views)
Highlighted

Yes the contents of the event registration wire changes as new events are added or removed. Attempts to type-def it fail when the wires feeding it change. To work-around the behaviour I generally will keep the event registration node in the same VI as the event struture as illustrated below.

 

 

 

This way the wire never passes through a connector pane and the need for the type def goes away. I have come to rationalize this approach since the sub-VI can now clearly document which events are monitored in the sub-VI "at-a-glance". For example, the above sub-VI handled the work associated with "collection" functions so if I find this VI while working on a collection task, I know I am in the right area.

 

another "gotcha" that I should mention (that I would like to cite the source but am restircted in saying who so I have to be happy with saying the gotcha was not my discovery but someone elses Smiley Wink ).

 

The "gotcha" is;

 

If you delete an input to the Event Registration the event reg wire changes and (here is the gotcha) all of the events get scrambled!

 

So make sure you add coments to each event case describing what they do BEFORE you change that event registration node!

 

At least the comments will let you put thing back the way they should be .

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 4
(1,015 Views)