Eclipse SUMO - Simulation of Urban MObility
MSLaneSpeedTrigger.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 /****************************************************************************/
21 // Changes the speed allowed on a set of lanes
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <string>
27 #include <vector>
28 #include <utils/common/Command.h>
29 #include <utils/common/Named.h>
32 
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class MSLane;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
51 class MSLaneSpeedTrigger : public Named, public SUMOSAXHandler {
52 public:
60  MSLaneSpeedTrigger(const std::string& id,
61  const std::vector<MSLane*>& destLanes,
62  const std::string& file);
63 
64 
66  virtual ~MSLaneSpeedTrigger();
67 
68 
77 
79 
80  SUMOTime processCommand(bool move2next, SUMOTime currentTime);
81 
82  double getDefaultSpeed() const;
83 
84  void setOverriding(bool val);
85 
86  void setOverridingValue(double val);
87 
88  double getLoadedSpeed();
89 
91  double getCurrentSpeed() const;
92 
94  double getCurrentFriction() const;
95 
97  static const std::map<std::string, MSLaneSpeedTrigger*>& getInstances() {
98  return myInstances;
99  }
100 
101  const std::vector<MSLane*>& getLanes() {
102  return myDestLanes;
103  }
104 
105 protected:
107 
108 
116  virtual void myStartElement(int element,
117  const SUMOSAXAttributes& attrs);
118 
125  virtual void myEndElement(int element);
127 
128 
129 protected:
131  std::vector<MSLane*> myDestLanes;
132 
134  const double myDefaultSpeed;
135 
137  const double myDefaultFriction;
138 
141 
144 
145  std::vector<std::pair<SUMOTime, double> > myLoadedSpeeds;
146  std::vector<std::pair<SUMOTime, double> > myLoadedFrictions;
147  std::vector<std::pair<SUMOTime, double> >::iterator myCurrentSpeedEntry;
148  std::vector<std::pair<SUMOTime, double> >::iterator myCurrentFrictionEntry;
149  static std::map<std::string, MSLaneSpeedTrigger*> myInstances;
150 
151 private:
154 
157 
158  void init();
159 
160 
161 private:
163  bool myDidInit;
164 
165 };
long long int SUMOTime
Definition: GUI.h:35
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
Changes the speed allowed on a set of lanes.
void setOverridingValue(double val)
void setOverriding(bool val)
static std::map< std::string, MSLaneSpeedTrigger * > myInstances
MSLaneSpeedTrigger(const std::string &id, const std::vector< MSLane * > &destLanes, const std::string &file)
Constructor.
const std::vector< MSLane * > & getLanes()
std::vector< std::pair< SUMOTime, double > >::iterator myCurrentFrictionEntry
MSLaneSpeedTrigger & operator=(const MSLaneSpeedTrigger &)
Invalidated assignment operator.
std::vector< std::pair< SUMOTime, double > > myLoadedSpeeds
virtual void myEndElement(int element)
Called on the closing of a tag;.
double getCurrentFriction() const
Returns the current friction.
double getCurrentSpeed() const
Returns the current speed.
double mySpeedOverrideValue
The speed to use if overriding the read speed.
SUMOTime executeFrictionChange(SUMOTime currentTime)
MSLaneSpeedTrigger(const MSLaneSpeedTrigger &)
Invalidated copy constructor.
virtual ~MSLaneSpeedTrigger()
Destructor.
const double myDefaultFriction
The original friction on the lanes.
std::vector< MSLane * > myDestLanes
std::vector< std::pair< SUMOTime, double > >::iterator myCurrentSpeedEntry
std::vector< std::pair< SUMOTime, double > > myLoadedFrictions
bool myAmOverriding
The information whether the read speed shall be overridden.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
SUMOTime executeSpeedChange(SUMOTime currentTime)
Executes a switch command.
const double myDefaultSpeed
The original speed allowed on the lanes.
SUMOTime processCommand(bool move2next, SUMOTime currentTime)
double getDefaultSpeed() const
static const std::map< std::string, MSLaneSpeedTrigger * > & getInstances()
return all MSLaneSpeedTrigger instances
bool myDidInit
The information whether init was called.
Base class for objects which have an id.
Definition: Named.h:54
Encapsulated SAX-Attributes.
SAX-handler base for SUMO-files.