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& subid,
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;
131 
135  const std::string getLogicType() const {
136  return "railSignal";
137  }
139 
140 
143 
148  int getCurrentPhaseIndex() const;
149 
150 
154  const MSPhaseDefinition& getCurrentPhaseDef() const;
156 
157 
160 
165  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
166 
167 
173  SUMOTime getOffsetFromIndex(int index) const;
174 
175 
181  int getIndexFromOffset(SUMOTime offset) const;
183 
184 
187 
195  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration) {
196  UNUSED_PARAMETER(tlcontrol);
197  UNUSED_PARAMETER(simStep);
198  UNUSED_PARAMETER(step);
199  UNUSED_PARAMETER(stepDuration);
200  }
202 
203 protected:
204 
206  std::vector<MSLane*> myOutgoingLanes;
207 
209  std::map<MSLink*, int> myLinkIndices;
210 
212  std::map<MSLane*, std::vector<MSLink*> > myLinksToLane;
213 
215  std::map<MSLink*, std::vector<const MSLane*> > myAfferentBlocks;
216 
218  std::map<MSLane*, std::vector<const MSLane*> > mySucceedingBlocks;
219 
221  std::map<const MSLane*, const MSLink*> mySucceedingBlocksIncommingLinks;
222 
223 
224 protected:
225 
231 
234 
235  static int myNumWarnings;
236 
237 };
238 
239 
240 #endif
241 
242 /****************************************************************************/
243 
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:195
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:212
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:221
#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:209
static int myNumWarnings
Definition: MSRailSignal.h:235
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:206
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:230
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:218
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:135
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.
MSPhaseDefinition myCurrentPhase
The current phase.
Definition: MSRailSignal.h:233
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:215
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.