QStringList LogManager::readLog(LogManager::LOG_FILE file, QDateTime starttime, QDateTime endtime){ //First get a list of all the various log files which encompass this time range QDir logdir(LOGDIR); // - get list of all this type of log QStringList files = logdir.entryList(QStringList() << flagToPath(file).arg("*"), QDir::Files, QDir::Name); // - filter out the dates we need (earlier first) QString tmp = flagToPath(file).arg(starttime.date().toString(Qt::ISODate)); while(!files.isEmpty()){ //Note we can do basic compare due to identical filenames *except* for some numbers near the end if( QString::compare(files[0], tmp)<0 ){ files.removeAt(0); } else{ break; } } // - now filter out any later dates than we need if(endtime.date() < QDate::currentDate()){ tmp = flagToPath(file).arg(endtime.date().toString(Qt::ISODate)); while(!files.isEmpty()){ //Note we can do basic compare due to identical filenames *except* for some numbers near the end if( QString::compare(files.last(), tmp)>0 ){ files.removeAt(files.length()-1); } else{ break; } } } //Now load each file in order (oldest->newest) and filter out the necessary logs QStringList logs; for(int i=0; i<files.length(); i++){ logs << readLog(LOGDIR+"/"+files[i], starttime, endtime); } return logs; }
int main(int argc, char *argv[]) { char *filename; EventProc proc; Res res; filename = parseArgs(argc,argv); if (strcmp(filename, "-") == 0) input = stdin; else { input = fopen(filename, "rb"); if (input == NULL) error("unable to open \"%s\"\n", filename); } res = EventProcCreate(&proc, partialLog, logReader, (void *)input); if (res != ResOK) error("Can't init EventProc module: error %d.", res); res = EventRepInit(partialLog); if (res != ResOK) error("Can't init EventRep module: error %d.", res); readLog(proc); EventRepFinish(); EventProcDestroy(proc); return EXIT_SUCCESS; }
void Logstalgia::init() { debugLog("init called\n"); ipSummarizer = new Summarizer(fontSmall, 2, 40, 0, 2.0f); reset(); readLog(); //add default groups if(summGroups.size()==0) { //images - file is under images or addGroup("CSS", "\\.css\\b", 15); addGroup("Script", "\\.js\\b", 15); addGroup("Images", "/images/|\\.(jpe?g|gif|bmp|tga|ico|png)\\b", 20); } //always fill remaining space with Misc, (if there is some) if(remaining_space>50) { addGroup(summGroups.size()>0 ? "Misc" : "", ".*"); } SDL_ShowCursor(false); //set start position if(gStartPosition > 0.0 && gStartPosition < 1.0) { seekTo(gStartPosition); } }
void Logstalgia::init() { ipSummarizer = new Summarizer(fontSmall, 100, 2.0f); ipSummarizer->setSize(2, 40, 0); reset(); readLog(); //add default groups if(summarizers.empty()) { //images - file is under images or addGroup("URI", "CSS", "(?i)\\.css\\b", 15); addGroup("URI", "Script", "(?i)\\.js\\b", 15); addGroup("URI", "Images", "(?i)/images/|\\.(jpe?g|gif|bmp|tga|ico|png)\\b", 20); } //always fill remaining space with Misc, (if there is some) if(remaining_space>50) { addGroup("URI", "Misc", ".*"); } resizeGroups(); SDL_ShowCursor(false); //set start position if(settings.start_position > 0.0 && settings.start_position < 1.0) { seekTo(settings.start_position); } // show slider so user knows its there unless recording if(frameExporter==0) slider.show(); }
int main(int argc, char *argv[]) { char *filename; FILE *input; assert(CHECKCONV(ulongest_t, Word)); assert(CHECKCONV(ulongest_t, Addr)); assert(CHECKCONV(ulongest_t, void *)); assert(CHECKCONV(ulongest_t, EventCode)); filename = parseArgs(argc, argv); if (!filename) { filename = getenv(TELEMETRY_FILENAME_ENVAR); if(!filename) filename = DEFAULT_TELEMETRY_FILENAME; } if (strcmp(filename, "-") == 0) input = stdin; else { input = fopen(filename, "rb"); if (input == NULL) everror("unable to open \"%s\"\n", filename); } readLog(input); return EXIT_SUCCESS; }
static int64 writeEventsToSQL(sqlite3 *db) { FILE *input; int64 count; input = openLog(db); count = readLog(input, db); (void)fclose(input); return count; }
int ScriptParser::filelogCommand() { if ( current_mode != DEFINE_MODE ) errorAndExit( "filelog: not in the define section" ); filelog_flag = true; readLog( script_h.log_info[ScriptHandler::FILE_LOG] ); return RET_CONTINUE; }
int RRSyncPolicy::replayLock(InternalLock* l){ lockcount[me->tid] ++; ReplayLog log = readLog(me->tid, lockcount[me->tid]); waitStatus(log, l); //waitLock(me->tid, lockcount[me->tid], l); Util::spinlock(&l->ilock); l->incVersion(); return 0; }
void Logstalgia::seekTo(float percent) { if(settings.disable_progress) return; //disable pause if enabled before seeking if(paused) paused = false; reset(); seeklog->seekTo(percent); readLog(); }
myShowManager::myShowManager(QObject *parent) : QObject(parent) { countShows = myLog::getCountCurDay(); last_time = myLog::getLastTime(); start_time = QDateTime::currentDateTime(); plan_showing = myLog::getPlanTime(countShows); readLog(); QTimer *timer = new QTimer(this); connect(timer,SIGNAL(timeout()),this,SLOT(checkTime())); timer->start(15000); }
void Logstalgia::seekTo(float percent) { debugLog("seekTo(%.2f)\n", percent); if(gDisableProgress) return; //disable pause if enabled before seeking if(paused) paused = false; reset(); seeklog->seekTo(percent); readLog(); }
List* cmdReadLog(cmdLog* cLog, List* env, cmdLine* line) { char* prevcmd; if ((strlen(line->arguments[0])>2) || (line->arguments[0][1]<'0' || line->arguments[0][1]>'9')) { perror("illegal arguments after '!'\n"); } else { prevcmd = readLog(cLog,(line->arguments[0][1])-48); if (!prevcmd) { perror("illegal arguments after '!'\n"); } else { return execString(cLog, env, prevcmd); } } return env; }
int main(int argc, char *argv[]) { FILE *input; parseArgs(argc, argv); if (!logFileName) { input = stdin; logFileName = "<stdin>"; } else { input = fopen(logFileName, "r"); if (input == NULL) everror("unable to open %s", logFileName); } createTables(); readLog(input); (void)fclose(input); return 0; }
int main(int argc, char *argv[]) { char *filename; EventProc proc; Res res; #if !defined(MPS_OS_FR) /* GCC -ansi -pedantic -Werror on FreeBSD will fail here * with the warning "statement with no effect". */ assert(CHECKCONV(ulong, Word)); assert(CHECKCONV(ulong, Addr)); assert(CHECKCONV(ulong, void *)); assert(CHECKCONV(unsigned, EventCode)); assert(CHECKCONV(Addr, void *)); /* for labelled pointers */ #endif filename = parseArgs(argc, argv); if (strcmp(filename, "-") == 0) input = stdin; else { input = fopen(filename, "rb"); if (input == NULL) error("unable to open \"%s\"\n", filename); } res = EventProcCreate(&proc, partialLog, logReader, (void *)input); if (res != ResOK) error("Can't init EventProc module: error %d.", res); readLog(proc); EventProcDestroy(proc); return EXIT_SUCCESS; }
void QtSyncStatusLogView::showEvent(QShowEvent* event) { readLog(); HbView::showEvent(event); }
void Gource::logic(float t, float dt) { if(draw_loading) return; if(splash>0.0) splash -= dt; //init log file if(commitlog == 0) { commitlog = determineFormat(logfile); if(commitlog == 0) { //if not in a git dir and no log file, show help if(logfile.size() == 0 || logfile == ".") { SDL_Quit(); gource_help(""); } else if(SDLAppDirExists(logfile)) { gource_quit("Directory not supported."); } else { gource_quit("Unsupported log format. You may need to regenerate your log file."); } } if(start_position>0.0) { seekTo(start_position); } } slider.logic(dt); //still want to update camera while paused if(paused) { updateCamera(dt); return; } // get more entries if(commitqueue.size() == 0) { readLog(); } //loop in attempt to find commits if(commitqueue.size()==0 && commitlog->isSeekable() && gGourceFileLoop) { first_read=true; seekTo(0.0); readLog(); } if(currtime==0 && commitqueue.size()) { currtime = commitqueue[0].timestamp; subseconds = 0.0; } //set current time float time_inc = (dt * 86400.0 * gGourceDaysPerSecond); int seconds = (int) time_inc; subseconds += time_inc - ((float) seconds); if(subseconds >= 1.0) { currtime += (int) subseconds; subseconds -= (int) subseconds; } currtime += seconds; // delete files for(std::vector<RFile*>::iterator it = gGourceRemovedFiles.begin(); it != gGourceRemovedFiles.end(); it++) { deleteFile(*it); } gGourceRemovedFiles.clear(); //add commits up until the current time while(commitqueue.size() > 0) { RCommit commit = commitqueue[0]; if(gGourceAutoSkipSeconds>=0.0 && idle_time >= gGourceAutoSkipSeconds) { currtime = commit.timestamp; idle_time = 0.0; } if(commit.timestamp > currtime) break; processCommit(commit, t); currtime = commit.timestamp; subseconds = 0.0; commitqueue.pop_front(); } //reset loop counters gGourceUserInnerLoops = 0; gGourceDirNodeInnerLoops = 0; gGourceFileInnerLoops = 0; interactUsers(); interactDirs(); updateUsers(t, dt); updateDirs(dt); updateCamera(dt); updateTime(); }
void QtSyncStatusLogView::updateView() { readLog(); }
void QtSyncStatusLogView::deleteLog() { mSyncLog.clear(); readLog(); }
TrackEditor::TrackEditor(QWidget *parent) : QMainWindow(parent), // m_idev_factory(), m_serial_port(0), m_device_io(0), m_dev_data(0), m_command_mode_step(-1), m_command_response_step(-1), m_device_file(0), m_socket_notifier(0), m_nema_string(""), m_line(""), m_log_buf(), m_tmp_buf(), m_read_start(-1), m_retry_count(-1), m_expect_binary_data(-1), m_binary_data_already_read(-1), m_lastsection(false), m_blocksize(-1), m_track_collection(0), m_selection_model(0), m_track_filename("") { ui.setupUi(this); // set m_track_collection to 0 to prevent setTrackCollection() from trying to delete it. m_track_collection = 0; PlotData::initializeMaps(); connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui.action_Connect, SIGNAL(triggered()), this, SLOT(connectDevice())); connect(ui.action_Disconnect, SIGNAL(triggered()), this, SLOT(disconnectDevice())); connect(ui.action_Load_Track, SIGNAL(triggered()), this, SLOT(loadTrack())); connect(ui.actionAppend_Track, SIGNAL(triggered()), this, SLOT(appendTrack())); connect(ui.action_Save_Track, SIGNAL(triggered()), this, SLOT(saveTrack())); connect(ui.action_Save_Track_As, SIGNAL(triggered()), this, SLOT(saveTrackAs())); connect(ui.action_Read_Log, SIGNAL(triggered()), this, SLOT(readLog())); ui.action_Read_Log->setDisabled(true); connect(ui.action_Start_Recording, SIGNAL(triggered()), this, SLOT(startRecording())); connect(ui.action_Stop_Recording, SIGNAL(triggered()), this, SLOT(stopRecording())); connect(ui.actionStart_Animation, SIGNAL(triggered()), &m_animation, SLOT(start())); connect(ui.actionStop_Animation, SIGNAL(triggered()), &m_animation, SLOT(stop())); connect(ui.actionFaster, SIGNAL(triggered()), &m_animation, SLOT(incSpeed())); connect(ui.actionSlower, SIGNAL(triggered()), &m_animation, SLOT(decSpeed())); connect(ui.actionX_0_125, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX0125())); connect(ui.actionX_0_25, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX025())); connect(ui.actionX_0_5, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX05())); connect(ui.actionX_1, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX1())); connect(ui.actionX_2, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX2())); connect(ui.actionX_4, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX4())); connect(ui.actionX_8, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX8())); connect(ui.actionX_16, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX16())); connect(ui.actionX_32, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX32())); connect(ui.actionX_64, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX64())); connect(ui.actionX_128, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX128())); connect(ui.actionSettings, SIGNAL(triggered()), this, SLOT(showSettingsDlg())); connect(ui.action_About, SIGNAL(triggered()), this, SLOT(showAboutDialog())); connect(this, SIGNAL(setText(QString)), ui.nemaText, SLOT(appendPlainText(QString))); m_track_view = new TrackView(ui.scrollArea); ui.scrollArea->setWidget(m_track_view); connect(&m_animation, SIGNAL(setMarkers(QList<CMarker>)), m_track_view, SLOT(setMarkers(QList<CMarker>))); connect(ui.actionZoom_in, SIGNAL(triggered()), m_track_view, SLOT(zoomIn())); connect(ui.actionZoom_out, SIGNAL(triggered()), m_track_view, SLOT(zoomOut())); ui.treeView->setSelectionMode(QAbstractItemView::ExtendedSelection); m_selection_model = ui.treeView->selectionModel(); connect(m_selection_model, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged(QItemSelection,QItemSelection))); m_diagrams_layout = new CDiagramsLayout(ui.diagramWidget); ui.diagramWidget->setLayout(m_diagrams_layout); connect(m_diagrams_layout, SIGNAL(setMarkers(QList<CMarker>)), m_track_view, SLOT(setMarkers(QList<CMarker>))); m_settings = new CSettings(); m_settings->load(); QList<enum plotTypeY> distList; distList = m_settings->getDistQuantities(); QList<enum plotTypeY> timeList; timeList = m_settings->getTimeQuantities(); QList<enum plotTypeY> trackPointsList; trackPointsList = m_settings->getTrackpointsQuantities(); m_diagrams_layout->setQuantities(distList, timeList, trackPointsList ); setTrackCollection(new TrackCollection); m_device_io = 0; m_dev_data = 0; m_expect_binary_data = 0; m_command_mode_step = 0; m_command_response_step = 0; m_track_filename.clear(); connect(ui.treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(treeViewClicked(QModelIndex))); ui.treeView->setEditTriggers( QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed ); m_progress_dlg = new QDialog(this); prg_dlg.setupUi(m_progress_dlg); m_progress_dlg->setModal(false); connect(prg_dlg.cancelButton, SIGNAL(clicked()), this, SLOT(readLogFinished())); statusBar()->addWidget(m_animation.statusBarWidget()); statusBar()->addPermanentWidget(m_track_view->statusBarWidget()); restoreLayout(); }
void Gource::logic(float t, float dt) { dt = std::min(dt, gGourceMaxDelta); if(draw_loading) return; if(splash>0.0) splash -= dt; //init log file if(commitlog == 0) { commitlog = determineFormat(logfile); if(commitlog == 0) { printf("unsupported log file or directory not supported\n", logfile.c_str()); exit(1); } if(start_position>0.0) { seekTo(start_position); } } slider.logic(dt); if(paused) return; elapsed_time += dt * 86400.0 * gGourceDaysPerSecond; // get more entries if(commitqueue.size() == 0) { readLog(); } //loop in attempt to find commits if(commitqueue.size()==0 && commitlog->isSeekable()) { seekTo(0.0); readLog(); if(commitqueue.size() == 0 && starttime==0) { debugLog("no commits and starttime is not defined - cant continue\n"); exit(1); } } if(starttime==0) { starttime = commitqueue[0].timestamp; } //set current time currtime = starttime + elapsed_time; float csubsec = elapsed_time - floorf(elapsed_time); // delete files for(std::vector<RFile*>::iterator it = gGourceRemovedFiles.begin(); it != gGourceRemovedFiles.end(); it++) { deleteFile(*it); } gGourceRemovedFiles.clear(); //add commits up until the current time while(commitqueue.size() > 0) { RCommit commit = commitqueue[0]; if(gGourceAutoSkipSeconds>=0.0 && idle_time >= gGourceAutoSkipSeconds) { currtime = commit.timestamp; elapsed_time = commit.timestamp - starttime; idle_time = 0.0; } if(commit.timestamp > currtime) break; processCommit(commit); commitqueue.pop_front(); } //reset loop counters gGourceUserInnerLoops = 0; gGourceDirNodeInnerLoops = 0; gGourceFileInnerLoops = 0; interactUsers(); interactDirs(); updateUsers(dt); updateDirs(dt); updateTime(); }
void Gource::logic(float t, float dt) { if(draw_loading) return; if(message_timer>0.0f) message_timer -= dt; if(splash>0.0f) splash -= dt; //init log file if(commitlog == 0) { try { commitlog = determineFormat(logfile); } catch(SeekLogException& exception) { throw SDLAppException("unable to read log file"); } if(commitlog == 0) { //if not in a git dir and no log file, show help if(logfile.size() == 0 || logfile == ".") { SDL_Quit(); SDLAppException exception(""); exception.setShowHelp(true); throw exception; } else if(SDLAppDirExists(logfile)) { throw SDLAppException("directory not supported"); } else { throw SDLAppException("unsupported log format (you may need to regenerate your log file)"); } } if(gGourceSettings.start_position>0.0) { seekTo(gGourceSettings.start_position); } } slider.logic(dt); //apply rotation if(rotate_angle != 0.0f) { float s = sinf(rotate_angle); float c = cosf(rotate_angle); root->rotate(s, c); for(std::map<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) { RUser* user = it->second; vec2f userpos = user->getPos(); user->setPos(userpos.rotate(s, c)); } rotate_angle = 0.0f; } //still want to update camera while paused if(paused) { updateBounds(); updateQuadTree(); updateCamera(dt); return; } // get more entries if(commitqueue.size() == 0) { readLog(); } //loop in attempt to find commits if(commitqueue.size()==0 && commitlog->isSeekable() && gGourceSettings.loop) { first_read=true; seekTo(0.0); readLog(); } if(currtime==0 && commitqueue.size()) { currtime = lasttime = commitqueue[0].timestamp; subseconds = 0.0; } //set current time float time_inc = (dt * 86400.0 * gGourceSettings.days_per_second); int seconds = (int) time_inc; subseconds += time_inc - ((float) seconds); if(subseconds >= 1.0) { currtime += (int) subseconds; subseconds -= (int) subseconds; } currtime += seconds; // delete files for(std::vector<RFile*>::iterator it = gGourceRemovedFiles.begin(); it != gGourceRemovedFiles.end(); it++) { deleteFile(*it); } gGourceRemovedFiles.clear(); //add commits up until the current time while(commitqueue.size() > 0) { RCommit commit = commitqueue[0]; //auto skip ahead, unless stop_position_reached if(gGourceSettings.auto_skip_seconds>=0.0 && idle_time >= gGourceSettings.auto_skip_seconds && !stop_position_reached) { currtime = lasttime = commit.timestamp; idle_time = 0.0; } if(commit.timestamp > currtime) break; processCommit(commit, t); currtime = lasttime = commit.timestamp; subseconds = 0.0; commitqueue.pop_front(); } //reset loop counters gGourceUserInnerLoops = 0; gGourceDirNodeInnerLoops = 0; gGourceFileInnerLoops = 0; interactUsers(); updateUsers(t, dt); updateQuadTree(); updateBounds(); updateDirs(dt); updateCamera(dt); updateTime(commitqueue.size() > 0 ? currtime : lasttime); }
void TestQgsWcsPublicServers::test( ) { QStringList versions; // It may happen that server supports 1.1.1, but does not accept 1.1 (http://zeus.pin.unifi.it/gi-wcs/http) versions << "" << "1.0.0" << "1.1.0"; // empty for default QStringList servers; // Some (first) coverages do not advertize any supportedCRS and sever gives // error both with native CRS (EPSG::561005) and EPSG:4326 // MOD* coverages work OK servers << "http://argon.geogr.uni-jena.de:8080/geoserver/ows"; servers << "http://demo.geonode.org/geoserver/wcs"; servers << "http://demo.mapserver.org/cgi-bin/wcs"; servers << "http://demo.opengeo.org/geoserver/wcs"; // geobrain.laits.gmu.edu servers are quite slow servers << "http://geobrain.laits.gmu.edu/cgi-bin/gbwcs-dem"; servers << "http://geobrain.laits.gmu.edu/cgi-bin/ows8/wcseo"; servers << "http://geobrain.laits.gmu.edu/cgi-bin/wcs110"; servers << "http://geobrain.laits.gmu.edu/cgi-bin/wcs-all"; servers << "http://iceds.ge.ucl.ac.uk/cgi-bin/icedswcs"; servers << "http://motherlode.ucar.edu:8080/thredds/wcs/fmrc/NCEP/DGEX/Alaska_12km/NCEP-DGEX-Alaska_12km_best.ncd"; servers << "http://navigator.state.or.us/ArcGIS/services/Framework/Imagery_Mosaic2009/ImageServer/WCSServer"; servers << "http://nsidc.org/cgi-bin/atlas_north"; servers << "http://sedac.ciesin.columbia.edu/geoserver/wcs"; // Big and slow //servers << "http://webmap.ornl.gov/ogcbroker/wcs"; servers << "http://ws.csiss.gmu.edu/cgi-bin/wcs-t"; // Big and slow //servers << "http://ws.laits.gmu.edu/cgi-bin/wcs-all"; // Currently very slow or down //servers << "http://www.sogeo.ch/geoserver/wcs"; // Slow and erroneous //servers << "http://zeus.pin.unifi.it/gi-wcs/http"; foreach ( QString server, servers ) { QStringList myServerLog; myServerLog << "server:" + server; QString myServerDirName = server; myServerDirName.replace( QRegExp( "[:/]+" ), "." ); myServerDirName.replace( QRegExp( "\\.$" ), "" ); QgsDebugMsg( "myServerDirName = " + myServerDirName ); QDir myServerDir( mCacheDir.absolutePath() + QDir::separator() + myServerDirName ); QString myServerLogPath = myServerDir.absolutePath() + QDir::separator() + "server.log"; if ( QFileInfo( myServerLogPath ).exists() ) { QgsDebugMsg( "cache exists " + myServerDir.absolutePath() ); continue; } if ( !myServerDir.exists() ) { mCacheDir.mkdir( myServerDirName ); } foreach ( QString version, versions ) { QgsDebugMsg( "server: " + server + " version: " + version ); QgsDataSourceURI myServerUri; myServerUri.setParam( "url", server ); if ( !version.isEmpty() ) { myServerUri.setParam( "version", version ); } QgsWcsCapabilities myCapabilities; myCapabilities.setUri( myServerUri ); if ( !myCapabilities.lastError().isEmpty() ) { QgsDebugMsg( myCapabilities.lastError() ); myServerLog << "error: (version: " + version + ") " + myCapabilities.lastError().replace( "\n", " " ); continue; } QVector<QgsWcsCoverageSummary> myCoverages; if ( !myCapabilities.supportedCoverages( myCoverages ) ) { QgsDebugMsg( "Cannot get list of coverages" ); myServerLog << "error: (version: " + version + ") Cannot get list of coverages"; continue; } int myCoverageCount = 0; int myStep = myCoverages.size() / mMaxCoverages; int myStepCount = -1; foreach ( QgsWcsCoverageSummary myCoverage, myCoverages ) { QgsDebugMsg( "coverage: " + myCoverage.identifier ); // Go in steps to get more success/errors if ( myStepCount == -1 || myStepCount > myStep ) { myStepCount = 0; } else { myStepCount++; continue; } myCoverageCount++; if ( myCoverageCount > mMaxCoverages ) break; QString myPath = myServerDir.absolutePath() + QDir::separator() + myCoverage.identifier; if ( !version.isEmpty() ) { myPath += "-" + version; } QString myLogPath = myPath + ".log"; if ( QFileInfo( myLogPath ).exists() ) { QMap<QString, QString> log = readLog( myLogPath ); if ( !log.value( "identifier" ).isEmpty() && log.value( "error" ).isEmpty() ) continue; } QStringList myLog; myLog << "identifier:" + myCoverage.identifier; myCapabilities.describeCoverage( myCoverage.identifier ); myCoverage = myCapabilities.coverage( myCoverage.identifier ); // get described QgsDataSourceURI myUri = myServerUri; myUri.setParam( "identifier", myCoverage.identifier ); if ( myCoverage.times.size() > 0 ) { myUri.setParam( "time", myCoverage.times.value( 0 ) ); } myLog << "version:" + version; myLog << "uri:" + myUri.encodedUri(); int myWidth = 100; int myHeight = 100; if ( myCoverage.hasSize ) { myHeight = static_cast<int>( qRound( 1.0 * myWidth * myCoverage.height / myCoverage.width ) ); } myLog << QString( "hasSize:%1" ).arg( myCoverage.hasSize ); QgsRasterLayer * myLayer = new QgsRasterLayer( myUri.encodedUri(), myCoverage.identifier, "wcs", true ); if ( myLayer->isValid() ) { int myBandCount = myLayer->dataProvider()->bandCount(); myLog << "bandCount:" + QString::number( myBandCount ); if ( myBandCount > 0 ) { myLog << "srcType:" + QString::number( myLayer->dataProvider()->srcDataType( 1 ) ); QgsRasterBandStats myStats = myLayer->dataProvider()->bandStatistics( 1, QgsRasterBandStats::All, QgsRectangle(), myWidth * myHeight ); myLog << "min:" + QString::number( myStats.minimumValue ); myLog << "max:" + QString::number( myStats.maximumValue ); } QgsMapRenderer myMapRenderer; QList<QgsMapLayer *> myLayersList; myLayersList.append( myLayer ); QgsMapLayerRegistry::instance()->addMapLayers( myLayersList, false ); QMap<QString, QgsMapLayer*> myLayersMap = QgsMapLayerRegistry::instance()->mapLayers(); myMapRenderer.setLayerSet( myLayersMap.keys() ); myMapRenderer.setExtent( myLayer->extent() ); QImage myImage( myWidth, myHeight, QImage::Format_ARGB32_Premultiplied ); myImage.fill( 0 ); myMapRenderer.setOutputSize( QSize( myWidth, myHeight ), myImage.logicalDpiX() ); QPainter myPainter( &myImage ); myMapRenderer.render( &myPainter ); // Save rendered image QString myPngPath = myPath + ".png"; QgsDebugMsg( "myPngPath = " + myPngPath ); myImage.save( myPngPath ); // Verify data QSet<QString> myValues; // cannot be QSet<double> void *myData = myLayer->dataProvider()->readBlock( 1, myLayer->extent(), myWidth, myHeight ); if ( myData ) { int myType = myLayer->dataProvider()->dataType( 1 ); for ( int row = 0; row < myHeight; row++ ) { for ( int col = 0; col < myWidth; col++ ) { double value = myLayer->dataProvider()->readValue( myData, myType, row * myWidth + col ); QString valueStr = QString::number( value ); if ( !myValues.contains( valueStr ) ) myValues.insert( valueStr ); } } free( myData ); } QgsDebugMsg( QString( "%1 values" ).arg( myValues.size() ) ); myLog << QString( "valuesCount:%1" ).arg( myValues.size() ); // Verify image colors QSet<QRgb> myColors; for ( int row = 0; row < myHeight; row++ ) { for ( int col = 0; col < myWidth; col++ ) { QRgb color = myImage.pixel( col, row ); if ( !myColors.contains( color ) ) myColors.insert( color ); } } QgsDebugMsg( QString( "%1 colors" ).arg( myColors.size() ) ); myLog << QString( "colorsCount:%1" ).arg( myColors.size() ); } else { QgsDebugMsg( "Layer is not valid" ); myLog << "error:Layer is not valid"; } QFile myLogFile( myLogPath ); myLogFile.open( QIODevice::WriteOnly | QIODevice::Text ); QTextStream myStream( &myLogFile ); myStream << myLog.join( "\n" ); myLogFile.close(); QgsMapLayerRegistry::instance()->removeAllMapLayers(); }
void Logstalgia::logic(float t, float dt) { float sdt = dt * settings.simulation_speed; //increment clock elapsed_time += sdt; currtime = starttime + (long)(elapsed_time); if(settings.stop_time && currtime > settings.stop_time) { currtime = settings.stop_time; } if(mousehide_timeout>0.0f) { mousehide_timeout -= dt; if(mousehide_timeout<0.0f) { SDL_ShowCursor(false); } } infowindow.hide(); if(end_reached && balls.empty()) { appFinished = true; return; } //if paused, dont move anything, only check what is under mouse if(paused) { for(auto& it: paddles) { Paddle* paddle = it.second; if(paddle->mouseOver(infowindow, mousepos)) { break; } } for(RequestBall* ball : balls) { if(ball->mouseOver(infowindow, mousepos)) { break; } } if(!ipSummarizer->mouseOver(infowindow,mousepos)) { for(Summarizer* s: summarizers) { if(s->mouseOver(infowindow, mousepos)) break; } } return; } //next will fast forward clock to the time of the next entry, //if the next entry is in the future if(next || (!settings.disable_auto_skip && balls.empty())) { if(!queued_entries.empty()) { LogEntry* le = queued_entries.front(); long entrytime = le->timestamp; if(entrytime > currtime) { elapsed_time = entrytime - starttime; currtime = starttime + (long)(elapsed_time); } } next = false; } //recalc spawn speed each second by if(currtime != lasttime) { //dont bother reading the log if we dont need to if(queued_entries.empty() || queued_entries.back()->timestamp <= currtime) { readLog(); } profile_start("determine new entries"); int items_to_spawn=0; for(LogEntry* le : queued_entries) { if(le->timestamp > currtime) break; items_to_spawn++; addStrings(le); } profile_stop(); //debugLog("items to spawn %d\n", items_to_spawn); if(items_to_spawn > 0) { profile_start("add new strings"); //re-summarize ipSummarizer->summarize(); for(Summarizer* s : summarizers) { s->summarize(); } profile_stop(); profile_start("add new entries"); float item_offset = 1.0 / (float) (items_to_spawn); int item_no = 0; while(!queued_entries.empty()) { LogEntry* le = queued_entries.front(); if(le->timestamp > currtime) break; float pos_offset = item_offset * (float) item_no++; float start_offset = std::min(1.0f, pos_offset); addBall(le, start_offset); queued_entries.pop_front(); } } //update date if(total_entries>0) { char datestr[256]; char timestr[256]; struct tm* timeinfo = localtime ( &currtime ); strftime(datestr, 256, "%A, %B %d, %Y", timeinfo); strftime(timestr, 256, "%X", timeinfo); displaydate = datestr; displaytime = timestr; } else { displaydate = ""; displaytime = ""; } lasttime=currtime; profile_stop(); } else { //do small reads per frame if we havent buffered the next second if(queued_entries.empty() || queued_entries.back()->timestamp <= currtime+1) { readLog(50); } } std::list<Paddle*> inactivePaddles; //update paddles for(auto& it: paddles) { std::string paddle_token = it.first; Paddle* paddle = it.second; if(settings.paddle_mode > PADDLE_SINGLE && !paddle->moving() && !paddle->visible()) { bool token_match = false; //are there any requests that will match this paddle? for(RequestBall* ball : balls) { if( (settings.paddle_mode == PADDLE_VHOST && ball->le->vhost == paddle_token) || (settings.paddle_mode == PADDLE_PID && ball->le->pid == paddle_token)) { token_match = true; break; } } //mark this paddle for deletion, continue if(!token_match) { inactivePaddles.push_back(paddle); continue; } } // find nearest ball to this paddle if( (retarget || !paddle->getTarget())) { RequestBall* ball = findNearest(paddle, paddle_token); if(ball != 0) { paddle->setTarget(ball); } else if(!paddle->moving()) { paddle->setTarget(0); } } paddle->logic(sdt); } retarget = false; profile_start("check ball status"); // NOTE: special handling for this iterator as items are being removed for(auto it = balls.begin(); it != balls.end();) { RequestBall* ball = *it; highscore += ball->logic(sdt); if(ball->isFinished()) { it = balls.erase(it); removeBall(ball); } else { it++; } } profile_stop(); profile_start("ipSummarizer logic"); ipSummarizer->logic(dt); profile_stop(); profile_start("updateGroups logic"); updateGroups(dt); profile_stop(); screen_blank_elapsed += dt; if(screen_blank_elapsed-screen_blank_interval > screen_blank_period) screen_blank_elapsed = 0.0f; //update font alpha font_alpha = 1.0f; if(screen_blank_elapsed>screen_blank_interval) { font_alpha = std::min(1.0f, (float) fabs(1.0f - (screen_blank_elapsed-screen_blank_interval)/(screen_blank_period*0.5))); font_alpha *= font_alpha; } }
void addNameToScore (ScoreNname newName){ printLog (sortNdropLog (readLog(), newName)); }
/* once the system is fully initialized, we wait for new messages. * We may think about replacing this with a read-loop, thus saving * us the overhead of the poll. * The timeout variable is the timeout to use for poll. During startup, * it should be set to 0 (non-blocking) and later to -1 (infinit, blocking). * This mimics the (strange) behaviour of the original syslogd. * rgerhards, 2010-04-19 */ static inline rsRetVal getMsgs(thrdInfo_t *pThrd, int timeout) { DEFiRet; int nfds; int iMaxLine; uchar *pRcv = NULL; /* receive buffer */ uchar bufRcv[4096+1]; char errStr[1024]; iMaxLine = glbl.GetMaxLine(); /* we optimize performance: if iMaxLine is below 4K (which it is in almost all * cases, we use a fixed buffer on the stack. Only if it is higher, heap memory * is used. We could use alloca() to achive a similar aspect, but there are so * many issues with alloca() that I do not want to take that route. * rgerhards, 2008-09-02 */ if((size_t) iMaxLine < sizeof(bufRcv) - 1) { pRcv = bufRcv; } else { CHKmalloc(pRcv = (uchar*) malloc(sizeof(uchar) * (iMaxLine + 1))); } while(pThrd->bShallStop != TRUE) { DBGPRINTF("imsolaris: waiting for next message (timeout %d)...\n", timeout); if(timeout == 0) { nfds = poll(&sun_Pfd, 1, timeout); /* wait without timeout */ if(pThrd->bShallStop == TRUE) { break; } if(nfds == 0) { if(timeout == 0) { DBGPRINTF("imsolaris: no more messages, getMsgs() terminates\n"); FINALIZE; } else { continue; } } if(nfds < 0) { if(errno != EINTR) { int en = errno; rs_strerror_r(en, errStr, sizeof(errStr)); DBGPRINTF("imsolaris: poll error: %d = %s.\n", errno, errStr); errmsg.LogError(en, NO_ERRCODE, "imsolaris: poll error: %s", errStr); } continue; } if(sun_Pfd.revents & POLLIN) { readLog(sun_Pfd.fd, pRcv, iMaxLine); } else if(sun_Pfd.revents & (POLLNVAL|POLLHUP|POLLERR)) { tryRecover(); } } else { /* if we have an infinite wait, we do not use poll at all * I'd consider this a waste of time. However, I do not totally * remove the code, as it may be useful if we decide at some * point to provide a capability to support multiple input streams * at once (this may be useful for a jail). In that case, the poll() * loop would be needed, and so it doesn't make much sense to change * the code to not support it. -- rgerhards, 2010-04-20 */ readLog(sun_Pfd.fd, pRcv, iMaxLine); } } finalize_it: if(pRcv != NULL && (size_t) iMaxLine >= sizeof(bufRcv) - 1) free(pRcv); RETiRet; }
int main() { readLog(); int sock, sock2, sock3; struct sockaddr_in addr, addr2, addr3; sock = socket(AF_INET, SOCK_DGRAM, 0); if(sock < 0) { perror("socket"); exit(1); } addr.sin_family = AF_INET; addr.sin_port = htons(3425); addr.sin_addr.s_addr = htonl(INADDR_ANY); if(bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { perror("bind"); exit(2); } sock2 = socket(AF_INET, SOCK_DGRAM, 0); if(sock2 < 0) { perror("socket"); exit(1); } addr2.sin_family = AF_INET; addr2.sin_port = htons(3427); addr2.sin_addr.s_addr = htonl(INADDR_ANY); if(bind(sock2, (struct sockaddr *)&addr2, sizeof(addr2)) < 0) { perror("bind"); exit(2); } sock3 = socket(AF_INET, SOCK_DGRAM, 0); if(sock3 < 0) { perror("socket"); exit(1); } addr3.sin_family = AF_INET; addr3.sin_port = htons(3429); addr3.sin_addr.s_addr = htonl(INADDR_ANY); if(bind(sock3, (struct sockaddr *)&addr3, sizeof(addr3)) < 0) { perror("bind"); exit(2); } std::thread sock1_thread(clientTreatment, sock, 3426); std::thread sock2_thread(clientTreatment, sock2, 3428); std::thread sock3_thread(clientTreatment, sock3, 3430); sock1_thread.join(); sock2_thread.join(); sock3_thread.join(); return 0; }