08-30-2023 04:17 PM
Hello everyone,
I'm working on a project involving TestStand and Python. I aim to optimize the runtime of a TestStand sequence by pre-fetching global variables and step-specific information for each step in the main sequence and its subsequences. This is to efficiently populate a custom test report.
TestStepName
, FileGlobals.Test_Sequence
, FileGlobals.xx
, etc.I've consulted the TestStand API documentation but have not found a clear solution to this issue.
Has anyone else faced a similar challenge or has any suggestions on how to resolve this? Your insights would be much appreciated.
Thank you in advance.
Solved! Go to Solution.
08-31-2023 01:01 AM
My understanding is that the script is to be run, before the MainSequence (and its subsequences are run)
If so, trying to access properties via RunSate might not work properly, since teh Sequences are actually not running.
Possible solution: open the sequence file, parse for sequence calls, store the call targets and then parse each of the sequences called.
From where are you calling the script? From the model?
08-31-2023 12:00 PM
Hello Oli,
Thank you for your response!
Yes, I'm calling the script from the predefined execution model. My intent is to run the script before the MainSequence and its subsequences actually execute, aiming to preprocess and gather information prior to the real execution.
You're right in suggesting that trying to access properties via RunState might not be apt in this context. Your idea about opening the sequence file and parsing for sequence calls sounds promising. Would you have an example or recommendation on how to go about it, especially on how to identify and access the subsequences?
Any guidance or suggestions you can provide would be greatly appreciated.
Best regards,
09-01-2023 12:21 AM
I don't have the exact example of what youre looking for at hand
As a starting point, you can use %teststandpublic%\Examples\TestStand API\Building a Sequence Using API\TestStand Expressions
This example shows how to build a sequence file using the API which showcases the object structure quite nicely.
If you happen to have access to the TestStand II (Architecting Testsystems using TestStand) Course on your learner dashboard on ni.com, there is Excercise (6-2) which scans a sequence for steps of a specific type
09-04-2023 05:17 PM
Hello Oli,
After several iterations, I finally came up with a solution to the functionality I was looking for in my script, you were right about your recommendations and basically I updated my script form that staring point, of course I added a lot more code with specifics associated to my application but in summary the solution was:
1. Open the sequence file (sequenceFile = engine.GetSequenceFile(sequence_filename))
2. Get main sequence form the previous call (mainSequence = sequenceFile.GetSequence(0)
3. parse sequence calls using GetSequenceByName method.
of course the script is a bit more complex with recursive functions called to be able to go to the entire sequences and get the info that I was looking for.
This script effectively allowed me to programmatically analyze TestStand sequences to extract the information I needed. I hope this will be helpful for others facing similar challenges.
Special thanks to Oli for the initial guidance.
Note: Attached is a simplified script version highlights the main sequence handling and recursion.