void FinishLogger() { if (loggerInitialized && (fileLogLevel < ELogLevel::ENONE)) { CClock now; *logFile << "*** Log file finished at " << now.GetDateLong() << " @[AK_log_end]@" << std::endl; logFile->close(); } }
void CProfiler::Init( void) { //if ( m_pClock ) { static CClock s_Clock; s_Clock.AutoMeasure( 3000); m_llTickPerMS = s_Clock.GetCustomTickPerMillisecond(); } //Reset(); }
void CAimer39RTSPClient::Run() { if (m_bIsShutDown) return; uint64_t nLastRecvBytes = m_nRecvVideoBytes; int nNoRecvAnyCnt = 0; CClock clock; BOOL bIsStartClock = FALSE; uint64_t nMs = 0; UsageEnvironment & env = m_pRTSPClient->envir(); // All subsequent activity takes place within the event loop: //env.taskScheduler().doEventLoop( &m_eventLoopWatchVariable ); if (m_nDisConnLimmtMSec < 0) m_nDisConnLimmtMSec = MAX_UNRECV_MS; while(1) { if (m_eventLoopWatchVariable != 0) break; if (m_bIsPlay) { if (((uint64_t)m_nRecvVideoBytes) == ((uint64_t)nLastRecvBytes)) { if (!bIsStartClock) { clock.ReInit(); timeval stTime; ZeroMemory(&stTime, sizeof(timeval)); clock.start(stTime); bIsStartClock = TRUE; continue; } clock.GetMsSinceStart(nMs); if (nMs > (uint64_t)(m_nDisConnLimmtMSec)) { bIsStartClock = FALSE; if (m_pDisConnCallback) m_pDisConnCallback(m_pDCCallBackParam, this); } }else { bIsStartClock = FALSE; nLastRecvBytes = m_nRecvVideoBytes; } } ((BasicTaskScheduler0*)(&(env.taskScheduler())))->SingleStep(); CalcBitsRatePerSec(); } }
void OnTimer(void* vp) { time_t t; CClock* p = (CClock*)vp; // 시계를 멈추기전까지 계속 현재시간을 구한다. while (p->bStop != FALSE) { Sleep(1000); t = time(NULL); //p->now = *localtime(&t); localtime_s(&(p->now), &t); // 매1분마다 콜백함수호출 if (p->now.tm_sec == 0) { if (p->m_cb) p->m_cb(); } } }
int main(int argc, char* argv[]) { CClock clock; clock.Start(); // OnAlarm함수를 콜백함수로 설정 clock.SetCallbackFunction(OnAlarm); isSleeping = 1; printf("zzz...\n"); while (isSleeping) { Sleep(1000); } clock.Stop(); printf("go to work...\n"); Sleep(1000); return 0; }
void CSession::run() { CClock *clock = CClock::instance(); while (bRunning) { iFrameStart = SDL_GetTicks(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); sdlManager->sdlEventHandle(); clock->updateClock(iFrameDelay); // Do stuff here. sdlManager->swapBuffers(); iFrameEnd = SDL_GetTicks(); if (iFrameDelay - (iFrameEnd - iFrameStart) > 0) { SDL_Delay(iFrameDelay - (iFrameEnd - iFrameStart)); } iFrameDelay = iFrameEnd - iFrameStart; iFrameDelay = iFrameDelay < 16 ? 16 : iFrameDelay; } }
void InitLogFile(const std::string& aAppName, const std::string& aLogFile, ELogLevel aFileLogLevel, ELogLevel aConsoleLogLevel, bool aSimplifiedConsoleOutput) { if (loggerInitialized) { LOG_WARN("Ignoring repeated init call"); } else { fileLogLevel = aFileLogLevel; consoleLogLevel = aConsoleLogLevel; simplifiedConsoleOutput = aSimplifiedConsoleOutput; appName = aAppName; if (fileLogLevel < ELogLevel::ENONE) { logFile = boost::in_place(aLogFile.c_str(), std::ofstream::out); CClock now; *logFile << "*** " << appName << " log file started at " << now.GetDateLong() << std::endl; *logFile << "*** " AK_PLATFORM_NAME " system detected as " << (sizeof(int*)*8) << " bit" << std::endl; } loggerInitialized = true; } }
void LogAppend(ELogLevel aLogLevel, const char* aFile, const std::string& aFunc, const std::string& aMessage, int aLine, ...) { if (!loggerInitialized && !uninitializedLoggerUseReported) { uninitializedLoggerUseReported = true; std::cout << "WARNING: Logger used without initialization. Call InitLogFile() first!" << std::endl; } // Remove the path from the filename aFile = RemovePath(aFile); // Assemble the user-generated message char buffer[510]; va_list args; va_start(args, aLine); #ifdef AK_SYSTEM_WINDOWS vsnprintf_s(buffer, 500, _TRUNCATE, aMessage.c_str(), args); #else vsnprintf(buffer, 500, aMessage.c_str(), args); #endif va_end(args); CClock now; std::string timestamp(now.GetTimeLong()); if (loggerInitialized && aLogLevel >= fileLogLevel) { WriteLogEntry(*logFile, timestamp, GetLevelString(aLogLevel), aFile, aFunc, aLine, buffer); } if (aLogLevel >= consoleLogLevel) { #ifdef AK_SYSTEM_ANDROID __android_log_print(ANDROID_LOG_DEBUG + static_cast<int32_t>(aLogLevel), appName.c_str(), buffer); #else if (simplifiedConsoleOutput) { std::cout << buffer << std::endl; } else { WriteLogEntry(std::cout, timestamp, GetLevelString(aLogLevel), aFile, aFunc, aLine, buffer); } #endif } }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; TCHAR szHello[MAX_LOADSTRING]; LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); POINTS mouse = MAKEPOINTS(lParam); switch (message) { case WM_CREATE: box.top = 100; box.bottom = 200; box.left = 100; box.right = 200; clock.setPosition(150, 150, 250, 250); pile.setPosition(100, 50, 120, 150); pile.setValue(60); pile.setChange(-500); pile.setCompLarger(false); break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: { hdc = BeginPaint(hWnd, &ps); #ifdef CLOCK clock.draw(hdc); #endif #ifdef PILE pile.draw(hdc); //Rectangle(hdc, 100, 50, 70, 200); #endif #ifdef BOX RECT rt; GetClientRect(hWnd, &rt); HPEN pen = CreatePen(PS_SOLID, 4, RGB(0,0,0)); HPEN oldPen = (HPEN)SelectObject(hdc, pen); HBRUSH brush; HBRUSH original_brush; brush = CreateSolidBrush(RGB(250,245,100)); original_brush = (HBRUSH)SelectObject(hdc, brush); Rectangle(hdc, box.left, box.top, box.right, box.bottom); SelectObject (hdc, original_brush); DeleteObject (brush); SelectObject (hdc, oldPen); DeleteObject (pen); #endif EndPaint(hWnd, &ps); } break; case WM_LBUTTONDOWN: #ifdef CLOCK clock.start(hWnd, 2); #endif #ifdef BOX SetTimer(hWnd, // handle to main window 1001, // timer identifier 25, // 0.01-second interval (TIMERPROC) MyTimerProc); // timer callback #endif break; case WM_RBUTTONDOWN: box.left = mouse.x; box.top = mouse.y; box.right = box.left + 5; box.bottom = box.top + 5; InvalidateRect(hWnd, NULL, TRUE); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
//--------------------------------------------------------------------- // Refresh Date //--------------------------------------------------------------------- void CFuiWeatherView::EditDate() { CClock *ck = globals->clk; datW->EditText("%04d/%02d/%02d",ck->GetYear(),ck->GetMonth(),ck->GetDay()); return; }