/****************************************************************************** * * Title : primFunc_testGlobalReg.c * Version 0.0 * * Description: * Related files: * * Author: Lukas Tomasek, tomasekl@fzu.cz * ******************************************************************************/ #ifdef PIXEL_ROD /****************************************************************************** * Header files * ******************************************************************************/ #include #include "primFunc_testGlobalReg.h" #include "fileUtility.h" #include "globalDefinitions.h" #include "uirUtility.h" #include "primParamsUir.h" #include "primFunctionInit.h" #include "mainUir.h" #include "RWlists.h" /****************************************************************************** * Global functions * ******************************************************************************/ /*============================================================================= * primFunction_testGlobalReg() *============================================================================= * * * */ ERROR_ID primFunction_testGlobalReg(PRIM_FUNC_OPTION funcOption, struct PRIM_TABLE *primTable, void *primitive, UINT32 inputParameter, UINT8 slotNumber){ FILE *file; ERROR_ID errorId=SUCCESS; char errorMessage[200]; int status; char *fileName; unsigned int fileSize; struct MSG_HEAD* primHeader=(struct MSG_HEAD*) primitive; UINT32 *primDataPtr=(UINT32*)((UINT32)primHeader+sizeof(struct MSG_HEAD)); struct HOST *host; UINT32 primBodyLength; UINT32 primitiveId; unsigned int paramsLength; int outputFile; struct TEST_GLOBAL_REG_PARAMS *testGlobalReg=&primTable->params.testGlobalReg; char subdir[PATHNAME_LENGTH]; const int panel=global.panel.primEdit[getPrimArrayId(TEST_GLOBAL_REG)]; unsigned int listIndex; struct TEST_GLOBAL_REG_IN *testGlobalRegBuff; struct TEST_GLOBAL_REG_OUT *testGlobalRegOut; if(R_TEST_GLOBAL_REG!=R_TEST_GLOBAL_REG_HOST){ ERROR_CHECK(PROGRAM_ERROR, primitive TEST_GLOBAL_REG - wrong revision number); return(PROGRAM_ERROR); } switch(funcOption){ case PRIM_PANEL_TO_TABLE: GetCtrlVal(panel, TESTGREG_STRUCT_ID, &testGlobalReg->inputParams.structId); GetCtrlVal(panel, TESTGREG_MODULE_ID, &testGlobalReg->inputParams.moduleId); GetCtrlVal(panel, TESTGREG_FE_INDEX, &testGlobalReg->inputParams.FEIndex); GetCtrlVal(panel, TESTGREG_OUT_FILE, &testGlobalReg->outFileName); /* NO BREAK HERE!!!*/ case PRIM_PARAMS_TO_TABLE: /* add table headers - don't set indexes!!! */ primTable->inPrimHeader.length=SIZEOF(struct MSG_HEAD)+SIZEOF(struct TEST_GLOBAL_REG_IN); primTable->inPrimHeader.id=TEST_GLOBAL_REG; primTable->inPrimHeader.primRevision=R_TEST_GLOBAL_REG_HOST; primTable->replyLength=SIZEOF(struct MSG_HEAD)+SIZEOF(struct TEST_GLOBAL_REG_OUT); // not known break; case PRIM_TABLE_TO_PANEL: if(primTable->inPrimHeader.primRevision!=R_TEST_GLOBAL_REG){ ERROR_CHECK(PROGRAM_ERROR, primitive TEST_GLOBAL_REG - wrong revision number); return(PROGRAM_ERROR); } SetCtrlVal(panel, TESTGREG_STRUCT_ID, testGlobalReg->inputParams.structId); SetCtrlVal(panel, TESTGREG_MODULE_ID, testGlobalReg->inputParams.moduleId); SetCtrlVal(panel, TESTGREG_FE_INDEX, testGlobalReg->inputParams.FEIndex); SetCtrlVal(panel, TESTGREG_OUT_FILE, testGlobalReg->outFileName); break; case PRIM_BUILD: testGlobalRegBuff=(struct TEST_GLOBAL_REG_IN*)(primDataPtr); /* copy data */ *testGlobalRegBuff=testGlobalReg->inputParams; break; case REP_DATA_PROCESS: host=global.host[HOST_INDEX(slotNumber)]; testGlobalRegOut= (struct TEST_GLOBAL_REG_OUT*) primDataPtr; if(testGlobalRegOut->testResult!=0){ HOST_ERROR_CHECK(HOST_ERROR, (struct HOST*)host, TEST_GLOBAL_REG not equal 0 !!); } SetCtrlVal(host->panel.parent, ROD_TGR_TIME, TimeStr()); listIndex=host->listTable.inListHeader.index; SetCtrlVal(host->panel.parent, ROD_TGR_INDEX, listIndex); SetCtrlVal(host->panel.parent, ROD_TEST_RESULT, testGlobalRegOut->testResult); if(testGlobalReg->outFileName[0]!=0){ strcpy(subdir, host->dataDir); strcat(subdir, testGlobalReg->outFileName); errorId=writeToBinFile(subdir, 0, &testGlobalRegOut->data, testGlobalRegOut->dataLen*sizeof(UINT32)); ERROR_CHECK(errorId, writeToBinFile()); } break; case WRITE_TO_FILE: file=(FILE*)inputParameter; fprintf(file, "structId= %d, moduleId= 0x%X, FEIndex= 0x%X\n", testGlobalReg->inputParams.structId, testGlobalReg->inputParams.moduleId, testGlobalReg->inputParams.FEIndex); fprintf(file, "outFileName[]= %s\n", testGlobalReg->outFileName); break; case READ_FROM_FILE: file=(FILE*)inputParameter; status=fscanf(file, "structId= %d, moduleId= 0x%X, FEIndex= 0x%X\n", &testGlobalReg->inputParams.structId, &testGlobalReg->inputParams.moduleId, &testGlobalReg->inputParams.FEIndex); if(status==-1) {ERROR_CHECK(FATAL_ERROR, Read from prim file error!); return(FATAL_ERROR);} status=readLineFromIndex(file, strlen("outFileName[]= "), PATHNAME_LENGTH, testGlobalReg->outFileName); if(status!=0) {ERROR_CHECK(FATAL_ERROR, Read from prim file error!); return(FATAL_ERROR);} break; default: ; } return(SUCCESS); } /******************************************************************************/ #endif /* PIXEL_ROD */