int main (int argc, char ** argv) { if (argc != 3) { printf ("no arguments given, will exit\n"); printf ("usage %s dir key (both dir+key are numbers)\n", argv[0]); exit (0); } else { num_dir = atoi (argv[1]); num_key = atoi (argv[2]); printf ("Using %d dirs %d keys\n", num_dir, num_key); } timeInit (); benchmarkCreate (); timePrint ("Created empty keyset"); benchmarkFillup (); timePrint ("New large keyset"); benchmarkIterate (); timePrint ("Iterated over keyset"); benchmarkDel (); timePrint ("Del large keyset"); }
void Omega::init(){ sceneFile=""; resetAllScenes(); sceneAnother=shared_ptr<Scene>(new Scene); timeInit(); createSimulationLoop(); }
bool BattleFieldUI::init() { Layer::init(); avatarInit(); bloodbarInit(); angrybarInit(); touchButtonInit(); timeInit(); setGlobalZOrder(10); setCameraMask(2); experimental::AudioEngine::stopAll(); AUDIO_ID.BATTLEFIELDBGM = experimental::AudioEngine::play2d(BGM_RES.BATTLEFIELDBGM, true, 0.6); return true; }
void convInit( ) { convObject.unMillimetersPerTrigger = CONV_MILLIMETERS_PER_TRIGGER; convObject.unLastTicks = 0; convObject.unLastDeltaTicks = 0; convObject.unNumTotalTriggerSignals = 0; convObject.unTimeoutTicks = timeFromMs( convHal.unTimeout ); convObject.bStanding = TRUE; // PRE: the HWI link to our handler function is set by the config tool. IRQ_clear( convHal.unExtInterrupt ); IRQ_enable( convHal.unExtInterrupt ); // Enable the interrupt in the FPGA ppuMemory[CONV_REG_INTENABLE_ADDR] |= CONV_REG_INTENABLE_MASK; // Init the high res timer that we're going to use timeInit(); }
int main () { key = keyNew (KEY_ROOT, KEY_END); timeInit (); benchmarkCreate (); timePrint ("Created empty keyset"); benchmarkFillup (); timePrint ("New large keyset"); benchmarkOpen (); keySetName (key, KEY_ROOT); timePrint ("Opened key database"); benchmarkInread (); timePrint ("Initialize read"); benchmarkInwrite (); timePrint ("Initialize write"); benchmarkWriteout (); timePrint ("Write key database"); benchmarkRewrite (); timePrint ("Rewrite key database"); benchmarkReadin (); timePrint ("Read in key database"); benchmarkLookupByName (); timePrint ("Lookup key database"); benchmarkReread (); timePrint ("Re read key database"); benchmarkClose (); timePrint ("Closed key database"); ksDel (large); keyDel (key); }
void D3D11Demo::paint (Graphics&) { if (renderThreadExists()) return; renderThreadStart ([this] (Thread* thread) { { ErrorReporter r (this); if (!d3d11.startup (getTopLevelComponent()->getWindowHandle())) return; } { ErrorReporter r (this); if (!demoStartup()) return; } timeInit(); while (!thread->threadShouldExit()) { ErrorReporter r (this); timeUpdate(); demoUpdate(); Thread::yield(); } { ErrorReporter r (this); demoShutdown(); } { ErrorReporter r (this); d3d11.shutdown(); } }); }
VkBool32 VKTS_APIENTRY engineInit() { if (!processorInit()) { VKTS_PRINTF("LOG [VKTS_LOG_ERROR]: Engine: Initialization failed! Could not initialize the processor!\n"); return VK_FALSE; } if (!logInit()) { VKTS_PRINTF("LOG [VKTS_LOG_ERROR]: Engine: Initialization failed! Could not initialize logging.\n"); return VK_FALSE; } if (!timeInit()) { logPrint(VKTS_LOG_ERROR, "Engine: Initialization failed! Could not initialize the timer!"); return VK_FALSE; } if (!barrierInit()) { logPrint(VKTS_LOG_ERROR, "Engine: Initialization failed! Could not initialize the barrier!"); return VK_FALSE; } if (!fileInit()) { logPrint(VKTS_LOG_ERROR, "Engine: Initialization failed! Could not initialize the file system!"); return VK_FALSE; } return VK_TRUE; }
/************************ Global *************************/ int main(int argc, char * argv[]) { char *platform_path = NULL; struct stat s; int err; // Install a signal handler // make ttyprintk at some point stdout = freopen("/tmp/log.txt", "w", stdout); if (stdout == NULL){ fprintf(stderr, "unable to remap stdout !\n"); exit(-1); } fflush(stdout); stderr = freopen("/tmp/log_er.txt", "w", stderr); if (stderr == NULL){ printf("Unable to remap stderr !\n"); exit(-1); } fflush(stderr); // Snapshot time counter if (timeInit() < 0) exit(-1); // debug for the user if (argc < 2){ fprintf(stderr, "./sketch tty0\n"); return -1; } printf("started with binary=%s Serial=%s\n", argv[0], argv[1]); fflush(stdout); // check if we're running on the correct platform // and refuse to run if no match platform_path = (char *)malloc(sizeof(PLATFORM_NAME_PATH) + sizeof(PLATFORM_NAME)); sprintf(platform_path,"%s%s", PLATFORM_NAME_PATH, PLATFORM_NAME); printf("checking platform_path [%s]\n", platform_path); fflush(stdout); err = stat(platform_path, &s); if(err != 0) { fprintf(stderr, "stat failed checking for %s with error code %d\n", PLATFORM_NAME, err); free(platform_path); return -1; } if(!S_ISDIR(s.st_mode)) { /* exists but is no dir */ fprintf(stderr, "Target board not a %s\n", PLATFORM_NAME); free(platform_path); return -1; } printf("Running on a %s platform (%s)\n", PLATFORM_NAME, platform_path); fflush(stdout); free(platform_path); // TODO: derive trace level and optional IP from command line trace_init(VARIANT_TRACE_LEVEL, 0); trace_target_enable(TRACE_TARGET_UART); // Call Arduino init init(argc, argv); // Init IRQ layer // Called after init() to ensure I/O permissions inherited by pthread interrupt_init(); #if defined(USBCON) USBDevice.attach(); #endif setup(); for (;;) { loop(); //if (serialEventRun) serialEventRun(); } return 0; }
int main() { timeInit(); ledInit(); traceInit(); // Enable global interrupts. // Needed for RST and ATN interrupt handlers. CyGlobalIntEnable; // Set interrupt handlers. scsiPhyInit(); configInit(&scsiDev.boardCfg); debugInit(); scsiInit(); scsiDiskInit(); // Optional bootup delay int delaySeconds = 0; while (delaySeconds < scsiDev.boardCfg.startupDelay) { // Keep the USB connection working, otherwise it's very hard to revert // silly extra-long startup delay settings. int i; for (i = 0; i < 200; i++) { CyDelay(5); scsiDev.watchdogTick++; configPoll(); } ++delaySeconds; } uint32_t lastSDPoll = getTime_ms(); sdCheckPresent(); while (1) { scsiDev.watchdogTick++; scsiPoll(); scsiDiskPoll(); configPoll(); sdPoll(); if (unlikely(scsiDev.phase == BUS_FREE)) { if (unlikely(elapsedTime_ms(lastSDPoll) > 200)) { lastSDPoll = getTime_ms(); sdCheckPresent(); } else { // Wait for our 1ms timer to save some power. // There's an interrupt on the SEL signal to ensure we respond // quickly to any SCSI commands. The selection abort time is // only 250us, and new SCSI-3 controllers time-out very // not long after that, so we need to ensure we wake up quickly. uint8_t interruptState = CyEnterCriticalSection(); if (!SCSI_ReadFilt(SCSI_Filt_SEL)) { __WFI(); // Will wake on interrupt, regardless of mask } CyExitCriticalSection(interruptState); } } else if (scsiDev.phase >= 0) { // don't waste time scanning SD cards while we're doing disk IO lastSDPoll = getTime_ms(); } } return 0; }
int main () { initCoCoSupport(); heapInit(); timeInit(); setHighSpeed(TRUE); width(32); if (dateTime->marker = 0x1234) { timeSet(dateTime->year, dateTime->month, dateTime->day, dateTime->hour, dateTime->minute, dateTime->second); } daliConfig.width = 256; daliConfig.height = 192; daliConfig.bitmap = 0xe00; daliConfig.max_fps = 30; daliConfig.max_cps = 30; daliConfig.render_state = 0; daliConfig.time_mode = HHMMSS; daliConfig.date_mode = MMDDYY; daliConfig.display_date_p = 0; daliConfig.test_hack = 0; render_init(&daliConfig); memset(daliConfig.bitmap, 0xff, 6144); pmode(4, daliConfig.bitmap); screen(1, 1); UInt32 displayTimeTime; UInt32 five = UInt32Init(0, 5); struct timeval now; struct timezone tzp; while(TRUE) { // Revert to time display if time if (daliConfig.display_date_p) { gettimeofday(&now, &tzp); if (UInt32GreaterThan(&now.tv_sec, &displayTimeTime)) { daliConfig.display_date_p = FALSE; } } byte a = MyInkey(); switch(a) { case '0': daliConfig.time_mode = HHMMSS; daliConfig.date_mode = MMDDYY; break; case '1': daliConfig.time_mode = HHMMSS; break; case '2': daliConfig.time_mode = HHMM; break; case '3': daliConfig.time_mode = SS; break; case '4': daliConfig.date_mode = MMDDYY; break; case '5': daliConfig.date_mode = DDMMYY; break; case '6': daliConfig.date_mode = YYMMDD; break; case ' ': daliConfig.display_date_p = TRUE; gettimeofday(&now, &tzp); UInt32Add(&displayTimeTime, &now.tv_sec, &five); break; } render_once(&daliConfig); } return 0; }
void CClassification::EnterTask() { #ifndef _WINDOWS // ------- Don't compile on windows ----- Uint32 unIntervalTicks; Bool bLed2 = FALSE; ledLight( 2, FALSE ); // Initialize the conveyor device driver and register the trigger semaphore. convInit( ); SEM_new( &m_semTrigger, 0 ); convRegisterSemTrigger( &m_semTrigger, &m_bTrigger ); // Reset statstics GetStats( NULL, TRUE ); // Initialize the high res timer timeInit(); // Pre-calculate the maximum wait time for the semaphore. unIntervalTicks = hlpMsToTicks( 1000 * MAXWAIT_SECONDS ); // Open the interlink UART channel and configure it. m_hPPUSerial = serOpen( INTERLINK_UART_CHAN, sizeof( ClassificationTable ) *4 ); assertLog( m_hPPUSerial != NULL ); serConfigChannel( m_hPPUSerial, 115000, FALSE, FALSE, FALSE ); // Initialize the jet controller TSK_sleep( 2000 ); CJetControl::Instance()->Init(); // Start watchdog and set it to twice the time of our maximum interval. m_unWatchId = CWatchdog::Instance()->AddToWatch( "Classification", MAXWAIT_SECONDS * 2 ); CWatchdog::Instance()->EnableWatch( m_unWatchId, TRUE ); while( 1 ) { // Wait for a trigger signal, timeout at some time to reset watchdog if ( SEM_pend( &m_semTrigger, unIntervalTicks ) ) { // Succesfully received a trigger ledLight( 2, bLed2 ); bLed2 = !bLed2; // Get the trigger time as exact as possible. Uint32 unCurTime = convGetLastTriggerTime(); // Increment our trigger counter. m_unCurrentTriggerPulse++; // dbgLog( "Entering Trigger %d", m_unCurrentTriggerPulse ); // Store that trigger in the stats. This increments the number of possible potatoes by the number // of lanes. m_sClassificationStats.unNumPossible += m_nNumLanes; // See if we're in service mode and handle it. if ( m_csmServiceMode != CSM_NORMAL ) { if ( (m_csmServiceMode == CSM_ADJUST_SMALL_EJECTION_PARAMS ) || (m_csmServiceMode == CSM_ADJUST_MEDIUM_EJECTION_PARAMS ) || (m_csmServiceMode == CSM_ADJUST_LARGE_EJECTION_PARAMS ) ) ServiceGenParamAdjustCommands( unCurTime ); } else { // If not in service mode, see if we've got any due ejections to make and generate // the commands for it. EjectionTable * pTable; // See if any ejections are due and generate the jetcontrol commands, which are then // sent to the jet control. pTable = GetDueEjectionTable(); if ( pTable != NULL ) { // Generate ejection commands, but only if we're in classification mode. if ( m_eOperationMode == OP_CLASSIFICATION ) { GenerateEjectionCommands( pTable, unCurTime ); } ReleaseEjectionTable( pTable ); } // Now we have to classify the potatoes and create the ejection table for the current // line. Only build the table if we've got a reference to the global potato table if ( m_pPotatoTable != NULL ) { // Build the local classification table (i.e. the per-frame classification) BuildTable( &m_LocalClassificationTable, m_pPotatoTable ); // Only exchange tables if we're in classification mode. if ( m_eOperationMode == OP_CLASSIFICATION ) { // Exchange the table with the other DSP if ( ExchangeTables( &m_LocalClassificationTable, &m_ForeignClassificationTable ) == TRUE ) { MergeTables( &m_LocalClassificationTable, &m_ForeignClassificationTable ); } } // Classify the potatoes using a new ejection table. This, we'll // have to do even in calibration mode, because of the statistics // for the GUI. pTable = GetNewEjectionTable( m_nNumTriggerPulsesDelay ); if ( pTable != NULL ) { ClassifyPotatoes( & m_LocalClassificationTable, &m_ForeignClassificationTable, pTable ); } } // if potatoobject table accessible } // if not in servicemode } // if trigger occured else { // Clean the objects list from time to time, if we don't receive trigger signals for // a long time. This prevents the number of objects from growing to big. CleanObjects( m_pPotatoTable ); // Check for service operation if ( m_csmServiceMode == CSM_CHECK_JETS ) ServiceGenJetCheckCommands(); } // See if any of the strictness values changed and apply it to the properties if ( m_propSplitStrictness.HasChanged() || m_propShapeStrictness.HasChanged() || m_propGreenStrictness.HasChanged() || m_propColorStrictness.HasChanged() ) { ApplyStrictness(); } // Signal the watchdog. CWatchdog::Instance()->SignalAlive( m_unWatchId ); } // while(1) #endif // ------------------------------------------------ }