NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
netsignalgroupcontroller.h
Go to the documentation of this file.
1
17#ifndef NeTrainSim_NetSignalGroupController_h
18#define NeTrainSim_NetSignalGroupController_h
19
20#include <memory>
21#include <string>
22#include <iostream>
23#include <map>
24#include <set>
25#include "../util/vector.h"
26#include "../util/map.h"
27
28class NetLink; // Forward declaration of NetLink class
29class NetNode; // Forward declaration of NetNode class
30class NetSignal; // Forward declaration of NetSignal class
31
32using namespace std;
33
39private:
46 static constexpr double timeout = 5;
47
48 static unsigned int NumberOfSignalsInSimulator;
50public:
55 double timeStamp;
56 std::shared_ptr<NetSignal> lockedOnSignal;
63 NetSignalGroupController(std::set<std::shared_ptr<NetNode>> nodes);
64
68 void clear();
69
74 void addNode(std::shared_ptr<NetNode> node);
75
82 void sendPassRequestToControlTo(std::shared_ptr<NetSignal> networkSignal,
83 double& simulationTime,
84 Vector<std::shared_ptr<NetSignal>>& sameDirectionSignals);
85
90 void updateTimeStep(double& timeStep);
91
96 std::pair<std::shared_ptr<NetSignal>, Vector<std::shared_ptr<NetSignal>>> getFeedback();
97
102 void setSignalsInSameDirection(Vector<std::shared_ptr<NetSignal>> sameDirectionSignals);
103
110 friend ostream& operator<<(ostream& ostr, const NetSignalGroupController& group);
111
112private:
117 void turnOffSignals(Vector<std::shared_ptr<NetSignal>> turnOffSignals);
118};
119
120#endif // NeTrainSim_NetSignalGroupController_h
A map.
Definition map.h:26
The NetNode class represents a network node in a simulation.
Definition netnode.h:35
The NetSignalGroupController class represents a controller for handling network signal groups in a si...
Definition netsignalgroupcontroller.h:38
void clear()
Clears the controller to its initial state.
Definition netsignalgroupcontroller.cpp:115
std::pair< std::shared_ptr< NetSignal >, Vector< std::shared_ptr< NetSignal > > > getFeedback()
Gets the feedback on which signals should be turned on/off.
Definition netsignalgroupcontroller.cpp:92
Vector< std::shared_ptr< NetNode > > atNodes
The nodes confined by this group controller.
Definition netsignalgroupcontroller.h:52
void sendPassRequestToControlTo(std::shared_ptr< NetSignal > networkSignal, double &simulationTime, Vector< std::shared_ptr< NetSignal > > &sameDirectionSignals)
Sends a pass request to control a specific network signal.
Definition netsignalgroupcontroller.cpp:35
void updateTimeStep(double &timeStep)
Updates the controller state based on the time step.
Definition netsignalgroupcontroller.cpp:86
std::shared_ptr< NetSignal > lockedOnSignal
The locked network signal.
Definition netsignalgroupcontroller.h:56
void addNode(std::shared_ptr< NetNode > node)
Adds a node to the group controller.
Definition netsignalgroupcontroller.cpp:22
double timeStamp
The timestamp of the controller.
Definition netsignalgroupcontroller.h:55
Vector< std::shared_ptr< NetLink > > confinedLinks
The confined links in the group.
Definition netsignalgroupcontroller.h:53
Vector< std::shared_ptr< NetSignal > > networkSignalsGroup
The network signals in the group.
Definition netsignalgroupcontroller.h:51
Vector< std::shared_ptr< NetSignal > > otherDirectionSignals
The signals in the opposite direction.
Definition netsignalgroupcontroller.h:57
friend ostream & operator<<(ostream &ostr, const NetSignalGroupController &group)
Overloaded ostream operator for printing the NetSignalGroupController object.
void setSignalsInSameDirection(Vector< std::shared_ptr< NetSignal > > sameDirectionSignals)
Sets the signals in the same direction as the train.
Definition netsignalgroupcontroller.cpp:72
Map< std::shared_ptr< NetSignal >, bool > movements
The movement status of the signals.
Definition netsignalgroupcontroller.h:54
The NetSignal class represents a network signal in a simulation.
Definition netsignal.h:35
A vector.
Definition vector.h:24