int main(int argc, char** argv) { InitWin7(); InitDevIL(); InitRun(argc,argv); InitGlut(argc, argv); if (bFreshRun) InitNx(); else ReInitNx(); glutMainLoop(); ReleaseNx(); return 0; }
BOOL QApp::Run( HINSTANCE hInstance ) { SetAppName(NULL); // 设置工作目录 SetCurrentDirectory(quibase::GetModulePath()); // 配置应用程序 QConfig *pCfg = QUIGetConfig(); if ((NULL == pCfg) || !(pCfg->SetConfigPath(GetConfigPath()))) { // 这个时候还没有加载UI,不能使用QUI里面的MessageBox ::MessageBox(NULL,L"读取配置文件失败!", L"错误", MB_OK); ATLASSERT(FALSE); return FALSE; } // 配置UI管理器 if (!QUIMgr::GetInstance()->Startup()) { ::MessageBox(NULL,L"UI管理器启动失败!", L"错误", MB_OK); ATLASSERT(FALSE); return FALSE; } // 默认开启窗口的圆角和阴影效果 CWndShadow::Initialize(hInstance); SetTopFrameStyle(WS_QEX_ROUNDCONNER|WS_QEX_WNDSHADOW); // 主界面线程循环 QMessageLoop loop; AddMessageLoop(&loop); // 启动主界面 if (!InitRun() || (m_pMainWnd == NULL)) { return FALSE; } loop.Run(); RemoveMessageLoop(); UnInit(); QUIGetMainWnd(); return TRUE; }
int main(int argc, char** argv) { #ifdef _DEBUG cout << "***DEBUG BUILD***" << endl; #endif ncc::whoami(); InitRun(argc,argv); InitGlut(argc,argv); InitHUD(); InitDevIL(); InitPhysX(); InitCUDA(); InitExperiment(); glutMainLoop(); // enter event processing return 0; // never actually reached. }
//--------------------------------------------------------- void CurvedINS2D::Run() //--------------------------------------------------------- { ti0=timer.read(); // function [Ux, Uy, PR, time] = CurvedINS2D(... // Ux, Uy, PR, FinalTime, nu, simtype, ExactSolution, BCfunction); // Purpose: integrate the incompressible Navier-Stokes equations to FinalTime InitRun(); // initialize timers & counters // choose order to integrate exactly int Nint = (int)ceil(3.0*N/2.0); // build cubature nodes for all elements CubatureOrder = 2*(Nint+1); CubatureVolumeMesh2D(CubatureOrder); // build Gauss node data for all element faces NGauss = (Nint+1); GaussFaceMesh2D(NGauss); #if (1) //------------------------------------- // check all node sets //------------------------------------- Output_Mesh(); //OutputNodes(false); // volume nodes //OutputNodes(true); // face nodes //OutputNodes_cub(); // cubature //OutputNodes_gauss(); // quadrature //umLOG(1, "\n*** Exiting after CUb, Gauss\n\n"); //return; #endif // recover memory from registry NDG_garbage_collect(); // prepare data... PreCalcBdryData(); // dual splitting scheme coefficients g0 = 1.0; a0 = 1.0; a1 = 0.0; b0 = 1.0; b1 = 0.0; CurvedINSPressureSetUp2D(); // Build pressure matrix and boundary forcing (IPDG) NDG_garbage_collect(); // recover memory from registry CurvedINSViscousSetUp2D(); // Build viscous matrix and boundary forcing (IPDG) NDG_garbage_collect(); // recover memory from registry (this->*ExactSolutionBC) // Form inhomogeneous boundary term for rhs data (Fx, Fy, nx,ny, mapI, mapO, mapW, mapC, 0.0, nu, refbcUx, refbcUy, refbcPR, refbcdUndt); // storage for history of fields and nonlinear terms Uxold=Ux; NUx=0.0; Uyold=Uy; NUy=0.0; dpdn=0.0; time_work += timer.read() - ti0; // add cost of NDG setup // start time stepping time = 0.0; for (tstep=1; tstep<=Nsteps; ++tstep) { tw1=timer.read(); // time NDG work // update dual splitting scheme coefficients after // first time step, then recalculate operators if (2 == tstep) { // release and recreate Cholesky solvers reset_solvers(); g0 = 1.5; a0 = 2.0; a1 = -0.5; b0 = 2.0; b1 = -1.0; // Rebuild pressure and viscous matrixes for new g0 CurvedINSPressureSetUp2D(); CurvedINSViscousSetUp2D(); NDG_garbage_collect(); umMSG(1, "2nd sparse setup completed\n"); //umERROR("Testing", "Exiting early"); } TimeScaleBCData(); // apply temporal scaling factors to bc data INSAdvection2D(); // compute nonlinear terms NUx, NUy //CurvedINSAdvection2D; // curved version INSPressure2D(); // compute pressure PR and intermediate UxTT, UyTT //CurvedINSPressure2D; // curved version CurvedINSViscous2D(); // compute viscous solves and update velocity time_work += timer.read() - tw1; // accumulate cost of NDG work time = tstep*dt; // increment time Report(); // report results // if (tstep>100) break; } time_total = timer.read()-ti0; // stop timing FinalReport(); // final report }
//--------------------------------------------------------- void EulerShock2D::Run() //--------------------------------------------------------- { // function Q = EulerShock2D(Q,FinalTime, ExactSolution, ExactSolutionBC, fluxtype) // Purpose : Integrate 2D Euler equations using a 2nd order SSP Runge-Kutta time integrator InitRun(); // choose order to integrate exactly CubatureOrder = (int)floor(2.0*(N+1)*3.0/2.0); NGauss = (int)floor(2.0*(N+1)); // build cubature node data for all elements CubatureVolumeMesh2D(CubatureOrder); // build Gauss node data for all element faces GaussFaceMesh2D(NGauss); Resize_cub(); // resize cubature arrays //MapGaussFaceData(); // {nx = gauss.nx}, etc. ti0=timer.read(); // time simulation loop #if (0) //------------------------------------- // check all node sets //------------------------------------- OutputNodes(false); // volume nodes OutputNodes(true); // face nodes OutputNodes_cub(); // cubature OutputNodes_gauss(); // quadrature Report(true); // show initial conditions umLOG(1, "\n*** Exiting after Cub, Gauss\n\n"); return; #endif // limit initial condition Q = EulerLimiter2D(Q, time); // outer time step loop while (time<FinalTime) { if (time+dt > FinalTime) {dt=FinalTime-time;} tw1=timer.read(); // time NDG work oldQ = Q; // store solutuion from previous step // 2nd order SSP Runge-Kutta this->RHS(Q, time, BCSolution); Q1 = Q + dt*rhsQ; Q1 = EulerLimiter2D(Q1, time); this->RHS(Q1, time, BCSolution); Q = (Q + Q1 + dt*rhsQ)/2.0; Q = EulerLimiter2D(Q, time); time += dt; // increment time SetStepSize(); // compute new timestep time_work += timer.read() - tw1; // accumulate cost of NDG work Report(); // optional reporting ++tstep; // increment timestep // if (tstep>=10) break; // testing } time_total = timer.read()-ti0; // stop timing FinalReport(); // final report }
int main(void) { // Initialize I/O DDRB = 0x3e; // 00111110 PORTB = 0x01; // 00000001 DDRC = 0x20; // 00100000 PORTC = 0x03; // 00000011 DDRD = 0xff; // 11111111 PORTD = 0xff; // 11111111 // Load saved state, if any Load(); // Setup the display timer... // prescaler 1/8; at 1MHz system clock, this gives us an overflow // at 488 Hz, providing a per-digit refresh rate of 97.6 Hz. TCCR0A = 0; TCCR0B = (1<<CS01); // Output compare value B - controls blanking. // In full brightness mode, we'll make this happen immediately before the refresh, // In lower brightness modes, we'll make it happen sooner. OCR0A = pgm_read_byte(&brighttable[bright]); // Enable overflow and compare match interrupts TIMSK0 = (1<<TOIE0) | (1<<OCIE0A); // Setup the RTC... gMin = 0; gSec = 0; // select asynchronous operation of Timer2 ASSR = (1<<AS2); // select prescaler: 32.768 kHz / 128 = 1 sec between each overflow TCCR2A = 0; TCCR2B = (1<<CS22) | (1<<CS20); // wait for TCN2UB and TCR2UB to be cleared while((ASSR & 0x01) | (ASSR & 0x04)); // clear interrupt-flags TIFR2 = 0xFF; // init the state machine enum State state = ST_TIME; enum State prevstate = ST_TIME; uint8_t remaining = 0; uint8_t cmode = 0; // Enable interrupts sei(); // Do some stuff for(;;) { uint8_t buttons = GetButtons(); if ((buttons & BUTTON_RIGHT) && (state < ST_BRIGHT)) { prevstate = state; remaining = count; cmode = 0; buttons = 0; state = ST_RUN_PRIME; } newstate: switch(state) { case ST_TIME: DisplayNum(stime[0], HIGH_POS, 0, 3); display[COLON_POS] = COLON; DisplayNum(stime[1], LOW_POS, 0, 0); if (buttons & BUTTON_LEFT) { state = ST_DELAY; } else if (buttons & BUTTON_UP) { state = ST_TIME_SET_MINS; } break; case ST_DELAY: DisplayNum(delay[0], HIGH_POS, 0, 3); display[COLON_POS] = LOWDOT; DisplayNum(delay[1], LOW_POS, 0, 0); if (buttons & BUTTON_LEFT) { state = ST_COUNT; } else if (buttons & BUTTON_UP) { state = ST_DELAY_SET_MINS; } break; case ST_COUNT: DisplayAlnum('\xC6', count, 0); if (buttons & BUTTON_LEFT) { state = ST_MLU; } else if (buttons & BUTTON_UP) { state = ST_COUNT_SET; } break; case ST_MLU: DisplayAlnum('\xC7', mlu, 0); if (buttons & BUTTON_LEFT) { state = ST_BRIGHT; } else if (buttons & BUTTON_UP) { state = ST_MLU_SET; } break; /* I'll put this in once there's more than one option ;) case ST_OPTIONS: display[0] = '\xC0'; // 00111111 = 'O' display[1] = '\x8C'; // 01110011 = 'P' display[2] = EMPTY; display[3] = '0x87'; // 01111000 = 't' display[4] = '0x92'; // 01101101 = 'S' if (buttons & BUTTON_LEFT) { state = ST_TIME; } else if (buttons & BUTTON_UP) { state = ST_BRIGHT; } break; */ case ST_BRIGHT: DisplayAlnum('\x83', 4 - bright, 0); // 10000011 = 'b' if (buttons & BUTTON_LEFT) { state = ST_TIME; } else if (buttons & BUTTON_UP) { bright = (bright - 1) & 3; OCR0A = pgm_read_byte(&brighttable[bright]); } else if (buttons & BUTTON_RIGHT) { Save(); state = ST_SAVED; remaining = 15; } break; case ST_SAVED: display[0] = '\x92'; // 01101101 = 'S' display[1] = '\x88'; // 01110111 = 'A' display[2] = EMPTY; display[3] = '\xc1'; // 00111110 = 'V' display[4] = '\x86'; // 01111001 = 'E' if (--remaining == 0) state = ST_BRIGHT; break; case ST_TIME_SET_MINS: DisplayNum(stime[0], HIGH_POS, 0x40, 0); display[COLON_POS] = COLON; DisplayNum(stime[1], LOW_POS, 0, 0); if (EditNum(&stime[0], buttons, 100)) { state = ST_TIME_SET_SECS; } break; case ST_TIME_SET_SECS: DisplayNum(stime[0], HIGH_POS, 0, 0); display[COLON_POS] = COLON; DisplayNum(stime[1], LOW_POS, 0x40, 0); if (EditNum(&stime[1], buttons, 60)) { state = ST_TIME; } break; case ST_DELAY_SET_MINS: DisplayNum(delay[0], HIGH_POS, 0x40, 0); display[COLON_POS] = LOWDOT; DisplayNum(delay[1], LOW_POS, 0, 0); if (EditNum(&delay[0], buttons, 100)) { state = ST_DELAY_SET_SECS; } break; case ST_DELAY_SET_SECS: DisplayNum(delay[0], HIGH_POS, 0, 0); display[COLON_POS] = LOWDOT; DisplayNum(delay[1], LOW_POS, 0x40, 0); if (EditNum(&delay[1], buttons, 60)) { state = ST_DELAY; } break; case ST_COUNT_SET: DisplayAlnum('\xC6', count, 0x40); if (EditNum(&count, buttons, 100)) { state = ST_COUNT; } break; case ST_MLU_SET: DisplayAlnum('\xC7', mlu, 0x40); if (EditNum(&mlu, buttons, 60)) { state = ST_MLU; } break; case ST_RUN_PRIME: if (mlu > 0) { state = ST_MLU_PRIME; SHUTTER_ON(); DisplayAlnum('\xC7', mlu, 0); } else { InitRun(&state); goto newstate; } break; case ST_RUN_AUTO: if (gDirection == 0) { // time has elapsed. close the shutter and stop the timer. SHUTTER_OFF(); clock_stop(); if (remaining > 0) { if (--remaining == 0) { // we're done. state = prevstate; break; } } gMin = delay[0]; gSec = delay[1]; gDirection = -1; state = ST_WAIT; clock_start(); goto newstate; } // fall through case ST_RUN_MANUAL: if (cmode == 0) { // time left in this exposure DisplayNum(gMin, HIGH_POS, 0, 3); DisplayNum(gSec, LOW_POS, 0, 0); } else { // remaining exposures DisplayAlnum('\xC6', remaining, 0); } display[COLON_POS] = (TCNT2 & 0x80) ? EMPTY : COLON; break; case ST_MLU_PRIME: SHUTTER_OFF(); gMin = 0; gSec = mlu; gDirection = -1; state = ST_MLU_WAIT; clock_start(); // fall-through case ST_MLU_WAIT: DisplayAlnum('\xC7', gSec, 0); if (gDirection == 0) { // MLU wait period has elapsed clock_stop(); InitRun(&state); goto newstate; } break; case ST_WAIT: if (cmode == 0) { // wait time DisplayNum(gMin, HIGH_POS, 0, 3); DisplayNum(gSec, LOW_POS, 0, 0); } else { // remaining exposures DisplayAlnum('\xC6', remaining, 0); } display[COLON_POS] = (TCNT2 & 0x80) ? EMPTY : LOWDOT; if (gDirection == 0) { // wait period has timed out; // stop the timer and start a new cycle clock_stop(); state = ST_RUN_PRIME; goto newstate; } break; } if (state >= ST_RUN_PRIME) { // check keys if (buttons & BUTTON_RIGHT) { // canceled. clock_stop(); SHUTTER_OFF(); // if counting up, freeze the count here if (state == ST_RUN_MANUAL) { stime[0] = gMin; stime[1] = gSec; } state = prevstate; } else if ((buttons & BUTTON_LEFT) && (count > 1)) { // toggle display, time left vs. count left cmode = (cmode + 1) & 1; } else if (buttons & BUTTON_UP) { // adjust brightness bright = (bright - 1) & 3; OCR0A = pgm_read_byte(&brighttable[bright]); } } Sleep(48); // approx 50ms at 1MHz } }
void KVINDRAOnlineDataAnalyser::ProcessRun() { // Perform treatment of a given run //Open data file fRunFile = (KVRawDataReader*)gDataSet->OpenRunfile(GetDataType().Data() , fRunNumber); if (fRunFile->GetStatus() == KVGRUNetClientGanilReader::kSTATUS_NOHOST) { // cannot connect to ACQ host Error("ProcessRun", "Cannot connect to acquisition host machine. Check KVGRUNetClientGanilReader.AcqHostName"); return; } //warning! real number of run may be different from that deduced from file name //we get the real run number from gMultiDetArray and use it to name any new files fRunNumber = gMultiDetArray->GetCurrentRunNumber(); fEventNumber = 0; //event number cout << endl << "Reading ONLINE events from RUN# " << fRunNumber << endl; cout << "Starting analysis of data on : "; TDatime now; cout << now.AsString() << endl << endl; preInitRun(); //call user's beginning of run InitRun(); postInitRun(); fDetEv = new KVDetectorEvent; //loop over events in file fGoEventLoop = kTRUE; fDumpEvents = kFALSE; while (fGoEventLoop) { Bool_t gotevent = fRunFile->GetNextEvent(); if (gotevent) { fEventNumber++; //reconstruct hit groups KVSeqCollection* fired = fRunFile->GetFiredDataParameters(); gMultiDetArray->GetDetectorEvent(fDetEv, fired); preAnalysis(); //call user's analysis. stop if returns kFALSE. if (!Analysis()) break; postAnalysis(); fDetEv->Clear(); if (!((fEventNumber) % 10000)) cout << " ++++ " << fEventNumber << " events read ++++ " << endl; } else { // got no event - why ? Int_t status = fRunFile->GetStatus(); switch (status) { case KVGRUNetClientGanilReader::kSTATUS_NOBUFF: Warning("ProcessRun", "Got no buffer from ACQHOST. Sleeping for 2 seconds."); gSystem->Sleep(2000); break; case KVGRUNetClientGanilReader::kSTATUS_NOEVENT: Warning("ProcessRun", "Got no event from ACQHOST. Sleeping for 2 seconds."); gSystem->Sleep(2000); break; case KVGRUNetClientGanilReader::kSTATUS_NOACQ: Warning("ProcessRun", "Acquisition is stopped. Sleeping for 5 seconds."); gSystem->Sleep(5000); break; } } } delete fDetEv; cout << "Ending analysis of run " << fRunNumber << " on : "; TDatime now2; cout << now2.AsString() << endl << endl; cout << endl << "Finished reading " << fEventNumber << " events" << endl << endl; preEndRun(); //call user's end of run function EndRun(); postEndRun(); if (fMessageThread) { fMessageThread->Kill(); TThread::Delete(fMessageThread); delete fMessageThread; fMessageThread = 0; } }