55 #ifdef CHECK_MEMORY_LEAKS
57 #endif // CHECK_MEMORY_LEAKS
69 main(
int argc,
char** argv) {
80 oc.
addDescription(
"timeline-file",
"Input",
"Defines the file to read the driving cycle from.");
83 oc.
addDescription(
"emission-class",
"Input",
"Defines for which emission class the emissions shall be generated. ");
88 oc.
addDescription(
"compute-a",
"Processing",
"If set, the acceleration is computed instead of being read from the file. ");
91 oc.
addDescription(
"skip-first",
"Processing",
"If set, the first line of the read file is skipped.");
94 oc.
addDescription(
"kmh",
"Processing",
"If set, the given speed is interpreted as being given in km/h.");
97 oc.
addDescription(
"have-slope",
"Processing",
"If set, the fourth column is read and used as slope (in [°]).");
100 oc.
addDescription(
"slope",
"Processing",
"Sets a global slope (in [°]) that is used if the file does not contain slope information.");
105 oc.
addDescription(
"emission-class",
"Output",
"Defines the file to write the emission cycle results into. ");
109 oc.
addDescription(
"phemlight-path",
"Emissions",
"Determines where to load PHEMlight definitions from.");
131 if (!oc.
isSet(
"timeline-file")) {
134 if (!oc.
isSet(
"output-file")) {
138 bool skipFirst = oc.
getBool(
"skip-first");
139 bool computeA = oc.
getBool(
"compute-a");
140 bool inKMH = oc.
getBool(
"kmh");
141 bool haveSlope = oc.
getBool(
"have-slope");
143 SUMOReal sumCO, sumCO2, sumHC, sumNOx, sumPMx, sumFuel;
144 sumCO = sumCO2 = sumHC = sumNOx = sumPMx = sumFuel = 0;
149 std::ofstream o(oc.
getString(
"output-file").c_str());
152 while (lr.hasMore()) {
153 std::string line = lr.readLine();
160 throw ProcessError(
"Each line must at least include the time and the speed.");
163 SUMOReal t = TplConvert::_2SUMOReal<char>(st.
next().c_str());
164 SUMOReal v = TplConvert::_2SUMOReal<char>(st.
next().c_str());
172 throw ProcessError(
"Acceleration information is missing; try running with --compute-a.");
174 a = TplConvert::_2SUMOReal<char>(st.
next().c_str());
181 s = TplConvert::_2SUMOReal<char>(st.
next().c_str());
196 o << t <<
";" << v <<
";" << a <<
";" << s
197 <<
";" << aCO <<
";" << aCO2 <<
";" << aHC <<
";" << aPMx <<
";" << aNOx <<
";" << aFuel << std::endl;
199 throw ProcessError(
"Missing an entry in line '" + line +
"'.");
201 throw ProcessError(
"Not numeric entry in line '" + line +
"'.");
205 std::cout <<
"sums" << std::endl
206 <<
"length:" << l << std::endl
207 <<
"CO:" << sumCO << std::endl
208 <<
"CO2:" << sumCO2 << std::endl
209 <<
"HC:" << sumHC << std::endl
210 <<
"NOx:" << sumNOx << std::endl
211 <<
"PMx:" << sumPMx << std::endl
212 <<
"fuel:" << sumFuel << std::endl;
219 if (std::string(e.what()) != std::string(
"Process Error") && std::string(e.what()) != std::string(
"")) {
231 if (ret == 0 && !quiet) {
232 std::cout <<
"Success." << std::endl;
SUMOEmissionClass getVehicleEmissionTypeID(const std::string &name)
Returns the class id of the emission class given by its name.
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 getOptions(bool loadConfig, int argc=0, char **argv=0)
Parses the command line arguments and loads the configuration optionally.
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 void close()
Closes all of an applications subsystems.
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 SUMOReal computeFuel(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of consumed fuel given the vehicle type and state (in ml/s)
SUMOEmissionClass
Definition of vehicle emission classes.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static SUMOReal computeCO2(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted CO2 given the vehicle type and state (in mg/s)
static SUMOReal computeNOx(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted NOx given the vehicle type and state (in mg/s)
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
static SUMOReal computeHC(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted HC given the vehicle type and state (in mg/s)
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
static SUMOReal computeCO(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted CO given the vehicle type and state (in mg/s)
void inform(std::string msg, bool addType=true)
adds a new error to the list
A storage for options typed value containers)
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
static SUMOReal computePMx(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted PMx given the vehicle type and state (in mg/s)
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.