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.dev/sumo
3 // Copyright (C) 2001-2024 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 /****************************************************************************/
19 // Representation of a timeline of floats with their names and moments
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
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 };
long long int SUMOTime
Definition: GUI.h:35
Representation of a timeline of floats with their names and moments.
void addValue(double value)
Adds a new value to the list.
void setAggregationSpan(SUMOTime as)
set the aggregation amount
RGBColor myActiveCol
The color to use when the value is set as "active".
int myValidNo
Counter for valid numbers within the current aggregation interval.
const std::string & getName() const
Returns the name of the value.
double getMax() const
Returns the values maximum.
void unlockValues()
Releases the locking after the values have been drawn.
std::vector< double > myValues
Values collected.
~TrackerValueDesc()
Destructor.
double getYCenter() const
Returns the center of the value.
SUMOTime myRecordingBegin
The time step the values are added from.
double getRange() const
returns the maximum value range
std::string myName
The name of the value.
const std::vector< double > & getValues()
returns the vector of collected values The values will be locked - no further addition will be perfom...
SUMOTime getAggregationSpan() const
get the aggregation amount
const std::vector< double > & getAggregatedValues()
returns the vector of aggregated values The values will be locked - no further addition will be perfo...
const RGBColor & getColor() const
Returns the color to use to display the value.
SUMOTime getRecordingBegin() const
Returns the timestep the recording started.
double myTmpLastAggValue
Temporary storage for the last aggregation interval.
double getMin() const
Returns the values minimum.
int myAggregationInterval
The aggregation interval in simulation steps.
RGBColor myInactiveCol
The color to use when the value is set as "inactive".
double myInvalidValue
Values like this shall not be counted on aggregation.
TrackerValueDesc(const std::string &name, const RGBColor &col, SUMOTime recordBegin, double aggregationSeconds)
Constructor.
double myMin
The minimum and the maximum of the value.
std::vector< double > myAggregatedValues
Collected values in their aggregated form.