NI TestStand Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
kosist90

Use expressions/variables for units in numeric limit tests

Status: New

Currently, for limits in numeric limit tests, I am using TestStand variables, values of which are stored in configuration file. These variables are directly set in limits fields, but units - are specified directly, explicitly. 

 

It would be nice to have possibility assign to Units field variable, which value will be unit itself. Then, units for measurements could be also possible to store in configuration file. But, unfortunatelly, now it is not possilbe to assign to units expression or variable.

 

TestStand_UnitsExpression.PNG

2 Comments
Kiebach
Member
ee-jallen
Member

I upvoted this idea; however, you can do this with some extra actions added to the step.

  1. Use the Precondition expression area to run a couple of SetPropertyObject methods against the Step container.  The SetPropertyObject is used to add any number of additional property variables to the Step. We need to do this at the Precondition action as this is completed prior to the PreStep callback action. (See "Step Execution" in TestSTand Help).  Then we can leverage the process model/engine callbacks which pass the Step property to it.
  2. Example below uses Precondition to set objects that are aliases to a data struct container and struct size (if an array):
  3. // clever way to add variable to the Step container to "Pass" it to the PreStep call back
    Step.AsPropertyObject().SetPropertyObject("TestData", PropOption_ReferToAlias | PropOption_NotOwning | PropOption_InsertIfMissing, Locals.testData_2) == 0 &&
    Step.AsPropertyObject().SetPropertyObject("MeasurementCount", PropOption_ReferToAlias | PropOption_NotOwning | PropOption_InsertIfMissing,Locals.testDataSize ) == 0
  4. Add SequenceFilePostStep and SequenceFilePreStep to your client sequence
  5. When the callbacks are called you now have access to your Step and all it's properties and the additional data struct which contains "units" data.
  6. During SequenceFilePostStep use the units data in the custom data struct container to set the units in the Step container

Please note that Units cannot be set programmatically if it not set to default value in the Step or you can use a InsertIfMissing option.  Set Units programmatically - NI Community