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-2023 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// ===========================================================================
28class MSRailSignal;
29class MSEdge;
30
31// ===========================================================================
32// class definitions
33// ===========================================================================
39public:
41
43
44 static bool hasInstance() {
45 return myInstance != nullptr;
46 }
47
48 static void cleanup();
49
51 static void clearState();
52
58 void vehicleStateChanged(const SUMOVehicle* const vehicle, MSNet::VehicleState to, const std::string& info = "");
59
61 void registerProtectedDriveway(MSRailSignal* rs, int driveWayID, const MSEdge* protectedBidi);
62
63 const std::set<const MSEdge*>& getUsedEdges() const {
64 return myUsedEdges;
65 }
66
67 void addSignal(MSRailSignal* signal);
68
69 const std::vector<MSRailSignal*>& getSignals() const {
70 return mySignals;
71 }
72
73
74private:
77
79 void updateDriveways(const MSEdge* used);
80
82 std::set<const MSEdge*> myUsedEdges;
83
85 std::map<const MSEdge*, std::vector<std::pair<MSRailSignal*, int> > > myProtectedDriveways;
86
88 std::vector<MSRailSignal*> mySignals;
89
91
92
93};
A road/street connecting two junctions.
Definition: MSEdge.h:77
Interface for objects listening to vehicle state changes.
Definition: MSNet.h:635
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:602
A signal for rails.
void addSignal(MSRailSignal *signal)
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
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
std::vector< MSRailSignal * > mySignals
list of all rail signals
MSRailSignalControl()
Constructor.
std::set< const MSEdge * > myUsedEdges
all rail edges that are part of a known route
static MSRailSignalControl * myInstance
static MSRailSignalControl & getInstance()
const std::set< const MSEdge * > & getUsedEdges() const
void updateDriveways(const MSEdge *used)
compute additioanl deadlock-check requirements for registered driveways
const std::vector< MSRailSignal * > & getSignals() const
static void clearState()
Perform resets events when quick-loading state.
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:62