CCCityEvent::CCCityEvent(CCGameMesManager* pMesManager, CT_DWORD id) : CCGameMesEvent(pMesManager, id) { RegistMessage(MAIN_G_EVENT_CITY, SUB_G_APPLY_AWARD_EVENT); RegistMessage(MSC_MAIN_EVENT_CITY, MSC_SUB_EVENT_FIGHTING_END); RegistMessage(MAIN_G_HEART_BEAT,0); RegistMessage(MSC_MAIN_BROADCAST, MSC_SUB_BROADCAST_WORLD); RegistMessage(MSC_MAIN_BROADCAST, MSC_SUB_BROADCAST_SYSTEM); RegistMessage(MSC_MAIN_BROADCAST, MSC_SUB_BROADCAST_GM); RegistMessage(MSC_MAIN_ANNOUNCEMENT_UPDATA,0); G_ValueRange vr = {0}; if(G_GetValueRange(VALUE_TYPE_UPDATEEVENTTIME, &vr)) { //建筑生产检测定时器 RegistTimer(IDI_EVENT_TIMER); SetTimer(IDI_EVENT_TIMER, (CT_INT32)(vr.fMaxVal * 1000 )); } //公告定时器 RegistTimer(IDI_ANNOUNCEMENT_UPDATA); SetTimer(IDI_ANNOUNCEMENT_UPDATA,TIME_ANNOUNCEMENT_UPDATA); //每日更新 if(m_dwThread == GAME_THREAD_CITY) { RegistClock(IDI_UPDATA_DATA); SetClock(IDI_UPDATA_DATA,0,0,0); } }
void ComponentClock::Initialize() { std::shared_ptr<GameObjectModule> gameObjectModule = GET_MODULE(GameObjectModule).lock(); if (gameObjectModule != nullptr) { std::shared_ptr<GameObject> newHoursLine = gameObjectModule->CloneObject(m_HoursLinePrefab).lock(); if (newHoursLine != nullptr) { newHoursLine->SetParent(GetOwner()); m_HoursLineTransformComponent = newHoursLine->GetComponent<ComponentTransform2D>(); } std::shared_ptr<GameObject> newMinutesLine = gameObjectModule->CloneObject(m_MinutesLinePrefab).lock(); if (newMinutesLine != nullptr) { newMinutesLine->SetParent(GetOwner()); m_MinutesLineTransformComponent = newMinutesLine->GetComponent<ComponentTransform2D>(); } std::shared_ptr<GameObject> newSecondsLine = gameObjectModule->CloneObject(m_SecondsLinePrefab).lock(); if (newSecondsLine != nullptr) { newSecondsLine->SetParent(GetOwner()); m_SecondsLineTransformComponent = newSecondsLine->GetComponent<ComponentTransform2D>(); } } SetClock(); }
int PerformKMeans(TRAININGSET *pTS, CODEBOOK *pCB, PARTITIONING *pP, int clus, int repeats, int InitMethod, int quietLevel, int useInitial) { PARTITIONING Pnew, Pinit; CODEBOOK CBnew, CBinit; llong distance[BookSize(pTS)]; llong distanceInit[BookSize(pTS)]; double totalTime, error, currError; int i, better, iter, totalIter; SetClock(&totalTime); totalIter = 0; currError = error = 0; if ((clus < 1) || (BookSize(pTS) < clus) || (repeats < 1)) { return 1; /* clustering failed */ } InitializeSolutions(pTS, pCB, pP, &CBnew, &Pnew, &CBinit, &Pinit, distanceInit, clus, useInitial); PrintHeader(quietLevel); /* perform repeats time full K-means */ for (i = 0; i < repeats; i++) { better = iter = 0; GenerateSolution(pTS, &CBnew, &Pnew, &CBinit, &Pinit, distance, distanceInit, InitMethod, useInitial); KMeansIterate(pTS, &CBnew, &Pnew, distance, quietLevel, i, &iter, &totalTime, &error, useInitial); totalIter += iter; /* got better result */ if ((i == 0) || (error < currError)) { CopyCodebook(&CBnew, pCB); CopyPartitioning(&Pnew, pP); currError = error; better = 1; } PrintRepeat(quietLevel, repeats, i, iter, error, GetClock(totalTime), better); } PrintFooterKM(quietLevel, currError, repeats, GetClock(totalTime), totalIter); FreeCodebook(&CBnew); FreePartitioning(&Pnew); FreeCodebook(&CBinit); FreePartitioning(&Pinit); return 0; } /* PerformKmeans() */
void task3(void) { OS_ERR err; BoardGPIOConfig();//IO口 UsartConfig();//串口设置配置 Nvic_Config(); SW_12V(1);//电源 SW_5V(1);//正负电源,用于检测回波Z FreqModuleInit();//测频率模块初始化 GetFreq(1); while(1) { // OSTimeDlyHMSM(0,0,500,0,OS_OPT_TIME_DLY,&err); // printf("SCT200T15002-Channel: 1 FREQUENCY:%f\r\n",GetFreq(1)); // printf("SCT200T15002-Channel: 2 FREQUENCY:%f\r\n",GetFreq(2)); // printf("SCT200T15002-Channel: 3 FREQUENCY:%f\r\n",GetFreq(3)); // printf("SCT200T15002-Channel: 4 FREQUENCY:%f\r\n",GetFreq(4)); OSTimeDlyHMSM(0,0,0,10,OS_OPT_TIME_DLY,&err); if(UploadFlag == 1)//确认需要上传数据了 { FreqModuleInit();//测频率模块初始化 GetFreq(1); printf("%s",aaa); printf("SCT200T15003-2015/7/8/Wednesday-15-36-9\r\n"); printf("SCT200T15003-ID=0x87031923 53578748 66eff48\r\n"); printf("SCT200T15003-Mode = 10 minutes Internal\r\n"); printf("SCT200T15003-Current voltage = 10.90V\r\n"); printf("SCT200T15003-Channel: 1 Temperature :34.47\r\n"); printf("SCT200T15003-Channel: 2 Temperature :34.43\r\n"); printf("SCT200T15003-Channel: 3 Temperature :30.40\r\n"); printf("SCT200T15003-Channel: 4 Temperature :25.90\r\n"); printf("SCT200T15003-Channel: 1 FREQUENCY:%f\r\n",GetFreq(1)); printf("SCT200T15003-Channel: 2 FREQUENCY:%f\r\n",GetFreq(2)); printf("SCT200T15003-Channel: 3 FREQUENCY:%f\r\n",GetFreq(3)); printf("SCT200T15003-Channel: 4 FREQUENCY:%f\r\n",GetFreq(4)); printf("%s",bbb); UploadFlag = 0; SW_12V(0);//电源 SW_5V(0);//正负电源,用于检测回波 OSTimeDlyHMSM(0,0,0,500,OS_OPT_TIME_DLY,&err); ConfigPINToListen(); PWR_EnterSTOPMode(PWR_Regulator_ON,PWR_STOPEntry_WFI); SetClock();//配置各级CPU时钟 BoardGPIOConfig();//IO口 SW_12V(1);//电源 SW_5V(1);//正负电源,用于检测回波 OSTimeDlyHMSM(0,0,0,500,OS_OPT_TIME_DLY,&err); UsartConfig();//串口设置配置 Nvic_Config(); } } }
/* ********************************************************************************************************* * 函 数 名: bsp_Init * 功能说明: 初始化硬件设备 * 形 参:无 * 返 回 值: 无 ********************************************************************************************************* */ void bsp_Init(void) { SetClock();//配置各级CPU时钟 // BoardGPIOConfig();//IO口 // UsartConfig();//串口设置配置 // Nvic_Config(); //RTC_Config(); // SW_12V(1);//电源 // SW_5V(1);//正负电源,用于检测回波 //printf("BSP init ok....\r\n"); }
NES_VRC7::NES_VRC7 () { patch_set = OPLL_VRC7_RW_TONE; opll = OPLL_new ( 3579545, DEFAULT_RATE); OPLL_reset_patch (opll, patch_set); SetClock(DEFAULT_CLOCK); for(int c=0;c<2;++c) for(int t=0;t<6;++t) sm[c][t] = 128; }
ECODE DTFUN::ConfigAD( UINT ChanType, UINT ListSize, DBL Gain, int ClockSource, DBL Freq, DWORD BufSize ) { int status; ECODE result= 0; BufferSize= (int)BufSize; result+= SetChanType( ChanType ); result+= SetChanList( ListSize, Gain ); Freq= SetClock(ClockSource, Freq ); // ClockSource=0 ... internal, 1=external result+= SetWndHandle(); result+= SetBuffers( BufSize ); ClockHz= Freq; // do we want to output the sample clock onto the user counter pin? // (this user counter pin can then be used as an A/D sample clock input for another board // and is also used to drive this particular board // NOTE that the user counter pin has to be wired externally to the A/D Sample Clock In pin if (outputclockonusercounter) { // set the cascade mode status= olDaSetCascadeMode(lphDassCT, OL_CT_SINGLE); // set up the clocks and gates // use an internal clock status= olDaSetClockSource(lphDassCT, OL_CLK_INTERNAL); // set the clock frequency status= olDaSetClockFrequency(lphDassCT, ClockHz); // specify the gate to enable the C/T operation status= olDaSetGateType(lphDassCT, OL_GATE_NONE); // status= olDaSetGateType(lphDassCT, OL_GATE_HIGH_LEVEL); // specify the mode for continuous output status= olDaSetCTMode(lphDassCT, OL_CTMODE_RATE); // as opposed to OL_CTMODE_ONESHOT // specify the output pulse type status= olDaSetPulseType(lphDassCT, OL_PLS_HIGH2LOW); // specify the duty cycle or pulse width status= olDaSetPulseWidth(lphDassCT, 100); // configure the subsystem status= olDaConfig( lphDassCT ); // if we use a self-generated clock, then pre-start the A/D conversion here // start of sampling will be triggered when counter/clock is started status= olDaStart( lphDass ); } return( result ); }
int main(void) { SetClock(); ConfigPins(); SetBaud(); UARTCharPut(UART0_BASE, 'H'); UARTCharPut(UART0_BASE, 'I'); while (1) { CheckReceivedBits(); } }
void I2C::Initialize (uint32_t clockSpeed, bool isDuty16_9, bool isFmMode, bool initializeGPIO) { Enable(false); SetSoftwareReset(true); SetSoftwareReset(false); EnablePeripheralClock(true); SetClock(clockSpeed, isDuty16_9, isFmMode); if (initializeGPIO) { InitGPIO(); } Enable(true); _stuckBUSY = false; }
CCVipEvent::CCVipEvent(CCGameMesManager *pMesManager,CT_WORD id) : CCGameMesEvent(pMesManager,id) { RegistMessage(MAIN_G_VIP_EVENT_CITY,SUB_G_VIP_RENEWALS_REQUEST); RegistMessage(MAIN_G_VIP_EVENT_CITY,SUB_G_VIP_GIFT_RECEIVE_REQUEST); RegistMessage(MAIN_G_VIP_EVENT_CITY,SUB_G_VIP_HARVEST_ONCE_REQUEST); RegistMessage(MAIN_G_VIP_EVENT_CITY,SUB_G_VIP_ACTIVE); G_ValueRange vr = {0}; if(G_GetValueRange(VALUE_TYPE_VIP_TIME, &vr)) { RegistTimer(IDI_VIP_TIMER); SetTimer(IDI_VIP_TIMER, (CT_INT32)(vr.fMaxVal * 1000)); } memset(&vr,0,sizeof(vr)); if (G_GetValueRange(VALUE_TYPE_VIP_GIFT_CLOCK,&vr)) { RegistClock(IDI_VIP_GIFT_CLOCK); SetClock(IDI_VIP_GIFT_CLOCK, (CT_BYTE)vr.fMinVal,0,0); } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////// //用户任务1 void task1(void) { OS_ERR err; while(1) { OSTimeDlyHMSM(0,0,5,0,OS_OPT_TIME_DLY,&err); if(UploadFlag == 0) { SW_12V(0);//电源 SW_5V(0);//正负电源,用于检测回波 OSTimeDlyHMSM(0,0,0,200,OS_OPT_TIME_DLY,&err); ConfigPINToListen(); PWR_EnterSTOPMode(PWR_Regulator_ON,PWR_STOPEntry_WFI); SetClock();//配置各级CPU时钟 BoardGPIOConfig();//IO口 SW_12V(1);//电源 SW_5V(1);//正负电源,用于检测回波 OSTimeDlyHMSM(0,0,0,200,OS_OPT_TIME_DLY,&err); UsartConfig();//串口设置配置 Nvic_Config(); } } }
void main(void) { counter = 1; inpeak = 0; beatCounter = 0; WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer SetClock(); //设置时钟,MCLK和SMCLK P1DIR|=RED_LED; //设置RED_LED为输出口 SetTimerA(); //设置timerA的基本配置 SetUART(); //设置UART的基本配置 LCD_init(); //设置LCD的基本配置 _BIS_SR(LPM0_bits+GIE); //这是汇编语言,话语的意思可以理解成 SR = LPM0_bits+GIE。SR是状态寄存器,status register。 //LPM0是MSP430一种低功耗模式,关闭了一些东西,详查UG。GIE: general interrupt enabled /* 所以整个程序的逻辑就是: 设置好两个时钟信号,MCLK,SMCLK; 开启LED的输出; 设置TimerA的,中断使能,定时时长,时钟信号,工作模式; 设置整个MSP430的工作模式:LPM0,此时CPU和MCLK关闭,SMCLK开启。一旦进入中断,CPU被唤醒。 编写TimerA0中断程序 */ }
/******************************************************************************* *Обработка прерывания USART2 ******************************************************************************/ void USART2_IRQHandler(void) { uint8_t byte; static uint8_t lock = 0; //Клавиша еще нажата static uint8_t byteCount = 0; //Счетчик байт в пакете static uint8_t comCount = 0; //Счетчик команд if (USART_GetITStatus(USART2, USART_IT_RXNE) == SET) { //Если пришел байт SetClock(); //Разогнали микроконтроллер state.taskList |= TASK_USER; // Отметим активность пользователя byte = USART_ReceiveData(USART2); switch (byteCount) { case 0: if (byte == 0xFF) byteCount = 1; break; case 1: if (byte == 0x55) byteCount = 2; else byteCount = 0; break; case 2: if (byte == 0x03) byteCount = 3; else byteCount = 0; break; case 3: if (byte == 0x02) byteCount = 4; else byteCount = 0; break; case 4: if (byte == 0x00) byteCount = 5; else byteCount = 0; break; case 5: if ((!lock || comCount == 5) && !state.button) { comCount = 0; switch (byte) { case 0x02: state.button = BUTTON_UP; break; case 0x04: state.button = BUTTON_DOWN; break; case 0x08: state.button = BUTTON_RIGHT; break; case 0x10: state.button = BUTTON_LEFT; break; } if (byte) lock = 1; } else if (!byte) { lock = 0; } else comCount++; byteCount = 6; break; case 6: byteCount = 0; break; } } }
void ComponentClock::Update(unsigned long deltaTime) { SetClock(); }
int control_loop() { int score_tally, score_tally2; struct timespec *sleep_time, *return_time; sleep_time = malloc(sizeof(struct timespec*)); sleep_time->tv_sec = 0; sleep_time->tv_nsec = 1; keypad(stdscr,true); while (doloop) { SetClock(); while(start_interval<end_interval) { current_getch = getch(); if ('q'==current_getch) doloop = 0; if (KEY_LEFT==current_getch && !pause) { if(!AgainstLeftWall()) ShiftTetradLeft(); UpdateDisplay(); } else if (KEY_RIGHT==current_getch && !pause) { if(!AgainstRightWall()) ShiftTetradRight(); UpdateDisplay(); } else if ('z'==current_getch && !pause){ RotateClockwise(); UpdateDisplay(); } else if('x'==current_getch && !pause){ Flip(); UpdateDisplay(); } else if ('c'==current_getch && !pause){ RotateCounterClockwise(); UpdateDisplay(); } else if(KEY_UP==current_getch && !pause){ RotateClockwise(); UpdateDisplay(); } else if(KEY_DOWN==current_getch && !pause){ if(!MadeContact()) { ShiftTetradDown(); SetClock(); UpdateDisplay(); } } else if(' '==current_getch && !pause){ int score_tally = 0; while(!MadeContact()){ score_tally += 1; ShiftTetradDown(); } score += score_tally * (level+1); SolidifyTetrad(); score_tally2 = ClearLines(); score += score_tally2 * score_tally2 * (level+1) * 100; lines_cleared += score_tally2; if (lines_cleared/10 > level) level++; if (!GenerateTetrad()) GameOver(); UpdateDisplay(); } else if('p'==current_getch){ pause = !pause; } if(!pause) start_interval=clock(); nanosleep(sleep_time, return_time); } if(MadeContact()) { SolidifyTetrad(); score_tally = ClearLines(); score += score_tally * score_tally * (level+1) * 100; lines_cleared += score_tally; if (lines_cleared/10 > level) level++; if (!GenerateTetrad()) GameOver(); } else { ShiftTetradDown(); } UpdateDisplay(); } endwin(); printf("Bye!\n"); return 0; }
void c_main(char *blockBase, u32 blockSize) { int numRead = 0; char commandline[128]; blobStatus status; int i; int retval = 0; /* We really want to be able to communicate, so initialise the * serial port at 9k6 (which works good for terminals) */ SerialInit(baud9k6); TimerInit(); /* initialise status */ status.kernelSize = 0; status.kernelType = fromFlash; status.ramdiskSize = 0; status.ramdiskType = fromFlash; status.blockSize = blockSize; status.downloadSpeed = baud115k2; /* Load kernel and ramdisk from flash to RAM */ Reload("kernel", &status); Reload("ramdisk", &status); /* Print the required GPL string */ SerialOutputString("\r" PACKAGE " version " VERSION "\r" "Copyright (C) 1999 2000 " "Jan-Derk Bakker and Erik Mouw\r" "Copyright (C) 2000 " "Johan Pouwelse.\r"); SerialOutputString(PACKAGE " comes with ABSOLUTELY NO WARRANTY; " "read the GNU GPL for details.\r"); SerialOutputString("This is free software, and you are welcome " "to redistribute it\r"); SerialOutputString("under certain conditions; " "read the GNU GPL for details.\r\r"); /* and some information */ #ifdef BLOB_DEBUG SerialOutputString("Running from "); if(RunningFromInternal()) SerialOutputString("internal flash\r"); else SerialOutputString("external flash\r"); SerialOutputString("blockBase = 0x"); SerialOutputHex((int) blockBase); SerialOutputString(", blockSize = 0x"); SerialOutputHex(blockSize); SerialOutputByte('\r'); #endif /* wait 10 seconds before starting autoboot */ SerialOutputString("Autoboot in progress, press any key to stop "); for(i = 0; i < 10; i++) { SerialOutputByte('.'); retval = SerialInputBlock(commandline, 1, 1); if(retval > 0) break; } /* no key was pressed, so proceed booting the kernel */ if(retval == 0) { commandline[0] = '\0'; BootKernel(commandline); } SerialOutputString("\rAutoboot aborted\r"); SerialOutputString("Type \"help\" to get a list of commands\r"); /* the command loop. endless, of course */ for(;;) { DisplayPrompt(NULL); /* wait an hour to get a command */ numRead = GetCommand(commandline, 128, 3600); if(numRead > 0) { if(MyStrNCmp(commandline, "boot", 4) == 0) { BootKernel(commandline + 4); } else if(MyStrNCmp(commandline, "clock", 5) == 0) { SetClock(commandline + 5); } else if(MyStrNCmp(commandline, "download ", 9) == 0) { Download(commandline + 9, &status); } else if(MyStrNCmp(commandline, "flash ", 6) == 0) { Flash(commandline + 6, &status); } else if(MyStrNCmp(commandline, "help", 4) == 0) { PrintHelp(); } else if(MyStrNCmp(commandline, "reload ", 7) == 0) { Reload(commandline + 7, &status); } else if(MyStrNCmp(commandline, "reset", 5) == 0) { ResetTerminal(); } else if(MyStrNCmp(commandline, "speed ", 6) == 0) { SetDownloadSpeed(commandline + 6, &status); } else if(MyStrNCmp(commandline, "status", 6) == 0) { PrintStatus(&status); } else { SerialOutputString("*** Unknown command: "); SerialOutputString(commandline); SerialOutputByte('\r'); } } } } /* c_main */