07-25-2005 11:21 AM
I want a TestStand sequence to dynamically create multiple copies of a test step (with different parameters). We are currently looping on the test step, but this doesn't provide a clear indication to the operator what test steps have been and will be executed. I tried to do a SetNumElements(RunState.Sequence.Main, numElements) and an InsertElements(RunState.Sequence.Main, index, numElements), but they both made the new steps of type "Container" instead of type "Step" and when I tried to copy the test step it gave me an Error: "-17321; Variable or property types do not match or are not compatible."
Has anyone successfully done this? Thank you in advance.
07-25-2005 02:39 PM
Roger -
Typically you will have to call Step.AsPropertyObject().Clone() to get a new copy of the step, call Step.CreateNewUniqueStepId to regenerate its unique step ID, and then call Sequence.InsertStep(Step, ...) insert it into a sequence.
07-25-2005 02:57 PM
Hello,
Here's one technique for doing this, there are probably others:
1. Call Engine.NewStep
2. Get the Module property of the Step
3. Cast the Module property to the apropriate module type object (note that the module types are found in a different Automation Server than the rest of the TS API objects).
4. Use the module object to specify the module (for example, if it's a SequenceCall object you might set SequenceFilePath, SequenceName and you might get the Parameters object and add some properties to it to specify parameters).
5. Get a reference to the sequence you want to insert the step into (probably by using SequenceFile.GetSequenceByName)
6. Call Sequence.InsertStep with the step you created.
Hope that helps,
Ryan K.
07-28-2005 10:06 AM
Thank everyone for your help. I have successfully copied test steps. I have had one difficulty though. If the step I copy is a function call with a relative path to the DLL and the DLL is located in the same directory as the test sequence, the copies are not able to find the DLL (the original step is able to do so). I have "Current Sequence File Directory" selected in the search directory list. I checked and it seems as though the paths to all of the pre-defined directories (including "Current Sequence File Directory") are empty ("") at run-time. I don't want to add the path in the directory search list, nor do I want to hard code the path in the sequence file.
Does anyone have a solution to this problem? Optimally I would like to dynamically specify the absolute path to the DLL, but I couldn't find a property or process to do this. Thank you in advance for your help.
07-28-2005 11:53 AM
Interesting. Unfortunately I don't have time right now to try to reproduce the behavior. As a workaround, maybe you could try just constructing the path dynamically by stripping the file name off the SequenceFile.Path property and then adding the dll name to it. Once you have the correct relative path you can assign it to the module using the apropriate property (for example CommonCModule.ModulePath for a sequence call step). Check my previous post if you're not sure how to get the reference to the module. I'd be interested in figuring out what is causing the step to loose the path in the first place. Here's a few questions that might shed some light on the subject:
1. Just to confirm, you are copying a step within a sequence file, and the sequence file is saved in the same directory as the DLL?
2. What adapter are you using?
3. If you read the value of the path in the module object, what does it return?
That's about all I can think of at the moment, maybe Scott will have more insight.
Regards,
Ryan K.
08-02-2005 04:06 PM
08-02-2005 05:01 PM
Roger,
That kind of makes sense, TestStand may not resolve relative paths as it executes each step, it may resolve them all at some previous point. You might try creating the step in a sequence callback somewhere closer to the start of the execution. However, if you've got it working I wouldn't worry about it.
Regards,
Ryan K.