NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to check programmatically the default checkbox.

Solved!
Go to solution

Dear all,

 

When calling a "SequenceB" from a "SequenceA", a "parameter1" from "SequenceB" can be used with its default value by ticking the "DEFAULT" checkbox .

My question is, during runtime within "SequenceB", how can I check whether the "SequenceB" was called with the "parameter1" "DEFAULT" checkbox ticked?

 

Is there a clean way to check whether the "DEFAULT" checkbox is ticked or not?

I know I can use a work around by assigning an impossible default value (such as "-999"), and check during runtime if "parameter1" is equal to "-999", but I would really appreciate a generic approach.

 

Best regards,

Ludovic

0 Kudos
Message 1 of 5
(825 Views)

Hi Ludovic,

 

I do not know a way how check exactly if the DEFAULT checkbox was checked in the calling step.

However you could make your way around by checking if the passed value is equal to the default value.

Something like this could be considered a pretty generic solution:

 

Locals.DefaultIsChecked = Parameters.parameter1 == Runstate.SequenceFile.GetSequenceByName(Runstate.Sequence.Name).Parameters.GetValVariant("parameter1",0)

 

Stefan

0 Kudos
Message 2 of 5
(810 Views)

Hello Stefan,

 

Thank you for your feedback!

 

Actually what I want to do is:

If the checkbox is ticked => ignore the parameter value and use the corresponding value from a FileGlobals variable in the "SequenceB"

If the checkbox is not ticked => assign the parameter value to the FileGlobals variable and use this value in the "SequenceB"

 

The parameter might not always be a number, it can be a string, an enumeration, a boolean...

 

Your approach is better than my workaround but actually both would not always work, especially when considering a boolean. 

I could just put the FileGlobals variable in the parameter value when calling the "SequenceB" but it would make the end user life much easier if we could just use the DEFAULT checkbox logic.

0 Kudos
Message 3 of 5
(806 Views)
Solution
Accepted by topic author Lchar

Actually I found the variable:

RunState.CallingStep.TS.SData.ActualArgs.parameter1.UseDef is the boolean indicating whether the DEFAULT box was checked.

I'm interested though if this could have been found anywhere in the documentation.

 

Out of curiousity, what is the purpose of passing FileGlobals as subsequence parameters in general?

Are we talking different sequence files or multiple executions? From your second explanation it sounds like neither is the case.

 

Stefan

Message 4 of 5
(800 Views)

Thanks a lot it works!

I have tried to google this issue but I couldn't find a solution.

Maybe I don't have the best practice to use the documentation to find a very specific information.

I am still quite new with TestStand (4 months).

 

To answer your question about the use case:

 

I have a measurement sequence running continuously in a parallel thread.

This continuous measurement is using several values from a FileGlobals to run such as:

  • TimeBetweenTwoMeasurements (number)
  • LogData (Boolean)
  • MeasurementType (Enum)
  • ...

A limit file is loaded into the measurement device and the device is evaluating the results according to the limits on its own.

 

During the test, from the main thread, the user can call a subsequence to change this limit file from the device, and I give the opportunity with the parameters to also change the values from the FileGlobals used by the parallel thread.

By using the checkbox, it would either keep the values already defined in the FileGlobals or overwrite the FileGlobals with the new value from the parameter.

 

Of course the user could simply use a "statement" step to change the FileGlobals values but as the values most often will be updated at the same time as changing the limit file, I merge in the same sequence to make it easier for the user, and more compact in the main sequence.

0 Kudos
Message 5 of 5
(779 Views)