LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic user event

Hello, I am a newbie regarding dynamic user events.

 

Basically, I want to create a user event that triggers  an event structure in a subvi.

 

To do this, I wire up a "create new user event" and then pass the refnum to my subvi "more info" as seen below.  But this piece of code get's stuck in the sub-vi and never leaves :[

 

5.png

 

 

here is my subvi below:

 

6.png

 

 

I'd greatly appreciate any help :]

0 Kudos
Message 1 of 4
(2,470 Views)

The sequence can't finish until the subVI finished.  And since I see your while loop is set to never end and you are probably not getting your event either, the subVI will never finish.  It is probably just a matter of removing the sequnce structure.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 4
(2,455 Views)

A few additional points:

 

  1. You should move the registration into the subVI. Each registeration reference should belong only to a single event structure or you will get weird behavior. The easiest way to do that is to have the register for events node right next to the event structure.
  2. You're not actually generating the event, so the event structure is just stuck. You need to generate the event after you register for it.
  3. You should use the unregister for events primitive after the loop. Just wire the output terminal straight to it.
  4. Have another look at the various examples and tutorials which exist (such as this).
  5. Read the caveats section about this in the LV help. It has some important information. Then read it again in a week.

___________________
Try to take over the world!
0 Kudos
Message 3 of 4
(2,427 Views)

To stop your main vi you will need to provide a mechanism to stop your sub vi.

 

I would use an additional boolean User Event to do this.

(This could be shared among other subvis).

 

When the (let's call it) Shutdown event is received, set your subvi while loop control terminal true.

 

Note: When using this scheme in an exe file, if the subvi front panel is open and you shutdown the main vi, the subvi can remain open. This happened to me using LabVIEW 2010. I had to use a Front Panel Close Method to avoid this issue.

 

When using the Front Panel Close Method you should first check if the front panel is open or not to avoid an error.

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 4
(2,420 Views)