12 _ceps = std::map<std::string, CEP*>();
21 if (!
Load(DataPath, Helper)) {
32 std::string emissionRep = Helper->
getgClass();
35 std::vector<std::vector<double> > matrixSpeedInertiaTable;
36 std::vector<std::vector<double> > normedTragTableSpeedInertiaTable;
37 std::vector<std::vector<double> > matrixFC;
38 std::vector<std::vector<double> > matrixPollutants;
39 std::vector<double> idlingValuesFC;
40 std::vector<double> idlingValuesPollutants;
41 std::vector<std::string> headerFC;
42 std::vector<std::string> headerPollutants;
45 double vehicleLoading;
46 double vehicleMassRot;
47 double crosssectionalArea;
55 std::vector<double> transmissionGearRatios;
58 double engineIdlingSpeed;
59 double engineRatedSpeed;
60 double effectiveWhellDiameter;
61 std::string vehicleMassType;
62 std::string vehicleFuelType;
68 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)) {
72 if (!
ReadEmissionData(
true, DataPath, emissionRep, Helper, headerFC, matrixFC, idlingValuesFC)) {
76 if (!
ReadEmissionData(
false, DataPath, emissionRep, Helper, headerPollutants, matrixPollutants, idlingValuesPollutants)) {
80 _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)));
85 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) {
99 engineIdlingSpeed = 0;
100 engineRatedSpeed = 0;
101 effectiveWheelDiameter = 0;
102 vehicleMassType =
"";
103 vehicleFuelType =
"";
108 transmissionGearRatios = std::vector<double>();
109 matrixSpeedInertiaTable = std::vector<std::vector<double> >();
110 normedDragTable = std::vector<std::vector<double> >();
116 std::ifstream vehicleReader;
117 for (std::vector<std::string>::const_iterator i = DataPath.begin(); i != DataPath.end(); i++) {
118 vehicleReader.open(((*i) + emissionClass +
".PHEMLight.veh").c_str());
119 if (vehicleReader.good()) {
123 if (!vehicleReader.good()) {
124 Helper->
setErrMsg(
"File does not exist! (" + emissionClass +
".PHEMLight.veh)");
131 while ((line =
ReadLine(vehicleReader)) !=
"" && dataCount <= 49) {
139 cell =
split(line,
',')[0];
142 if (dataCount == 1) {
147 if (dataCount == 2) {
152 if (dataCount == 3) {
157 if (dataCount == 4) {
162 if (dataCount == 7) {
167 if (dataCount == 9) {
172 if (dataCount == 10) {
177 if (dataCount == 11) {
182 if (dataCount == 12) {
187 if (dataCount == 14) {
192 if (dataCount == 15) {
197 if (dataCount == 16) {
202 if (dataCount == 17) {
207 if (dataCount == 18) {
212 if (dataCount == 21) {
217 if (dataCount == 22) {
218 effectiveWheelDiameter =
todouble(cell);
221 if (dataCount >= 23 && dataCount <= 40) {
222 transmissionGearRatios.push_back(
todouble(cell));
226 if (dataCount == 45) {
227 vehicleMassType = cell;
231 if (dataCount == 46) {
232 vehicleFuelType = cell;
236 if (dataCount == 47) {
241 if (dataCount == 48) {
246 if (dataCount == 49) {
251 if (dataCount == 50) {
264 while ((line =
ReadLine(vehicleReader)) !=
"") {
275 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) {
278 header = std::vector<std::string>();
279 matrix = std::vector<std::vector<double> >();
280 idlingValues = std::vector<double>();
282 std::string pollutantExtension =
"";
284 pollutantExtension += std::string(
"_FC");
287 std::ifstream fileReader;
288 for (std::vector<std::string>::const_iterator i = DataPath.begin(); i != DataPath.end(); i++) {
289 fileReader.open(((*i) + emissionClass + pollutantExtension +
".csv").c_str());
290 if (fileReader.good()) {
294 if (!fileReader.good()) {
295 Helper->
setErrMsg(
"File does not exist! (" + emissionClass + pollutantExtension +
".csv)");
300 if ((line =
ReadLine(fileReader)) !=
"") {
301 std::vector<std::string> entries =
split(line,
',');
303 for (
int i = 1; i < (int)entries.size(); i++) {
304 header.push_back(entries[i]);
317 std::vector<std::string> stringIdlings =
split(line,
',');
318 stringIdlings.erase(stringIdlings.begin());
322 while ((line =
ReadLine(fileReader)) !=
"") {
329 std::vector<std::string> elems;
330 std::stringstream ss(s);
332 while (std::getline(ss, item, delim)) {
333 elems.push_back(item);
339 std::stringstream ss(s);
346 std::vector<double> result;
347 for (std::vector<std::string>::const_iterator i = s.begin(); i != s.end(); ++i) {
355 std::getline(s, line);
356 line.erase(line.find_last_not_of(
" \n\r\t") + 1);
std::vector< double > todoubleList(const std::vector< std::string > &s)
std::map< std::string, CEP * > _ceps
void setErrMsg(const std::string &value)
bool Load(const std::vector< std::string > &DataPath, Helpers *Helper)
static const std::string HeavyVehicle
std::string ReadLine(std::ifstream &s)
bool GetCEP(const std::vector< std::string > &DataPath, Helpers *Helper)
const std::string & getgClass() const
double todouble(const std::string &s)
std::vector< std::string > split(const std::string &s, char delim)
const std::map< std::string, CEP * > & getCEPS() const
const std::string & getCommentPrefix() const
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)