06-19-2009 02:41 PM
I would like to add local or file global variables to all new sequence files that I create. I was hoping I could just add the variable to the process model and have it show up anytime I created a new sequence or in any sequence that used that process model, but it doesn't seem to work.
Does anyone know of a way to do what I'm trying to do?
Thanks.
Solved! Go to Solution.
06-19-2009 03:40 PM
Skeptical,
If you are using TestStand 4.0 and later you can create a template Sequence by adding a selected sequence into the Templates pane of the TestStand Sequence Editor. You can then use this template to create all of your future sequences. Once you configure the template the way you want it it will be easy to reuse that skeleton sequence again.
06-19-2009 04:32 PM
A more elaborate approach is to modify the file programmatically. This is not the preferred solution if a template meets your needs. If you instantiate the class below in a station global and call the Connect method, any file you display that has only an empty main sequence will automatically be edited to contain an additional local. This example could be extended to copy locals or sequences from another file or to vary what it inserts based on other criteria.
using System; using NationalInstruments.TestStand.Interop.API; using NationalInstruments.TestStand.Interop.UI; public class EventMonitor { private ApplicationMgr mApplicationMgr = null; private Engine mEngine = null; public void Connect() { if (this.mApplicationMgr == null) { this.mEngine = new NationalInstruments.TestStand.Interop.API.Engine(); this.mApplicationMgr = mEngine.GetInternalOption(InternalOptions.InternalOption_ApplicationManager) as ApplicationMgr; if (this.mApplicationMgr != null) { _ApplicationMgrEvents_Event appMgrEvents = this.mApplicationMgr; appMgrEvents.DisplaySequenceFile += new NationalInstruments.TestStand.Interop.UI._ApplicationMgrEvents_DisplaySequenceFileEventHandler(appMgrEvents_DisplaySequenceFile); } } } void appMgrEvents_DisplaySequenceFile(SequenceFile file, SequenceFileDisplayReasons reason) { if (file.NumSequences == 1 && file.GetSequenceIndex("MainSequence") == 0) { Sequence sequence = file.GetSequenceByName("MainSequence"); PropertyObject locals = sequence.Locals; if ((sequence.GetNumSteps(StepGroups.StepGroup_Main) + sequence.GetNumSteps(StepGroups.StepGroup_Cleanup) + sequence.GetNumSteps(StepGroups.StepGroup_Setup)) == 0) { if (locals.GetNumSubProperties("") <= 1) { if (!locals.Exists("MySpecialLocal", PropertyOptions.PropOption_NoOptions)) { locals.SetValNumber("MySpecialLocal", PropertyOptions.PropOption_InsertIfMissing, 1234.5678); file.IncChangeCount(); this.mEngine.PostUIMessage(null, null, UIMessageCodes.UIMsg_RefreshWindows, 0.0, "", file, false); } } } } } }