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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // A rail signal logic
19 /****************************************************************************/
20 #ifndef MSRailSignal_h
21 #define MSRailSignal_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 //#include <utility>
34 //#include <vector>
35 //#include <bitset>
36 //#include <map>
37 //#include <microsim/MSEventControl.h>
39 //#include "MSSimpleTrafficLightLogic.h"
40 #include "MSPhaseDefinition.h"
41 #include "MSTLLogicControl.h"
42 //#include <microsim/output/MSInductLoop.h>
43 
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
54 public:
61  MSRailSignal(MSTLLogicControl& tlcontrol,
62  const std::string& id, const std::string& subid,
63  const std::map<std::string, std::string>& parameters);
64 
65 
70  void init(NLDetectorBuilder& nb);
71 
72 
74  ~MSRailSignal();
75 
78 
85 
86 
89 
90 
98  std::string getAppropriateState();
99 
101  void updateCurrentPhase();
102 
108 
110 
111 
114 
119  int getPhaseNumber() const;
120 
121 
126  const Phases& getPhases() const;
127 
136  const MSPhaseDefinition& getPhase(int givenstep) const;
137 
141  const std::string getLogicType() const {
142  return "railSignal";
143  }
145 
146 
149 
154  int getCurrentPhaseIndex() const;
155 
156 
160  const MSPhaseDefinition& getCurrentPhaseDef() const;
162 
163 
166 
171  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
172 
173 
179  SUMOTime getOffsetFromIndex(int index) const;
180 
181 
187  int getIndexFromOffset(SUMOTime offset) const;
189 
190 
193 
201  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration) {
202  UNUSED_PARAMETER(tlcontrol);
203  UNUSED_PARAMETER(simStep);
204  UNUSED_PARAMETER(step);
205  UNUSED_PARAMETER(stepDuration);
206  }
208 
209 protected:
210 
212  std::vector<MSLane*> myOutgoingLanes;
213 
215  std::map<MSLink*, int> myLinkIndices;
216 
218  std::map<MSLane*, std::vector<MSLink*> > myLinksToLane;
219 
221  std::map<MSLink*, std::vector<const MSLane*> > myAfferentBlocks;
222 
224  std::map<MSLane*, std::vector<const MSLane*> > mySucceedingBlocks;
225 
227  std::map<const MSLane*, const MSLink*> mySucceedingBlocksIncommingLinks;
228 
229 
230 protected:
231 
237 
240 
241 };
242 
243 
244 #endif
245 
246 /****************************************************************************/
247 
Builds detectors for microsim.
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:53
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
Definition: MSRailSignal.h:201
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:218
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:227
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
std::map< MSLink *, int > myLinkIndices
A map that maps a link to its link index.
Definition: MSRailSignal.h:215
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:212
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:236
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:224
int getPhaseNumber() const
Returns the number of phases.
const std::string getLogicType() const
Returns the type of the logic as a string.
Definition: MSRailSignal.h:141
SUMOTime trySwitch()
Switches to the next phase.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
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.
long long int SUMOTime
Definition: TraCIDefs.h:51
MSPhaseDefinition myCurrentPhase
The current phase.
Definition: MSRailSignal.h:239
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:221
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.
MSRailSignal(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &subid, const std::map< std::string, std::string > &parameters)
Constructor.
int getCurrentPhaseIndex() const
Returns the current index within the program.
~MSRailSignal()
Destructor.