DataStream* ResourceManager::GetResource(const char* ResRef, SClass_ID type, bool silent) const { if (ResRef[0] == '\0') return NULL; if (!silent) { printMessage("ResourceManager", "Searching for %s.%s...", WHITE, ResRef, core->TypeExt(type)); } FileStream *str = OpenCacheFile(ConstructFilename(ResRef, core->TypeExt(type))); if (str) { if (!silent) printStatus("Cache", GREEN ); return str; } for (size_t i = 0; i < searchPath.size(); i++) { DataStream *ds = searchPath[i]->GetResource(ResRef, type); if (ds) { if (!silent) { printStatus( searchPath[i]->GetDescription(), GREEN ); } return ds; } } if (!silent) { printStatus( "ERROR", LIGHT_RED ); } return NULL; }
int main () { TrafficLight l = TL_Off; printStatus( l ); printf( "Press any key to enable traffic..." ); getchar(); l = TL_Red; while ( true ) { printStatus( l ); printf( "Input 'q' to quit, 'e' to turn on/off, 'b' to toggle blinking mode, any other key for next state\n" ); switch ( getchar() ) { case 'q': return 0; case 'e': l = ( l == TL_Off ) ? TL_Yellow : TL_Off; break; case 'b': l = ( l == TL_Off ) ? TL_Off : ( ( l == TL_YellowBlinking ) ? TL_Yellow : TL_YellowBlinking ); break; default: l = nextTrafficLight( l ); break; } } }
static void waitTimeout(niport *pniport,double seconds) { epicsEventWaitStatus status; transferState_t saveState; if(seconds<0.0) { status = epicsEventWait(pniport->waitForInterrupt); } else { status = epicsEventWaitWithTimeout(pniport->waitForInterrupt,seconds); } if(status==epicsEventWaitOK) return; saveState = pniport->transferState; pniport->transferState = transferStateIdle; switch(saveState) { case transferStateRead: pniport->status=asynTimeout; printStatus(pniport,"waitTimeout transferStateRead\n"); break; case transferStateWrite: pniport->status=asynTimeout; printStatus(pniport,"waitTimeout transferStateWrite\n"); break; case transferStateCmd: pniport->status=asynTimeout; printStatus(pniport,"waitTimeout transferStateCmd\n"); break; default: pniport->status=asynTimeout; printStatus(pniport,"waitTimeout transferState ?\n"); } }
/* Function that will determine whether an Super Invader has been hit by player's missile */ int checkSuperInvaderHit(){ for (int k = 0; k<5; k++) { /* Rememeber Super Invaders are 5 chars long, so need to determine where the player's missile hit the invader */ if ((p.missileX == (superInvader.posX)) && ((p.missileY == (superInvader.posY+k)))) { mvprintw(superInvader.posX, superInvader.posY, " "); /* go back 5 spaces on the Y and delete the super invader*/ superInvader.alive = 0; /* super invader has been defeated */ score += 500 * level; /* add a score of 500 with regards to the current level */ updateScore(); /* pass this new score into the updateScore() function in player.c */ /* Switch statement that will prompt 'encouraging' messages to the user */ switch(rand()%3){ case 0: printStatus("Earth 1 Aliens 0!!!!!!!!!"); break; case 1: printStatus("Thats the way to gooooo!!!!!!!"); break; case 2: printStatus("We will destroy them, bravoooo !!!!"); break; } return 1; /* boolean for Super Invader has been hit */ } } return 0; }
void genCode() { printProc("Generating code... "); printStatus("DONE",10); printProc("Writing on file... "); printStatus("DONE",10); writeHeader(); int i, k; for(i=1; i<=charCount; i++) { k=mark[charSet[i]]; while(k!=parent[k]) { k=parent[k]; if(k<0) k = -k, push(0); else push(1); } while((k=pop())> -1) writeOnFile(k); } if(dc<7) { for(i=dc+1; i<8; i++) s[i] = '0'; toDec(); fputc(7-dc+'0', fp); } else { fputc(0+'0', fp); } closeFile2Write(); }
void ExecutionListView::deleteRegex() { CSMesBackgroundComputations::Pauser pauser; ExecutionListModel *model_p=_model(); if (! model_p) return; WExecutionDelete dialog(csmes_p,this); if (dialog.exec()) { ExecutionNames sources=dialog.sourceList(); csmes_p->beginUndoGroup(tr("Delete executions '%1'").arg(dialog.source())); int sz=sources.size(); for (int i=0; i<sz; i++) { printStatus(tr("Deleting '%1'...").arg(sources.at(i)),static_cast<float>(i)/static_cast<float>(sz)); if (!model_p->deleteExecution(sources.at(i))) { if (QMessageBox::warning(this,tr("Error"),tr("Deleting '%1' not possible.").arg(sources.at(i)), QMessageBox::Abort, QMessageBox::Ignore)==QMessageBox::Abort) break; } } csmes_p->endUndoGroup(); printStatus("",-1); } }
/* Function that will determine whether an invader has been hit by player's missile */ int checkInvaderHit(){ for (int i = 0; i<INVADERS_ROWS; i++) for (int j = 0; j<INVADERS_COLUMNS; j++) { if (inv[i][j].alive) { for (int k = -1; k<2; k++) { /* Remember invaders are 3 chars long, so need to determine where the player's missile hit the invader */ if ((p.missileX == (inv[i][j].posX)) && ((p.missileY == (inv[i][j].posY+k)))) { mvprintw(inv[i][j].posX, inv[i][j].posY-1, " "); /* go back 3 spaces on the Y and delete the invader */ inv[i][j].alive = 0; /* current invader has been defeated */ count--; /* number of invaders has been decreased */ score += 100 * level; /* add a score of 100 with regards to what level user is on */ updateScore(); /* pass this new score into the updateScore() function in player.c */ /* Switch statement that will prompt 'encouraging' messages to the user */ switch(rand()%3){ case 0: printStatus("Great Shot! Just keep going."); break; case 1: printStatus("Nuke them down, nuke them down!!!"); break; case 2: printStatus("Superb shot!!!"); break; } return 1; /* boolean for invader has been hit */ } } } } return 0; }
void MotionGraphController::iterateStatus() { //transitions to follow if (path.size() > 0) { status.isTransitioning = true; // take the first one off the list; vertexTargets temp = path.front(); path.pop_front(); //first seq status.SeqID = temp.SeqID; //first seq framenumber where we transition status.FrameNumberTransition = temp.FrameNumber; //what we are transitioning to status.TransitionToSeqId = temp.SeqID2; //what frame we are transitioning to on the second seq; status.FrameNumberTransitionTo = temp.FrameNumber2; } //let it play out else if (status.isTransitioning==true) { status.SeqID = status.TransitionToSeqId; status.FrameNumber = status.FrameNumberTransitionTo; status.FrameNumberTransition = returnMotionSequenceContainerFromID(status.SeqID).MS->numFrames(); status.isTransitioning = false; printStatus(); }// none left so repeat else { path = pathBackup; iterateStatus(); printStatus(); return; //status.isTransitioning = true; // the last transition is now the new seqId aka what is playing status.SeqID = status.TransitionToSeqId; // MotionSequence *motion_sequence = returnMotionSequenceContainerFromID(status.SeqID).MS; //where to transition on the last frame //status.FrameNumberTransition = motion_sequence->numFrames(); /// set transition to to fame 0 of the same motion sequence //status.FrameNumberTransitionTo = 0; } //iterate the motio }
SequenceStatus GestureSeqRecorder::findActivation(Pose::Type gesture, ControlState state, commandData& response) { SequenceStatus status = SequenceStatus::SUCCESS; sequenceList *seqList = (*seqMapPerMode)[state.getMode()]; // Loop through all possible sequences in this mode, and activate any that // have a matching first gesture. for (sequenceList::iterator it = seqList->begin(); it != seqList->end(); it++) { if ((it->seq.size() >= 0) && (it->seq.at(0).type == gesture)) { clock_t now = clock(); progressBaseTime = now; if (it->seq.at(0).poseLen == SeqElement::PoseLength::IMMEDIATE) { // Special case. Immediate isn't 'held' response = it->sequenceResponse; break; } // found sequence to activate! activeSequencesMutex.lock(); activeSequences.push_back(&(*it)); activeSequencesMutex.unlock(); printStatus(true); holdGestTimer = REQ_HOLD_TIME; // set count on any progression } } seqList = NULL; return status; }
void initInjectorCentral(Logging *sharedLogger) { logger = sharedLogger; chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL); for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { is_injector_enabled[i] = true; } startInjectionPins(); startIgnitionPins(); printStatus(); addConsoleActionII("injector", setInjectorEnabled); addConsoleAction("fuelpumpbench", fuelPumpBench); addConsoleActionS("fuelpumpbench2", fuelPumpBenchExt); addConsoleAction("fanbench", fanBench); addConsoleAction("milbench", milBench); addConsoleActionSSS("fuelbench", fuelbench); addConsoleActionSSS("sparkbench", sparkbench); addConsoleActionSSSSS("fuelbench2", fuelbench2); addConsoleActionSSSSS("sparkbench2", sparkbench2); }
bool ResourceManager::Exists(const char *ResRef, const TypeID *type, bool silent) const { if (ResRef[0] == '\0') return false; // TODO: check various caches const std::vector<ResourceDesc> &types = PluginMgr::Get()->GetResourceDesc(type); for (size_t j = 0; j < types.size(); j++) if (cacheMap.get(ConstructFilename(ResRef, types[j].GetExt()))) return true; for (size_t j = 0; j < types.size(); j++) { for (size_t i = 0; i < searchPath.size(); i++) { if (searchPath[i]->HasResource(ResRef, types[j])) { return true; } } } if (!silent) { printMessage("ResourceManager", "Searching for %s... ", WHITE, ResRef); print("Tried "); PrintPossibleFiles(ResRef,type); printStatus( "NOT FOUND", YELLOW ); } return false; }
void StatusTestGenResNorm<Sacado::MP::Vector<StorageType>,MV,OP>::print(std::ostream& os, int indent) const { for (int j = 0; j < indent; j ++) os << ' '; printStatus(os, status_); os << resFormStr(); if (status_==Undefined) os << ", tol = " << tolerance_ << std::endl; else { os << std::endl; if(showMaxResNormOnly_ && curBlksz_ > 1) { const MagnitudeType maxRelRes = *std::max_element( testvector_.begin()+curLSIdx_[0],testvector_.begin()+curLSIdx_[curBlksz_-1] ); for (int j = 0; j < indent + 13; j ++) os << ' '; os << "max{residual["<<curLSIdx_[0]<<"..."<<curLSIdx_[curBlksz_-1]<<"]} = " << maxRelRes << ( maxRelRes <= tolerance_ ? " <= " : " > " ) << tolerance_ << std::endl; } else { for ( int i=0; i<numrhs_; i++ ) { for (int j = 0; j < indent + 13; j ++) os << ' '; os << "residual [ " << i << " ] = " << testvector_[ i ]; os << ((testvector_[i]<tolerance_) ? " < " : (testvector_[i]==tolerance_) ? " == " : (testvector_[i]>tolerance_) ? " > " : " " ) << tolerance_ << std::endl; } } } os << std::endl; }
int main() { // Declares struct for screen coordinates struct scrCoord Scr; // Declares struct for commands struct Command Cmd; // Initializes variables Cmd.play = TRUE; Cmd.pu = FALSE; Cmd.colorPair = 1; Cmd.cmndIndex = -1; // Initializes screen initScreen(&Scr); while(Cmd.play) { // Prints coordinates and angle printStatus(&Scr); // Receives the command recCommand(&Scr, &Cmd); // Interprets command interpCommand(&Scr, &Cmd); } // Ends NCURSE screen endwin(); return 0; }
void initInjectorCentral(void) { initLogging(&logger, "InjectorCentral"); chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL); for (int i = 0; i < engineConfiguration->cylindersCount; i++) { is_injector_enabled[i] = true; } // todo: should we move this code closer to the injection logic? for (int i = 0; i < engineConfiguration->cylindersCount; i++) { io_pin_e pin = (io_pin_e) ((int) INJECTOR_1_OUTPUT + i); outputPinRegisterExt2(getPinName(pin), pin, boardConfiguration->injectionPins[i], &boardConfiguration->injectionPinMode); } printStatus(); addConsoleActionII("injector", setInjectorEnabled); addConsoleActionII("fuelpumpbench", &fuelpumpbench); addConsoleActionSSS("fuelbench", &fuelbench); addConsoleActionSSS("sparkbench", &sparkbench); addConsoleActionSSSSS("fuelbench2", &fuelbench2); addConsoleActionSSSSS("sparkbench2", &sparkbench2); }
void loopCommandLine(void) { // print status if we're not in the menu if (! menuEnabled) { if (TimerReached(&cmdline_looptime, 1000)) { printStatus(); } } // check for serial command unsigned int c = uart_getc(); if (!(c & UART_NO_DATA)) { if (! menuEnabled) { menuEnabled=1; printHelp(); } switch((char) c) { case 'x': case 'X': // terminates menu uart_puts_P("Leaving menu." NEWLINESTR); menuEnabled=0; break; case 'b': case 'B': // show PID values printPID(); break; case 'r': case 'R': // reset PID values restorePIDDefault(); break; case 'o': case 'O': // print out PID debug data togglePIDDebug(); break; case 'p': setPID_P(getPID_P() - delta); printPID(); break; case 'P': setPID_P(getPID_P() + delta); printPID();break; case 'i': setPID_I(getPID_I() - delta); printPID(); break; case 'I': setPID_I(getPID_I() + delta); printPID(); break; case 'd': setPID_D(getPID_D() - delta); printPID(); break; case 'D': setPID_D(getPID_D() + delta); printPID(); break; case 't': setPIDSetpoint(getPIDSetpoint() - delta); printPID(); break; case 'T': setPIDSetpoint(getPIDSetpoint() + delta); printPID(); break; case 's': case 'S': savePIDConfig(); break; case '+': {// adjust delta delta *= 10.0; if (delta > MAX_DELTA) delta = MAX_DELTA; uart_print_delta(); break; } case '-': {// adjust delta delta /= 10.0; if (delta < MIN_DELTA) delta = MIN_DELTA; uart_print_delta(); break; } case '?': // show menu printHelp(); break; } } }
void dijkstra(graph* G, long initial_node, char debug) { long i,j,k; long aN; //actualNode G->D[initial_node] = 0; aN = initial_node; printf("Running dijkstra on graph\n"); if(debug) printGraph(G); for(i = 0; i < G->N; i++) { G->visited[aN] = VISITED; if(debug){ printf("It[%d] aN [%d]",i, aN); printStatus(G); printf("\n"); } //Find all nodes connected to aN for(j=0;j<G->N;j++){ if( (G->node[aN][j] != NO_CONN) ){ if( (G->D[aN] + G->node[aN][j]) < G->D[j] ){ G->D[j] = (G->D[aN] + G->node[aN][j]); } } } aN = getNextNode(G); } printf("Finished Dijkstra\n"); }
void XMOSControlPlugin::down(){ printStatus(status, curLayer); switch(status){ case SELECT_LAYER: curLayer=((curLayer)%XmosConfig::instance().numLayers())+1; break; case START_LAYER: XmosConfig::instance().stopLayer(curLayer); layerStarted[curLayer]=false; break; case ON_PERIOD: XmosConfig::instance().setOnPeriod(curLayer,XmosConfig::instance().getLayer(curLayer).getOnPeriod()-1); XmosConfig::instance().loadLayer(curLayer); break; case OFFSET: XmosConfig::instance().setOffset(curLayer,XmosConfig::instance().getLayer(curLayer).getOffset()-1); XmosConfig::instance().loadLayer(curLayer); break; case CYCLE: XmosConfig::instance().setCycleTime(curLayer,XmosConfig::instance().getLayer(curLayer).getCycleTime()-1); XmosConfig::instance().loadLayer(curLayer); break; case RUNNING: //ignore break; } }
void XMOSControlPlugin::left(){ printStatus(status, curLayer); switch(status){ case SELECT_LAYER: XmosConfig::instance().loadLayer(curLayer); XmosConfig::instance().startAllLayers(); status=RUNNING; break; case START_LAYER: status=SELECT_LAYER; break; case ON_PERIOD: status=START_LAYER; break; case OFFSET: status=ON_PERIOD; break; case CYCLE: status=OFFSET; break; case RUNNING: //ignore break; } }
void setChartSize(int newSize) { if (newSize < 5) { return; } engineConfiguration->engineChartSize = newSize; printStatus(); }
void HTTPServer::printHeaders(const __FlashStringHelper* contentType, const __FlashStringHelper* status) { printStatus(status); print(F("Content-Type: ")); println(contentType); println(); }
static void setChartActive(int value) { engineConfiguration->isEngineChartEnabled = value; printStatus(); #if EFI_CLOCK_LOCKS maxLockedDuration = 0; // todo: why do we reset this here? why only this and not all metrics? #endif /* EFI_CLOCK_LOCKS */ }
void initialize(void) { installEmptySignalHandler(SIGUSR1); initializeTerminal(); printf("\n\n\n\n\n\n\n"); printStatus(MXT_TMANAGER_RUNNING, MXT_TMANAGER_RUNNING, MXT_TMANAGER_RUNNING); }
int main(void) { printStatus(); int num; while(std::cin>>num) { std::cout<<num<<std::endl; } printStatus(); std::cin.clear(); return 0; }
void LSQRStatusTest<ScalarType,MV,OP>::print(std::ostream& os, int indent) const { for (int j = 0; j < indent; j++) os << ' '; printStatus(os, status_); os << "limit of condition number = " << condMax_ << std::endl; os << "limit of condition number = " << condMax_ << std::endl; }
int main() { fs::create_directory("rainer"); printStatus("rainer"); std::ofstream("rainer/regularFile.txt"); printStatus("rainer/regularFile.txt"); fs::create_directory("rainer/directory"); printStatus("rainer/directory"); // Unix specific mkfifo("rainer/namedPipe", 0644); printStatus("rainer/namedPipe"); // Unix specific? struct sockaddr_un addr; addr.sun_family = AF_UNIX; std::strcpy(addr.sun_path, "rainer/socket"); int fd = socket(PF_UNIX, SOCK_STREAM, 0); bind(fd, (struct sockaddr*)&addr, sizeof addr); printStatus("rainer/socket"); fs::create_symlink("rainer/regularFile.txt", "symlink"); printStatus("symlink"); printStatus("dummy.txt"); fs::remove_all("rainer"); }
void HTTPServer::redirect(const __FlashStringHelper* location) { printStatus(status302); print(F("Location: ")); println(location); println(); println(status302); sendReply(); }
void StopMotors() { bool previousState = getMotorStatus(); setMotorStatus(previousState); if(previousState == false) { printStatus("Motor stopped!"); InvertUART(); } else { ResetInputData(); InvertUART(); printStatus("Motor started!"); } }
int main() { ArModuleLoader::Status status; ArSerialConnection con; ArRobot robot; int ret; std::string str; Aria::init(); status=ArModuleLoader::load("./joydriveActionMod", &robot); printStatus(status); if (status == ArModuleLoader::STATUS_INIT_FAILED) return(1); if ((ret = con.open()) != 0) { str = con.getOpenMessage(ret); printf("Open failed: %s\n", str.c_str()); Aria::shutdown(); return 1; } robot.setDeviceConnection(&con); if (!robot.blockingConnect()) { printf("Could not connect to robot... exiting\n"); Aria::shutdown(); return 1; } robot.comInt(ArCommands::SONAR, 0); robot.comInt(ArCommands::ENABLE, 1); robot.comInt(ArCommands::SOUNDTOG, 0); robot.run(true); status=ArModuleLoader::close("./joydriveActionMod"); printStatus(status); Aria::shutdown(); return 0; }
int main(int argc, char **argv) { Aria::init(); ArArgumentParser parser(&argc, argv); // set up our simple connector ArSimpleConnector simpleConnector(&parser); ArRobot robot; // set up the robot for connecting if (!simpleConnector.connectRobot(&robot)) { printf("Could not connect to robot... exiting\n"); Aria::exit(1); } robot.runAsync(true); ArModuleLoader::Status status; std::string str; ArLog::log(ArLog::Terse, "moduleActionExample: Loading the module \"moduleActionExample_Mod\" with a string argument..."); status=ArModuleLoader::load("./moduleActionExample_Mod", &robot, (char *)"You've loaded a module!"); printStatus(status); ArLog::log(ArLog::Terse, "moduleActionExample: Loading the module \"moduleActionExample_Mod2\" with a string argument..."); status=ArModuleLoader::load("./moduleActionExample2_Mod", &robot, (char *)"You've loaded a second module!"); printStatus(status); //ArLog::log(ArLog::Terse, "moduleActionExample: Reloading \"moduleActionExample_Mod\" with no argument..."); //status=ArModuleLoader::reload("./moduleActionExample_Mod", &robot); //printStatus(status); //ArLog::log(ArLog::Terse, "moduleActionExample: Closing \"moduleActionExample_Mod\"..."); //status=ArModuleLoader::close("./moduleActionExample_Mod"); //printStatus(status); ArUtil::sleep(3000); Aria::exit(0); return(0); }
QT_BEGIN_NAMESPACE HelpGenerator::HelpGenerator() { generator = new QHelpGenerator(this); connect(generator, SIGNAL(statusChanged(QString)), this, SLOT(printStatus(QString))); connect(generator, SIGNAL(warning(QString)), this, SLOT(printWarning(QString))); }