I need to have my GPIB devices simultaneously (and preferably gradually) be set to zero when the program is stopped. How can I accomplish this? Also, what does clearing the devices do?
I would say: the answer to both questions is given in the manuals of your GPIB devices...
You need to programmatically capture and discard all events that try to close the VI and initiate your shutdown code instead. (you can also simply disable these mechansims) Of course the regular ways on the front panel (e.g. a stop button) should also do the same thing.
Look for the filtering events "Application close?" and "panel close?".
(For the (hopefully rare) cases where the application crashes or is killed by the task manager, you might still have a problem. What is your OS).
I'm using a flat sequence with three frames: initialization, run test, and shut down. I want a stop button to just skip the "run test" frame and go straight to shut down. I was going to put the contents of the second frame in a case structure triggered by a stop button, so the stopped case just goes through to the third frame without running the test, or stopping mid-run.
Would this work, and if so where do I need to put the stop button to accomplish this?
That would work if the stop button is pressed before the run test frame starts executing. Once it has started, you would be inside the run case and the stop button would have no effect.
A much better way is to convert your program to a state machine. The initialization would be one state. Shut down is another state. Run test probably consists of multiple states. With such a state machine pushing the stop button will make the next state "shutdown" regardless of the present state when the button is pushed.
It is also much easier to modifiy a state machine if anything ever needs to be changes about your tests.
I'll be honest, I'm pretty new to LV, so I'm not confident in my ability to make those kinds of changes. Would it be possible to use an Application Exit? Event structure with my shutdown procedure inside? If so, would I need a while loop around my flat sequence frames?
It is actually rather easy to start the conversion to a state machine. (Be sure to make a back up copy of your program first!) Pop up on the edge of the sequence frame and select Replace >> With Case Structure. Wrap a while loop around the case structure. Create a typedefed enumerated control for the state selector. Then fix the errors which occurred due to the replacement.
Look at the examples and Design Patterns which come with LV.
You should plan on having a stop button on the front panel. Application Exit has its place, but get the basic architecture right first.