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,
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);
352 std::vector<double> vi;
353 while (std::getline(lineStream, cell,
',')) {
355 std::istringstream(cell) >> entry;
359 matrixSpeedInertiaTable.push_back(vi);
362 while (std::getline(fileVehicle, line)) {
363 if (line.substr(0, 1) == commentPrefix) {
367 std::stringstream lineStream(line);
368 std::vector<double> vi;
369 while (std::getline(lineStream, cell,
',')) {
371 std::istringstream(cell) >> entry;
375 normedDragTable.push_back(vi);
385 std::vector<std::string>& header, std::vector<std::vector<double> >& matrix, std::vector<double>& idlingValues) {
387 std::string pollutantExtension =
"";
389 pollutantExtension +=
"_FC";
392 std::ifstream fileEmission;
393 for (std::vector<std::string>::const_iterator i = path.begin(); i != path.end(); i++) {
394 fileEmission.open(((*i) + emissionClass + pollutantExtension +
".csv").c_str());
395 if (fileEmission.good()) {
400 if (!fileEmission.good()) {
407 if (std::getline(fileEmission, line)) {
408 std::stringstream lineStream(line);
411 std::getline(lineStream, cell,
',');
413 while (std::getline(lineStream, cell,
',')) {
414 header.push_back(cell);
420 std::getline(fileEmission, line);
423 std::getline(fileEmission, line);
426 std::getline(fileEmission, line);
428 std::stringstream idlingStream(line);
429 std::string idlingCell;
432 std::getline(idlingStream, idlingCell,
',');
434 while (std::getline(idlingStream, idlingCell,
',')) {
436 std::istringstream(idlingCell) >> entry;
437 idlingValues.push_back(entry);
440 while (std::getline(fileEmission, line)) {
441 std::stringstream lineStream(line);
442 std::vector <double> vi;
443 while (std::getline(lineStream, cell,
',')) {
445 std::istringstream(cell) >> entry;
449 matrix.push_back(vi);
452 fileEmission.close();
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.