/****************************************************************************** * * Title : primFunc_BOChisto.c * Version 0.0 * * Description: BOC histogram primitive function. * Related files: * * Author: Lukas Tomasek, tomasekl@fzu.cz * ******************************************************************************/ /****************************************************************************** * Header files * ******************************************************************************/ #include #include "primFunc_BOChisto.h" #include "uirUtility.h" #include "primParamsUir.h" #include #include "primFunctionInit.h" /****************************************************************************** * Global functions * ******************************************************************************/ /*============================================================================= * primFunction_BOChisto() *============================================================================= * * * */ ERROR_ID primFunction_BOChisto(PRIM_FUNC_OPTION funcOption, struct PRIM_TABLE *primTable, void *primitive, UINT32 inputParameter, UINT8 slotNumber){ FILE *file; struct MSG_HEAD* primHeader=(struct MSG_HEAD*) primitive; UINT32 *primDataPtr=(UINT32*)((UINT32)primHeader+sizeof(struct MSG_HEAD)); ERROR_ID errorId=SUCCESS; int status; struct BOC_HISTOGRAM_IN *BOChisto=&primTable->params.BOChisto; const int panel=global.panel.primEdit[getPrimArrayId(BOC_HISTOGRAM)]; struct HOST *host; UINT32 dataLength; char subdir[PATHNAME_LENGTH]; if(R_BOC_HISTOGRAM!=R_BOC_HISTOGRAM_HOST){ // ERROR_CHECK(PROGRAM_ERROR, primitive BOC_HISTOGRAM - wrong revision number); return(PROGRAM_ERROR); } switch(funcOption){ case PRIM_PANEL_TO_TABLE: GetCtrlVal(panel, BOC_HIST_NUM_SAMPLES, &BOChisto->numSamples); GetCtrlVal(panel, BOC_HIST_NUM_LOOPS, &BOChisto->numLoops); /* NO BREAK HERE!!!*/ case PRIM_PARAMS_TO_TABLE: /* add table headers - don't set indexes!!! */ primTable->inPrimHeader.length=SIZEOF(struct BOC_HISTOGRAM_IN)+SIZEOF(struct MSG_HEAD); primTable->inPrimHeader.id=BOC_HISTOGRAM; primTable->inPrimHeader.primRevision=R_BOC_HISTOGRAM; primTable->replyLength=192+SIZEOF(struct MSG_HEAD); break; case PRIM_TABLE_TO_PANEL: if(primTable->inPrimHeader.primRevision!=R_BOC_HISTOGRAM){ ERROR_CHECK(PROGRAM_ERROR, primitive BOC_HISTOGRAM - wrong revision number); return(PROGRAM_ERROR); } SetCtrlVal(panel, BOC_HIST_NUM_SAMPLES, BOChisto->numSamples); SetCtrlVal(panel, BOC_HIST_NUM_LOOPS, BOChisto->numLoops); break; case PRIM_BUILD: /* copy data */ *(struct BOC_HISTOGRAM_IN*)(primDataPtr)=*BOChisto; break; case REP_DATA_PROCESS: host=global.host[HOST_INDEX(slotNumber)]; /* save reply data */ strcpy(subdir, host->dataDir); strcat(subdir, " BOC_histo.out"); errorId=writeToBinFile(subdir, 0, primDataPtr, 192); ERROR_CHECK(errorId, writeToBinFile()); break; case WRITE_TO_FILE: file=(FILE*)inputParameter; fprintf(file, "numSamples= 0x%X, numLoops= 0x%X\n", BOChisto->numSamples, BOChisto->numLoops); break; case READ_FROM_FILE: file=(FILE*)inputParameter; status=fscanf(file, "numSamples= 0x%X, numLoops= 0x%X\n", &BOChisto->numSamples, &BOChisto->numLoops); if(status==-1) {ERROR_CHECK(FATAL_ERROR, Read from prim file error!); return(FATAL_ERROR);} break; default: ; } return(SUCCESS); } /******************************************************************************/