Esempio n. 1
0
void testApp::guisetup()
{
    float dim = 20;
	float xInit = OFX_UI_GLOBAL_WIDGET_SPACING;
	float length = 200 - xInit;
	gui = new ofxUICanvas(0, 0, length + xInit * 2, 2560);
	gui->setFont("/System/Library/Fonts/Geneva.dfont");
	ofColor cb(64, 192),
	co(192, 192),
	coh(128, 192),
	cf(240, 255),
	cfh(128, 255),
	cp(96, 192),
	cpo(255, 192);
	gui->setUIColors(cb, co, coh, cf, cfh, cp, cpo);
	   
    gui->addLabel("Sensor", OFX_UI_FONT_LARGE);
    gui->addSlider("Zoom", 0.01, 1.0, &scale, length, dim);
    gui->add2DPad("Shift", ofPoint(-1.0,1.0), ofPoint(-1.0,1.0), &shift, length, length);
    gui->addSlider("Sensor Angle", 0, 360, &sensor_angle, length, dim);

    gui->addLabel("Region", OFX_UI_FONT_LARGE);
	gui->addLabelButton("Register", &register_region, length, dim);
    gui->addLabelButton("Clear", &clear_region, length, dim);
    
    gui->addLabel("Visualization");
    gui->addLabelToggle("Data", &draw_data, length, dim);

}
Esempio n. 2
0
void testApp::setup() {
	ofSetVerticalSync(true);
    ofEnableSmoothing();
	
	int n = ofxKinect::numAvailableDevices();    
	while(sensors.size() < n) {
		sensors.push_back(ofPtr<CircleSensor>(new CircleSensor()));
		sensors.back()->setup();
	}
    ofSort(sensors, bySerial);
    
    ofxXmlSettings xml;
    xml.loadFile("settings.xml");
	
	float dim = 20;
	float xInit = OFX_UI_GLOBAL_WIDGET_SPACING; 
	float length = 320 - xInit;
	gui = new ofxUICanvas(0, 0, length + xInit * 2, 2560);
	gui->setFont("/System/Library/Fonts/Geneva.dfont");
	ofColor cb(64, 192),
	co(192, 192),
	coh(128, 192),
	cf(240, 255),
	cfh(128, 255),
	cp(96, 192),
	cpo(255, 192);
	gui->setUIColors(cb, co, coh, cf, cfh, cp, cpo);
	
    gui->addLabel("Kinects: " +  ofToString(ofxKinect::numConnectedDevices()) + " / " + ofToString(ofxKinect::numTotalDevices()), OFX_UI_FONT_SMALL);
    
	gui->addLabel("Background", OFX_UI_FONT_LARGE);
	gui->addLabelToggle("Debug", &showDebug, length, dim);
	gui->addLabelButton("Set dead zones", &setDeadZones, length, dim);
	gui->addLabelButton("Clear", &backgroundClear, length, dim);
	gui->addLabelToggle("Calibrate", &backgroundCalibrate, length, dim);
	gui->addSlider("Threshold", 0, 255, &backgroundThreshold, length, dim);
	
	gui->addLabel("Tracking", OFX_UI_FONT_LARGE);
	gui->addSlider("Blur radius", 0, 11, &blurRadius, length, dim);
	gui->addSlider("Threshold", 0, 255, &circleThreshold, length, dim);
	gui->addSlider("Min radius", 0, 12, &minRadius, length, dim);
	gui->addSlider("Max radius", 0, 12, &maxRadius, length, dim);
	gui->addSlider("Sample radius", 0, 24, &sampleRadius, length, dim);
	
	gui->addLabel("Registration", OFX_UI_FONT_LARGE);
	gui->addLabelButton("Clear", &registrationClear, length, dim);
	gui->addLabelToggle("Calibrate", &registrationCalibrate, length, dim);
	gui->addSlider("Calibration accuracy", 100, 10000, &registrationCalibrationAccuracy, length, dim);
    
    gui->addLabel("Filtering", OFX_UI_FONT_LARGE);
	gui->addSlider("Max velocity", 0, 10000, &maxVelocity, length, dim);  
	gui->addSlider("Filter rate", 0, 1, &filterRate, length, dim);
}
Esempio n. 3
0
MaterialDataFiles_t SetMaterialFiles()
{
    MaterialDataFiles_t material_files;
    std::string elementDir("../../Data/MaterialData/PhotonCrossSection");
    std::string coh("../../Data/MaterialData/XrayFormFactor/pgs5form_X100_Z100.dat");
    std::string incoh("../../Data/MaterialData/XrayFormFactor/incoh_X45_Z100.dat");
    std::string k_alpha("../../Data/MaterialData/CharacteristicXray/CharacteristicXrayK_alpha_Z100.dat");

    material_files.PhotonCrossSectionDir = elementDir;
    material_files.CoherentFilepath = coh;
    material_files.IncoherentFilepath = incoh;
    material_files.K_alphaFilepath = k_alpha;

    return material_files;
}
int main( int argc, char** argv ) {
   uint32 format = MAX_UINT32;
   uint32 port = 0;
   PropertyHelper::PropertyInit propInit;

   auto_ptr<CommandlineOptionHandler>
      coh( new CommandlineOptionHandler( argc, argv ) );
   coh->setSummary( "The TrafficServer has a listening socket that "
                   "accepts traffic information files. Each received "
                   "file will be processed and the resulting traffic "
                   "situations sent to the InfoModule.\n\n"
                   "Optionally it can be run with one or more files "
                   "specified on the commandline. Each file will be "
                   "read and processed in turn. When all files have "
                   "been processed, the TrafficServer will exit. " );

   coh->addOption( "-n", "--TrafficServerPort",
                  CommandlineOptionHandler::uint32Val,
                  1, &port, "0",
                  "Sets the preferred TrafficServerPort.");

   typedef pair< MC2String, MC2String > OptionPair;
   const OptionPair options[] = {
      make_pair( "--datexii_as",  "Vägverket DatexII Accident Service" ),
      make_pair( "--datexii_eis", "Vägverket DatexII Emergency Info Service" ),
      make_pair( "--datexii_rws", "Vägverket DatexII Road Work Service" ),
      make_pair( "--datexii_tmx", "Vägverket DatexII Traffic Message Service" )
   };

   coh->addSingleChoiceOption( "-f", 
                              options,
                              options + sizeof (options) / sizeof (*options),
                              &format, MAX_UINT32,
                              "Sets the type of data to read." );
   coh->setTailHelp("[files]");
   if ( ! coh->parse() ) {
      mc2log << error << "TrafficServer: Error on commandline (-h for help)"
             << endl;
      return 2;
   }

   if ( ! Properties::setPropertyFileName( coh->getPropertyFileName() ) ) {
      mc2log << error << "TrafficServer: No such file or directory: '"
             << coh->getPropertyFileName() << "'" << endl;
      return 3;
   }


   // Initialize the XML system
   XMLTool::XMLInit xmlInit;
   SSLCleaner sslInit;
   ISABThreadInitialize threadInit;

   TrafficParser* parser = createParser( format );

   if ( parser == NULL ) {
      mc2log << error << "Invalid parser choice!" << endl;
      return 4;
   }

   TrafficFeed* feed = NULL;

   TrafficServerComponent trafficServer( coh.get() );

   if ( port != 0 ) {
      feed = new TCPTrafficFeed( port,
                                 trafficServer.getShutdownPipe() );
   } else {

      vector<MC2String> files;
      for ( uint32 i = 0; i < coh->getTailLength(); ++i ) {
         files.push_back( coh->getTail( i ) );
      }

      feed = new FileTrafficFeed( files );
   }
   coh.release();

   ISABThreadHandle workThread =
      new TrafficThread( parser->getProvider(),
                         parser, feed,
                         trafficServer.getShutdownPipe() );

   trafficServer.setWorkThread( workThread );
   trafficServer.init();
   trafficServer.gotoWork( threadInit );

   return 0;
}
Esempio n. 5
0
/**
 * Reads and merges sfd (wfd) files together.
 */
int
sfdmerger2( int argc, char* argv[] ) {
   // COH to get BT and handle arguments
   CommandlineOptionHandler coh( argc, argv, 2 );

   coh.setSummary( "Merges any number of sfd files together "
                   "into one. But the result must form a square." );
   coh.setTailHelp( "outSFDfile inSFDfile+" );

   int wfdVersion = 0; // Only version 0 supported by all sfd readers 20081121
   bool testRun = false;
   char* name;

   coh.addOption( "-w", "--wfd-version", CommandlineOptionHandler::integerVal,
                  1, &wfdVersion, "0", 
                  "Set the sfd version to save, default 0. Only version 0 "
                  "supported by any reader but this.");
   coh.addOption( "-t", "--test", CommandlineOptionHandler::presentVal,
                  1, &testRun, "F", 
                  "If to only test to load the sfd files not make any output, "
                  "default false" );
   coh.addOption( "-n", "--name",
                  CommandlineOptionHandler::stringVal,
                  1, &name, "\0",
                  "The name of the merged sfd, like 22_6_3 for a 3x3 tile "
                  "merge of x 66-68 and y 18-20.");

   if ( !coh.parse() ) {
      coh.printHelp( cout );
      return 1;
   }

   MC2String outFile( coh.getTail( 0 ) );
   SFDFile outSfd( name, false/*debug, overwritten by load*/ );
   uint32 totalBuffSize = 0;

   int res = 0;

   // For all the input files
   for ( int i = 1/*0 is out file name*/; 
         i < coh.getTailLength() && res == 0 ; ++i ) {
      // Read and merge
      MC2String inFile( coh.getTail( i ) );
      mc2dbg << "Attempting to read " << inFile << endl;
      vector<byte> buff;
      int fres = File::readFile( inFile.c_str(), buff );
      if ( fres < 0 ) {
         res = 2;
      } else {
         mc2dbg << "Attempting to load " << inFile << endl;
         auto_ptr<BitBuffer> bitBuff( 
            new BitBuffer( &buff.front(), buff.size() ) );
         SFDFile sfd( inFile.c_str(), false/*debug, overwritten by load*/ );
         sfd.load( *bitBuff );

         // Size calculation! (Add all input file sizes and use)
         totalBuffSize += buff.size();

         if ( false && !testRun ) {
            auto_ptr<BitBuffer> outBuff( new BitBuffer( buff.size() ) );
            sfd.save( *outBuff, wfdVersion );

            MC2String saveFile( inFile + ".test" );
            int fres = File::writeFile( saveFile.c_str(), 
                                        outBuff->getBufferAddress(), 
                                        outBuff->getCurrentOffset() );
            if ( fres < 0 ) {
               mc2dbg << "Failed to save saved copy of sfd " << fres << endl;
               res = 2;
            } else {
               mc2dbg << "Saved copy of sfd " << saveFile << " size " << fres 
                      << " bytes" << endl;
            }
         } // End if to save each input as .test 

         if ( i == 1 ) {
            // Set first as out
            outSfd.assign( sfd );
            // Set the name
            outSfd.setName( name );
         } else {
            if ( !outSfd.merge( sfd ) ) {
               mc2dbg << "Failed to merge " << inFile << " into all buffers" 
                      << endl;
               res = false;
            }
         }
      }

   } // End for all input files

   if ( res == 0 && !testRun ) {
      auto_ptr<BitBuffer> outBuff( 
         new BitBuffer( totalBuffSize * (wfdVersion > 0 ? 2 : 1 ) ) );
      outSfd.save( *outBuff, wfdVersion );
      int fres = File::writeFile( outFile.c_str(), 
                                  outBuff->getBufferAddress(), 
                                  outBuff->getCurrentOffset() );
      if ( fres < 0 ) {
         mc2dbg << "Failed to save merged sfd " << fres << endl;
         res = 2;
      } else {
         mc2dbg << "Saved merged sfd " << outFile << " size " << fres 
                << " bytes" << endl;
      }
   }

   coh.deleteTheStrings();

   return res;
}
Esempio n. 6
0
/**
 * Reads and merges sfd (wfd) files together.
 */
int
sfdmerger( int argc, char* argv[] ) {
   if ( argc < 3 ) {
      mc2log << error << "Usage: sfdmerger outSFDfile inSFDfile+" << endl;
      return 1;
   }
   // COH to get BT
   CommandlineOptionHandler coh( argc, argv );

   SFDSavableHeader outHeader( argv[ 1 ], false/*debug*/ );
   SFDMultiBufferWriter out( 0/*startOffset*/ );
   int res = 0;

   // TODO: First go thou all files and read headers and merge them
   // TODO: Check for buffers with same crc and reuse the old if so

   for ( int i = 2/*0 is program name, 1 is out file name*/; 
         i < argc && res == 0 ; ++i ) {
      // Read and add to out
      mc2dbg << "Attempting to read " << argv[ i ] << endl;
      vector<byte> buff;
      int fres = File::readFile( argv[ i ], buff );
      if ( fres < 0 ) {
         res = 2;
      } else {
         mc2dbg << "Attempting to load " << argv[ i ] << endl;
         BitBuffer* bitBuff = new BitBuffer( &buff.front(), buff.size() );
         mc2dbg << "file size " << bitBuff->getBufferSize() << endl;
         // Header
         SFDLoadableHeader header( argv[ i ], false/*debug*/ );
         mc2dbg << "pos before header " << bitBuff->getCurrentOffset() << endl;
         header.load( *bitBuff );
         mc2dbg << "pos after header " << bitBuff->getCurrentOffset() << endl;

         mc2dbg << "header.m_stringsAreNullTerminated " << header.stringsAreNullTerminated() << endl;
         mc2dbg << "header.m_strIdxEntrySizeBits " << header.getStrIdxEntrySizeBits() << endl;
         mc2dbg << "header.m_strIdxStartOffset " <<  header.getStrIdxStartOffset() << endl;
         mc2dbg << "header.m_nbrStrings " << header.getNbrStrings() << endl;
         mc2dbg << "header.m_strDataStartOffset " << header.getStrDataStartOffset() << endl;
         mc2dbg << "header.m_bufferIdxStartOffset " << header.getBufferIdxStartOffset() << endl;
         mc2dbg << "header.m_bufferDataStartOffset " << header.getBufferDataStartOffset() << endl;
         mc2dbg << "header.m_maxStringSize " << header.maxStringSize() << endl;
         // str_offset_buf
         mc2dbg << "pos before str_offset_buf " << bitBuff->getCurrentOffset() << endl;
         for ( uint32 i = 0 ; i < header.getNbrStrings() + 1 ; ++i ) {
            bitBuff->readNextBALong();
         }
         // strBuf
         mc2dbg << "pos before strBuf " << bitBuff->getCurrentOffset() << endl;
         for ( uint32 i = 0 ; i < header.getNbrStrings() ; ++i ) {
            bitBuff->readNextString();
         }
         // buf_offset_buf
         mc2dbg << "pos before buf_offset_buf " << bitBuff->getCurrentOffset() << endl;
         uint32 buffOffset = 0;
         for ( uint32 i = 0 ; i < header.getNbrStrings() + 1 ; ++i ) {
            buffOffset = bitBuff->readNextBALong();
            mc2dbg << "buffOffset " << buffOffset << endl;
         }
         // mapBuf
         mc2dbg << "pos before mapBuff " << bitBuff->getCurrentOffset() << endl;
         for ( uint32 i = 0 ; i < header.getNbrStrings() ; ++i ) {
            // TileMap
         }
         // Skipp to buffOffset
         bitBuff->readPastBytes( buffOffset -
                                 bitBuff->getCurrentOffset() );
         mc2dbg << "pos after mapBuff " << bitBuff->getCurrentOffset() 
                << " buffOffset " << buffOffset << endl;
         // offsetBuf
         //  offset for each tile in the tile collection
         //  Get min, max from TileCollectionNotice...
         const vector<TileCollectionNotice>& tileCollection =
            header.getTileCollection();
         uint32 nbrOffsets = 0;
         int aLatIdx = MAX_INT32;
         int aLonIdx = MAX_INT32;
         for ( uint32 i = 0 ; i < tileCollection.size() ; ++i ) {
            const vector<TilesForAllDetailsNotice>& tileDetail =
               tileCollection[ i ].getTilesForAllDetails();
            for ( uint32 j = 0 ; j < tileDetail.size() ; ++j ) {
               const vector<TilesNotice>& tileNotices = 
                  tileDetail[ j ].getTilesNotices();
               for ( uint32 k = 0 ; k < tileNotices.size() ; ++k ) {
                  int startLatIdx = tileNotices[ k ].getStartLatIdx();
                  if ( aLatIdx == MAX_INT32 ) {
                     aLatIdx = startLatIdx;
                  }
                  int endLatIdx = tileNotices[ k ].getEndLatIdx();
                  int startLonIdx = tileNotices[ k ].getStartLonIdx();
                  if ( aLonIdx == MAX_INT32 ) {
                     aLonIdx = startLonIdx;
                  }
                  int endLonIdx = tileNotices[ k ].getEndLonIdx();
                  int nbrLayers = tileNotices[ k ].getNbrLayers();
                  nbrOffsets += 
                     (endLatIdx - startLatIdx + 1) * (endLonIdx-startLonIdx + 1);
                  mc2dbg << "startLatIdx " << startLatIdx << endl;
                  mc2dbg << "endLatIdx " << endLatIdx << endl;
                  mc2dbg << "startLonIdx " << startLonIdx << endl;
                  mc2dbg << "endLonIdx " << endLonIdx << endl;
                  mc2dbg << "nbrLayers " << nbrLayers << endl;
                  //mc2dbg << "nbrOffsets += " << ((endLatIdx - startLatIdx + 1) * (endLonIdx-startLonIdx + 1))  << endl;
               } // End for all TilesNotice

            } // End for all TilesForAllDetailsNotice

         } // End for all TileCollectionNotice

         mc2dbg << "Nbr offsets = " << (nbrOffsets+1) << endl;
         
         bitBuff->readPastBytes( (nbrOffsets+1) * 4 );

         uint32 nbrMultiBuffers = 0;
         for ( uint32 i = 0 ; i < tileCollection.size() ; ++i ) {
            const vector<TilesForAllDetailsNotice>& tileDetail =
               tileCollection[ i ].getTilesForAllDetails();
            for ( uint32 j = 0 ; j < tileDetail.size() ; ++j ) {
               const vector<TilesNotice>& tileNotices = 
                  tileDetail[ j ].getTilesNotices();
               for ( uint32 det = 0 ; det < tileNotices.size() ; ++det ) {

                  int startLatIdx = tileNotices[ det ].getStartLatIdx();
                  int endLatIdx = tileNotices[ det ].getEndLatIdx();
                  int startLonIdx = tileNotices[ det ].getStartLonIdx();
                  int endLonIdx = tileNotices[ det ].getEndLonIdx();
                  int nbrLayers = tileNotices[ det ].getNbrLayers();
                  mc2dbg << "startLatIdx " << startLatIdx << endl;
                  mc2dbg << "endLatIdx " << endLatIdx << endl;
                  mc2dbg << "startLonIdx " << startLonIdx << endl;
                  mc2dbg << "endLonIdx " << endLonIdx << endl;
                  mc2dbg << "nbrLayers " << nbrLayers << endl;

                        
                  for ( int32 lat = startLatIdx ; lat <= endLatIdx ; ++lat ) {
                     for ( int32 lon = startLonIdx ; lon <= endLonIdx ; ++lon ) {
                              
                        //for ( int imp = tileNotices[ k ].getFirstImportanceNbr( 0/*lay*/ ) ; imp <= tileNotices[ k ].getLastImportanceNbr( 0/*lay*/ ) ; ++imp ) {

                        mc2dbg << "multiBuff  " << nbrMultiBuffers++ << " lat " << lat << "/" << endLatIdx << " lon " << lon << "/" << endLonIdx << " det " << det << "/" << tileNotices.size() /*<< " imp " << imp << "/" << tileNotices[ k ].getLastImportanceNbr( 0*lay* )*/ /*<< " lay " << lay << "/" << nbrLayers*/ << " tileNotice " << det << "/" << tileNotices.size() << " tileDetails " << j << "/" << tileDetail.size() << " " << " tileCollection " << i << endl;
                        mc2dbg << "pos before multiBuff " << bitBuff->getCurrentOffset() << endl;
                        // multiBuf
                        const TileMapParams param( 
                           9/*serverPrefix*/, 1/*gzip*/, 0/*layer*/, 
                           TileMapTypes::tileMapData, 0/*imp*//*importanceNbr*/, LangTypes::english,
                           lat/*tileIndexLat*/, lon, det/*detailLevel*/ ); // FIXME: Less hardcoded values
                        auto_ptr<SFDMultiBufferReader> reader( new SFDMultiBufferReader( bitBuff, param, &header ) );
                        mc2dbg << "reader.hasNext() " << reader->hasNext() << endl;
                        while ( reader->hasNext() ) {
                           LangTypes::language_t lang = LangTypes::english; // FIXME:
                           // Data
                           SFDMultiBufferReader::bufPair_t data = reader->readNext( lang );
                           // TODO: Add more to outHeader
                           outHeader.updateMetaData( data.first.getAsString() );
                           out.addMap( data.first, data.second );
                        }
                        mc2dbg << "pos after multiBuff " << bitBuff->getCurrentOffset() 
                               << " buffer is " << bitBuff->getBufferSize() << endl;

                        //mc2dbg << "Done with importance " << imp << "/" << tileNotices[ k ].getLastImportanceNbr( 0/*lay*/ ) << endl;
                        //} // End for all importances

                     } // End for all lon
                  } // End for all lat
                              
                  mc2dbg << "TileNotice " << det << " done" << endl;
               } // End for all TilesNotice
               
               mc2dbg << "TileDetailNotice " << j << " done" << endl;
            } // End for all TilesForAllDetailsNotice
         } // End for all TileCollectionNotice

         mc2dbg << "pos after all multiBuff " << bitBuff->getCurrentOffset() 
                << " buffer is " << bitBuff->getBufferSize() << endl;
      } // End else could read input file
   } // For all input sfd-files

   if ( res == 0 ) {
      mc2dbg << "Read all sfd files now saving meta sfd" << endl;
      // SharedBuffer& buf;
      // outHeader
      out.writeAdded();
      const SharedBuffer* outData = out.getBuffer();
      mc2dbg << "Writing " << outData->getBufferSize() << " bytes "
             << "to " << outHeader.getName().c_str() << endl;
      int fres = File::writeFile( 
         outHeader.getName().c_str(), 
         outData->getBufferAddress(), outData->getBufferSize() );
      if ( fres <= 0 ) {
         mc2dbg << "Write failed res " << fres << endl;
         res = 2;
      }
   }

   return res;
}
int main(int argc, char *argv[])
try {
   ISABThreadInitialize init;
   PropertyHelper::PropertyInit propInit;


   bool   profileCalcRoute = false;

   uint32 mapToLoad = MAX_UINT32;


   auto_ptr<CommandlineOptionHandler> 
      coh( new CommandlineOptionHandler( argc, argv ) );
       
   coh->addOption("-c", "--profile-calcroute",
                  CommandlineOptionHandler::presentVal,
                  1, &profileCalcRoute, "F",
                  "If present the processor will be run in the main "
                  "thread and read packets of the format 4 bytes len, "
                  "len bytes packet from stdin");

   char defVal[20];
   sprintf(defVal, "%u", MAX_UINT32);
   coh->addOption("-m", "--loadmap",
                  CommandlineOptionHandler::uint32Val,
                  1, &mapToLoad, defVal,
                  "Load a map and delete it again and exit");
      
   RouteModule* routeModule = new RouteModule( coh.release() );
   ISABThreadHandle routeHandle = routeModule;

   routeModule->parseCommandLine();

   if ( profileCalcRoute ) {
      profile();
   }
   
   if ( mapToLoad != MAX_UINT32 ) {
      char packInfo[Processor::c_maxPackInfo];
      MapSafeVector loadedMaps;      

      RouteProcessor processor( &loadedMaps );
      LoadMapRequestPacket* lmap = new LoadMapRequestPacket(mapToLoad);     
      DeleteMapRequestPacket* dmap = new DeleteMapRequestPacket(mapToLoad);
      auto_ptr<ReplyPacket> lmapRepl( (ReplyPacket*)
                                      processor.handleRequest(lmap, packInfo));
      if ( lmapRepl->getSubType() != Packet::PACKETTYPE_LOADMAPREPLY ||
           lmapRepl->getStatus() != StringTable::OK ) {
         return 1;
      }
      mc2dbg << "Memory: " << SysUtility::getMemoryInfo() << endl;
      // delete 
      processor.handleRequest(dmap, packInfo);
      Properties::Destroy();

      exit(0);
   }

   routeModule->init();
   routeModule->start();
   routeModule->gotoWork( init );

   return 0;

} catch ( const ComponentException& ex ) {
   mc2log << fatal << "Could not initialize RouteModule. " 
          << ex.what() << endl;
   return 1;
}
Esempio n. 8
0
int main( int argc, char** argv ) {
    CommandlineOptionHandler coh( argc, argv );
    typedef pair< MC2String, MC2String > OptionPair;

    uint32 format = MAX_UINT32;

    const OptionPair options[] = {
        make_pair( "--datexii_as", "Vägverket DatexII Accident Service" ),
        make_pair( "--datexii_eis", "Vägverket DatexII Emergency Info Service" ),
        make_pair( "--datexii_rws", "Vägverket DatexII Road Work Service" ),
        make_pair( "--datexii_tmx", "Vägverket DatexII Traffic Message Service" ),
    };

    coh.addSingleChoiceOption( "-f",
                               options,
                               options + sizeof (options) / sizeof (*options),
                               &format, MAX_UINT32,
                               "Sets the type of data to read." );

    coh.setTailHelp("[files]");

    if ( ! coh.parse() ) {
        mc2log << error << "Failed to parse command line!" << endl;
        return 1;
    }

    if ( ! Properties::setPropertyFileName( coh.getPropertyFileName() ) ) {
        mc2log << error << "TrafficServer: No such file or directory: '"
               << coh.getPropertyFileName() << "'" << endl;
        return 2;
    }

    // Initialize the XML system
    XMLTool::XMLInit xmlInit;

    vector<MC2String> files;
    for ( uint32 i = 0; i < coh.getTailLength(); ++i ) {
        files.push_back( coh.getTail( i ) );
    }


    FileTrafficFeed feed( files );
    // we need files!
    if ( feed.eos() ) {
        mc2log << error << "No feed!" << endl;
        return 3;
    }

    auto_ptr<TrafficParser> parser( createParser( format ) );

    if ( ! parser.get() ) {
        mc2log << error << "Failed to create parser" << endl;
        return 4;
    }

    while ( ! feed.eos() ) {

        // get data and parse situations

        TrafficFeed::Data data;
        if ( ! feed.getData( data ) ) {
            mc2log << error << "Failed to get feed." << endl;
            break;
        }

        TrafficParser::Situations situations;
        if ( ! parser->parse( data, situations ) ) {
            mc2log << error << "Failed to parse feed." << endl;
            return 5;
        }

        if ( situations.empty() ) {
            mc2log << error << "No situations parsed from feed." << endl;
            return 6;
        }

        mc2log << "Situations parsed: " << situations.size() << endl;

        STLUtility::deleteValues( situations );
    }

    return 0;
}