SUMO - Simulation of Urban MObility
MSRailSignal.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // A rail signal logic
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2002-2015 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef MSRailSignal_h
22 #define MSRailSignal_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 //#include <utility>
35 //#include <vector>
36 //#include <bitset>
37 //#include <map>
38 //#include <microsim/MSEventControl.h>
40 //#include "MSSimpleTrafficLightLogic.h"
41 #include "MSPhaseDefinition.h"
42 #include "MSTLLogicControl.h"
43 //#include <microsim/output/MSInductLoop.h>
44 
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
55 public:
62  MSRailSignal(MSTLLogicControl& tlcontrol,
63  const std::string& id, const std::string& subid,
64  const std::map<std::string, std::string>& parameters);
65 
66 
71  void init(NLDetectorBuilder& nb);
72 
73 
75  ~MSRailSignal();
76 
79 
86 
87 
90 
91 
99  std::string getAppropriateState();
100 
102  void updateCurrentPhase();
103 
109 
111 
112 
115 
120  unsigned int getPhaseNumber() const;
121 
122 
127  const Phases& getPhases() const;
128 
137  const MSPhaseDefinition& getPhase(unsigned int givenstep) const;
138 
142  const std::string getLogicType() const {
143  return "railSignal";
144  }
146 
147 
150 
155  unsigned int getCurrentPhaseIndex() const;
156 
157 
161  const MSPhaseDefinition& getCurrentPhaseDef() const;
163 
164 
167 
172  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
173 
174 
180  SUMOTime getOffsetFromIndex(unsigned int index) const;
181 
182 
188  unsigned int getIndexFromOffset(SUMOTime offset) const;
190 
191 
194 
202  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep, unsigned int step, SUMOTime stepDuration) {
203  UNUSED_PARAMETER(tlcontrol);
204  UNUSED_PARAMETER(simStep);
205  UNUSED_PARAMETER(step);
206  UNUSED_PARAMETER(stepDuration);
207  }
209 
210 protected:
211 
213  std::vector<MSLane*> myOutgoingLanes;
214 
216  std::map<MSLink*, unsigned int> myLinkIndices;
217 
219  std::map<MSLane*, std::vector<MSLink*> > myLinksToLane;
220 
222  std::map<MSLink*, std::vector<MSLane*> > myAfferentBlocks;
223 
225  std::map<MSLane*, std::vector<const MSLane*> > mySucceedingBlocks;
226 
227 
228 protected:
229 
235 
238 
239 };
240 
241 
242 #endif
243 
244 /****************************************************************************/
245 
std::map< MSLink *, std::vector< 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:222
Builds detectors for microsim.
void updateCurrentPhase()
updates the current phase of the signal
A signal for rails.
Definition: MSRailSignal.h:54
const MSPhaseDefinition & getPhase(unsigned int givenstep) const
Returns the definition of the phase from the given position within the plan.
std::map< MSLink *, unsigned int > myLinkIndices
A map that maps a link to its link index.
Definition: MSRailSignal.h:216
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:219
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, unsigned int step, SUMOTime stepDuration)
Changes the current phase and her duration.
Definition: MSRailSignal.h:202
A class that stores and controls tls and switching of their programs.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
std::vector< MSLane * > myOutgoingLanes
The set of lanes going out from the junction.
Definition: MSRailSignal.h:213
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:234
SUMOTime getOffsetFromIndex(unsigned int index) const
Returns the position (start of a phase during a cycle) from of a given step.
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:225
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
SUMOTime trySwitch()
Switches to the next phase.
unsigned int getPhaseNumber() const
Returns the number of phases.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
unsigned int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
unsigned int getCurrentPhaseIndex() const
Returns the current index within the program.
void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
const std::string getLogicType() const
Returns the type of the logic as a string.
Definition: MSRailSignal.h:142
const Phases & getPhases() const
Returns the phases of this tls program.
int SUMOTime
Definition: SUMOTime.h:43
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:237
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.
~MSRailSignal()
Destructor.