Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/tools/TrajectoriesHandler.h
169666 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2014-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file TrajectoriesHandler.h
15
/// @author Michael Behrisch
16
/// @date 14.03.2014
17
///
18
// An XML-Handler for amitran and netstate trajectories
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <string>
24
#include <utility>
25
#include <utils/xml/SUMOSAXHandler.h>
26
27
class EnergyParams;
28
29
// ===========================================================================
30
// class definitions
31
// ===========================================================================
32
/**
33
* @class TrajectoriesHandler
34
* @brief An XML-Handler for amitran and netstate trajectories
35
*
36
* This SUMOSAXHandler parses vehicles and their speeds.
37
*/
38
class TrajectoriesHandler : public SUMOSAXHandler {
39
public:
40
static const int INVALID_VALUE = -999999;
41
42
public:
43
/** @brief Constructor
44
*
45
* @param[in] file The file that will be processed
46
*/
47
TrajectoriesHandler(const bool computeA, const bool computeAForward, const bool accelZeroCorrection,
48
const SUMOEmissionClass defaultClass,
49
EnergyParams* params, long long int attributes,
50
const double defaultSlope, std::ostream* stdOut, OutputDevice* xmlOut);
51
52
53
/// @brief Destructor
54
~TrajectoriesHandler();
55
56
const PollutantsInterface::Emissions computeEmissions(const std::string id,
57
const SUMOEmissionClass c, EnergyParams* params, double& v,
58
double& a, double& s);
59
60
bool writeEmissions(std::ostream& o, const std::string id,
61
const SUMOEmissionClass c,
62
EnergyParams* params, long long int attributes,
63
double t, double& v,
64
double& a, double& s);
65
66
bool writeXMLEmissions(const std::string id,
67
const SUMOEmissionClass c,
68
EnergyParams* params,
69
SUMOTime t, double& v,
70
double a = INVALID_VALUE, double s = INVALID_VALUE);
71
72
void writeSums(std::ostream& o, const std::string id);
73
74
void writeNormedSums(std::ostream& o, const std::string id, const double factor);
75
76
77
protected:
78
/// @name inherited from GenericSAXHandler
79
//@{
80
81
/** @brief Called when an opening-tag occurs
82
*
83
* Processes vehicle and motionState elements.
84
*
85
* @param[in] element The enum of the currently opened element
86
* @param[in] attrs Attributes of the currently opened element
87
* @exception ProcessError If an error within the parsed file occurs
88
* @see GenericSAXHandler::myStartElement
89
*/
90
void myStartElement(int element,
91
const SUMOSAXAttributes& attrs);
92
//@}
93
94
private:
95
void writeOptional(std::ostream& o, long long int attributes, const SumoXMLAttr attr, double v);
96
97
private:
98
const bool myComputeA;
99
const bool myComputeAForward;
100
const bool myAccelZeroCorrection;
101
const SUMOEmissionClass myDefaultClass;
102
EnergyParams* myParams;
103
long long int myAttributes;
104
const double myDefaultSlope;
105
std::ostream* myStdOut;
106
OutputDevice* myXMLOut;
107
std::map<std::string, double> myLastV;
108
std::map<std::string, double> myLastSlope;
109
SUMOTime myCurrentTime;
110
double myStepSize;
111
std::map<std::string, PollutantsInterface::Emissions> mySums;
112
std::map<std::string, SUMOEmissionClass> myEmissionClassByType;
113
std::map<std::string, SUMOEmissionClass> myEmissionClassByVehicle;
114
115
116
private:
117
/// @brief invalidated copy constructor
118
TrajectoriesHandler(const TrajectoriesHandler& s);
119
120
/// @brief invalidated assignment operator
121
TrajectoriesHandler& operator=(const TrajectoriesHandler& s);
122
123
124
};
125
126