NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I do something that would cause all new sequence files to have the same local variables?

Solved!
Go to solution

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.

0 Kudos
Message 1 of 3
(2,860 Views)
Solution
Accepted by Skeptical

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.

John B.
Applications Engineer
National Instruments
Message 2 of 3
(2,853 Views)

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); } } } } } }

 

 

 

0 Kudos
Message 3 of 3
(2,843 Views)