Eclipse SUMO - Simulation of Urban MObility
TrackerValueDesc.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 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 /****************************************************************************/
16 // Representation of a timeline of floats with their names and moments
17 /****************************************************************************/
18 #ifndef TrackerValueDesc_h
19 #define TrackerValueDesc_h
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <fx.h>
26 #include <string>
27 #include <vector>
28 #include <utils/common/RGBColor.h>
29 #include <utils/common/SUMOTime.h>
31 
32 
33 // ===========================================================================
34 // class definitions
35 // ===========================================================================
43 class TrackerValueDesc : public ValueRetriever<double> {
44 public:
46  TrackerValueDesc(const std::string& name, const RGBColor& col,
47  SUMOTime recordBegin,
48  double aggregationSeconds);
49 
52 
54  double getRange() const;
55 
57  double getMin() const;
58 
60  double getMax() const;
61 
63  double getYCenter() const;
64 
66  const RGBColor& getColor() const;
67 
71  const std::vector<double>& getValues();
72 
76  const std::vector<double>& getAggregatedValues();
77 
79  const std::string& getName() const;
80 
82  void addValue(double value);
83 
85  void unlockValues();
86 
89 
92 
95 
96 
97 private:
99  std::string myName;
100 
103 
106 
108  std::vector<double> myValues;
109 
111  std::vector<double> myAggregatedValues;
112 
114  double myMin, myMax;
115 
116  // Mutex to avoid parallel drawing and insertion of new items
117  FXMutex myLock;
118 
121 
124 
127 
130 
133 
134 };
135 
136 
137 #endif
138 
139 /****************************************************************************/
140 
double getYCenter() const
Returns the center of the value.
long long int SUMOTime
Definition: SUMOTime.h:35
TrackerValueDesc(const std::string &name, const RGBColor &col, SUMOTime recordBegin, double aggregationSeconds)
Constructor.
int myAggregationInterval
The aggregation interval in simulation steps.
void unlockValues()
Releases the locking after the values have been drawn.
SUMOTime getRecordingBegin() const
Returns the timestep the recording started.
Representation of a timeline of floats with their names and moments.
double myInvalidValue
Values like this shall not be counted on aggregation.
SUMOTime getAggregationSpan() const
get the aggregation amount
SUMOTime myRecordingBegin
The time step the values are added from.
std::vector< double > myAggregatedValues
Collected values in their aggregated form.
std::vector< double > myValues
Values collected.
const std::vector< double > & getAggregatedValues()
returns the vector of aggregated values The values will be locked - no further addition will be perfo...
RGBColor myActiveCol
The color to use when the value is set as "active".
int myValidNo
Counter for valid numbers within the current aggregation interval.
double myMin
The minimum and the maximum of the value.
RGBColor myInactiveCol
The color to use when the value is set as "inactive".
const std::string & getName() const
Returns the name of the value.
double getMax() const
Returns the values maximum.
const std::vector< double > & getValues()
returns the vector of collected values The values will be locked - no further addition will be perfom...
double myTmpLastAggValue
Temporary storage for the last aggregation interval.
~TrackerValueDesc()
Destructor.
const RGBColor & getColor() const
Returns the color to use to display the value.
double getMin() const
Returns the values minimum.
void addValue(double value)
Adds a new value to the list.
std::string myName
The name of the value.
double getRange() const
returns the maximum value range
void setAggregationSpan(SUMOTime as)
set the aggregation amount