SUMO - Simulation of Urban MObility
sumo_main.cpp
Go to the documentation of this file.
1
/****************************************************************************/
11
// Main for SUMO
12
/****************************************************************************/
13
// SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
14
// Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
15
/****************************************************************************/
16
//
17
// This file is part of SUMO.
18
// SUMO is free software: you can redistribute it and/or modify
19
// it under the terms of the GNU General Public License as published by
20
// the Free Software Foundation, either version 3 of the License, or
21
// (at your option) any later version.
22
//
23
/****************************************************************************/
24
25
26
// ===========================================================================
27
// included modules
28
// ===========================================================================
29
#ifdef _MSC_VER
30
#include <
windows_config.h
>
31
#else
32
#include <
config.h
>
33
#endif
34
35
#ifdef HAVE_VERSION_H
36
#include <
version.h
>
37
#endif
38
39
#include <ctime>
40
#include <string>
41
#include <iostream>
42
#include <
netload/NLBuilder.h
>
43
#include <
utils/options/OptionsCont.h
>
44
#include <
utils/options/OptionsIO.h
>
45
#include <
utils/common/MsgHandler.h
>
46
#include <
utils/common/SystemFrame.h
>
47
#include <
utils/common/UtilExceptions.h
>
48
#include <
utils/common/ToString.h
>
49
#include <
utils/xml/XMLSubSys.h
>
50
51
#ifndef NO_TRACI
52
#include <
traci-server/TraCIServer.h
>
53
#endif
54
55
56
// ===========================================================================
57
// functions
58
// ===========================================================================
59
/* -------------------------------------------------------------------------
60
* main
61
* ----------------------------------------------------------------------- */
62
int
63
main
(
int
argc,
char
** argv) {
64
OptionsCont
& oc =
OptionsCont::getOptions
();
65
// give some application descriptions
66
oc.
setApplicationDescription
(
"A microscopic road traffic simulation."
);
67
oc.
setApplicationName
(
"sumo"
,
"SUMO Version "
VERSION_STRING
);
68
int
ret = 0;
69
try
{
70
// initialise subsystems
71
XMLSubSys::init
();
72
OptionsIO::setArgs
(argc, argv);
73
// load the net
74
ret =
NLBuilder::loadAndRun
();
75
}
catch
(
const
ProcessError
& e) {
76
if
(std::string(e.what()) != std::string(
"Process Error"
) && std::string(e.what()) != std::string(
""
)) {
77
WRITE_ERROR
(e.what());
78
}
79
MsgHandler::getErrorInstance
()->
inform
(
"Quitting (on error)."
,
false
);
80
ret = 1;
81
#ifndef _DEBUG
82
}
catch
(
const
std::exception& e) {
83
if
(std::string(e.what()) != std::string(
""
)) {
84
WRITE_ERROR
(e.what());
85
}
86
MsgHandler::getErrorInstance
()->
inform
(
"Quitting (on error)."
,
false
);
87
ret = 1;
88
}
catch
(...) {
89
MsgHandler::getErrorInstance
()->
inform
(
"Quitting (on unknown error)."
,
false
);
90
ret = 1;
91
#endif
92
}
93
#ifndef NO_TRACI
94
TraCIServer::close
();
95
#endif
96
SystemFrame::close
();
97
return
ret;
98
}
99
100
101
/****************************************************************************/
XMLSubSys::init
static void init()
Initialises the xml-subsystem.
Definition:
XMLSubSys.cpp:54
MsgHandler::getErrorInstance
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition:
MsgHandler.cpp:76
UtilExceptions.h
windows_config.h
OptionsCont::setApplicationDescription
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
Definition:
OptionsCont.cpp:498
config.h
SystemFrame::close
static void close()
Closes all of an applications subsystems.
Definition:
SystemFrame.cpp:128
main
int main(int argc, char **argv)
Definition:
sumo_main.cpp:63
MsgHandler.h
OptionsIO::setArgs
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
Definition:
OptionsIO.cpp:62
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition:
OptionsCont.cpp:65
TraCIServer::close
static void close()
request termination of connection
Definition:
TraCIServer.cpp:195
NLBuilder::loadAndRun
static int loadAndRun()
Definition:
NLBuilder.cpp:223
ToString.h
VERSION_STRING
#define VERSION_STRING
Definition:
config.h:210
NLBuilder.h
version.h
XMLSubSys.h
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition:
MsgHandler.h:206
OptionsIO.h
MsgHandler::inform
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition:
MsgHandler.cpp:85
OptionsCont
A storage for options typed value containers)
Definition:
OptionsCont.h:99
OptionsCont.h
TraCIServer.h
SystemFrame.h
ProcessError
Definition:
UtilExceptions.h:49
OptionsCont::setApplicationName
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.
Definition:
OptionsCont.cpp:490
src
sumo_main.cpp
Generated on Sun Dec 17 2017 21:15:31 for SUMO - Simulation of Urban MObility by
1.8.13