Eclipse SUMO - Simulation of Urban MObility
MSRailSignalControl.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-2020 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 /****************************************************************************/
18 // Centralized services for rail signal control (Singleton)
19 // - monitors track usage for long-range deadlock prevention
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 #include <microsim/MSNet.h>
24 
25 // ===========================================================================
26 // class declarations
27 // ===========================================================================
28 class MSRailSignal;
29 class MSEdge;
30 
31 // ===========================================================================
32 // class definitions
33 // ===========================================================================
39 public:
41 
43 
44  static bool hasInstance() {
45  return myInstance != nullptr;
46  }
47 
48  static void cleanup();
49 
55  void vehicleStateChanged(const SUMOVehicle* const vehicle, MSNet::VehicleState to, const std::string& info = "");
56 
58  void registerProtectedDriveway(MSRailSignal* rs, int driveWayID, const MSEdge* protectedBidi);
59 
60  const std::set<const MSEdge*>& getUsedEdges() const {
61  return myUsedEdges;
62  }
63 
64 private:
67 
69  void updateDriveways(const MSEdge* used);
70 
72  std::set<const MSEdge*> myUsedEdges;
73 
75  std::map<const MSEdge*, std::vector<std::pair<MSRailSignal*, int> > > myProtectedDriveways;
76 
78 
79 
80 };
A road/street connecting two junctions.
Definition: MSEdge.h:77
Interface for objects listening to vehicle state changes.
Definition: MSNet.h:620
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:587
A signal for rails.
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
const std::set< const MSEdge * > & getUsedEdges() const
std::map< const MSEdge *, std::vector< std::pair< MSRailSignal *, int > > > myProtectedDriveways
map of driveways that must perform additional checks if the key edge is used by a train route
MSRailSignalControl()
Constructor.
std::set< const MSEdge * > myUsedEdges
all rail edges that are part of a known route
static MSRailSignalControl * myInstance
static MSRailSignalControl & getInstance()
void updateDriveways(const MSEdge *used)
compute additioanl deadlock-check requirements for registered driveways
void registerProtectedDriveway(MSRailSignal *rs, int driveWayID, const MSEdge *protectedBidi)
mark driveway that must receive additional checks if protectedBidi is ever used by a train route
A signal for rails.
Definition: MSRailSignal.h:46
Representation of a vehicle.
Definition: SUMOVehicle.h:58