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.org/sumo
3 // Copyright (C) 2001-2022 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>
31 #include "MSTrigger.h"
32 
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class MSLane;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
51 class MSLaneSpeedTrigger : public MSTrigger, public SUMOSAXHandler, public Command {
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 
76  SUMOTime execute(SUMOTime currentTime);
77 
78 
79  SUMOTime processCommand(bool move2next, SUMOTime currentTime);
80 
81  double getDefaultSpeed() const;
82 
83  void setOverriding(bool val);
84 
85  void setOverridingValue(double val);
86 
87  double getLoadedSpeed();
88 
90  double getCurrentSpeed() const;
91 
93  static const std::map<std::string, MSLaneSpeedTrigger*>& getInstances() {
94  return myInstances;
95  }
96 
97  const std::vector<MSLane*>& getLanes() {
98  return myDestLanes;
99  }
100 
101 protected:
103 
104 
112  virtual void myStartElement(int element,
113  const SUMOSAXAttributes& attrs);
114 
121  virtual void myEndElement(int element);
123 
124 
125 protected:
127  std::vector<MSLane*> myDestLanes;
128 
131 
134 
137 
140 
141  std::vector<std::pair<SUMOTime, double> > myLoadedSpeeds;
142  std::vector<std::pair<SUMOTime, double> >::iterator myCurrentEntry;
143  static std::map<std::string, MSLaneSpeedTrigger*> myInstances;
144 
145 private:
148 
151 
152  void init();
153 
154 
155 private:
157  bool myDidInit;
158 
159 };
long long int SUMOTime
Definition: SUMOTime.h:32
Base (microsim) event class.
Definition: Command.h:50
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Changes the speed allowed on a set of lanes.
void setOverridingValue(double val)
std::vector< std::pair< SUMOTime, double > >::iterator myCurrentEntry
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()
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 getCurrentSpeed() const
Returns the current speed.
double mySpeedOverrideValue
The speed to use if overriding the read speed.
MSLaneSpeedTrigger(const MSLaneSpeedTrigger &)
Invalidated copy constructor.
virtual ~MSLaneSpeedTrigger()
Destructor.
double myDefaultSpeed
The original speed allowed on the lanes.
std::vector< MSLane * > myDestLanes
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 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.
SUMOTime execute(SUMOTime currentTime)
Executes a switch command.
An abstract device that changes the state of the micro simulation.
Definition: MSTrigger.h:38
Encapsulated SAX-Attributes.
SAX-handler base for SUMO-files.