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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // An XML-Handler for amitran and netstate trajectories
16 /****************************************************************************/
17 #ifndef TrajectoriesHandler_h
18 #define TrajectoriesHandler_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <string>
27 #include <utility>
29 
30 
31 // ===========================================================================
32 // class definitions
33 // ===========================================================================
41 public:
42  static const int INVALID_VALUE = -999999;
43 
44 public:
49  TrajectoriesHandler(const bool computeA, const bool computeAForward, const bool accelZeroCorrection,
50  const SUMOEmissionClass defaultClass,
51  const double defaultSlope, std::ostream* stdOut, OutputDevice* xmlOut);
52 
53 
56 
57  const PollutantsInterface::Emissions computeEmissions(const std::string id,
58  const SUMOEmissionClass c, double& v,
59  double& a, double& s);
60 
61  bool writeEmissions(std::ostream& o, const std::string id,
62  const SUMOEmissionClass c,
63  double t, double& v,
64  double& a, double& s);
65 
66  bool writeXMLEmissions(const std::string id,
67  const SUMOEmissionClass c,
68  SUMOTime t, double& v,
69  double a = INVALID_VALUE, double s = INVALID_VALUE);
70 
71  void writeSums(std::ostream& o, const std::string id);
72 
73  void writeNormedSums(std::ostream& o, const std::string id, const double factor);
74 
75 
76 protected:
78 
79 
89  void myStartElement(int element,
90  const SUMOSAXAttributes& attrs);
92 
93 
94 private:
95  const bool myComputeA;
96  const bool myComputeAForward;
99  const double myDefaultSlope;
100  std::ostream* myStdOut;
102  std::map<std::string, double> myLastV;
103  std::map<std::string, double> myLastSlope;
105  double myStepSize;
106  std::map<std::string, PollutantsInterface::Emissions> mySums;
107  std::map<std::string, SUMOEmissionClass> myEmissionClassByType;
108  std::map<std::string, SUMOEmissionClass> myEmissionClassByVehicle;
109 
110 
111 private:
114 
117 
118 
119 };
120 
121 
122 #endif
123 
124 /****************************************************************************/
125 
void writeNormedSums(std::ostream &o, const std::string id, const double factor)
long long int SUMOTime
Definition: SUMOTime.h:36
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
const bool myAccelZeroCorrection
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:64
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