We have our code separated into drivebase and “other” sections. The Drivebase vi is a Case statement with cases for Begin, Teleop, Finish, and 10ms Periodic. The refnum name constants are outside the case and tunneled in.
We call the Drivebase vi from inside Begin, passing it the “Begin” selector. We also call it from within Teleop, Finish, and a 10ms loop in Periodic Tasks, passing the appropriate selector each time.
The “other” vi (name withheld to protect the mechanism) is similar, but also includes 5ms and 100ms cases.
I started out trying to use shift registers in a single-execution while loop to hold the refnum values, but Test mode requires everything to be in the RefNum Registry. Since I had to use Refnum Set anyway, I went with Refnum Get wherever resources are used. I might do some timing tests to see how the timing is affected by using shift registers instead.