09-13-2018 07:06 PM
I am using sequence templates in my example sequences so that users can drag and drop pre-configured functions. The issue is that those sequence templates contain subsequences. Is there a way to auto-include the subsequence as well when a user drags in a parent sequence?
Solved! Go to Solution.
09-14-2018 01:25 PM
Hi rdecarre11,
There isn't a way to automatically include all of those subsequences when you place the template for your main sequence that I know of. You could however create a Folder under Sequences for each of your main sequence templates that would group the top level sequence as well as the subsequences it calls that way the user could easily select them all and know they have included everything necessary.
Hope this help!
09-14-2018 01:30 PM
Hey Robert,
I'm investigating a workaround for you. I'll get back to you if I can get something to work.
09-14-2018 01:33 PM
That is what I did at first. Then I decided to put all those sequences/subseqs into another sequence file. I then configured a sequence call step and put that in a folder under the "Steps" folder. The user need only include that sequencefile in their environment and then they drag and drop a step, configured to call the sequence. Feels like it makes more sense in this case as a step template.
09-14-2018 01:35 PM
Nice, let me know if you find something!
09-17-2018 04:47 PM
Hey Robert,
You can use the TestStand API to programmatically read in the templates file, which is just a sequence file, then populate your current sequence file with those sequences. My templates file had two subsequences, Seq0 and Seq1, so my code looks like the following:
//Locals.File, Locals.Seq0 and Locals.Seq1 are object references used to store the temp file object reference, and the two sequence references.
//Locals.userCancelled is a boolean
//The option of 1, the last parameter, is a workaround in this case and should not be used outside of this scenario. It bypasses the check we have for having multiple instances of the same file open.
Locals.File = RunState.Engine.ReadPropertyObjectFile("C:\\ProgramData\\National Instruments\\TestStand 2017 (64-bit)\\Cfg\\Templates.ini", Locals.userCancelled,ConflictHandler_Prompt,1), #NoValidation(Locals.Seq0 = Locals.File.Data.Root["Sequences"]["Seq0"].AsPropertyObject.Clone("",0)), #NoValidation(Locals.Seq1 = Locals.File.Data.Root["Sequences"]["Seq1"].AsPropertyObject.Clone("",0))
RunState.SequenceFile.InsertSequenceEx(1,Locals.Seq0),RunState.SequenceFile.InsertSequenceEx(2,Locals.Seq1)
Then use the InsertSequenceEx() method to add the two object references to the current sequence context. Few caveats to this - the sequence file names are hard-coded, and that may be less than ideal. You would also have to ensure that code modules and types are all available (but this is true for templates, regardless). Ultimately, you can add a tools menu item that would run this and automatically add it to the sequence file you want your user to work with - this would be the easiest workflow for your consumers.
Let me know if you have questions on this.
09-24-2018 12:41 PM
Right now I just created another sequencefile in our framework repo and have the templates as steps, instead of sequences. The solution you provided is a bit more complicated, but would certainly work for other situations though, thanks.