sumo_main.cpp File Reference


Detailed Description

Author:
Daniel Krajzewicz
Date:
Tue, 20 Nov 2001
Version:
Id
sumo_main.cpp 8648 2010-04-27 09:34:37Z dkrajzew

Definition in file sumo_main.cpp.

#include <config.h>
#include <ctime>
#include <string>
#include <iostream>
#include <microsim/MSNet.h>
#include <microsim/MSRoute.h>
#include <microsim/MSEmitControl.h>
#include <microsim/MSVehicleControl.h>
#include <netload/NLBuilder.h>
#include <netload/NLHandler.h>
#include <netload/NLTriggerBuilder.h>
#include <netload/NLEdgeControlBuilder.h>
#include <netload/NLJunctionControlBuilder.h>
#include <netload/NLDetectorBuilder.h>
#include <netload/NLGeomShapeBuilder.h>
#include <utils/options/OptionsCont.h>
#include <utils/options/OptionsIO.h>
#include <utils/common/MsgHandler.h>
#include <utils/common/SystemFrame.h>
#include <utils/common/UtilExceptions.h>
#include <utils/common/FileHelpers.h>
#include <utils/common/StringTokenizer.h>
#include <utils/common/ToString.h>
#include <utils/xml/XMLSubSys.h>
#include <microsim/MSFrame.h>
#include <microsim/output/MSDetectorControl.h>
#include <utils/iodevices/OutputDevice.h>

Go to the source code of this file.

Functions

MSNetload (OptionsCont &oc)
int main (int argc, char **argv)


Function Documentation

MSNet* load ( OptionsCont oc  ) 

loads the net, additional routes and the detectors

Definition at line 75 of file sumo_main.cpp.

References NLBuilder::build(), NLTriggerBuilder::setHandler(), and MSFrame::setMSGlobals().

Referenced by FXEX::FXSevenSegment::load(), FX::FXRealSpinDial::load(), FXEX::FXLCDLabel::load(), FXEX::FXBaseObject::load(), PCLoaderVisum::loadIfSet(), PCLoaderArcView::loadIfSet(), and main().

00075                       {
00076     MSFrame::setMSGlobals(oc);
00077     MSNet *net = new MSNet(new MSVehicleControl(), new MSEventControl(),
00078                            new MSEventControl(), new MSEventControl());
00079     NLEdgeControlBuilder eb;
00080     NLJunctionControlBuilder jb(*net, oc);
00081     NLDetectorBuilder db(*net);
00082     NLTriggerBuilder tb;
00083     NLGeomShapeBuilder sb(*net);
00084     NLHandler handler("", *net, db, tb, eb, jb, sb);
00085     tb.setHandler(&handler);
00086     NLBuilder builder(oc, *net, eb, jb, db, handler);
00087     if (!builder.build()) {
00088         delete net;
00089         throw ProcessError();
00090     }
00091     return net;
00092 }

int main ( int  argc,
char **  argv 
)

Definition at line 99 of file sumo_main.cpp.

References MSFrame::checkOptions(), SystemFrame::close(), OutputDevice::closeAll(), MSFrame::fillOptions(), MSNet::getCurrentTimeStep(), MsgHandler::getErrorInstance(), OptionsIO::getOptions(), OptionsCont::getOptions(), OptionsCont::getString(), MsgHandler::inform(), XMLSubSys::init(), initGuiShapeNames(), MsgHandler::initOutputOptions(), RandHelper::initRandGlobal(), load(), OptionsCont::processMetaOptions(), OptionsCont::setApplicationDescription(), OptionsCont::setApplicationName(), MSNet::simulate(), string2time(), time2string(), and WRITE_MESSAGE.

00099                             {
00100     OptionsCont &oc = OptionsCont::getOptions();
00101     // give some application descriptions
00102     oc.setApplicationDescription("A microscopic road traffic simulation.");
00103     oc.setApplicationName("sumo", "SUMO sumo Version " + (std::string)VERSION_STRING);
00104     int ret = 0;
00105     MSNet *net = 0;
00106     try {
00107         // initialise subsystems
00108         XMLSubSys::init(false);
00109         MSFrame::fillOptions();
00110         OptionsIO::getOptions(true, argc, argv);
00111         if (oc.processMetaOptions(argc < 2)) {
00112             SystemFrame::close();
00113             return 0;
00114         }
00115         // init simulation structures
00116         initGuiShapeNames();
00117         MsgHandler::initOutputOptions();
00118         if (!MSFrame::checkOptions()) throw ProcessError();
00119         RandHelper::initRandGlobal();
00120         // load the net
00121         net = load(oc);
00122         if (net!=0) {
00123             SUMOTime begin = string2time(oc.getString("begin"));
00124             SUMOTime end = string2time(oc.getString("end"));
00125             // report the begin when wished
00126             WRITE_MESSAGE("Simulation started with time: " + time2string(begin));
00127             // simulate
00128             ret = net->simulate(begin, end);
00129             // report the end when wished
00130             WRITE_MESSAGE("Simulation ended at time: " + time2string(net->getCurrentTimeStep()));
00131         }
00132     } catch (ProcessError &e) {
00133         if (std::string(e.what())!=std::string("Process Error") && std::string(e.what())!=std::string("")) {
00134             MsgHandler::getErrorInstance()->inform(e.what());
00135         }
00136         MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
00137         ret = 1;
00138 #ifndef _DEBUG
00139     } catch (...) {
00140         MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
00141         ret = 1;
00142 #endif
00143     }
00144     delete net;
00145     OutputDevice::closeAll();
00146     SystemFrame::close();
00147     return ret;
00148 }


Generated on Wed May 5 00:06:39 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6