NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
NetLink Class Reference

The NetLink class represents a network link in a simulation. More...

#include <netlink.h>

Public Member Functions

 NetLink (int simulatorID, int linkID, std::shared_ptr< NetNode > fromNode, std::shared_ptr< NetNode > toNode, double maxSpeed, int trafficSignalID, string signalAtEnd, double linkGrade, double linkCurvature, int linkNoOfDirections, double speedVariationfactor, bool isCatenaryAvailable, string linkInRegion, double maxSpeedScale)
 Constructor.
 
 ~NetLink ()
 Destructor.
 
void setLinkSimulatorID (int newID)
 Sets the simulator identifier of the link.
 
void updateLinksScaleFreeSpeed (double newScale)
 Updates the links scale free speed.
 
map< int, double > setGrade (double grade)
 Sets the grade of the link.
 
double getCost ()
 Gets the cost associated with the link.
 
std::pair< std::pair< double, double >, std::pair< double, double > > vectorizeLinkOfOneSegment (std::shared_ptr< NetNode > startNode)
 Creates a vector representation of a link with respect to a given start node.
 
pair< double, double > findPositionOnLink (double travelledLength, std::shared_ptr< NetNode > startNode)
 

Static Public Member Functions

static unsigned int getNumberOfLinks ()
 Gets the number of links in the simulator.
 

Public Attributes

int id
 The identifier of the link.
 
int userID
 The user identifier of the link.
 
std::shared_ptr< NetNodefromLoc
 The starting node of the link.
 
std::shared_ptr< NetNodetoLoc
 The end node of the link.
 
Vector< std::shared_ptr< NetNode > > intermediatePoints
 
double length
 This extends the line link to a polyline link.
 
double freeFlowSpeed
 The free flow speed of the link.
 
int trafficSignalNo
 The traffic network signal number of the link.
 
map< int, double > grade
 The grade of the link.
 
double curvature
 The curvature of the link.
 
int direction
 The direction of the link.
 
double speedVariation
 The speed variation of the link.
 
std::string region
 The region in which the link is located.
 
double linksScaleFreeSpeed
 The free speed scale of the links.
 
Vector< std::shared_ptr< Train > > currentTrains
 A vector of pointers to trains currently on this link.
 
double cost
 The cost associated with this link.
 
bool hasCatenary
 Indicates whether the link has catenary.
 
double catenaryCumRegeneratedEnergy
 The amount of energy regenerated by all trains on the network.
 
double catenaryCumConsumedEnergy
 The amount of energy consumed by all trains on the network.
 
Vector< int > trafficSignalAtEnd
 

Detailed Description

The NetLink class represents a network link in a simulation.

Constructor & Destructor Documentation

◆ NetLink()

NetLink::NetLink ( int  simulatorID,
int  linkID,
std::shared_ptr< NetNode fromNode,
std::shared_ptr< NetNode toNode,
double  maxSpeed,
int  trafficSignalID,
string  signalAtEnd,
double  linkGrade,
double  linkCurvature,
int  linkNoOfDirections,
double  speedVariationfactor,
bool  isCatenaryAvailable,
string  linkInRegion,
double  maxSpeedScale 
)

Constructor.

Parameters
simulatorIDThe simulator identifier of the link.
linkIDThe identifier of the link.
fromNodeThe starting node of the link.
toNodeThe end node of the link.
linkLengthThe length of the link.
maxSpeedThe maximum speed of the link.
trafficSignalIDThe traffic signal identifier of the link.
signalAtEndWhich End of the link, the signal is placed at
linkGradeThe grade of the link.
linkCurvatureThe curvature of the link.
linkNoOfDirectionsThe number of directions of the link.
speedVariationfactorThe speed variation factor of the link.
isCatenaryAvailableIndicates whether catenary is available on the link.
linkInRegionThe region in which the link is located.
lengthScaleThe length scale of the link.
maxSpeedScaleThe maximum speed scale of the link.

◆ ~NetLink()

NetLink::~NetLink ( )

Destructor.

Member Function Documentation

◆ findPositionOnLink()

pair< double, double > NetLink::findPositionOnLink ( double  travelledLength,
std::shared_ptr< NetNode startNode 
)

◆ getCost()

double NetLink::getCost ( )

Gets the cost associated with the link.

Returns
The cost value.

◆ getNumberOfLinks()

unsigned int NetLink::getNumberOfLinks ( )
static

Gets the number of links in the simulator.

Returns
The number of links.

◆ setGrade()

map< int, double > NetLink::setGrade ( double  grade)

Sets the grade of the link.

Parameters
gradeThe grade map.
Returns
The grade map.

◆ setLinkSimulatorID()

void NetLink::setLinkSimulatorID ( int  newID)

Sets the simulator identifier of the link.

Parameters
newIDThe new simulator identifier.

◆ updateLinksScaleFreeSpeed()

void NetLink::updateLinksScaleFreeSpeed ( double  newScale)

Updates the links scale free speed.

Parameters
newScaleThe new scale value.

◆ vectorizeLinkOfOneSegment()

std::pair< std::pair< double, double >, std::pair< double, double > > NetLink::vectorizeLinkOfOneSegment ( std::shared_ptr< NetNode startNode)

Creates a vector representation of a link with respect to a given start node.

Parameters
startNodeA shared_ptr to a NetNode object representing the start node.
Returns
A pair of pairs of doubles, where the first pair represents the coordinates of the start node, and the second pair represents the vector from the start node to the end node.
Author
Ahmed
Date
2/14/2023
Parameters
linkA shared_ptr to a NetLink object.
startNodeA shared_ptr to a NetNode object representing the start node.
Returns
A pair of pairs of doubles, where the first pair represents the coordinates of the start node, and the second pair represents the vector from the start node to the end node.
Author
Ahmed
Date
2/14/2023

Member Data Documentation

◆ catenaryCumConsumedEnergy

double NetLink::catenaryCumConsumedEnergy

The amount of energy consumed by all trains on the network.

◆ catenaryCumRegeneratedEnergy

double NetLink::catenaryCumRegeneratedEnergy

The amount of energy regenerated by all trains on the network.

◆ cost

double NetLink::cost

The cost associated with this link.

◆ currentTrains

Vector<std::shared_ptr<Train> > NetLink::currentTrains

A vector of pointers to trains currently on this link.

◆ curvature

double NetLink::curvature

The curvature of the link.

◆ direction

int NetLink::direction

The direction of the link.

◆ freeFlowSpeed

double NetLink::freeFlowSpeed

The free flow speed of the link.

◆ fromLoc

std::shared_ptr<NetNode> NetLink::fromLoc

The starting node of the link.

◆ grade

map<int, double> NetLink::grade

The grade of the link.

◆ hasCatenary

bool NetLink::hasCatenary

Indicates whether the link has catenary.

◆ id

int NetLink::id

The identifier of the link.

◆ intermediatePoints

Vector<std::shared_ptr<NetNode> > NetLink::intermediatePoints

◆ length

double NetLink::length

This extends the line link to a polyline link.

The length of the link.

◆ linksScaleFreeSpeed

double NetLink::linksScaleFreeSpeed

The free speed scale of the links.

◆ region

std::string NetLink::region

The region in which the link is located.

◆ speedVariation

double NetLink::speedVariation

The speed variation of the link.

◆ toLoc

std::shared_ptr<NetNode> NetLink::toLoc

The end node of the link.

◆ trafficSignalAtEnd

Vector<int> NetLink::trafficSignalAtEnd

◆ trafficSignalNo

int NetLink::trafficSignalNo

The traffic network signal number of the link.

◆ userID

int NetLink::userID

The user identifier of the link.