How do I Access the String or Numeric Measurement when Using the DLL Flexible Prototype Adapter?

Publish Date: Sep 06, 2006 | 1 Ratings | 4.00 out of 5 |  PDF

1. Passing the arguments to the code module

You can pass the numeric or string measurement to the test function. You access these properties in TestStand using the expressions: Step.Result.Numeric and Step.Result.String.

In the test function, just set the string or numeric measurement. In fact, the code templates for the DLL adapter will create the code to set the numeric measurement or string measurement. When you specify the module for the DLL Flexible Prototype Adapter and you click Create Code in the Source Code tab of the Edit DLL Call dialog, TestStand will create the function that you specified from the code template. Look at the code copied below.

To allow the test function to modify the string that was passed in, you must set the Pass ring in TestStand's specify module dialog for the string measurement step type, to C String Buffer. If you set it to C String, the string will not be modified when the test function returns.

void __declspec(dllexport) __stdcall test(CAObjHandle seqContextCVI, double *measurement,
short *errorOccurred, long *errorCode, char errorMsg[1024])
{

    int error = 0;
    // ErrMsg errMsg = {'\0'};
    // ERRORINFO errorInfo;

    double testMeasurement = 5.0;
    *measurement = testMeasurement;

Error:
    // If an error occurred, set the error flag to cause a run-time error in TestStand.
    if (error < 0)
      {
      *errorOccurred = TRUE;
      // OPTIONALLY SET THE ERROR CODE AND STRING
      // *errorCode = error;
      // strcpy(errorMsg, errMsg);
      }
    return;
}


void __declspec(dllexport) __stdcall strTest(CAObjHandle seqContextCVI, char stringMeasurement[1024],
short *errorOccurred, long *errorCode, char errorMsg[1024])
{
    int error = 0;
    // ErrMsg errMsg = {'\0'};
    // ERRORINFO errorInfo;

    char *stringValue = "String value from test.";
    StringCopyMax(stringMeasurement, stringValue, 1024);


Error:
    // If an error occurred, set the error flag to cause a run-time error in TestStand.
    if (error < 0)
      {
      *errorOccurred = TRUE;
      // OPTIONALLY SET THE ERROR CODE AND STRING
      // *errorCode = error;
      // strcpy(errorMsg, errMsg);
      }
    return;
}

Back to Top

2. Using the TestStand API


You can use the TestStand API to set the numeric or string measurement. The following example demonstrates this: TestStand\examples\AccessingPropertiesAndVariables\PassingSequenceContextToDLL.

The TestStand API has more overhead than directly passing the String or Numeric Measurement property as described above.

Back to Top

Bookmark & Share

Ratings

Rate this document

Answered Your Question?
Yes No

Submit