33 _ceps = std::map<std::string, CEP*>();
42 if (!
Load(DataPath, Helper)) {
53 std::string emissionRep = Helper->
getgClass();
56 std::vector<std::vector<double> > matrixSpeedInertiaTable;
57 std::vector<std::vector<double> > normedTragTableSpeedInertiaTable;
58 std::vector<std::vector<double> > matrixFC;
59 std::vector<std::vector<double> > matrixPollutants;
60 std::vector<double> idlingValuesFC;
61 std::vector<double> idlingValuesPollutants;
62 std::vector<std::string> headerFC;
63 std::vector<std::string> headerPollutants;
66 double vehicleLoading;
67 double vehicleMassRot;
68 double crosssectionalArea;
76 std::vector<double> transmissionGearRatios;
79 double engineIdlingSpeed;
80 double engineRatedSpeed;
81 double effectiveWhellDiameter;
82 std::string vehicleMassType;
83 std::string vehicleFuelType;
89 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)) {
93 if (!
ReadEmissionData(
true, DataPath, emissionRep, Helper, headerFC, matrixFC, idlingValuesFC)) {
97 if (!
ReadEmissionData(
false, DataPath, emissionRep, Helper, headerPollutants, matrixPollutants, idlingValuesPollutants)) {
101 _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)));
106 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) {
120 engineIdlingSpeed = 0;
121 engineRatedSpeed = 0;
122 effectiveWheelDiameter = 0;
123 vehicleMassType =
"";
124 vehicleFuelType =
"";
129 transmissionGearRatios = std::vector<double>();
130 matrixSpeedInertiaTable = std::vector<std::vector<double> >();
131 normedDragTable = std::vector<std::vector<double> >();
137 std::ifstream vehicleReader;
138 for (std::vector<std::string>::const_iterator i = DataPath.begin(); i != DataPath.end(); i++) {
139 vehicleReader.open(((*i) + emissionClass +
".PHEMLight.veh").c_str());
140 if (vehicleReader.good()) {
144 if (!vehicleReader.good()) {
145 Helper->
setErrMsg(
"File does not exist! (" + emissionClass +
".PHEMLight.veh)");
152 while ((line =
ReadLine(vehicleReader)) !=
"" && dataCount <= 49) {
160 cell =
split(line,
',')[0];
163 if (dataCount == 1) {
168 if (dataCount == 2) {
173 if (dataCount == 3) {
178 if (dataCount == 4) {
183 if (dataCount == 7) {
188 if (dataCount == 9) {
193 if (dataCount == 10) {
198 if (dataCount == 11) {
203 if (dataCount == 12) {
208 if (dataCount == 14) {
213 if (dataCount == 15) {
218 if (dataCount == 16) {
223 if (dataCount == 17) {
228 if (dataCount == 18) {
233 if (dataCount == 21) {
238 if (dataCount == 22) {
239 effectiveWheelDiameter =
todouble(cell);
242 if (dataCount >= 23 && dataCount <= 40) {
243 transmissionGearRatios.push_back(
todouble(cell));
247 if (dataCount == 45) {
248 vehicleMassType = cell;
252 if (dataCount == 46) {
253 vehicleFuelType = cell;
257 if (dataCount == 47) {
262 if (dataCount == 48) {
267 if (dataCount == 49) {
272 if (dataCount == 50) {
285 while ((line =
ReadLine(vehicleReader)) !=
"") {
296 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) {
299 header = std::vector<std::string>();
300 matrix = std::vector<std::vector<double> >();
301 idlingValues = std::vector<double>();
303 std::string pollutantExtension =
"";
305 pollutantExtension += std::string(
"_FC");
308 std::ifstream fileReader;
309 for (std::vector<std::string>::const_iterator i = DataPath.begin(); i != DataPath.end(); i++) {
310 fileReader.open(((*i) + emissionClass + pollutantExtension +
".csv").c_str());
311 if (fileReader.good()) {
315 if (!fileReader.good()) {
316 Helper->
setErrMsg(
"File does not exist! (" + emissionClass + pollutantExtension +
".csv)");
321 if ((line =
ReadLine(fileReader)) !=
"") {
322 std::vector<std::string> entries =
split(line,
',');
324 for (
int i = 1; i < (int)entries.size(); i++) {
325 header.push_back(entries[i]);
338 std::vector<std::string> stringIdlings =
split(line,
',');
339 stringIdlings.erase(stringIdlings.begin());
343 while ((line =
ReadLine(fileReader)) !=
"") {
350 std::vector<std::string> elems;
351 std::stringstream ss(s);
353 while (std::getline(ss, item, delim)) {
354 elems.push_back(item);
360 std::stringstream ss(s);
367 std::vector<double> result;
368 for (std::vector<std::string>::const_iterator i = s.begin(); i != s.end(); ++i) {
376 std::getline(s, line);
377 line.erase(line.find_last_not_of(
" \n\r\t") + 1);