47 std::map<SUMOEmissionClass, PHEMCEP*>::iterator iter =
_ceps.begin();
48 while (iter !=
_ceps.end()) {
69 std::vector< std::vector<double> > matrixSpeedInertiaTable;
70 std::vector< std::vector<double> > matrixFC;
71 std::vector< std::vector<double> > matrixPollutants;
72 std::vector<std::string> headerFC;
73 std::vector<std::string> headerPollutants;
76 double vehicleLoading;
77 double vehicleMassRot;
78 double crosssectionalArea;
86 std::string vehicleMassType;
87 std::string vehicleFuelType;
94 std::string phemPath = oc.
getString(
"phemlight-path") +
"/";
95 if (!
ReadVehicleFile(phemPath, emissionClassIdentifier, vehicleMass, vehicleLoading, vehicleMassRot, crosssectionalArea, cwValue, f0, f1, f2, f3, f4, ratedPower, vehicleMassType, vehicleFuelType,
96 pNormV0, pNormP0, pNormV1, pNormP1, matrixSpeedInertiaTable)) {
100 if (!
ReadEmissionData(
true, phemPath, emissionClassIdentifier, headerFC, matrixFC)) {
104 if (!
ReadEmissionData(
false, phemPath, emissionClassIdentifier, headerPollutants, matrixPollutants)) {
108 _ceps[emissionClass] =
new PHEMCEP(vehicleMassType ==
"HV",
110 vehicleMass, vehicleLoading, vehicleMassRot,
111 crosssectionalArea, cwValue,
113 ratedPower, pNormV0, pNormP0, pNormV1, pNormP1,
114 vehicleFuelType, matrixFC, headerPollutants, matrixPollutants, matrixSpeedInertiaTable);
123 if (
_ceps.find(emissionClass) ==
_ceps.end()) {
129 return _ceps[emissionClass];
135 double& vehicleMass,
double& vehicleLoading,
double& vehicleMassRot,
136 double& crossArea,
double& cWValue,
137 double& f0,
double& f1,
double& f2,
double& f3,
double& f4,
double& ratedPower, std::string& vehicleMassType, std::string& vehicleFuelType,
138 double& pNormV0,
double& pNormP0,
double& pNormV1,
double& pNormP1, std::vector< std::vector<double> >& matrixRotFactor) {
139 std::ifstream fileVehicle(std::string(path + emissionClass +
".veh").c_str());
141 if (!fileVehicle.good()) {
147 std::string commentPrefix =
"c";
151 std::getline(fileVehicle, line);
153 while (std::getline(fileVehicle, line) && dataCount <= 49) {
154 std::stringstream lineStream(line);
156 if (line.substr(0, 1) == commentPrefix) {
162 std::getline(lineStream, cell,
',');
165 if (dataCount == 1) {
166 std::istringstream(cell) >> vehicleMass;
170 if (dataCount == 2) {
171 std::istringstream(cell) >> vehicleLoading;
175 if (dataCount == 3) {
176 std::istringstream(cell) >> cWValue;
180 if (dataCount == 4) {
181 std::istringstream(cell) >> crossArea;
185 if (dataCount == 7) {
186 std::istringstream(cell) >> vehicleMassRot;
190 if (dataCount == 10) {
191 std::istringstream(cell) >> ratedPower;
195 if (dataCount == 14) {
196 std::istringstream(cell) >> f0;
200 if (dataCount == 15) {
201 std::istringstream(cell) >> f1;
205 if (dataCount == 16) {
206 std::istringstream(cell) >> f2;
210 if (dataCount == 17) {
211 std::istringstream(cell) >> f3;
215 if (dataCount == 18) {
216 std::istringstream(cell) >> f4;
220 if (dataCount == 45) {
221 vehicleMassType = cell;
225 if (dataCount == 46) {
226 vehicleFuelType = cell;
230 if (dataCount == 47) {
231 std::istringstream(cell) >> pNormV0;
235 if (dataCount == 48) {
236 std::istringstream(cell) >> pNormP0;
240 if (dataCount == 49) {
241 std::istringstream(cell) >> pNormV1;
245 if (dataCount == 50) {
246 std::istringstream(cell) >> pNormP1;
250 while (std::getline(fileVehicle, line)) {
251 std::stringstream lineStream(line);
253 std::vector <double> vi;
254 while (std::getline(lineStream, cell,
',')) {
256 std::istringstream(cell) >> entry;
260 matrixRotFactor.push_back(vi);
271 std::vector<std::string>& header, std::vector<std::vector<double> >& matrix) {
274 std::string pollutantExtension =
"";
276 pollutantExtension +=
"_FC";
279 std::ifstream fileEmission(std::string(path + emissionClass + pollutantExtension +
".csv").c_str());
281 if (!fileEmission.good()) {
288 if (std::getline(fileEmission, line)) {
289 std::stringstream lineStream(line);
292 std::getline(lineStream, cell,
',');
294 while (std::getline(lineStream, cell,
',')) {
295 header.push_back(cell);
301 std::getline(fileEmission, line);
303 while (std::getline(fileEmission, line)) {
304 std::stringstream lineStream(line);
306 std::vector <double> vi;
307 while (std::getline(lineStream, cell,
',')) {
309 std::istringstream(cell) >> entry;
313 matrix.push_back(vi);
316 fileEmission.close();
Data Handler for a single CEP emission data set.
std::map< SUMOEmissionClass, PHEMCEP * > _ceps
bijection between PHEMEmissionClass and CEPs
bool ReadEmissionData(bool readFC, const std::string &path, const std::string &emissionClass, std::vector< std::string > &header, std::vector< std::vector< double > > &matrix)
Helper method to read a CEP file from file system.
StringBijection< SUMOEmissionClass > SumoEmissionClassStrings(SumoEmissionClassStringInitializer, SVE_Solo_LKW_D_EU6_II)
bool Load(SUMOEmissionClass emissionClass)
Helper method to load CEP and vehicle files from file system.
Data Handler for all CEP emission and vehicle Data.
bool ReadVehicleFile(const 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 &ratedPower, std::string &vehicleMassType, std::string &vehicleFuelType, double &pNormV0, double &pNormP0, double &pNormV1, double &pNormP1, std::vector< std::vector< double > > &matrixRotFactor)
Helper method to read a vehicle file from file system.
static OptionsCont & getOptions()
Retrieves the options.
static PHEMCEPHandler & getHandlerInstance()
Implementatio of Singelton pattern.
SUMOEmissionClass
Definition of vehicle emission classes.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
~PHEMCEPHandler()
Destructor.
PHEMCEPHandler()
Implementation of Singelton pattern private (copy) constructor and =operator to avoid more than one i...
A storage for options typed value containers)
PHEMCEP * GetCep(SUMOEmissionClass emissionClass)
Returns the CEP data for a PHEM emission class.