/****************************************************************************** * * Title : primFunc_flashLed.c * Version 0.0, * * Description: Flash Led primitive function. * Related files: * * Author: Lukas Tomasek, tomasekl@fzu.cz * ******************************************************************************/ /****************************************************************************** * Header files * ******************************************************************************/ #include #include "processor.h" #include "primFunc_flashLed.h" #include "fileUtility.h" #include "globalDefinitions.h" #include "uirUtility.h" #include "primParamsUir.h" #include "mainUir.h" #include #include "primFunctionInit.h" /****************************************************************************** * Global functions * ******************************************************************************/ /*============================================================================= * primFunction_flashLed() *============================================================================= * * * */ ERROR_ID primFunction_flashLed(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 FLASH_LED_IN *flashLed=&primTable->params.flashLed; const int panel=global.panel.primEdit[getPrimArrayId(FLASH_LED)]; UINT32 i; UINT32 dataLength; struct FLASH_LED_IN *flashLedIn; struct FLASH_LED_OUT *flashLedOut; char textMessage[200]; char errorText[100]; UINT32 listIndex; int ringIndex; if(R_FLASH_LED!=R_FLASH_LED_HOST){ ERROR_CHECK(PROGRAM_ERROR, primitive FLASH_LED - wrong revision number); return(PROGRAM_ERROR); } switch(funcOption){ case PRIM_PANEL_TO_TABLE: GetCtrlVal(panel, FLASH_LEDP_PERIOD, &flashLed->period); GetCtrlVal(panel, FLASH_LEDP_NUM_TIMES, &flashLed->numTimes); GetCtrlVal(panel, FLASH_LEDP_NUMBER, &flashLed->ledNum); /* NO BREAK HERE!!!*/ case PRIM_PARAMS_TO_TABLE: /* add table headers - don't set indexes!!! */ primTable->inPrimHeader.length=SIZEOF(struct FLASH_LED_IN)+SIZEOF(struct MSG_HEAD); primTable->inPrimHeader.id=FLASH_LED; primTable->inPrimHeader.primRevision=R_FLASH_LED; primTable->replyLength=0; break; case PRIM_TABLE_TO_PANEL: if(primTable->inPrimHeader.primRevision!=R_FLASH_LED){ ERROR_CHECK(PROGRAM_ERROR, primitive FLASH_LED - wrong revision number); return(PROGRAM_ERROR); } SetCtrlVal(panel, FLASH_LEDP_PERIOD, flashLed->period); SetCtrlVal(panel, FLASH_LEDP_NUM_TIMES, flashLed->numTimes); SetCtrlVal(panel, FLASH_LEDP_NUMBER, flashLed->ledNum); break; case PRIM_BUILD: /* copy mask */ *(struct FLASH_LED_IN*)(primDataPtr)=*flashLed; break; case REP_DATA_PROCESS: /* no reply */ break; case WRITE_TO_FILE: file=(FILE*)inputParameter; fprintf(file, "ledNum= %d, period= 0x%X, numTimes= 0x%X\n", flashLed->ledNum, flashLed->period, flashLed->numTimes); break; case READ_FROM_FILE: file=(FILE*)inputParameter; status=fscanf(file, "ledNum= %d, period= 0x%X, numTimes= 0x%X\n", &flashLed->ledNum, &flashLed->period, &flashLed->numTimes); if(status==-1) {ERROR_CHECK(FATAL_ERROR, Read from prim file error!); return(FATAL_ERROR);} break; default: ; } return(SUCCESS); } /******************************************************************************/