50 std::map<SUMOEmissionClass, PHEMCEP*>::iterator iter =
_ceps.begin();
51 while (iter !=
_ceps.end()) {
69 std::vector< std::vector<double> > matrixSpeedInertiaTable;
70 std::vector< std::vector<double> > normedDragTable;
71 std::vector< std::vector<double> > matrixFC;
72 std::vector< std::vector<double> > matrixPollutants;
73 std::vector<std::string> headerFC;
74 std::vector<std::string> headerPollutants;
75 std::vector<double> idlingValues;
76 std::vector<double> idlingValuesFC;
79 double vehicleLoading;
80 double vehicleMassRot;
81 double crosssectionalArea;
90 double engineIdlingSpeed;
91 double engineRatedSpeed;
92 double effectiveWheelDiameter;
93 std::string vehicleMassType;
94 std::string vehicleFuelType;
102 std::vector<std::string> phemPath;
103 phemPath.push_back(oc.
getString(
"phemlight-path") +
"/");
104 if (getenv(
"PHEMLIGHT_PATH") != 0) {
105 phemPath.push_back(std::string(getenv(
"PHEMLIGHT_PATH")) +
"/");
107 if (getenv(
"SUMO_HOME") != 0) {
108 phemPath.push_back(std::string(getenv(
"SUMO_HOME")) +
"/data/emissions/PHEMlight/");
125 effectiveWheelDiameter,
132 matrixSpeedInertiaTable,
137 if (!
ReadEmissionData(
true, phemPath, emissionClassIdentifier, headerFC, matrixFC, idlingValuesFC)) {
141 if (!
ReadEmissionData(
false, phemPath, emissionClassIdentifier, headerPollutants, matrixPollutants, idlingValues)) {
145 _ceps[emissionClass] =
new PHEMCEP(vehicleMassType ==
"HV",
146 emissionClass, emissionClassIdentifier,
165 effectiveWheelDiameter,
166 idlingValuesFC.front(),
171 matrixSpeedInertiaTable,
182 if (
_ceps.find(emissionClass) ==
_ceps.end()) {
186 return _ceps[emissionClass];
193 double& vehicleLoading,
194 double& vehicleMassRot,
204 double& engineIdlingSpeed,
205 double& engineRatedSpeed,
206 double& effectiveWheelDiameter,
207 std::string& vehicleMassType,
208 std::string& vehicleFuelType,
213 std::vector< std::vector<double> >& matrixSpeedInertiaTable,
214 std::vector< std::vector<double> >& normedDragTable)
217 std::ifstream fileVehicle;
218 for (std::vector<std::string>::const_iterator i = path.begin(); i != path.end(); i++) {
219 fileVehicle.open(((*i) + emissionClass +
".PHEMLight.veh").c_str());
220 if (fileVehicle.good()) {
224 if (!fileVehicle.good()) {
230 std::string commentPrefix =
"c";
234 std::getline(fileVehicle, line);
236 while (std::getline(fileVehicle, line) && dataCount <= 49) {
238 if (line.size() > 0 && line.substr(line.size() - 1) ==
"\r") {
239 line = line.substr(0, line.size() - 1);
242 std::stringstream lineStream(line);
244 if (line.substr(0, 1) == commentPrefix) {
250 std::getline(lineStream, cell,
',');
253 if (dataCount == 1) {
254 std::istringstream(cell) >> vehicleMass;
258 if (dataCount == 2) {
259 std::istringstream(cell) >> vehicleLoading;
263 if (dataCount == 3) {
264 std::istringstream(cell) >> cWValue;
268 if (dataCount == 4) {
269 std::istringstream(cell) >> crossArea;
273 if (dataCount == 7) {
274 std::istringstream(cell) >> vehicleMassRot;
278 if (dataCount == 10) {
279 std::istringstream(cell) >> ratedPower;
283 if (dataCount == 11) {
284 std::istringstream(cell) >> engineRatedSpeed;
288 if (dataCount == 12) {
289 std::istringstream(cell) >> engineIdlingSpeed;
293 if (dataCount == 14) {
294 std::istringstream(cell) >> f0;
298 if (dataCount == 15) {
299 std::istringstream(cell) >> f1;
303 if (dataCount == 16) {
304 std::istringstream(cell) >> f2;
308 if (dataCount == 17) {
309 std::istringstream(cell) >> f3;
313 if (dataCount == 18) {
314 std::istringstream(cell) >> f4;
317 if (dataCount == 21) {
318 std::istringstream(cell) >> axleRatio;
322 if (dataCount == 22) {
323 std::istringstream(cell) >> effectiveWheelDiameter;
327 if (dataCount == 45) {
328 vehicleMassType = cell;
332 if (dataCount == 46) {
333 vehicleFuelType = cell;
337 if (dataCount == 47) {
338 std::istringstream(cell) >> pNormV0;
342 if (dataCount == 48) {
343 std::istringstream(cell) >> pNormP0;
347 if (dataCount == 49) {
348 std::istringstream(cell) >> pNormV1;
352 if (dataCount == 50) {
353 std::istringstream(cell) >> pNormP1;
357 while (std::getline(fileVehicle, line) && line.substr(0, 1) != commentPrefix) {
358 std::stringstream lineStream(line);
360 std::vector <double> vi;
361 while (std::getline(lineStream, cell,
',')) {
363 std::istringstream(cell) >> entry;
367 matrixSpeedInertiaTable.push_back(vi);
370 while (std::getline(fileVehicle, line)) {
371 if (line.substr(0, 1) == commentPrefix) {
375 std::stringstream lineStream(line);
377 std::vector <double> vi;
378 while (std::getline(lineStream, cell,
',')) {
380 std::istringstream(cell) >> entry;
384 normedDragTable.push_back(vi);
394 std::vector<std::string>& header, std::vector<std::vector<double> >& matrix, std::vector<double>& idlingValues) {
396 std::string pollutantExtension =
"";
398 pollutantExtension +=
"_FC";
401 std::ifstream fileEmission;
402 for (std::vector<std::string>::const_iterator i = path.begin(); i != path.end(); i++) {
403 fileEmission.open(((*i) + emissionClass + pollutantExtension +
".csv").c_str());
404 if (fileEmission.good()) {
409 if (!fileEmission.good()) {
416 if (std::getline(fileEmission, line)) {
417 std::stringstream lineStream(line);
420 std::getline(lineStream, cell,
',');
422 while (std::getline(lineStream, cell,
',')) {
423 header.push_back(cell);
429 std::getline(fileEmission, line);
432 std::getline(fileEmission, line);
435 std::getline(fileEmission, line);
437 std::stringstream idlingStream(line);
438 std::string idlingCell;
441 std::getline(idlingStream, idlingCell,
',');
443 while (std::getline(idlingStream, idlingCell,
',')) {
445 std::istringstream(idlingCell) >> entry;
446 idlingValues.push_back(entry);
449 while (std::getline(fileEmission, line)) {
450 std::stringstream lineStream(line);
452 std::vector <double> vi;
453 while (std::getline(lineStream, cell,
',')) {
455 std::istringstream(cell) >> entry;
459 matrix.push_back(vi);
462 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.