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 /****************************************************************************/
15 // Representation of a timeline of floats with their names and moments
16 /****************************************************************************/
17 #ifndef TrackerValueDesc_h
18 #define TrackerValueDesc_h
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #include <fx.h>
25 #include <string>
26 #include <vector>
27 #include <utils/common/RGBColor.h>
28 #include <utils/common/SUMOTime.h>
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
42 class TrackerValueDesc : public ValueRetriever<double> {
43 public:
45  TrackerValueDesc(const std::string& name, const RGBColor& col,
46  SUMOTime recordBegin,
47  double aggregationSeconds);
48 
51 
53  double getRange() const;
54 
56  double getMin() const;
57 
59  double getMax() const;
60 
62  double getYCenter() const;
63 
65  const RGBColor& getColor() const;
66 
70  const std::vector<double>& getValues();
71 
75  const std::vector<double>& getAggregatedValues();
76 
78  const std::string& getName() const;
79 
81  void addValue(double value);
82 
84  void unlockValues();
85 
88 
91 
94 
95 
96 private:
98  std::string myName;
99 
102 
105 
107  std::vector<double> myValues;
108 
110  std::vector<double> myAggregatedValues;
111 
113  double myMin, myMax;
114 
115  // Mutex to avoid parallel drawing and insertion of new items
116  FXMutex myLock;
117 
120 
123 
126 
129 
132 
133 };
134 
135 
136 #endif
137 
138 /****************************************************************************/
139 
TrackerValueDesc::myValues
std::vector< double > myValues
Values collected.
Definition: TrackerValueDesc.h:107
SUMOTime.h
TrackerValueDesc::getMin
double getMin() const
Returns the values minimum.
Definition: TrackerValueDesc.cpp:89
TrackerValueDesc::myValidNo
int myValidNo
Counter for valid numbers within the current aggregation interval.
Definition: TrackerValueDesc.h:125
TrackerValueDesc::getColor
const RGBColor & getColor() const
Returns the color to use to display the value.
Definition: TrackerValueDesc.cpp:107
TrackerValueDesc::myName
std::string myName
The name of the value.
Definition: TrackerValueDesc.h:98
TrackerValueDesc::myInactiveCol
RGBColor myInactiveCol
The color to use when the value is set as "inactive".
Definition: TrackerValueDesc.h:104
TrackerValueDesc::addValue
void addValue(double value)
Adds a new value to the list.
Definition: TrackerValueDesc.cpp:55
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
TrackerValueDesc::getMax
double getMax() const
Returns the values maximum.
Definition: TrackerValueDesc.cpp:95
TrackerValueDesc::myLock
FXMutex myLock
Definition: TrackerValueDesc.h:116
TrackerValueDesc::unlockValues
void unlockValues()
Releases the locking after the values have been drawn.
Definition: TrackerValueDesc.cpp:132
TrackerValueDesc::~TrackerValueDesc
~TrackerValueDesc()
Destructor.
Definition: TrackerValueDesc.cpp:46
RGBColor.h
TrackerValueDesc::getYCenter
double getYCenter() const
Returns the center of the value.
Definition: TrackerValueDesc.cpp:101
RGBColor
Definition: RGBColor.h:39
TrackerValueDesc::setAggregationSpan
void setAggregationSpan(SUMOTime as)
set the aggregation amount
Definition: TrackerValueDesc.cpp:138
TrackerValueDesc::getValues
const std::vector< double > & getValues()
returns the vector of collected values The values will be locked - no further addition will be perfom...
Definition: TrackerValueDesc.cpp:113
TrackerValueDesc::myTmpLastAggValue
double myTmpLastAggValue
Temporary storage for the last aggregation interval.
Definition: TrackerValueDesc.h:131
TrackerValueDesc
Representation of a timeline of floats with their names and moments.
Definition: TrackerValueDesc.h:42
TrackerValueDesc::getName
const std::string & getName() const
Returns the name of the value.
Definition: TrackerValueDesc.cpp:127
TrackerValueDesc::myMax
double myMax
Definition: TrackerValueDesc.h:113
TrackerValueDesc::myAggregationInterval
int myAggregationInterval
The aggregation interval in simulation steps.
Definition: TrackerValueDesc.h:119
TrackerValueDesc::myAggregatedValues
std::vector< double > myAggregatedValues
Collected values in their aggregated form.
Definition: TrackerValueDesc.h:110
ValueRetriever
Definition: ValueRetriever.h:32
ValueRetriever.h
TrackerValueDesc::myMin
double myMin
The minimum and the maximum of the value.
Definition: TrackerValueDesc.h:113
TrackerValueDesc::myRecordingBegin
SUMOTime myRecordingBegin
The time step the values are added from.
Definition: TrackerValueDesc.h:128
TrackerValueDesc::myActiveCol
RGBColor myActiveCol
The color to use when the value is set as "active".
Definition: TrackerValueDesc.h:101
config.h
TrackerValueDesc::getRange
double getRange() const
returns the maximum value range
Definition: TrackerValueDesc.cpp:83
TrackerValueDesc::getAggregatedValues
const std::vector< double > & getAggregatedValues()
returns the vector of aggregated values The values will be locked - no further addition will be perfo...
Definition: TrackerValueDesc.cpp:120
TrackerValueDesc::getRecordingBegin
SUMOTime getRecordingBegin() const
Returns the timestep the recording started.
Definition: TrackerValueDesc.cpp:172
TrackerValueDesc::myInvalidValue
double myInvalidValue
Values like this shall not be counted on aggregation.
Definition: TrackerValueDesc.h:122
TrackerValueDesc::getAggregationSpan
SUMOTime getAggregationSpan() const
get the aggregation amount
Definition: TrackerValueDesc.cpp:166
TrackerValueDesc::TrackerValueDesc
TrackerValueDesc(const std::string &name, const RGBColor &col, SUMOTime recordBegin, double aggregationSeconds)
Constructor.
Definition: TrackerValueDesc.cpp:34