Description
Description-Separate-1
Overview
This example demonstrates how you can use the TestStand API to create new variables in your sequence file which persist at edit-time.
Description
You can create variables in a sequence using the Runstate.Sequence object in the TestStand API. However, since this sequence object refers to the running copy of the sequence, and changes or new properties are only persisted for the active execution.
To access the edit-copy of the sequence file, you must access the sequence from the sequence file object in one of two ways:
- Runstate.SequenceFile - Use this approach to access the currently running sequence file.
- Runstate.Engine.GetSequenceFileEx("mySequenceFile.seq") - Use this approach to access a different sequence file.
Once you have obtained the sequence file object, complete these steps to make a modification:
- Access the desired property. For a local variable in the main sequence, Use Runstate.SequenceFile.GetSequenceByName("MainSequence").Locals.
- Modify or create new properties using the SetVal methods, for example SetValString.
- Increment the change count of the sequence file using SequenceFile.IncChangeCount() to indicate that it has been modified.
- Save the file if desired using SequenceFile.Save().
- If you obtained the sequence file using Engine.GetSequenceFileEx(), you must release it using Engine.ReleaseSequenceFileEx().
Hardware and Software Requirements
Add Persistant Variable to Sequence File - TS2012.seq
TestStand 2012 or compatible
Add Persistant Variable to Sequence File - TS2019.zip (seq)
TestStand 2019 or compatible
Steps to Implement or Execute Code
- Open the attached sequence file, and select Execute » Run MainSequence.
- When prompted, choose whether to use the current sequence file or another file.
- If you choose to use another file, the browse dialog appears. Select a sequence file.
- Once the execution completes, observe that the file you chose has a new local variable called "Locals.myNewVar".
- If the sequence file you modified was already open, observe that the file is marked as modified due to the call to IncChangeCount().
Additional Information or References
Description-Separate-2
Al B.
Staff Software Engineer - TestStand
CTA/CLD