Rockwell Automation FactoryTalk Historian Classic User Guide User Manual
Page 149

Creating RSBizWare Custom Analysis Tools Chapter 7
The first thing the program must do is check that valid output
pointers were passed into the
Calculate()
function. The following
code is created automatically for
Calculate()
function by Visual
C++:
if (xOutArray == NULL)
return E_POINTER;
if (yOutArray == NULL)
return E_POINTER;
To complete the
Calculate()
function, do the following by adding
the specified code to the function (contained in the NegativeCalc.h
file):
1. Determine the size of the output array. The Configuration
Console does not assume that the output array will be the
same size as the input array. In this case, the program will
return X and Y arrays of the same size, but the program must
still allocate the arrays in the
Calculate()
function. The
following code determines the size of the input arrays by using
the
GetVariantDoubleArraySize()
utility function:
// Convert input args to double arrays
long xInSize = GetVariantDoubleArraySize(&xInArray);
long yMinInSize = GetVariantDoubleArraySize(&yMinInArray);
long yMaxSize = GetVariantDoubleArraySize(&yMaxInArray);
long countInSize = GetVariantDoubleArraySize(&CountInArray);
2. Extract the data from the input arrays. Remember, the data is
passed in as a series of VARIANTs which contain arrays of
double precision floating point numbers. Another VARIANT
utility function (ExtractVariantDoubleArray()) is used to
convert the VARIANTs into arrays of C++ native double
precision floating point numbers:
// Create double arrays to hold the values in the VARIANT
// array input args
double *xIn = new double[xInSize];
double *yMinIn = new double[yMinInSize];
Rockwell Automation Publication HIST-UM001K-EN-E-June 2014
149