05-18-2007 10:41 AM - edited 05-18-2007 10:41 AM
Reading Jim's post about loop debugging on this LAVA thread reminded me of a similar trick I do with Event Structures. In my event-based UIs, I always wire the iteration count of the While Loop containing my Event Structure through to the inner border of the Event Structure, like so:
I also deselect the "Use Default if Unwired" option on the output tunnel...that way when I create a new Event case, the VI will be broken, reminding me that I need to wire the iteration wire through on the new case:
Now, the reason I do this little trick is to help when debugging the execution order of events for my event structure. In my current project, I've got mouse events firing all over the place...Mouse Move, Mouse Enter, Mouse Leave, Mouse Down, Mouse Up, Shortcut Menu Activation, etc. Sometimes I really need to know the order in which certain events executed...to do this, I can probe these iteration wires within the event cases that interest me, and by comparing the values of the iteration counts, I can easily determine which events fired first. If the events are firing multiple times and I want a history of their firing order, I can use my home-grown History Probes (see my previous Nugget on this topic).
-D
P.S. - Check out past nuggets here.
Message Edited by Darren on 05-18-2007 10:41 AM
05-18-2007 10:52 AM
Darren:
Interesting thought. This would be a very quick and easy way to debug without having to make any real changes to exisiting code and while running in the IDE.
I typically will just log the events to a text file with a quick drop in VI. The VI takes a string input. I pass the subVI the event info including arguments sent as well as what event. Tends to give me more information that I can review after running the code as an Executable. Upon completing debugging I remove the VI from the code. Tedius, sure, but allows me to run the Exe and I still clean up after myself.
05-19-2007 11:30 AM
05-19-2007 01:12 PM
I tried to do it using scripting for an existing application I had to work on which uses an event structure state machine. Unfortunately, the ES does not expose that information (and I would probably have to poll anyway).
Your solution is too simplistic for my use case (although I used a similar approach in some specific cases), but maybe I could have used the subVI approach (either by providing it with the event data or by using some more scripting if enough is exposed) and I may still need to, so thanks for the idea.
05-21-2007 08:11 AM
Ah - logging. That's always a nice topic ;).
I always use a simple selfmade library. So I can get rid of breakpoints (most of the time) and still can "debug" code when it is built as an exe.
Here you can find the library and have a look at it.
http://forums.ni.com/ni/board/message?board.id=170&message.id=199742&query.id=144862#M199742
Thomas
06-14-2007 09:25 AM
Great Thought! And I think the trick can also be used widely to determine the order of state machine and so on.
Thanks!