NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to ask user for specific variables based on which modules are in sequence?

Solved!
Go to solution

Let's say I have three tests set up in individual LabVIEW modules - Test 1 has variable x, Test 2 has variable y, Test 3 has variable z. In TestStand, I want to ask the user for values of the variables at the beginning that are only needed based on what tests are in the sequence (Example: Sequence has Tests 1 and 2. I want the pop-up messages to only ask for variables x and y). It's a time-based sequence, so I need to collect variables at the very beginning and not in between calling the modules. I think I should use ThisContext to access the variables, but I don't know how to only limit it to the variables that are present in the current running sequence.

Alternatively, I was thinking to have an if statement that goes through all the possible Tests and asks for variables, but that will be limiting if later we add more tests, change the names of tests, etc.

 

Any idea?

0 Kudos
Message 1 of 7
(664 Views)

Hello Wootie, and welcome to NI Forums, in order to get the best help from the community it always a good idea to attach the VI's and/or photos of your VI in your post. Do this by using the "Drag and drop here or browse files attach" option in your reply. 

0 Kudos
Message 2 of 7
(637 Views)

Unfortunately, I work in a secure facility.  

Does my question make sense though?

0 Kudos
Message 3 of 7
(566 Views)
Solution
Accepted by topic author Wootie

Try something like this:

1.) Create a Shared Container for Inputs 

  • In the sequence file, go to -> Variables -> FileGlobals
  • Create a container call it something like 'TestInputs'
    • FileGlobals.TestInputs
      • x (Number)
      • y (Number)
      • z (Number)

2.) Tag each test step with what it needs

  • For each step that calls a LabVIEW module:
    • add a custom property named something like 'RequiredInputs' it might be a string array
      • Test 1 step -> ["x"]
      • Test 2 step -> ["y"]
      • Test 3 step -> ["z"] this will tell TestStand which variables each step needs

3.) Add a "Collect Inputs" step at the beginning 

  • In the Setup group, insert a new step called Collect Inputs.
  • This step will:
    • Look at all steps in the sequence (Main group).
    • Check which ones are enabled and not skipped.
    • Gather all RequiredInputs from those steps.
    • Prompt the user for those values (only the ones needed).
    • Store them in FileGlobals.TestInputs

4.) Bind each test's parameters to FileGlobals

  • For Test 1’s LabVIEW module:
    • Map its input parameter to FileGlobals.TestInputs.x
  • For Test 2:
    • Map to FileGlobals.TestInputs.y
  • For Test 3:
    • Map to FileGlobals.TestInputs.z

5.) Try it

  • The "Collect Inputs" should only ask for x and y if the sequence includes Test 1 and Test 2
  • If you add a 4th Test needing 'a', just tag it with ["a"] and add 'a' to the container

 

Accessing Dynamic Properties - NI

Accessing Dynamic Properties in LabVIEW - NI

TestStand Custom Step Type Development Best Practices - NI

0 Kudos
Message 4 of 7
(562 Views)

Thank you so much for your help. I'm a TestStand and LabVIEW newb, so it took me a good while to write up your solution. I'm currently stuck on the step 3: 

  • Prompt the user for those values (only the ones needed).
  • Store them in FileGlobals.TestInputs

Right now, my subVI results in a 1D string array of variable names needed to run the sequence. I also still have the array that I input to the subvi where each row corresponds to one step

i.e. x y z &

x

y

z

 

I could display this array and get my user to input their values in another array; however, how do I know how to assign the values they input? There doesn't seem to be a way to name a variable using a string variable. I tried to write a separate subVI that would display the array, make a copy and change to indicator and then ask for user to input values using original as reference for position, but that failed - when I put the subVI into my original subVI, it failed because the control and indicator were connected (i.e. the copying).

 

I could use setValNumber in TestStand so at least now the element is a number, but still how do I know which variable to link it with. Note: some steps require multiple variables so one by one assignment would not work.

 

Edit to add: I think I'm going to try one more thing and then report back.

0 Kudos
Message 5 of 7
(434 Views)

Thank you a million times over! 

 

The trick was to use Set Property Value with the TestStand API in LabVIEW - I could use the step name string to identify the correct TestStand array.

 

Thanks again!

Message 6 of 7
(407 Views)

That is awesome! LabVIEW can be tricky sometimes but very happy you figured it out! 

0 Kudos
Message 7 of 7
(404 Views)