Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
Command_SaveTLSProgram Class Reference

Writes the switch times of a tls into a file when the tls switches. More...

#include <Command_SaveTLSProgram.h>

Inheritance diagram for Command_SaveTLSProgram:
[legend]
Collaboration diagram for Command_SaveTLSProgram:
[legend]

Public Member Functions

 Command_SaveTLSProgram (const MSTLLogicControl::TLSLogicVariants &logics, OutputDevice &od)
 Constructor.
virtual SUMOTime shiftTime (SUMOTime, SUMOTime, SUMOTime)
 Reschedule or deschedule the command when quick-loading state.
 ~Command_SaveTLSProgram ()
 Destructor.
Derived from Command
SUMOTime execute (SUMOTime currentTime)
 Writes the state of the tls if a change occurred.

Data Fields

int priority = 0

Private Member Functions

 Command_SaveTLSProgram (const Command_SaveTLSProgram &)
 Invalidated copy constructor.
Command_SaveTLSProgramoperator= (const Command_SaveTLSProgram &)
 Invalidated assignment operator.
void writeCurrent ()
 Write the current program.

Private Attributes

const MSTLLogicControl::TLSLogicVariantsmyLogics
 The traffic light logic to use.
OutputDevicemyOutputDevice
 The device to write to.
std::string myPreviousProgramID
 Storage for prior sub-id.
std::vector< MSPhaseDefinitionmyPreviousStates
 Storage for prior state.
std::string myTLSID
 Storage for the tls ID (needed in destructor).

Detailed Description

Writes the switch times of a tls into a file when the tls switches.

Todo
Revalidate this - as tls are not seting the link information directly ater being switched, the computed information may be delayed

Definition at line 46 of file Command_SaveTLSProgram.h.

Constructor & Destructor Documentation

◆ Command_SaveTLSProgram() [1/2]

Command_SaveTLSProgram::Command_SaveTLSProgram ( const MSTLLogicControl::TLSLogicVariants & logics,
OutputDevice & od )

Constructor.

Parameters
[in]tllsThe logic to write state of
[in]odThe output device to write the state into

Definition at line 34 of file Command_SaveTLSProgram.cpp.

References MSEventControl::addEvent(), MSNet::getEndOfTimestepEvents(), MSNet::getInstance(), myLogics, and myOutputDevice.

Referenced by Command_SaveTLSProgram(), and operator=().

Here is the caller graph for this function:

◆ ~Command_SaveTLSProgram()

Command_SaveTLSProgram::~Command_SaveTLSProgram ( )

Destructor.

Definition at line 42 of file Command_SaveTLSProgram.cpp.

References writeCurrent().

◆ Command_SaveTLSProgram() [2/2]

Command_SaveTLSProgram::Command_SaveTLSProgram ( const Command_SaveTLSProgram & )
private

Invalidated copy constructor.

References Command_SaveTLSProgram().

Member Function Documentation

◆ execute()

SUMOTime Command_SaveTLSProgram::execute ( SUMOTime currentTime)
virtual

Writes the state of the tls if a change occurred.

If the state or the active program has changed, the state is written to the output device.

Parameters
[in]currentTimeThe current simulation time
Returns
Always DELTA_T (will be executed in next time step)
See also
Command
Todo
Here, a discrete even (on switch / program change) would be appropriate

Implements Command.

Definition at line 48 of file Command_SaveTLSProgram.cpp.

References DELTA_T, myLogics, myPreviousProgramID, myPreviousStates, myTLSID, and writeCurrent().

◆ operator=()

Command_SaveTLSProgram & Command_SaveTLSProgram::operator= ( const Command_SaveTLSProgram & )
private

Invalidated assignment operator.

References Command_SaveTLSProgram().

◆ shiftTime()

virtual SUMOTime Command::shiftTime ( SUMOTime ,
SUMOTime ,
SUMOTime  )
inlinevirtualinherited

Reschedule or deschedule the command when quick-loading state.

The implementations should return -1 if the command shall not be re-scheduled, or a value >= 0 that describe the new time at which the command shall be executed again.

Parameters
[in]currentTimeThe current simulation time
[in]execTimeThe time at which the command would have been executed
[in]newTimeThe simulation time at which the simulation is restarted
Returns
The time at which the command shall be executed again

Reimplemented in MSCalibrator::CalibratorCommand, and MSTrafficLightLogic::SwitchCommand.

Definition at line 83 of file Command.h.

◆ writeCurrent()

void Command_SaveTLSProgram::writeCurrent ( )
private

Write the current program.

Definition at line 64 of file Command_SaveTLSProgram.cpp.

References myOutputDevice, myPreviousProgramID, myPreviousStates, myTLSID, STEPS2TIME, SUMO_ATTR_DURATION, SUMO_ATTR_ID, SUMO_ATTR_NAME, SUMO_ATTR_PROGRAMID, SUMO_ATTR_STATE, SUMO_ATTR_TYPE, SUMO_TAG_PHASE, SUMO_TAG_TLLOGIC, and TIME2STEPS.

Referenced by execute(), and ~Command_SaveTLSProgram().

Here is the caller graph for this function:

Field Documentation

◆ myLogics

const MSTLLogicControl::TLSLogicVariants& Command_SaveTLSProgram::myLogics
private

The traffic light logic to use.

Definition at line 86 of file Command_SaveTLSProgram.h.

Referenced by Command_SaveTLSProgram(), and execute().

◆ myOutputDevice

OutputDevice& Command_SaveTLSProgram::myOutputDevice
private

The device to write to.

Definition at line 83 of file Command_SaveTLSProgram.h.

Referenced by Command_SaveTLSProgram(), and writeCurrent().

◆ myPreviousProgramID

std::string Command_SaveTLSProgram::myPreviousProgramID
private

Storage for prior sub-id.

Definition at line 92 of file Command_SaveTLSProgram.h.

Referenced by execute(), and writeCurrent().

◆ myPreviousStates

std::vector<MSPhaseDefinition> Command_SaveTLSProgram::myPreviousStates
private

Storage for prior state.

Definition at line 89 of file Command_SaveTLSProgram.h.

Referenced by execute(), and writeCurrent().

◆ myTLSID

std::string Command_SaveTLSProgram::myTLSID
private

Storage for the tls ID (needed in destructor).

Definition at line 95 of file Command_SaveTLSProgram.h.

Referenced by execute(), and writeCurrent().

◆ priority

int Command::priority = 0
inherited

The documentation for this class was generated from the following files: