void setup(void) { pwmInit(); dirInit(); }
void performCommandPLC() { UINT8 ui8NameStrDL[15]; UINT32 pos; UINT32 err = SUCCESS; UINT32 ui32dstDirPos; switch(ucHMI_addr) { case PLC_TIME: stime.tm_sec = uiHMIWord[PLC_TIME+5]; stime.tm_min = uiHMIWord[PLC_TIME+4]; stime.tm_hour = uiHMIWord[PLC_TIME+3]; stime.tm_mday = uiHMIWord[PLC_TIME+2]; stime.tm_mon = uiHMIWord[PLC_TIME+1]; stime.tm_year = uiHMIWord[PLC_TIME]-1900; timeSet(&stime); #if C_LEVI_DEBUG printf("time=%d/%d/%d %d:%d:%d ",uiHMIWord[PLC_TIME],uiHMIWord[PLC_TIME+1],uiHMIWord[PLC_TIME+2],uiHMIWord[PLC_TIME+3],uiHMIWord[PLC_TIME+4],uiHMIWord[PLC_TIME+5]); #endif if((uiHMIWord[PLC_TIME]!=2000)||(uiHMIWord[PLC_TIME+1]!=01)) ui8TimeFlag = 1; timeGet(&ptime); sio_psprintf(ui8NameStrDL, "%02d%02d%02dDC.CSV", (UINT32)(ptime->tm_year-100)%100, ptime->tm_mon,ptime->tm_mday); xdcfCurRootDirSet(ui8TermModule); //mp3_GetFileList(); pos = myFindFile(ui8NameStrDL); myGetSingleDayDL(pos, &ui32SuccessNum); break; case PLC_PARA_BUF: memcpy((UINT8 *)&curDevice, (UINT8 *)&uiHMIWord[PLC_PARA_BUF], C_PLC_PARA_NUM*sizeof(UINT16)); #if C_LEVI_DEBUG printf("device=%d, class=%d ",uiHMIWord[PLC_MODULE_NO],uiHMIWord[PLC_MODULE_NO+1]); #endif getModuleName(ui16CurModule, ui8TermModule); writePara(); //readPara(); break; case PLC_MODULE_NO: #if C_LEVI_DEBUG printf("device=%d, class=%d ",uiHMIWord[PLC_MODULE_NO],uiHMIWord[PLC_MODULE_NO+1]); #endif ui16CurModule = uiHMIWord[PLC_MODULE_NO]; ui16CurClass = uiHMIWord[PLC_MODULE_NO+1]; getModuleName(ui16CurModule, ui8TermModule); readPara(); writePara(); readParadelaytime(); writeParadelaytime(); break; case TESTSTEP0: test_step0=(~uiHMIWord[TESTSTEP0])&0xffff; test_step1=(~uiHMIWord[TESTSTEP1])&0xff; test_mode=(uiHMIWord[TestMode]&0x01); printf("test_step0=%d, test_step1=%d, test_mode=%d ",test_step0,test_step1,test_mode); break; case delay_time: memcpy((UINT8 *)&delay,(UINT8 *)&uiHMIWord[delay_time],C_delay_NUM*sizeof(UINT16)); //memcpy((UINT8 *)&uiHMIWord[delay_time], (UINT8 *)&delay, C_delay_NUM*sizeof(UINT16)); getModuleName(ui16CurModule, ui8TermModule); writeParadelaytime(); //readParadelaytime(); break; case PLC_BAKCMD: gpioConfig(GPIO_CARD_DET, 0); gpioSet(GPIO_CARD_DET, 1); if(gpioGet(GPIO_CARD_DET)==0) { err = xdcfActiveDevIdSet(DRIVE_SD); xdcfInit(imageDirNameStr, imageFileNameStr, 0); dirInit(); if(err==SUCCESS) { xdcfChange2Root(); vfsMkdir(ui8TermModule); xdcfCurRootDirSet(ui8TermModule); xdcfCurDirPosGet(&ui32dstDirPos); myXdcfDelFile(); xdcfActiveDevIdSet(DRIVE_NAND); xdcfCurRootDirSet(ui8TermModule); xdcfChange2Root(); vfsChdir(ui8TermModule); err |= myXdcfCopyDisk(ui32dstDirPos); if(uiHMIWord[PLC_BAKCMD]) { myXdcfDelFile(); } if(err==SUCCESS) uiHMIWord[PLC_BAKINFO] = 2; else uiHMIWord[PLC_BAKINFO] = 4; // ¶ÁSD¿¨´íÎó } else { uiHMIWord[PLC_BAKINFO] = 4; // ¶ÁSD¿¨´íÎó } } else { uiHMIWord[PLC_BAKINFO] = 3; // ûÓÐSD¿¨ } #if C_FILE_DEBUG printf("backup end "); #endif break; default: break; } }