From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Copied Steps Retain Reference From Original

Hello All,

 

  Seeing odd behavior in Test Stand when I copy and paste steps.  The pasted version of the step appears to still be tied to the original somehow.  Example:

 

Step 1. Read In value and inject limits into Step 2

Step 2. Numeric Limit Test

Step 3...

Step 4...

Step 5...

Step 6 Read In value and inject limits into Step 7

Step 7 (copied from step 2 and renamed) Numeric Limit Test

 

What I am seeing is that Step 6 is injecting Limits into Step 2, rather than Step 7, even after step 2 has already run.  Not sure how to seperate 7 from 2, oither than giving it a different name.  Any ideas?  Please advise.  Thanks Much.

 

GSinMN 

 

 

0 Kudos
Message 1 of 5
(4,349 Views)

How are you doing the injection?  A code module?  An expression?

 

A copy paste won't work.  You need to find the code that is getting the next step and change it to be the right step name or index.  The other option is to use the StepID.  Historically, copying and pasting steps would use the same stepid.  Not sure if that is true anymore.  In anycase you should be able to regenerate the id if they are the same.

 

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 5
(4,345 Views)

Hello jigg,

 

  Thanks for the quick response.  I had been avoiding using the step ID for the exact reason you mentioned (it follows the step).  I have a little sequence that gets the step name of the future step and injects the limits based on that. 

 

  In any case, I think I figured it out.  It wasn't the step that was receiveing the limits that caused the problem, it was the step that was setting the name (just as you said).  It appears that all of the steps in the sequence need to have a unique name, otherwise it just refers back the first step with that name. 

 

Thanks for the help.

 

GSinMN 

0 Kudos
Message 3 of 5
(4,341 Views)

Yes, either make each step name unique.  Or you can use Caller.RunState.NextStepIndex if you know what you are doing.  The problem with this is that you are now enforcing the injection step to occur just before the injectee step.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 4 of 5
(4,336 Views)

Just want to clarify some things for readers of this thread:

 

1) If you copy and paste a step, the newly created step gets a new, unique id. I'm pretty sure it's been this way as long as step ids have existed in teststand. You can see this directly if you turn on "Show Hidden Properties" in the station options Preferences tab and look at Step.TS.Id in the variables view.

 

2) If you cut and paste rather than copy and paste then the unique ids are preserved since that is really a move operation.

 

3) If you are programmatically cloning/copying a step, you need to call Step.CreateUniqueStepId() on the copy before inserting it into a sequence to guarantee you have a new unique step id for the step.

 

4) If you refer to steps by id rather than name, then you can have duplicate names and still refer to specific steps. That is why preconditions use the step id by default. Here's an example of using a step id:

RunState.Sequence.Main["ID#:PHf5NngRb0+OVNYzTGhTSC"].Result.Status == "Failed"

 

 

5) The expression browser dialog will actually show the name as a comment when you view the expression (even if you don't have such a comment in the actual expression):

RunState.Sequence.Main["ID#:PHf5NngRb0+OVNYzTGhTSC"/* Unique Id of 'Statement' */].Result.Status == "Failed"

 

 

Hope this helps clarify things,

-Doug

0 Kudos
Message 5 of 5
(4,304 Views)