 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
59 main(
int argc,
char** argv) {
71 oc.
addDescription(
"timeline-file",
"Input",
"Defines the file to read the driving cycle from.");
74 oc.
addSynonyme(
"timeline.skip",
"timeline-file.skip");
75 oc.
addDescription(
"timeline-file.skip",
"Input",
"Skips the firs NUM lines.");
78 oc.
addSynonyme(
"timeline.separator",
"timeline-file.separator");
79 oc.
addDescription(
"timeline-file.separator",
"Input",
"Defines the entry separator.");
84 oc.
addDescription(
"netstate-file",
"Input",
"Defines the netstate, route and trajectory files to read the driving cycles from.");
87 oc.
addDescription(
"emission-class",
"Input",
"Defines for which emission class the emissions shall be generated. ");
92 oc.
addDescription(
"compute-a",
"Processing",
"If set, the acceleration is computed instead of being read from the file. ");
95 oc.
addDescription(
"compute-a.forward",
"Processing",
"If set, the acceleration for time t is computed from v(t+1) - v(t) instead of v(t) - v(t-1). ");
98 oc.
addDescription(
"compute-a.zero-correction",
"Processing",
"If set, the acceleration for time t is set to 0 if the speed is 0. ");
101 oc.
addDescription(
"skip-first",
"Processing",
"If set, the first line of the read file is skipped.");
104 oc.
addDescription(
"kmh",
"Processing",
"If set, the given speed is interpreted as being given in km/h.");
107 oc.
addDescription(
"have-slope",
"Processing",
"If set, the fourth column is read and used as slope (in deg).");
110 oc.
addDescription(
"slope",
"Processing",
"Sets a global slope (in deg) that is used if the file does not contain slope information.");
115 oc.
addDescription(
"output",
"Output",
"Defines the file to write the emission cycle results into. ");
118 oc.
addDescription(
"emission-output",
"Output",
"Save the emission values of each vehicle in XML");
122 oc.
addDescription(
"sum-output",
"Output",
"Save the aggregated and normed emission values of each vehicle in CSV");
126 oc.
addDescription(
"phemlight-path",
"Emissions",
"Determines where to load PHEMlight definitions from.");
146 if (!oc.
isSet(
"timeline-file") && !oc.
isSet(
"netstate-file")) {
147 throw ProcessError(
"Either a timeline or a netstate / amitran file must be given.");
149 if (!oc.
isSet(
"output-file") && (oc.
isSet(
"timeline-file") || !oc.
isSet(
"emission-output"))) {
152 std::ostream* out =
nullptr;
153 if (oc.
isSet(
"output-file")) {
154 out =
new std::ofstream(oc.
getString(
"output-file").c_str());
158 if (oc.
isSet(
"emission-output")) {
160 }
else if (out ==
nullptr) {
163 std::ostream* sumOut =
nullptr;
164 if (oc.
isSet(
"sum-output")) {
165 sumOut =
new std::ofstream(oc.
getString(
"sum-output").c_str());
166 (*sumOut) <<
"Vehicle,Cycle,Time,Speed,Gradient,Acceleration,FC,FCel,CO2,NOx,CO,HC,PM" << std::endl;
170 const bool computeA = oc.
getBool(
"compute-a") || oc.
getBool(
"compute-a.forward");
173 if (oc.
isSet(
"timeline-file")) {
174 int skip = oc.
getBool(
"skip-first") ? 1 : oc.
getInt(
"timeline-file.skip");
175 const bool inKMH = oc.
getBool(
"kmh");
176 const bool haveSlope = oc.
getBool(
"have-slope");
183 while (lr.hasMore()) {
205 if (handler.writeEmissions(*out,
"", defaultClass, t, v, a, s)) {
212 throw ProcessError(
"Missing an entry in line '" + line +
"'.");
214 throw ProcessError(
"Not numeric entry in line '" + line +
"'.");
219 std::cout <<
"sums" << std::endl
220 <<
"length:" << l << std::endl;
222 if (sumOut !=
nullptr) {
223 (*sumOut) << oc.
getString(
"emission-class") <<
"," << lr.getFileName() <<
"," << time <<
","
224 << (l / time * 3.6) <<
"," << (totalS / time) <<
"," << (totalA / time) <<
",";
225 handler.writeNormedSums(*sumOut,
"", l);
228 if (oc.
isSet(
"netstate-file")) {
232 handler.writeSums(std::cout,
"");
240 if (std::string(e.what()) != std::string(
"Process Error") && std::string(e.what()) != std::string(
"")) {
252 if (ret == 0 && !quiet) {
253 std::cout <<
"Success." << std::endl;
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything's ok.
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
static void close()
Closes all of an applications subsystems.
Static storage of an output device and its base (abstract) implementation.
bool readLine(LineHandler &lh)
Reads a single (the next) line from the file and reports it to the given LineHandler.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
static const int INVALID_VALUE
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
std::vector< std::string > StringVector
Definition of a vector of strings.
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
static void init()
Initialises the xml-subsystem.
A storage for options typed value containers)
Retrieves a file linewise and reports the lines to a handler.
An XML-Handler for amitran and netstate trajectories.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
int main(int argc, char **argv)
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.