NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
netsignalgroupcontrollerwithqueuing.h
Go to the documentation of this file.
1#ifndef NETSIGNALGROUPCONTROLLERWITHQUEUING_H
2#define NETSIGNALGROUPCONTROLLERWITHQUEUING_H
3
4
5#include "../util/map.h"
6#include "../util/vector.h"
7#include <deque>
8#include <set>
9
10class NetLink; // Forward declaration of NetLink class
11class NetNode; // Forward declaration of NetNode class
12class NetSignal; // Forward declaration of NetSignal class
13class Train; // Forward declaration of a train
14
21{
22private:
23 // Timeout for network signal in seconds.
24 double timeout;
25
26 // Queue of waiting trains along with their associated timestamps.
27 std::deque<std::pair<std::shared_ptr<Train>, double>> waitingTrains;
28
29 // Collection of network signals associated with this controller.
30 Vector<std::shared_ptr<NetSignal>> networkSignalsGroup;
31
32 // Collection of nodes that this controller is associated with.
34
35 // Map tracking the movement status of different network signals.
36 Map<std::shared_ptr<NetSignal>, bool> movements;
37
38 // The timestamp at which the controller last updated.
39 double timeStamp;
40
41 double clearTrainsAt;
42
43public:
44
54 NetSignalGroupControllerWithQueuing(std::set<std::shared_ptr<NetNode>> nodes,
55 double timeStep);
56
66
73 void addNode(std::shared_ptr<NetNode> node);
74
84 void addTrain(std::shared_ptr<Train> train, double simulatorTime);
85
97 void sendPassRequestToControlTo(std::shared_ptr<Train> train,
98 std::shared_ptr<NetSignal> networkSignal,
99 double& simulatorTime,
100 Vector<std::shared_ptr<NetSignal>> &sameDirectionSignals);
101
102 void clearTimeoutTrains(double simulatorTime);
114 void updateTimeStep(std::shared_ptr<Train> train,
115 std::shared_ptr<NetSignal> networkSignal,
116 double& simulatorTime,
117 Vector<std::shared_ptr<NetSignal>> &sameDirectionSignals);
118
127 std::pair<Vector<std::shared_ptr<NetSignal> >,
129
138 void turnOffSignals(Vector<std::shared_ptr<NetSignal>> turnOffSignals);
139
140
141private:
150 void setOpenSignals(Vector<std::shared_ptr<NetSignal>>& sameDirectionSignals);
151
158 void clearMovements();
159};
160
161#endif // NETSIGNALGROUPCONTROLLERWITHQUEUING_H
A map.
Definition map.h:26
The NetNode class represents a network node in a simulation.
Definition netnode.h:35
Responsible for controlling and queuing network signals and managing train movements.
Definition netsignalgroupcontrollerwithqueuing.h:21
void sendPassRequestToControlTo(std::shared_ptr< Train > train, std::shared_ptr< NetSignal > networkSignal, double &simulatorTime, Vector< std::shared_ptr< NetSignal > > &sameDirectionSignals)
Send Pass Request to Control.
Definition netsignalgroupcontrollerwithqueuing.cpp:100
std::pair< Vector< std::shared_ptr< NetSignal > >, Vector< std::shared_ptr< NetSignal > > > getFeedback()
Get Feedback.
Definition netsignalgroupcontrollerwithqueuing.cpp:179
void clearTimeoutTrains(double simulatorTime)
Definition netsignalgroupcontrollerwithqueuing.cpp:153
void updateTimeStep(std::shared_ptr< Train > train, std::shared_ptr< NetSignal > networkSignal, double &simulatorTime, Vector< std::shared_ptr< NetSignal > > &sameDirectionSignals)
Update Time Step.
Definition netsignalgroupcontrollerwithqueuing.cpp:59
void turnOffSignals(Vector< std::shared_ptr< NetSignal > > turnOffSignals)
Turn off signal.
Definition netsignalgroupcontrollerwithqueuing.cpp:208
void addNode(std::shared_ptr< NetNode > node)
Clear Movements.
Definition netsignalgroupcontrollerwithqueuing.cpp:37
void addTrain(std::shared_ptr< Train > train, double simulatorTime)
Add Train.
Definition netsignalgroupcontrollerwithqueuing.cpp:86
Vector< std::shared_ptr< NetSignal > > getControllerSignals()
Get the signals this controller is managing.
Definition netsignalgroupcontrollerwithqueuing.cpp:221
The NetSignal class represents a network signal in a simulation.
Definition netsignal.h:35
A train.
Definition train.h:42
A vector.
Definition vector.h:24