57 #ifdef CHECK_MEMORY_LEAKS
59 #endif // CHECK_MEMORY_LEAKS
71 main(
int argc,
char** argv) {
83 oc.
addDescription(
"timeline-file",
"Input",
"Defines the file to read the driving cycle from.");
88 oc.
addDescription(
"netstate-file",
"Input",
"Defines the netstate, route and trajectory files to read the driving cycles from.");
91 oc.
addDescription(
"emission-class",
"Input",
"Defines for which emission class the emissions shall be generated. ");
96 oc.
addDescription(
"compute-a",
"Processing",
"If set, the acceleration is computed instead of being read from the file. ");
99 oc.
addDescription(
"skip-first",
"Processing",
"If set, the first line of the read file is skipped.");
102 oc.
addDescription(
"kmh",
"Processing",
"If set, the given speed is interpreted as being given in km/h.");
105 oc.
addDescription(
"have-slope",
"Processing",
"If set, the fourth column is read and used as slope (in deg).");
108 oc.
addDescription(
"slope",
"Processing",
"Sets a global slope (in deg) that is used if the file does not contain slope information.");
113 oc.
addDescription(
"output",
"Output",
"Defines the file to write the emission cycle results into. ");
116 oc.
addDescription(
"emission-output",
"Output",
"Save the emission values of each vehicle in XML");
120 oc.
addDescription(
"phemlight-path",
"Emissions",
"Determines where to load PHEMlight definitions from.");
140 if (!oc.
isSet(
"timeline-file") && !oc.
isSet(
"netstate-file")) {
141 throw ProcessError(
"Either a timeline or a netstate / amitran file must be given.");
143 if (!oc.
isSet(
"output-file") && (oc.
isSet(
"timeline-file") || !oc.
isSet(
"emission-output"))) {
146 std::ostream* out = 0;
147 if (oc.
isSet(
"output-file")) {
148 out =
new std::ofstream(oc.
getString(
"output-file").c_str());
152 if (oc.
isSet(
"emission-output")) {
154 }
else if (out == 0) {
161 if (oc.
isSet(
"timeline-file")) {
162 bool skipFirst = oc.
getBool(
"skip-first");
163 const bool computeA = oc.
getBool(
"compute-a");
164 const bool inKMH = oc.
getBool(
"kmh");
165 const bool haveSlope = oc.
getBool(
"have-slope");
169 while (lr.hasMore()) {
177 throw ProcessError(
"Each line must at least include the time and the speed.");
180 const SUMOReal t = TplConvert::_2SUMOReal<char>(st.
next().c_str());
181 SUMOReal v = TplConvert::_2SUMOReal<char>(st.
next().c_str());
188 handler.writeEmissions(*out,
"", defaultClass, t, v, a, s);
190 throw ProcessError(
"Missing an entry in line '" + line +
"'.");
192 throw ProcessError(
"Not numeric entry in line '" + line +
"'.");
196 std::cout <<
"sums" << std::endl
197 <<
"length:" << l << std::endl;
200 if (oc.
isSet(
"netstate-file")) {
204 handler.writeSums(std::cout,
"");
211 if (std::string(e.what()) != std::string(
"Process Error") && std::string(e.what()) != std::string(
"")) {
223 if (ret == 0 && !quiet) {
224 std::cout <<
"Success." << std::endl;
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
static void init()
Initialises the xml-subsystem.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
static void getOptions(bool loadConfig, int argc=0, char **argv=0)
Parses the command line arguments and loads the configuration optionally.
bool readLine(LineHandler &lh)
Reads a single (the next) line from the file and reports it to the given LineHandler.
Retrieves a file linewise and reports the lines to a handler.
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
int main(int argc, char **argv)
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
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 close()
Closes all of an applications subsystems.
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
static OptionsCont & getOptions()
Retrieves the options.
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
static const int INVALID_VALUE
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
const std::string getBuildName(const std::string &version)
attach some build flags to the version string
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
An XML-Handler for amitran and netstate trajectories.
void inform(std::string msg, bool addType=true)
adds a new error to the list
A storage for options typed value containers)
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.
Static storage of an output device and its base (abstract) implementation.
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.