50 std::map<SUMOEmissionClass, PHEMCEP*>::iterator iter =
_ceps.begin();
51 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",
109 emissionClass, emissionClassIdentifier,
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()) {
127 return _ceps[emissionClass];
133 double& vehicleMass,
double& vehicleLoading,
double& vehicleMassRot,
134 double& crossArea,
double& cWValue,
135 double& f0,
double& f1,
double& f2,
double& f3,
double& f4,
double& ratedPower, std::string& vehicleMassType, std::string& vehicleFuelType,
136 double& pNormV0,
double& pNormP0,
double& pNormV1,
double& pNormP1, std::vector< std::vector<double> >& matrixRotFactor) {
137 std::ifstream fileVehicle(std::string(path + emissionClass +
".veh").c_str());
139 if (!fileVehicle.good()) {
145 std::string commentPrefix =
"c";
149 std::getline(fileVehicle, line);
151 while (std::getline(fileVehicle, line) && dataCount <= 49) {
152 std::stringstream lineStream(line);
154 if (line.substr(0, 1) == commentPrefix) {
160 std::getline(lineStream, cell,
',');
163 if (dataCount == 1) {
164 std::istringstream(cell) >> vehicleMass;
168 if (dataCount == 2) {
169 std::istringstream(cell) >> vehicleLoading;
173 if (dataCount == 3) {
174 std::istringstream(cell) >> cWValue;
178 if (dataCount == 4) {
179 std::istringstream(cell) >> crossArea;
183 if (dataCount == 7) {
184 std::istringstream(cell) >> vehicleMassRot;
188 if (dataCount == 10) {
189 std::istringstream(cell) >> ratedPower;
193 if (dataCount == 14) {
194 std::istringstream(cell) >> f0;
198 if (dataCount == 15) {
199 std::istringstream(cell) >> f1;
203 if (dataCount == 16) {
204 std::istringstream(cell) >> f2;
208 if (dataCount == 17) {
209 std::istringstream(cell) >> f3;
213 if (dataCount == 18) {
214 std::istringstream(cell) >> f4;
218 if (dataCount == 45) {
219 vehicleMassType = cell;
223 if (dataCount == 46) {
224 vehicleFuelType = cell;
228 if (dataCount == 47) {
229 std::istringstream(cell) >> pNormV0;
233 if (dataCount == 48) {
234 std::istringstream(cell) >> pNormP0;
238 if (dataCount == 49) {
239 std::istringstream(cell) >> pNormV1;
243 if (dataCount == 50) {
244 std::istringstream(cell) >> pNormP1;
248 while (std::getline(fileVehicle, line)) {
249 std::stringstream lineStream(line);
251 std::vector <double> vi;
252 while (std::getline(lineStream, cell,
',')) {
254 std::istringstream(cell) >> entry;
258 matrixRotFactor.push_back(vi);
269 std::vector<std::string>& header, std::vector<std::vector<double> >& matrix) {
272 std::string pollutantExtension =
"";
274 pollutantExtension +=
"_FC";
277 std::ifstream fileEmission(std::string(path + emissionClass + pollutantExtension +
".csv").c_str());
279 if (!fileEmission.good()) {
286 if (std::getline(fileEmission, line)) {
287 std::stringstream lineStream(line);
290 std::getline(lineStream, cell,
',');
292 while (std::getline(lineStream, cell,
',')) {
293 header.push_back(cell);
299 std::getline(fileEmission, line);
301 while (std::getline(fileEmission, line)) {
302 std::stringstream lineStream(line);
304 std::vector <double> vi;
305 while (std::getline(lineStream, cell,
',')) {
307 std::istringstream(cell) >> entry;
311 matrix.push_back(vi);
314 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.
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.
bool Load(SUMOEmissionClass emissionClass, const std::string &emissionClassIdentifier)
Helper method to load CEP and vehicle files from file system.
static PHEMCEPHandler & getHandlerInstance()
Implementatio of Singelton pattern.
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.