NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Create unique reference in custom step type to store execution

Solved!
Go to solution

I'll explain what I'm trying to do first... 🙂

 

I'm trying to create a step type (combined with a sequence call) that creates a new execution.

I want to store the execution created in a reference object so I can send it to a user interface vis uiMsg.

 

To allow maximum flexibility to the developpers using the step type, I'm trying to make everything 'magic' when they instert the new step type (creating ref obj variable using substep OnNewStep, sending uiMsg, etc.).

 

I'm having a problem for the obj variable. I want to create it with a unique name so everytime they add the step type, it doesn't conflict with another variable name. I though using the Step.TS.ID for the name of the variable, but I realized that some IDs contains the characters '/', '#' or '+'. Those characters aren't accepted by TestStand for a variable name, but it seems we don't get the error when we create them programmaticaly. It actually creates the variable with the name ID:#12243+12/asdf for example.

 

When I use the Locals.GetPropertyObject("Executions." + Step.TS.Id, 0x00) as a reference to store the execution, it doesn't work.

 

When I add the step in sequence, the ref obj is correctly created as expected (Locals.Executions.*stepID*).

 

But the reference is never stored in the variable expected. It is stored instead in Locals.__SC_Executions.ID_ID#:OAIrDBpzuUuukUYrRX1gGC.

 

Am I doing something wrong or do you see any other way of doing this? I included an example in attachment. Thank you.

 

PS: I tried to remove the first 4 characters of step ID (ID#:) and I tried with a step ID containing only letters or numbers and it still didn't work. So the illegal characters used to name the ref object might not be the problem

0 Kudos
Message 1 of 10
(5,542 Views)

Howdy Mat,

 

I found another discussion dealing with the UniqueStepID here. If you're looking for a simple way to generate a unique name for a variable, then you might first remove non-alphanumeric characters from the unique ID and prepend what's left with a TicCount. That would give you a very unique local variable. Another consideration may have the variable name be a simple number that gets incremented after each variable creation.

 

I hope this helps! Please let me know if I've misinterpreted your question.

Warm regards,

pBerg
Message 2 of 10
(5,501 Views)

The other discussion is interesting and I didn't know all the details of the step.id (all the characters possible, etc.) but I don't think I'll have the same issue of the guy who started the thread since my steps only need to be unique in the sequence and TS can take care of that.

 

I don't think the step unique ID is the problem there anyways. I though it was at the beginning, but by removing the "ID#:" and creating a variable with only alpha-numerical characters, everything is standart. Please take a look at my sequence in attachment to see.

 

My question is more why it doesn't store the obj ref in the variable created in the substep OnNewStep. In that case Locals.Executions.zeYt36eLr060JYbbyoXyIB

 

The local variable exist before the sequence is run since it is created when you add the step type in the sequence, so everything should be ok.

 

Thanks for your time and for your help.

 

 

 

0 Kudos
Message 3 of 10
(5,494 Views)
Solution
Accepted by topic author MatLaroche

Mat -

 

Instead of: Locals.GetPropertyObject("Executions." + Mid(Step.TS.Id, 4), 0x00)

 

Use: Evaluate("Locals.Executions." + Mid(Step.UniqueStepID, 4))

 

The __SC_Executions container is automatically generated by TestStand to be used for other things and has nothing to do with the Local variable that you are defining.

 

Hope this helps.

Manooch H.
National Instruments
Message 4 of 10
(5,488 Views)

Thanks, it works using Evaluate instead.

 

What is the difference between Evaluate(string lookupstr) and GetPropertyObject(lookupstr, options)?

 

They both seem to return the propertyobject that I want.

0 Kudos
Message 5 of 10
(5,471 Views)
Perhaps you could store the execution in a subproperty of the step instead of in a local variable.
0 Kudos
Message 6 of 10
(5,451 Views)
Good idea Erik! I'll give it a shot, it makes more sense.
0 Kudos
Message 7 of 10
(5,425 Views)

Thank you Manooch for the solution.

I would like to know:

 

What is the difference between Evaluate(string lookupstr) and GetPropertyObject(lookupstr, options)?

 

They both seem to return the propertyobject that I want.

0 Kudos
Message 8 of 10
(5,309 Views)

Mat -

 

Evaluate() returns the actual Property Object where as GetPropertyObject() returns a Property Object that contains the actual Property Object as a Referenced Property Object. See the image below:

 

forumResponse.png

 

The Locals.getPropObj variable was set using GetPropertyObject() whereas the Locals.useEvaluate variable was set using Evaluate(). As you can see, Locals.getPropObj is actually a Property Object that contains a reference to the Executions.zeYt36eLr060JYbbyoXyIB Object Reference. However, Locals.useEvaluate is a copy of the actual Executions.zeYt36eLr060JYbbyoXyIB Object Reference.

 

We are considering adding de-reference operators in a future version of TestStand. Hope this helps.

Manooch H.
National Instruments
Message 9 of 10
(5,303 Views)
Thank you for the example. I understand now the difference between both.
0 Kudos
Message 10 of 10
(5,301 Views)