void Main::run() { PMOptixRenderer renderer; FileLogger logger; try { QString logPath = QFileInfo(filePath).dir().absoluteFilePath("log.txt"); logger = FileLogger(logPath); } catch(std::exception &ex) { std::cerr << "Could not initialize logger: " << ex.what() << std::endl; return; } renderer.initialize(device, &logger); Problem problem; try { logger.log("Load definition XML & Scene\n"); problem = Problem::fromFile(&logger, filePath, &renderer); } catch(std::exception& ex){ logger.log("Error reading file: %s\n", ex.what()); emit finished(); return; } try { logger.log("Optimizing\n"); problem.optimize(); }catch(std::exception& ex){ logger.log("Error optimizing: %s\n", ex.what()); } logger.log("Cleaning up\n"); QThreadPool::globalInstance()->waitForDone(); emit finished(); }
void fileLoggerOutPut(const string& message) { //--log message from server msgLog.log(message); msgLog.log("\n---------------------------\n"); //--log localization if ( message[0] == 'S') { stringstream ss; ss << WM->getGameTime() <<' '<< WM->getMyGlobalPos() << ' ' << WM->getMyGlobalVel() <<endl; localizationLog.log(ss.str()); } //--log ball's position if ( message[0] == 'S') { stringstream ss; ss << WM->getGameTime() <<' '<< WM->getBallGlobalPos() << ' ' << WM->getBallGlobalVel() <<endl; ballPosLog.log(ss.str()); } }
void Agent::think() { // Stime time data // This is a sensation to be given to the agent. It begins a // thinking cycle. The first time is the simulation time the // sensation was generated (also known as the send time) and the // second is the time that the sensation is delivered to the agent // (also known as the arrive time). If the parameter send agent send // time is off, -1 is always sent as the send time, and if the // parameter send agent arrive time is off, -1 is always sent as the // arrive time. The data is an arbitrary data string generated by // the world model. The agent can reply with act messages, and must // finish with a done thinking message. LOGBEGIN; LOG( 1, "received sensation %i" , _sensationCount ); //if ( WM->getGameTime() > 150 ) exit(0); WM->update(); _panTilted = false; switch ( _sensationCount ) { case 0: createAgent(); break; case 1: initAgent(); break; default:; playMatch(); } ++_sensationCount; //if ( _sensationCount > 1000 ) exit(1);//profile the program //--------------for DEBUG----------------- //-- init FileLogger and open file if ( _sensationCount == 10 ) { init(); WM->setSameTypeTeammateNum(); //-* can only update after set the num #ifdef ENABLE_LOG msgLog.openFile("msgLog"); //-* logging all msg for communcation with the server localizationLog.openFile("myPos");//-* for debuging localization ballPosLog.openFile("ballPos"); //-* for debuging localize ball's position #endif } //-------------end DEBUG---------------------- /* ** From 'NEWS' in SPADES 1.10 ** * * Agents can now, in the middle of a thinking cycle, send a "request current think time" message. The commserver responds with the * current think time for this thinking cycle. This message is processed by the commserver (no network message to the engine) and * the commserver responds as quickly as it can. The format: * Agent->CS: "C" is a request current think time message * CS->Agent: "C<time>" is the response, where <time> is the current thinking time * CS->Agent: "req_curr_think_time_when_not_thinking" is a new error code if the agent sends this message when it's not thinking */ //-* "C" message //-- send a "C" to commserver //-- commserver reply current think time //-- the reply formation is "C<time>" // Time timeBeforeThink = WM->getRealTime(); COMM->PutOutput( requestThinkTimeMessage() ); LOG( 2, "---------after send C-------"); if ( COMM->GetInput() ) { LOG( 2, COMM->GetMsg() ); #ifdef ENABLE_LOG msgLog.log( COMM->GetMsg() ); msgLog.log( "\n"); #endif PA->parseAll(COMM->GetMsg()); LOG( 2, "C time: %f",WM->getCurrentThinkTime() ); } sendActionNotifys(); }