Ed Dickens Posted September 1, 2004 Report Share Posted September 1, 2004 I think two needed events for the <This VI> Event Source are First Run, and Error Handler. The First Run could be used for any initialization code you need to do. I've faked this function by wiring a Select function to the Timeout terminal with a 0 and -1 and when the While loop iteration terninal equals 0, it passes in the 0 so it times outs right away, then on the next iteration, it passes in the -1 so it never times out. Of course, if you don't need the Timeout feature for some other reason, you'd need to add a Case structure in the Timeout event case to run different code when the loop count does not equal 0. The Error Handler event would watch a single error cluster and if it contains an error, that case would run any error handling code that have. I know all of these features can be accomplished registering a dynamic event and triggering a user event for them, but it would be nice not to have add all that extra code since these are two things that almost every application needs. Ed Quote Link to comment
Ed Dickens Posted September 1, 2004 Author Report Share Posted September 1, 2004 I know all of these features can be accomplished registering a dynamic event and triggering a user event for them, but it would be nice not to have add all that extra code since these are two things that almost every application needs. 1600[/snapback] So the dynamic events sounded promising to me after I said it, so I made up an example of how it would work. The sub-vi on the left creates and registers the dynamic events. It also can fire the first Run event so it will run right away. The Trigger Error sub-vi watches the error cluster and will fire the error user event when ti sees one. Pushing the code into sub-vis cleaned up the diagram a lot and saves space. (until NI adds these events natively to the event structure ) I've attached the example library if your interested. Ed Download File:post-47-1094056528.llb Quote Link to comment
didierj Posted September 2, 2004 Report Share Posted September 2, 2004 Ed, Is the element First Call? in the palette Advanced->Synchronisation not what you were looking for? Didier Quote Link to comment
Ed Dickens Posted September 2, 2004 Author Report Share Posted September 2, 2004 Ed,Is the element First Call? in the palette Advanced->Synchronisation not what you were looking for? Didier 1606[/snapback] The First Call? function by itself can't fire an event. You'd either have to write to a Value Signaling property node or have a Case Structure around your Event Structure to catch the First Call? value. I've used both in the past, but the Dynamic Events is much cleaner in my opinion. You end up with just a While Loop with an Event Structure and just a single VI outside the loop. Plus, if you need to run your init code again, you just need to fire the First Call user event. Ed Quote Link to comment
Ed Dickens Posted February 28, 2005 Author Report Share Posted February 28, 2005 I've updated this Event structure a bit. It's now saved as a VI Template with front panel and block diagram images for the template browser. I've also added an "Exit" event to handle all the shutdown code. I keep the two sub-vis in my user.lib directory. This is built in LabVIEW 7.0, but works just as good in 7.1 Ed Download File:post-47-1109606765.zip Quote Link to comment
todd Posted February 28, 2005 Report Share Posted February 28, 2005 I catch Event errors with the subvi in the attached image - even if the Stop button is not visible on the FP. For init, I still use one subvi before the While-Event loop. Usually, the init vi enqueues commands that are interpreted by queue handlers outside the Event-While loop. I agree it would be more convenient if there were First Run and Error events. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.