NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I programmatically make a copy of a TestStand step?

I am trying to programmatically read a step from one sequence and copy it into another sequence. I tried just getting and inserting, with no attempts to clone, but I just ended up with the same step object instance in two sequences

TS::StepPtr spStep;
TS::SequencePtr spSequence1;
TS::SequencePtr spSequence2;
/* Initialize sequence pointers here */
spStep = spSequence1->GetStep( 0, TS::StepGroup_Main );
spSequence2->InsertStep( spStep, 0, TS::StepGroup_Main );

Change the step in sequence 1, and it changes in sequence 2.

I then tried to create a new step of the same type, using IEngine::NewStep, and copy the property object of the original using IEngine::CopyPropertyObject(). I then had a cloned property o
bject, but couldn't see a way to write it to the new step object.

Anyway, the sequence editor does it, so I know there's a way. Want to let me in on the secret?

Thanks,

Aaron
Message 1 of 10
(6,678 Views)
Hi Aaron,

Not to sure of the syntax.
When you have selected the Step, you need to Clone the object which will return a reference. Then instead of using the spStep reference in the Insert you would use the Clone reference.

eg
TS::PropObjPtr spCloneObJ;
..
..
spCloneObj = spStep->Clone("", TS::StepGroup_Main);
spSequence2->InsertStep(spCloneObj, 0, TS::StepGroup_Main);

Like I said not sure of the syntax but that how I have done it using TS API calls.

Regards
Ray Farmer
Regards
Ray Farmer
Message 2 of 10
(6,677 Views)
Aaron,

Cloning is the way to copy a step from one sequence and paste a new instance in another sequence file.

There is an example found in a previous post "Does anyone have example code of using TestStand API in LabView to clone a step" although that is using LabVIEW. If you have LabVIEW, you can open the VI and see each of the API methods that are used. If not, there are still steps that you can follow to clone an existing step.

If you have questions, please let us know!
Regards,
Shannon R
Applications Engineer
National Instruments
0 Kudos
Message 3 of 10
(6,678 Views)
Sharon,

I used the example in my program to clone a step to multiple steps in MainSequence. Then I tried to change each step name to a unique one by looping indexing each step. The result is all cloned steps are following the last name chnage. I tried to reverse the direction of indexing but the result is alway all cloned step names following the last name change. I tried to create CreateUniqueIDs. That works but unique IDs are not very meaningful. Is there any way to change the step names uniquely?

Thank you.
0 Kudos
Message 4 of 10
(6,645 Views)
Hello,

You can explicitly name a step whatever you would like by accessing the step property, "Name". These names do not need to be unique, but will be if you make them so. Only IDs are forced to be unique.

Regards,

Aaron B.
National Instruments
0 Kudos
Message 5 of 10
(6,631 Views)
I am kind of answering to my own question, but I think it is good for anyone who will have same problem that I experienced.

I have cloned a step and tried to insert it into multiple steps. Then I tried to change the step name property of each step with unique names. Although I was able to assign computer generated unique ID for each step using "CreateNewUniqueStepID" method, I failed to assign different step names using "Name" property. Whenever I change the step name property of one step, all copied steps changed their names to the last name change I made.

It took me a while to figure out that I could not assign different step names because they all copied from the same clone. I fixed this by cloning as many objects as I need to insert as new steps to a target sequence. There is only one original step. But, I had to make multiple clones before I insert them as new steps. My mistake was I made only one clone and insert it multiple times. And, I failed to change the name properties of those new steps with different names. It is a simple concept but wabn't so easy to practice.

LegalEngineer
Message 6 of 10
(6,625 Views)
This thread is quite interesting to read. This forum is a great learning place.

However, I fail to understand why cloning a sequence step.
Can you provide an example of where this would be useful?

And thanks for sharing your solution.

Ray
Message 7 of 10
(6,599 Views)
Ray -
Some developers of TestStand applications like to create a custom editor that uses a palette of steps from an existing sequence to create a new sequences. Some call this a type of sequence-builder application. This is typically the only reason to clone steps.
Scott Richardson
https://testeract.com
Message 8 of 10
(6,584 Views)


@Scott Richardson (NI) wrote:
Ray -
Some developers of TestStand applications like to create a custom editor that uses a palette of steps from an existing sequence to create a new sequences. Some call this a type of sequence-builder application. This is typically the only reason to clone steps.



Thanks!

😄
Message 9 of 10
(6,575 Views)


@LegalEngineer wrote:
Sharon,

I used the example in my program to clone a step to multiple steps in MainSequence. Then I tried to change each step name to a unique one by looping indexing each step. The result is all cloned steps are following the last name chnage. I tried to reverse the direction of indexing but the result is alway all cloned step names following the last name change. I tried to create CreateUniqueIDs. That works but unique IDs are not very meaningful. Is there any way to change the step names uniquely?

Thank you.




Hi, I find this thread very interesting. If you still have the sequences about, would you try to make unique comments for the steps. It seems to me that the comments are part of the sequence rather than the step and each one of the 'step references' will properly display a unique comment when you click open the step, even though they have the same name.

I have been saving test steps as serializations and then re-instantiating them as needed; but I have had trouble getting the step comment to work. It seems to me that the comment belongs with the step rather than the sequence; but then again, I can think of a number of arguements for the other way around. I would have to say that, if the comment is part of the sequence, then it would be more difficult to identify a 'clone' from a 'reference', and really, if your sub-sequence calls are in distinct sequence files, how would TestStand even hope to portray this distinction of step IDs?
0 Kudos
Message 10 of 10
(6,548 Views)