NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

I am

looking for a sequence in teststand that searches for the maximum and minimum values (not bounds) within an array of numbers. Also, how do you use variables declared inside the testand locals tab outside of the teststand environments with programs like C.
0 Kudos
Message 1 of 2
(2,986 Views)
looking for a sequence in teststand that searches for the maximum and minimum values (not bounds) within an array of numbers. Also, how do you use variables declared inside the testand locals tab outside of the teststand environments with programs like C.Israel,

In order to answer your first question (search for max and min values within an array) let me start by addressing the second one. There are two ways to access TestStand variables in your C program.

1) Pass the sequence context to your C function and access variables such as "Locals.Number1" with the TestStand ActiveX API.
For example, the following statement can be executed in your C program to set the TestStand Local variable "Number1" to the value 10.0 (the syntax might change depending on your C compiler):

SeqContext.SetValNumber("Locals.Number1", 0, 10.0)

To use this method, you need to be able to call ActiveX servers from your C code.

2) Pass a reference to TestStand properties/variables directly by using the correct function prototype in a DLL.
If you ha
ve a C compiler capable of building DLLs, you can easily export a function that can receive TestStand variables.
For example, if we have the following exported function in a DLL

void __stdcall myfunc(double* num1, int* errorCode) {
*num1 = 10.0;
*errorCode = 0;
}

then we can call this function from TestStand and pass a reference to our local variable "Number1." Inside the function "myfunc" we are setting Locals.Number1 equal to 10.0. The changes will be reflected back in TestStand automatically.

Now back to your first question, you can access a TestStand array in your C code and do a search for the max and min just the same as you would a number. There are some examples that ship with TestStand (with C code included) that access 1D and 2D arrays. Look under the Examples folder.

If you have any other questions, don't hesitate to reply back.

Regards,

Azucena Perez
0 Kudos
Message 2 of 2
(2,986 Views)