/************************************************************************************* * slavePrimFuncts_sct.c * * synopsis: Contains the SCT-specific primitive functions which are used only by * the SDSPs. * * in this file: histogramSetup. * * related files: * histogram_sct.c: Contains the histogramming setup function. * * Douglas Ferguson, UW Madison (510) 486-5230 dpferguson@lbl.gov ************************************************************************************/ #include #include #include #include #include "resources.h" #include "primParams.h" #include "histogram.h" extern far HistoCtrl histoCtrl; extern far BinCtr binCtr; extern far FLOAT32 varRange[2][HISTOGRAM_BIN_MAX]; extern char genStr[]; #pragma CODE_SECTION(histogramSetup, "xcode"); /************************************************************************************ * histogramSetup * * synopsis: Sets up and initializes histograms and histogramming variables. This * is a shell which simply passes on the input parameters to the histogram * routine histoSetup, located inside histogram.c. * * arguments: See histoSetup.c in histogram.c * * author: Douglas Ferguson ************************************************************************************/ INT32 histogramSetup(PrimData *primData) { struct HISTOGRAM_SETUP_IN *histogramSetupIn= (struct HISTOGRAM_SETUP_IN *) primData->priBodyPtr; struct HISTOGRAM_SETUP_OUT *histogramSetupOut= (struct HISTOGRAM_SETUP_OUT *) primData->repBodyPtr; INT32 returnCode= SUCCESS; UINT32 *base, nBins, binSize, routineType, dataType[2], opt[4], i; UINT32 validModules[2], moduleRangeMap[2][2]; MDAT32 *xPtr[2]; base= histogramSetupIn->base; nBins= histogramSetupIn->nBins; binSize= histogramSetupIn->binSize; routineType= histogramSetupIn->routineType; for (i=0; i<4; ++i) opt[i]= histogramSetupIn->opt[i]; for (i=0; i<2; ++i) { validModules[i]= histogramSetupIn->validModules[i]; xPtr[i]= histogramSetupIn->xPtr[i]; dataType[i]= histogramSetupIn->dataType[i]; moduleRangeMap[i][0]= histogramSetupIn->moduleRangeMap[i][0]; moduleRangeMap[i][1]= histogramSetupIn->moduleRangeMap[i][1]; } primData->repBodyLength= SIZEOF(struct HISTOGRAM_SETUP_OUT); histogramSetupOut->ctrlPtr= (UINT32 *) &histoCtrl; histogramSetupOut->binCtrPtr= (UINT32 *) &binCtr; histogramSetupOut->varRangePtr= (UINT32 *) &varRange; if ((xPtr[0] == (MDAT32 *) DEFAULT)||(xPtr[1] == (MDAT32 *) DEFAULT)) { /* Both must be set to the default position (in list), or neither. */ if ((xPtr[0] != (MDAT32 *) DEFAULT)||(xPtr[1] != (MDAT32 *) DEFAULT)) { newError(&returnCode, PRIM_PARAMETER_ERROR, FATAL_ERR, "histogramSetup", "Both data pointers must be included in the list, if one is.\n", __FILE__, __LINE__); return returnCode; } xPtr[0]= ((MDAT32 *) histogramSetupIn) +SIZEOF(struct HISTOGRAM_SETUP_IN); xPtr[1]= xPtr[0] +nBins; } returnCode= histoSetup(base, nBins, binSize, routineType, dataType, opt, validModules, moduleRangeMap, xPtr); if (returnCode!= SUCCESS) { addError(&returnCode, HISTOGRAM_SETUP_ERROR, "histogramSetup", "Fatal error while setting up histograms.\n", __FILE__, __LINE__); } return returnCode; }