43 std::map<SUMOEmissionClass, PHEMCEP*>::iterator iter =
_ceps.begin();
44 while (iter !=
_ceps.end()) {
45 delete (iter->second);
62 std::vector< std::vector<double> > matrixSpeedInertiaTable;
63 std::vector< std::vector<double> > normedDragTable;
64 std::vector< std::vector<double> > matrixFC;
65 std::vector< std::vector<double> > matrixPollutants;
66 std::vector<std::string> headerFC;
67 std::vector<std::string> headerPollutants;
68 std::vector<double> idlingValues;
69 std::vector<double> idlingValuesFC;
72 double vehicleLoading;
73 double vehicleMassRot;
74 double crosssectionalArea;
83 double engineIdlingSpeed;
84 double engineRatedSpeed;
85 double effectiveWheelDiameter;
86 std::string vehicleMassType;
87 std::string vehicleFuelType;
95 std::vector<std::string> phemPath;
96 phemPath.push_back(oc.
getString(
"phemlight-path") +
"/");
97 if (getenv(
"PHEMLIGHT_PATH") !=
nullptr) {
98 phemPath.push_back(std::string(getenv(
"PHEMLIGHT_PATH")) +
"/");
100 if (getenv(
"SUMO_HOME") !=
nullptr) {
101 phemPath.push_back(std::string(getenv(
"SUMO_HOME")) +
"/data/emissions/PHEMlight/");
118 effectiveWheelDiameter,
125 matrixSpeedInertiaTable,
130 if (!
ReadEmissionData(
true, phemPath, emissionClassIdentifier, headerFC, matrixFC, idlingValuesFC)) {
134 if (!
ReadEmissionData(
false, phemPath, emissionClassIdentifier, headerPollutants, matrixPollutants, idlingValues)) {
138 _ceps[emissionClass] =
new PHEMCEP(vehicleMassType ==
"HV",
139 emissionClass, emissionClassIdentifier,
158 effectiveWheelDiameter,
159 idlingValuesFC.front(),
164 matrixSpeedInertiaTable,
175 if (
_ceps.find(emissionClass) ==
_ceps.end()) {
179 return _ceps[emissionClass];
186 double& vehicleLoading,
187 double& vehicleMassRot,
197 double& engineIdlingSpeed,
198 double& engineRatedSpeed,
199 double& effectiveWheelDiameter,
200 std::string& vehicleMassType,
201 std::string& vehicleFuelType,
206 std::vector< std::vector<double> >& matrixSpeedInertiaTable,
207 std::vector< std::vector<double> >& normedDragTable)
210 std::ifstream fileVehicle;
211 for (std::vector<std::string>::const_iterator i = path.begin(); i != path.end(); i++) {
212 fileVehicle.open(((*i) + emissionClass +
".PHEMLight.veh").c_str());
213 if (fileVehicle.good()) {
217 if (!fileVehicle.good()) {
223 std::string commentPrefix =
"c";
227 std::getline(fileVehicle, line);
229 while (std::getline(fileVehicle, line) && dataCount <= 49) {
231 if (line.size() > 0 && line.substr(line.size() - 1) ==
"\r") {
232 line = line.substr(0, line.size() - 1);
235 std::stringstream lineStream(line);
237 if (line.substr(0, 1) == commentPrefix) {
243 std::getline(lineStream, cell,
',');
246 if (dataCount == 1) {
247 std::istringstream(cell) >> vehicleMass;
251 if (dataCount == 2) {
252 std::istringstream(cell) >> vehicleLoading;
256 if (dataCount == 3) {
257 std::istringstream(cell) >> cWValue;
261 if (dataCount == 4) {
262 std::istringstream(cell) >> crossArea;
266 if (dataCount == 7) {
267 std::istringstream(cell) >> vehicleMassRot;
271 if (dataCount == 10) {
272 std::istringstream(cell) >> ratedPower;
276 if (dataCount == 11) {
277 std::istringstream(cell) >> engineRatedSpeed;
281 if (dataCount == 12) {
282 std::istringstream(cell) >> engineIdlingSpeed;
286 if (dataCount == 14) {
287 std::istringstream(cell) >> f0;
291 if (dataCount == 15) {
292 std::istringstream(cell) >> f1;
296 if (dataCount == 16) {
297 std::istringstream(cell) >> f2;
301 if (dataCount == 17) {
302 std::istringstream(cell) >> f3;
306 if (dataCount == 18) {
307 std::istringstream(cell) >> f4;
310 if (dataCount == 21) {
311 std::istringstream(cell) >> axleRatio;
315 if (dataCount == 22) {
316 std::istringstream(cell) >> effectiveWheelDiameter;
320 if (dataCount == 45) {
321 vehicleMassType = cell;
325 if (dataCount == 46) {
326 vehicleFuelType = cell;
330 if (dataCount == 47) {
331 std::istringstream(cell) >> pNormV0;
335 if (dataCount == 48) {
336 std::istringstream(cell) >> pNormP0;
340 if (dataCount == 49) {
341 std::istringstream(cell) >> pNormV1;
345 if (dataCount == 50) {
346 std::istringstream(cell) >> pNormP1;
350 while (std::getline(fileVehicle, line) && line.substr(0, 1) != commentPrefix) {
351 std::stringstream lineStream(line);
353 std::vector <double> vi;
354 while (std::getline(lineStream, cell,
',')) {
356 std::istringstream(cell) >> entry;
360 matrixSpeedInertiaTable.push_back(vi);
363 while (std::getline(fileVehicle, line)) {
364 if (line.substr(0, 1) == commentPrefix) {
368 std::stringstream lineStream(line);
370 std::vector <double> vi;
371 while (std::getline(lineStream, cell,
',')) {
373 std::istringstream(cell) >> entry;
377 normedDragTable.push_back(vi);
387 std::vector<std::string>& header, std::vector<std::vector<double> >& matrix, std::vector<double>& idlingValues) {
389 std::string pollutantExtension =
"";
391 pollutantExtension +=
"_FC";
394 std::ifstream fileEmission;
395 for (std::vector<std::string>::const_iterator i = path.begin(); i != path.end(); i++) {
396 fileEmission.open(((*i) + emissionClass + pollutantExtension +
".csv").c_str());
397 if (fileEmission.good()) {
402 if (!fileEmission.good()) {
409 if (std::getline(fileEmission, line)) {
410 std::stringstream lineStream(line);
413 std::getline(lineStream, cell,
',');
415 while (std::getline(lineStream, cell,
',')) {
416 header.push_back(cell);
422 std::getline(fileEmission, line);
425 std::getline(fileEmission, line);
428 std::getline(fileEmission, line);
430 std::stringstream idlingStream(line);
431 std::string idlingCell;
434 std::getline(idlingStream, idlingCell,
',');
436 while (std::getline(idlingStream, idlingCell,
',')) {
438 std::istringstream(idlingCell) >> entry;
439 idlingValues.push_back(entry);
442 while (std::getline(fileEmission, line)) {
443 std::stringstream lineStream(line);
445 std::vector <double> vi;
446 while (std::getline(lineStream, cell,
',')) {
448 std::istringstream(cell) >> entry;
452 matrix.push_back(vi);
455 fileEmission.close();
A storage for options typed value containers)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static OptionsCont & getOptions()
Retrieves the options.
Data Handler for all CEP emission and vehicle Data.
PHEMCEPHandler()
Implementation of Singelton pattern private (copy) constructor and =operator to avoid more than one i...
static PHEMCEPHandler & getHandlerInstance()
Implementatio of Singelton pattern.
~PHEMCEPHandler()
Destructor.
PHEMCEP * GetCep(SUMOEmissionClass emissionClass)
Returns the CEP data for a PHEM emission class.
bool Load(SUMOEmissionClass emissionClass, const std::string &emissionClassIdentifier)
Helper method to load CEP and vehicle files from file system.
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.
std::map< SUMOEmissionClass, PHEMCEP * > _ceps
bijection between PHEMEmissionClass and CEPs
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.
Data Handler for a single CEP emission data set.