/****************************************************************************** * * Title : primFunc_sendConfig.c * Version 0.0, * * Description: * Related files: * * Author: Lukas Tomasek, tomasekl@fzu.cz * ******************************************************************************/ /****************************************************************************** * Header files * ******************************************************************************/ #include #include "primFunc_sendConfig.h" #include "globalDefinitions.h" #include "uirUtility.h" #include "primParamsUir.h" #include "mainUir.h" #include #include "primFunctionInit.h" /****************************************************************************** * Global functions * ******************************************************************************/ /*============================================================================= * primFunction_sendConfig() *============================================================================= * * * */ ERROR_ID primFunction_sendConfig(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; char errorMessage[200]; int status; int xx[]= {0,0}; UINT32 primBodyLength; UINT32 primitiveId; SendConfigIn *sendConfig=&primTable->params.sendConfig; const int panel=global.panel.primEdit[getPrimArrayId(SEND_CONFIG)]; if(R_SEND_CONFIG!=R_SEND_CONFIG_HOST){ ERROR_CHECK(PROGRAM_ERROR, primitive SEND_CONFIG - wrong revision number); return(PROGRAM_ERROR); } switch(funcOption){ case PRIM_PANEL_TO_TABLE: GetCtrlVal(panel, SEND_CFGP_CMD_BUFF, &sendConfig->port); //dpsf: GetCtrlVal(panel, SEND_CFGP_CAP_SER_ON, &sendConfig->captureSerOn); GetCtrlVal(panel, SEND_CFGP_MODULE0, &sendConfig->module[0]); GetCtrlVal(panel, SEND_CFGP_MODULE1, &sendConfig->module[1]); GetCtrlVal(panel, SEND_CFGP_CHIP, &sendConfig->chip); GetCtrlVal(panel, SEND_CFGP_SET_LINKS, &sendConfig->setLinks); //dpsf: GetCtrlVal(panel, SEND_CFGP_RESTORE, &sendConfig->restore); GetCtrlVal(panel, SEND_CFGP_STRUCT_ID, &sendConfig->cfgSet); GetCtrlVal(panel, SEND_CFGP_GROUP_ID, &sendConfig->groupId); GetCtrlVal(panel, SEND_CFGP_TYPE, &sendConfig->dataType); GetCtrlVal(panel, SEND_CFGP_ACTIVE, &sendConfig->activeOnly); GetCtrlVal(panel, SEND_CFGP_ENABLE_DATA_TAKING, &sendConfig->enableDataTaking); /* NO BREAK HERE!!!*/ case PRIM_PARAMS_TO_TABLE: /* add table headers - don't set indexes!!! */ primTable->inPrimHeader.length=SIZEOF(SendConfigIn)+SIZEOF(struct MSG_HEAD); primTable->inPrimHeader.id=SEND_CONFIG; primTable->inPrimHeader.primRevision=R_SEND_CONFIG; primTable->replyLength=0; /* no reply */ break; case PRIM_TABLE_TO_PANEL: if(primTable->inPrimHeader.primRevision!=R_SEND_CONFIG){ ERROR_CHECK(PROGRAM_ERROR, primitive SEND_CONFIG - wrong revision number); return(PROGRAM_ERROR); } SetCtrlVal(panel, SEND_CFGP_CMD_BUFF, sendConfig->port); //dpsf: SetCtrlVal(panel, SEND_CFGP_CAP_SER_ON, sendConfig->captureSerOn); SetCtrlVal(panel, SEND_CFGP_MODULE0, sendConfig->module[0]); SetCtrlVal(panel, SEND_CFGP_MODULE1, sendConfig->module[1]); SetCtrlVal(panel, SEND_CFGP_CHIP, sendConfig->chip); SetCtrlVal(panel, SEND_CFGP_SET_LINKS, sendConfig->setLinks); //dpsf: SetCtrlVal(panel, SEND_CFGP_RESTORE, sendConfig->restore); SetCtrlVal(panel, SEND_CFGP_STRUCT_ID, sendConfig->cfgSet); SetCtrlVal(panel, SEND_CFGP_GROUP_ID, sendConfig->groupId); SetCtrlVal(panel, SEND_CFGP_TYPE, sendConfig->dataType); SetCtrlVal(panel, SEND_CFGP_ACTIVE, sendConfig->activeOnly); SetCtrlVal(panel, SEND_CFGP_ENABLE_DATA_TAKING, sendConfig->enableDataTaking); break; case PRIM_BUILD: /* copy data */ *(SendConfigIn*)(primDataPtr)=*sendConfig; break; case REP_DATA_PROCESS: /* no reply data */ break; case WRITE_TO_FILE: file=(FILE*)inputParameter; fprintf(file, "port= %d, captureSerOn= %d, moduleNum[]={ %d, %d }, chipNum= 0x%x\n", sendConfig->port, xx[0], sendConfig->module[0], sendConfig->module[1], sendConfig->chip); fprintf(file, "setLinks= %d, restore= %d, structId= %d, groupId= %d\n", sendConfig->setLinks, xx[1], sendConfig->cfgSet, sendConfig->groupId); fprintf(file, "dataType= %d, activeOnly= %d, enableDataTaking= %d\n", sendConfig->dataType, sendConfig->activeOnly, sendConfig->enableDataTaking); break; case READ_FROM_FILE: file=(FILE*)inputParameter; status=fscanf(file, "port= %d, captureSerOn= %d, moduleNum[]={ %d, %d }, chipNum= 0x%x\n", &sendConfig->port, &xx[0], &sendConfig->module[0], &sendConfig->module[1], &sendConfig->chip); if(status==-1) {ERROR_CHECK(FATAL_ERROR, Read from prim file error!); return(FATAL_ERROR);} status=fscanf(file, "setLinks= %d, restore= %d, structId= %d, groupId= %d\n", &sendConfig->setLinks, &xx[1], &sendConfig->cfgSet, &sendConfig->groupId); if(status==-1) {ERROR_CHECK(FATAL_ERROR, Read from prim file error!); return(FATAL_ERROR);} status=fscanf(file, "dataType= %d, activeOnly= %d, enableDataTaking= %d\n", &sendConfig->dataType, &sendConfig->activeOnly, &sendConfig->enableDataTaking); if(status==-1) {ERROR_CHECK(FATAL_ERROR, Read from prim file error!); return(FATAL_ERROR);} break; default: ;//error } return(SUCCESS); } /******************************************************************************/