/****************************************************************************** * * Title : primFunc_configSlave.c * Version 0.0, * * Description: Config slave DSP primitive function. * Related files: * * Author: Lukas Tomasek, tomasekl@fzu.cz * ******************************************************************************/ /****************************************************************************** * Header files * ******************************************************************************/ #include #include "primFunc_configSlave.h" #include "globalDefinitions.h" #include "uirUtility.h" #include "primParamsUir.h" #include "mainUir.h" #include #include "primFunctionInit.h" /****************************************************************************** * Global functions * ******************************************************************************/ /*============================================================================= * primFunction_configSlave() *============================================================================= * * * */ ERROR_ID primFunction_configSlave(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; UINT32 primBodyLength; UINT32 primitiveId; struct CONFIG_SLAVE_IN *configSlave=&primTable->params.configSlave; const int panel=global.panel.primEdit[getPrimArrayId(CONFIG_SLAVE)]; UINT32 i; UINT32 dataLength; struct CONFIG_SLAVE_DSP_IN *configSlaveIn; struct CONFIG_SLAVE_DSP_OUT *configSlaveOut; char textMessage[200]; char errorText[100]; UINT32 listIndex; int ringIndex; struct HOST *host; if(R_CONFIG_SLAVE!=R_CONFIG_SLAVE_HOST){ ERROR_CHECK(PROGRAM_ERROR, primitive CONFIG_SLAVE - wrong revision number); return(PROGRAM_ERROR); } switch(funcOption){ case PRIM_PANEL_TO_TABLE: GetCtrlVal(panel, CONFIG_SLV_SLV_ID, &configSlave->slaveNumber); GetCtrlVal(panel, CONFIG_SLV_ON_OFF, &configSlave->commOnOff); GetCtrlVal(panel, CONFIG_SLV_TYPE, &configSlave->slaveType); /* NO BREAK HERE!!!*/ case PRIM_PARAMS_TO_TABLE: /* add table headers - don't set indexes!!! */ primTable->inPrimHeader.length=SIZEOF(struct CONFIG_SLAVE_IN)+SIZEOF(struct MSG_HEAD); primTable->inPrimHeader.id=CONFIG_SLAVE; primTable->inPrimHeader.primRevision=R_CONFIG_SLAVE; primTable->replyLength=0; break; case PRIM_TABLE_TO_PANEL: if(primTable->inPrimHeader.primRevision!=R_CONFIG_SLAVE){ ERROR_CHECK(PROGRAM_ERROR, primitive CONFIG_SLAVE - wrong revision number); return(PROGRAM_ERROR); } SetCtrlVal(panel, CONFIG_SLV_SLV_ID, configSlave->slaveNumber); SetCtrlVal(panel, CONFIG_SLV_ON_OFF, configSlave->commOnOff); SetCtrlVal(panel, CONFIG_SLV_TYPE, configSlave->slaveType); break; case PRIM_BUILD: /* copy data */ *(struct CONFIG_SLAVE_IN*)(primDataPtr)=*configSlave; /* set panel LED's on or off - should be moved to reply!!! */ host=global.host[HOST_INDEX(slotNumber)]; switch(configSlave->slaveNumber){ case 0: SetCtrlVal(host->panel.parent, ROD_SLAVE0, configSlave->commOnOff); break; case 1: SetCtrlVal(host->panel.parent, ROD_SLAVE1, configSlave->commOnOff); break; case 2: SetCtrlVal(host->panel.parent, ROD_SLAVE2, configSlave->commOnOff); break; case 3: SetCtrlVal(host->panel.parent, ROD_SLAVE3, configSlave->commOnOff); break; } break; case REP_DATA_PROCESS: /* no reply */ break; case WRITE_TO_FILE: file=(FILE*)inputParameter; fprintf(file, "slaveNumber= %d, commOnOff= %d, slaveType= %d\n", configSlave->slaveNumber, configSlave->commOnOff, configSlave->slaveType); break; case READ_FROM_FILE: file=(FILE*)inputParameter; status=fscanf(file, "slaveNumber= %d, commOnOff= %d, slaveType= %d\n", &configSlave->slaveNumber, &configSlave->commOnOff, &configSlave->slaveType); if(status==-1) {ERROR_CHECK(FATAL_ERROR, Read from prim file error!); return(FATAL_ERROR);} break; default: ; } return(SUCCESS); } /******************************************************************************/