SUMO - Simulation of Urban MObility
TrajectoriesHandler.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2014-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // An XML-Handler for amitran and netstate trajectories
18 /****************************************************************************/
19 #ifndef TrajectoriesHandler_h
20 #define TrajectoriesHandler_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <string>
33 #include <utility>
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
47 public:
48  static const int INVALID_VALUE = -999999;
49 
50 public:
55  TrajectoriesHandler(const bool computeA, const bool computeAForward, const bool accelZeroCorrection,
56  const SUMOEmissionClass defaultClass,
57  const double defaultSlope, std::ostream* stdOut, OutputDevice* xmlOut);
58 
59 
62 
63  const PollutantsInterface::Emissions computeEmissions(const std::string id,
64  const SUMOEmissionClass c, double& v,
65  double& a, double& s);
66 
67  bool writeEmissions(std::ostream& o, const std::string id,
68  const SUMOEmissionClass c,
69  double t, double& v,
70  double& a, double& s);
71 
72  bool writeXMLEmissions(const std::string id,
73  const SUMOEmissionClass c,
74  SUMOTime t, double& v,
75  double a = INVALID_VALUE, double s = INVALID_VALUE);
76 
77  void writeSums(std::ostream& o, const std::string id);
78 
79  void writeNormedSums(std::ostream& o, const std::string id, const double factor);
80 
81 
82 protected:
84 
85 
95  void myStartElement(int element,
96  const SUMOSAXAttributes& attrs);
98 
99 
100 private:
101  const bool myComputeA;
102  const bool myComputeAForward;
105  const double myDefaultSlope;
106  std::ostream* myStdOut;
108  std::map<std::string, double> myLastV;
109  std::map<std::string, double> myLastSlope;
111  double myStepSize;
112  std::map<std::string, PollutantsInterface::Emissions> mySums;
113  std::map<std::string, SUMOEmissionClass> myEmissionClassByType;
114  std::map<std::string, SUMOEmissionClass> myEmissionClassByVehicle;
115 
116 
117 private:
120 
123 
124 
125 };
126 
127 
128 #endif
129 
130 /****************************************************************************/
131 
void writeNormedSums(std::ostream &o, const std::string id, const double factor)
TrajectoriesHandler(const bool computeA, const bool computeAForward, const bool accelZeroCorrection, const SUMOEmissionClass defaultClass, const double defaultSlope, std::ostream *stdOut, OutputDevice *xmlOut)
Constructor.
const SUMOEmissionClass myDefaultClass
std::map< std::string, SUMOEmissionClass > myEmissionClassByType
Storage for collected values of all emission types.
const PollutantsInterface::Emissions computeEmissions(const std::string id, const SUMOEmissionClass c, double &v, double &a, double &s)
SAX-handler base for SUMO-files.
static const int INVALID_VALUE
Encapsulated SAX-Attributes.
int SUMOEmissionClass
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called when an opening-tag occurs.
bool writeXMLEmissions(const std::string id, const SUMOEmissionClass c, SUMOTime t, double &v, double a=INVALID_VALUE, double s=INVALID_VALUE)
TrajectoriesHandler & operator=(const TrajectoriesHandler &s)
invalidated assignment operator
~TrajectoriesHandler()
Destructor.
std::map< std::string, double > myLastV
std::map< std::string, double > myLastSlope
std::map< std::string, SUMOEmissionClass > myEmissionClassByVehicle
void writeSums(std::ostream &o, const std::string id)
An XML-Handler for amitran and netstate trajectories.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
long long int SUMOTime
Definition: TraCIDefs.h:51
bool writeEmissions(std::ostream &o, const std::string id, const SUMOEmissionClass c, double t, double &v, double &a, double &s)
std::map< std::string, PollutantsInterface::Emissions > mySums