SUMO - Simulation of Urban MObility
MSRailSignal.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2018 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 // A rail signal logic
17 /****************************************************************************/
18 #ifndef MSRailSignal_h
19 #define MSRailSignal_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 //#include <utility>
28 //#include <vector>
29 //#include <bitset>
30 //#include <map>
31 //#include <microsim/MSEventControl.h>
33 //#include "MSSimpleTrafficLightLogic.h"
34 #include "MSPhaseDefinition.h"
35 #include "MSTLLogicControl.h"
36 //#include <microsim/output/MSInductLoop.h>
37 
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
48 public:
55  MSRailSignal(MSTLLogicControl& tlcontrol,
56  const std::string& id, const std::string& programID,
57  const std::map<std::string, std::string>& parameters);
58 
59 
64  void init(NLDetectorBuilder& nb);
65 
66 
68  ~MSRailSignal();
69 
72 
79 
80 
83 
84 
92  std::string getAppropriateState();
93 
95  void updateCurrentPhase();
96 
102 
104 
105 
108 
113  int getPhaseNumber() const;
114 
115 
120  const Phases& getPhases() const;
121 
130  const MSPhaseDefinition& getPhase(int givenstep) const;
132 
133 
136 
141  int getCurrentPhaseIndex() const;
142 
143 
147  const MSPhaseDefinition& getCurrentPhaseDef() const;
149 
150 
153 
158  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
159 
160 
166  SUMOTime getOffsetFromIndex(int index) const;
167 
168 
174  int getIndexFromOffset(SUMOTime offset) const;
176 
177 
180 
188  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration) {
189  UNUSED_PARAMETER(tlcontrol);
190  UNUSED_PARAMETER(simStep);
191  UNUSED_PARAMETER(step);
192  UNUSED_PARAMETER(stepDuration);
193  }
195 
196 protected:
197 
199  std::vector<MSLane*> myOutgoingLanes;
200 
202  std::map<MSLink*, int> myLinkIndices;
203 
205  std::map<MSLane*, std::vector<MSLink*> > myLinksToLane;
206 
208  std::map<MSLink*, std::vector<const MSLane*> > myAfferentBlocks;
209 
211  std::map<MSLane*, std::vector<const MSLane*> > mySucceedingBlocks;
212 
214  std::map<const MSLane*, const MSLink*> mySucceedingBlocksIncommingLinks;
215 
216 
217 protected:
218 
224 
227 
228  static int myNumWarnings;
229 
230 };
231 
232 
233 #endif
234 
235 /****************************************************************************/
236 
Builds detectors for microsim.
long long int SUMOTime
Definition: SUMOTime.h:36
void updateCurrentPhase()
updates the current phase of the signal
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
A signal for rails.
Definition: MSRailSignal.h:47
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
Definition: MSRailSignal.h:188
std::map< MSLane *, std::vector< MSLink * > > myLinksToLane
A map that maps an outgoing lane from the junction to its set of links that lead to this lane...
Definition: MSRailSignal.h:205
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
std::map< const MSLane *, const MSLink * > mySucceedingBlocksIncommingLinks
A map of lanes to links of approaching vehicles of succeeding blocks.
Definition: MSRailSignal.h:214
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:33
std::map< MSLink *, int > myLinkIndices
A map that maps a link to its link index.
Definition: MSRailSignal.h:202
static int myNumWarnings
Definition: MSRailSignal.h:228
A class that stores and controls tls and switching of their programs.
std::vector< MSLane * > myOutgoingLanes
The set of lanes going out from the junction.
Definition: MSRailSignal.h:199
void init(NLDetectorBuilder &nb)
Initialises the rail signal with information about adjacent rail signals.
Phases myPhases
The list of phases this logic uses.
Definition: MSRailSignal.h:223
const Phases & getPhases() const
Returns the phases of this tls program.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
std::map< MSLane *, std::vector< const MSLane * > > mySucceedingBlocks
A map that maps an outgoing lane from the junction to its vector of lanes leading to the next signal...
Definition: MSRailSignal.h:211
int getPhaseNumber() const
Returns the number of phases.
SUMOTime trySwitch()
Switches to the next phase.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
MSRailSignal(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, const std::map< std::string, std::string > &parameters)
Constructor.
void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
std::string getAppropriateState()
returns the state of the signal that actually required
The parent class for traffic light logics.
MSPhaseDefinition myCurrentPhase
The current phase.
Definition: MSRailSignal.h:226
std::map< MSLink *, std::vector< const MSLane * > > myAfferentBlocks
A map that maps a link from the junction to its vector of lanes leading from a previous signal to thi...
Definition: MSRailSignal.h:208
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
The definition of a single phase of a tls logic.
int getCurrentPhaseIndex() const
Returns the current index within the program.
~MSRailSignal()
Destructor.