56 std::string emissionRep = Helper->
getgClass();
59 std::vector<std::vector<double> > matrixSpeedInertiaTable;
60 std::vector<std::vector<double> > normedTragTableSpeedInertiaTable;
61 std::vector<std::vector<double> > matrixFC;
62 std::vector<std::vector<double> > matrixPollutants;
63 std::vector<double> idlingValuesFC;
64 std::vector<double> idlingValuesPollutants;
65 std::vector<std::string> headerFC;
66 std::vector<std::string> headerPollutants;
69 double vehicleLoading;
70 double vehicleMassRot;
71 double crosssectionalArea;
79 std::vector<double> transmissionGearRatios;
82 double engineIdlingSpeed;
83 double engineRatedSpeed;
84 double effectiveWhellDiameter;
85 std::string vehicleMassType;
86 std::string vehicleFuelType;
92 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)) {
96 if (!
ReadEmissionData(
true, DataPath, emissionRep, Helper, headerFC, matrixFC, idlingValuesFC)) {
100 if (!
ReadEmissionData(
false, DataPath, emissionRep, Helper, headerPollutants, matrixPollutants, idlingValuesPollutants)) {
104 _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)));
109 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) {
123 engineIdlingSpeed = 0;
124 engineRatedSpeed = 0;
125 effectiveWheelDiameter = 0;
126 vehicleMassType =
"";
127 vehicleFuelType =
"";
132 transmissionGearRatios = std::vector<double>();
133 matrixSpeedInertiaTable = std::vector<std::vector<double> >();
134 normedDragTable = std::vector<std::vector<double> >();
140 std::ifstream vehicleReader;
141 for (std::vector<std::string>::const_iterator i = DataPath.begin(); i != DataPath.end(); i++) {
142 vehicleReader.open(((*i) + emissionClass +
".PHEMLight.veh").c_str());
143 if (vehicleReader.good()) {
147 if (!vehicleReader.good()) {
148 Helper->
setErrMsg(
"File does not exist! (" + emissionClass +
".PHEMLight.veh)");
155 while ((line =
ReadLine(vehicleReader)) !=
"" && dataCount <= 49) {
163 cell =
split(line,
',')[0];
166 if (dataCount == 1) {
171 if (dataCount == 2) {
176 if (dataCount == 3) {
181 if (dataCount == 4) {
186 if (dataCount == 7) {
191 if (dataCount == 9) {
196 if (dataCount == 10) {
201 if (dataCount == 11) {
206 if (dataCount == 12) {
211 if (dataCount == 14) {
216 if (dataCount == 15) {
221 if (dataCount == 16) {
226 if (dataCount == 17) {
231 if (dataCount == 18) {
236 if (dataCount == 21) {
241 if (dataCount == 22) {
242 effectiveWheelDiameter =
todouble(cell);
245 if (dataCount >= 23 && dataCount <= 40) {
246 transmissionGearRatios.push_back(
todouble(cell));
250 if (dataCount == 45) {
251 vehicleMassType = cell;
255 if (dataCount == 46) {
256 vehicleFuelType = cell;
260 if (dataCount == 47) {
265 if (dataCount == 48) {
270 if (dataCount == 49) {
275 if (dataCount == 50) {
288 while ((line =
ReadLine(vehicleReader)) !=
"") {
299 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) {
302 header = std::vector<std::string>();
303 matrix = std::vector<std::vector<double> >();
304 idlingValues = std::vector<double>();
306 std::string pollutantExtension =
"";
308 pollutantExtension += std::string(
"_FC");
311 std::ifstream fileReader;
312 for (std::vector<std::string>::const_iterator i = DataPath.begin(); i != DataPath.end(); i++) {
313 fileReader.open(((*i) + emissionClass + pollutantExtension +
".csv").c_str());
314 if (fileReader.good()) {
318 if (!fileReader.good()) {
319 Helper->
setErrMsg(
"File does not exist! (" + emissionClass + pollutantExtension +
".csv)");
324 if ((line =
ReadLine(fileReader)) !=
"") {
325 std::vector<std::string> entries =
split(line,
',');
327 for (
int i = 1; i < (int)entries.size(); i++) {
328 header.push_back(entries[i]);
341 std::vector<std::string> stringIdlings =
split(line,
',');
342 stringIdlings.erase(stringIdlings.begin());
346 while ((line =
ReadLine(fileReader)) !=
"") {
bool 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)
bool 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)