32 _ceps = std::map<std::string, CEP*>();
41 if (!
Load(DataPath, Helper)) {
52 std::string emissionRep = Helper->
getgClass();
55 std::vector<std::vector<double> > matrixSpeedInertiaTable;
56 std::vector<std::vector<double> > normedTragTableSpeedInertiaTable;
57 std::vector<std::vector<double> > matrixFC;
58 std::vector<std::vector<double> > matrixPollutants;
59 std::vector<double> idlingValuesFC;
60 std::vector<double> idlingValuesPollutants;
61 std::vector<std::string> headerFC;
62 std::vector<std::string> headerPollutants;
65 double vehicleLoading;
66 double vehicleMassRot;
67 double crosssectionalArea;
75 std::vector<double> transmissionGearRatios;
78 double engineIdlingSpeed;
79 double engineRatedSpeed;
80 double effectiveWhellDiameter;
81 std::string vehicleMassType;
82 std::string vehicleFuelType;
88 if (!
ReadVehicleFile(DataPath, emissionRep, Helper, vehicleMass, vehicleLoading, vehicleMassRot, crosssectionalArea, cwValue, f0, f1, f2, f3, f4, axleRatio, auxPower, ratedPower, engineIdlingSpeed, engineRatedSpeed, effectiveWhellDiameter, transmissionGearRatios, vehicleMassType, vehicleFuelType, pNormV0, pNormP0, pNormV1, pNormP1, matrixSpeedInertiaTable, normedTragTableSpeedInertiaTable)) {
92 if (!
ReadEmissionData(
true, DataPath, emissionRep, Helper, headerFC, matrixFC, idlingValuesFC)) {
96 if (!
ReadEmissionData(
false, DataPath, emissionRep, Helper, headerPollutants, matrixPollutants, idlingValuesPollutants)) {
100 _ceps.insert(std::make_pair(Helper->
getgClass(),
new CEP(vehicleMassType ==
Constants::HeavyVehicle, vehicleMass, vehicleLoading, vehicleMassRot, crosssectionalArea, cwValue, f0, f1, f2, f3, f4, axleRatio, transmissionGearRatios, auxPower, ratedPower, engineIdlingSpeed, engineRatedSpeed, effectiveWhellDiameter, pNormV0, pNormP0, pNormV1, pNormP1, vehicleFuelType, matrixFC, headerPollutants, matrixPollutants, matrixSpeedInertiaTable, normedTragTableSpeedInertiaTable, idlingValuesFC.front(), idlingValuesPollutants)));
105 bool CEPHandler::ReadVehicleFile(
const std::vector<std::string>& DataPath,
const std::string& emissionClass,
Helpers* Helper,
double& vehicleMass,
double& vehicleLoading,
double& vehicleMassRot,
double& crossArea,
double& cWValue,
double& f0,
double& f1,
double& f2,
double& f3,
double& f4,
double& axleRatio,
double& auxPower,
double& ratedPower,
double& engineIdlingSpeed,
double& engineRatedSpeed,
double& effectiveWheelDiameter, std::vector<double>& transmissionGearRatios, 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) {
119 engineIdlingSpeed = 0;
120 engineRatedSpeed = 0;
121 effectiveWheelDiameter = 0;
122 vehicleMassType =
"";
123 vehicleFuelType =
"";
128 transmissionGearRatios = std::vector<double>();
129 matrixSpeedInertiaTable = std::vector<std::vector<double> >();
130 normedDragTable = std::vector<std::vector<double> >();
136 std::ifstream vehicleReader;
137 for (std::vector<std::string>::const_iterator i = DataPath.begin(); i != DataPath.end(); i++) {
138 vehicleReader.open(((*i) + emissionClass +
".PHEMLight.veh").c_str());
139 if (vehicleReader.good()) {
143 if (!vehicleReader.good()) {
144 Helper->
setErrMsg(
"File does not exist! (" + emissionClass +
".PHEMLight.veh)");
151 while ((line =
ReadLine(vehicleReader)) !=
"" && dataCount <= 49) {
159 cell =
split(line,
',')[0];
162 if (dataCount == 1) {
167 if (dataCount == 2) {
172 if (dataCount == 3) {
177 if (dataCount == 4) {
182 if (dataCount == 7) {
187 if (dataCount == 9) {
192 if (dataCount == 10) {
197 if (dataCount == 11) {
202 if (dataCount == 12) {
207 if (dataCount == 14) {
212 if (dataCount == 15) {
217 if (dataCount == 16) {
222 if (dataCount == 17) {
227 if (dataCount == 18) {
232 if (dataCount == 21) {
237 if (dataCount == 22) {
238 effectiveWheelDiameter =
todouble(cell);
241 if (dataCount >= 23 && dataCount <= 40) {
242 transmissionGearRatios.push_back(
todouble(cell));
246 if (dataCount == 45) {
247 vehicleMassType = cell;
251 if (dataCount == 46) {
252 vehicleFuelType = cell;
256 if (dataCount == 47) {
261 if (dataCount == 48) {
266 if (dataCount == 49) {
271 if (dataCount == 50) {
284 while ((line =
ReadLine(vehicleReader)) !=
"") {
295 bool CEPHandler::ReadEmissionData(
bool readFC,
const std::vector<std::string>& DataPath,
const std::string& emissionClass,
Helpers* Helper, std::vector<std::string>& header, std::vector<std::vector<double> >& matrix, std::vector<double>& idlingValues) {
298 header = std::vector<std::string>();
299 matrix = std::vector<std::vector<double> >();
300 idlingValues = std::vector<double>();
302 std::string pollutantExtension =
"";
304 pollutantExtension += std::string(
"_FC");
307 std::ifstream fileReader;
308 for (std::vector<std::string>::const_iterator i = DataPath.begin(); i != DataPath.end(); i++) {
309 fileReader.open(((*i) + emissionClass + pollutantExtension +
".csv").c_str());
310 if (fileReader.good()) {
314 if (!fileReader.good()) {
315 Helper->
setErrMsg(
"File does not exist! (" + emissionClass + pollutantExtension +
".csv)");
320 if ((line =
ReadLine(fileReader)) !=
"") {
321 std::vector<std::string> entries =
split(line,
',');
323 for (
int i = 1; i < (int)entries.size(); i++) {
324 header.push_back(entries[i]);
337 std::vector<std::string> stringIdlings =
split(line,
',');
338 stringIdlings.erase(stringIdlings.begin());
342 while ((line =
ReadLine(fileReader)) !=
"") {
349 std::vector<std::string> elems;
350 std::stringstream ss(s);
352 while (std::getline(ss, item, delim)) {
353 elems.push_back(item);
359 std::stringstream ss(s);
366 std::vector<double> result;
367 for (std::vector<std::string>::const_iterator i = s.begin(); i != s.end(); ++i) {
375 std::getline(s, line);
376 line.erase(line.find_last_not_of(
" \n\r\t") + 1);