51 std::map<SUMOEmissionClass, PHEMCEP*>::iterator iter =
_ceps.begin();
52 while (iter !=
_ceps.end()) {
70 std::vector< std::vector<double> > matrixSpeedInertiaTable;
71 std::vector< std::vector<double> > normedDragTable;
72 std::vector< std::vector<double> > matrixFC;
73 std::vector< std::vector<double> > matrixPollutants;
74 std::vector<std::string> headerFC;
75 std::vector<std::string> headerPollutants;
76 std::vector<double> idlingValues;
77 std::vector<double> idlingValuesFC;
80 double vehicleLoading;
81 double vehicleMassRot;
82 double crosssectionalArea;
91 double engineIdlingSpeed;
92 double engineRatedSpeed;
93 double effectiveWheelDiameter;
94 std::string vehicleMassType;
95 std::string vehicleFuelType;
103 std::vector<std::string> phemPath;
104 phemPath.push_back(oc.
getString(
"phemlight-path") +
"/");
105 if (getenv(
"PHEMLIGHT_PATH") != 0) {
106 phemPath.push_back(std::string(getenv(
"PHEMLIGHT_PATH")) +
"/");
108 if (getenv(
"SUMO_HOME") != 0) {
109 phemPath.push_back(std::string(getenv(
"SUMO_HOME")) +
"/data/emissions/PHEMlight/");
126 effectiveWheelDiameter,
133 matrixSpeedInertiaTable,
138 if (!
ReadEmissionData(
true, phemPath, emissionClassIdentifier, headerFC, matrixFC, idlingValuesFC)) {
142 if (!
ReadEmissionData(
false, phemPath, emissionClassIdentifier, headerPollutants, matrixPollutants, idlingValues)) {
146 _ceps[emissionClass] =
new PHEMCEP(vehicleMassType ==
"HV",
147 emissionClass, emissionClassIdentifier,
166 effectiveWheelDiameter,
167 idlingValuesFC.front(),
172 matrixSpeedInertiaTable,
183 if (
_ceps.find(emissionClass) ==
_ceps.end()) {
187 return _ceps[emissionClass];
194 double& vehicleLoading,
195 double& vehicleMassRot,
205 double& engineIdlingSpeed,
206 double& engineRatedSpeed,
207 double& effectiveWheelDiameter,
208 std::string& vehicleMassType,
209 std::string& vehicleFuelType,
214 std::vector< std::vector<double> >& matrixSpeedInertiaTable,
215 std::vector< std::vector<double> >& normedDragTable)
218 std::ifstream fileVehicle;
219 for (std::vector<std::string>::const_iterator i = path.begin(); i != path.end(); i++) {
220 fileVehicle.open(((*i) + emissionClass +
".PHEMLight.veh").c_str());
221 if (fileVehicle.good()) {
225 if (!fileVehicle.good()) {
231 std::string commentPrefix =
"c";
235 std::getline(fileVehicle, line);
237 while (std::getline(fileVehicle, line) && dataCount <= 49) {
239 if (line.size() > 0 && line.substr(line.size() - 1) ==
"\r") {
240 line = line.substr(0, line.size() - 1);
243 std::stringstream lineStream(line);
245 if (line.substr(0, 1) == commentPrefix) {
251 std::getline(lineStream, cell,
',');
254 if (dataCount == 1) {
255 std::istringstream(cell) >> vehicleMass;
259 if (dataCount == 2) {
260 std::istringstream(cell) >> vehicleLoading;
264 if (dataCount == 3) {
265 std::istringstream(cell) >> cWValue;
269 if (dataCount == 4) {
270 std::istringstream(cell) >> crossArea;
274 if (dataCount == 7) {
275 std::istringstream(cell) >> vehicleMassRot;
279 if (dataCount == 10) {
280 std::istringstream(cell) >> ratedPower;
284 if (dataCount == 11) {
285 std::istringstream(cell) >> engineRatedSpeed;
289 if (dataCount == 12) {
290 std::istringstream(cell) >> engineIdlingSpeed;
294 if (dataCount == 14) {
295 std::istringstream(cell) >> f0;
299 if (dataCount == 15) {
300 std::istringstream(cell) >> f1;
304 if (dataCount == 16) {
305 std::istringstream(cell) >> f2;
309 if (dataCount == 17) {
310 std::istringstream(cell) >> f3;
314 if (dataCount == 18) {
315 std::istringstream(cell) >> f4;
318 if (dataCount == 21) {
319 std::istringstream(cell) >> axleRatio;
323 if (dataCount == 22) {
324 std::istringstream(cell) >> effectiveWheelDiameter;
328 if (dataCount == 45) {
329 vehicleMassType = cell;
333 if (dataCount == 46) {
334 vehicleFuelType = cell;
338 if (dataCount == 47) {
339 std::istringstream(cell) >> pNormV0;
343 if (dataCount == 48) {
344 std::istringstream(cell) >> pNormP0;
348 if (dataCount == 49) {
349 std::istringstream(cell) >> pNormV1;
353 if (dataCount == 50) {
354 std::istringstream(cell) >> pNormP1;
358 while (std::getline(fileVehicle, line) && line.substr(0, 1) != commentPrefix) {
359 std::stringstream lineStream(line);
361 std::vector <double> vi;
362 while (std::getline(lineStream, cell,
',')) {
364 std::istringstream(cell) >> entry;
368 matrixSpeedInertiaTable.push_back(vi);
371 while (std::getline(fileVehicle, line)) {
372 if (line.substr(0, 1) == commentPrefix) {
376 std::stringstream lineStream(line);
378 std::vector <double> vi;
379 while (std::getline(lineStream, cell,
',')) {
381 std::istringstream(cell) >> entry;
385 normedDragTable.push_back(vi);
395 std::vector<std::string>& header, std::vector<std::vector<double> >& matrix, std::vector<double>& idlingValues) {
397 std::string pollutantExtension =
"";
399 pollutantExtension +=
"_FC";
402 std::ifstream fileEmission;
403 for (std::vector<std::string>::const_iterator i = path.begin(); i != path.end(); i++) {
404 fileEmission.open(((*i) + emissionClass + pollutantExtension +
".csv").c_str());
405 if (fileEmission.good()) {
410 if (!fileEmission.good()) {
417 if (std::getline(fileEmission, line)) {
418 std::stringstream lineStream(line);
421 std::getline(lineStream, cell,
',');
423 while (std::getline(lineStream, cell,
',')) {
424 header.push_back(cell);
430 std::getline(fileEmission, line);
433 std::getline(fileEmission, line);
436 std::getline(fileEmission, line);
438 std::stringstream idlingStream(line);
439 std::string idlingCell;
442 std::getline(idlingStream, idlingCell,
',');
444 while (std::getline(idlingStream, idlingCell,
',')) {
446 std::istringstream(idlingCell) >> entry;
447 idlingValues.push_back(entry);
450 while (std::getline(fileEmission, line)) {
451 std::stringstream lineStream(line);
453 std::vector <double> vi;
454 while (std::getline(lineStream, cell,
',')) {
456 std::istringstream(cell) >> entry;
460 matrix.push_back(vi);
463 fileEmission.close();
Data Handler for a single CEP emission data set.
std::map< SUMOEmissionClass, PHEMCEP * > _ceps
bijection between PHEMEmissionClass and CEPs
bool ReadVehicleFile(const std::vector< std::string > &path, const std::string &emissionClass, double &vehicleMass, double &vehicleLoading, double &vehicleMassRot, double &crossArea, double &cWValue, double &f0, double &f1, double &f2, double &f3, double &f4, double &axleRatio, double &ratedPower, double &engineIdlingSpeed, double &engineRatedSpeed, double &effectiveWheelDiameter, std::string &vehicleMassType, std::string &vehicleFuelType, double &pNormV0, double &pNormP0, double &pNormV1, double &pNormP1, std::vector< std::vector< double > > &matrixSpeedInertiaTable, std::vector< std::vector< double > > &normedDragTable)
Helper method to read a vehicle file from file system.
Data Handler for all CEP emission and vehicle Data.
static OptionsCont & getOptions()
Retrieves the options.
bool Load(SUMOEmissionClass emissionClass, const std::string &emissionClassIdentifier)
Helper method to load CEP and vehicle files from file system.
static PHEMCEPHandler & getHandlerInstance()
Implementatio of Singelton pattern.
bool ReadEmissionData(bool readFC, const std::vector< std::string > &path, const std::string &emissionClass, std::vector< std::string > &header, std::vector< std::vector< double > > &matrix, std::vector< double > &idlingValues)
Helper method to read a CEP file from file system.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
~PHEMCEPHandler()
Destructor.
PHEMCEPHandler()
Implementation of Singelton pattern private (copy) constructor and =operator to avoid more than one i...
A storage for options typed value containers)
PHEMCEP * GetCep(SUMOEmissionClass emissionClass)
Returns the CEP data for a PHEM emission class.