LHarris Posted June 22, 2010 Report Share Posted June 22, 2010 I need to add a routine that will re-initialize almost all the controls and indicators of the top-level vi to the start state (but retain a few that show history etc). Two ways spring to mind - a straight-forward wiring of required values (eg FALSE constant wired to all LEDs that should be off, etc) or use of an invoke node for Reinitialize to Default for each control/indicator. Invoke nodes have the advantage of always matching the default value set on the FP, but I could (and probably will) call the re-initialize routine at startup anyway, so that shouldn't be a big issue. Then I started wondering whether the performance hit for property nodes applied to invoke nodes as well. Granted I will probably use DeferPanelUpdates anyway to only refresh the FP once after all values are set, and the user won't mind a small pause at reset (in fact they'd probably expect it) but the function could be called frequently so I'd still like to make it efficient. Anyway, just wondering what other people think ..... Quote Link to comment
Daklu Posted June 22, 2010 Report Share Posted June 22, 2010 Anyway, just wondering what other people think ..... I think local variables are faster than reinitializing each control through an invoke node. If you have lots of fp controls and only a few controls you want to preserve you could buffer those values on a wire and copy it back into the control after resetting all the fp controls. That would probably make your code easier to read than a bunch of local variables or invoke nodes. I don't know if there is a performance difference between reinitializing each control separately and the entire fp at once. You'd have to benchmark it. Quote Link to comment
Yair Posted June 23, 2010 Report Share Posted June 23, 2010 I wouldn't bother with individual controls, even if you're going to do this fairly often. It should probably not take long to execute if you defer updates. Based on your description, I would say you should get the references to all the controls on the FP once (using the Controls[] property or, if you have nested controls, using <vi.lib>\utility\traverseref.llb\TRef Get All FP References.vi) and then build the controls you don't want to reset into an array and remove them from the first array using a for loop. You now have an array of all the controls you want to reset which you can go over in a for loop. You can call the reinit method for each one. 2 Quote Link to comment
LHarris Posted June 24, 2010 Author Report Share Posted June 24, 2010 I wouldn't bother with individual controls, even if you're going to do this fairly often. It should probably not take long to execute if you defer updates. Based on your description, I would say you should get the references to all the controls on the FP once (using the Controls[] property or, if you have nested controls, using <vi.lib>\utility\traverseref.llb\TRef Get All FP References.vi) and then build the controls you don't want to reset into an array and remove them from the first array using a for loop. You now have an array of all the controls you want to reset which you can go over in a for loop. You can call the reinit method for each one. Good idea - and any new controls I add will be automatically added to this too. Thanks! 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.