Eclipse SUMO - Simulation of Urban MObility
Command_SaveTLSSwitchStates Class Reference

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

#include <Command_SaveTLSSwitchStates.h>

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

Public Member Functions

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

Data Fields

int priority = 0
 

Private Member Functions

 Command_SaveTLSSwitchStates (const Command_SaveTLSSwitchStates &)
 Invalidated copy constructor. More...
 
Command_SaveTLSSwitchStatesoperator= (const Command_SaveTLSSwitchStates &)
 Invalidated assignment operator. More...
 

Private Attributes

const MSTLLogicControl::TLSLogicVariantsmyLogics
 The traffic light logic to use. More...
 
OutputDevicemyOutputDevice
 The device to write to. More...
 
std::string myPreviousProgramID
 Storage for prior sub-id. More...
 
std::string myPreviousState
 Storage for prior state. More...
 

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_SaveTLSSwitchStates.h.

Constructor & Destructor Documentation

◆ Command_SaveTLSSwitchStates() [1/2]

Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates ( 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 35 of file Command_SaveTLSSwitchStates.cpp.

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

◆ ~Command_SaveTLSSwitchStates()

Command_SaveTLSSwitchStates::~Command_SaveTLSSwitchStates ( )

Destructor.

Definition at line 43 of file Command_SaveTLSSwitchStates.cpp.

◆ Command_SaveTLSSwitchStates() [2/2]

Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates ( const Command_SaveTLSSwitchStates )
private

Invalidated copy constructor.

Member Function Documentation

◆ execute()

SUMOTime Command_SaveTLSSwitchStates::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_SaveTLSSwitchStates.cpp.

References OutputDevice::closeTag(), DELTA_T, MSTLLogicControl::TLSLogicVariants::getActive(), MSTrafficLightLogic::getCurrentPhaseDef(), MSTrafficLightLogic::getCurrentPhaseIndex(), Named::getID(), MSPhaseDefinition::getName(), MSTrafficLightLogic::getProgramID(), MSPhaseDefinition::getState(), myLogics, myOutputDevice, myPreviousProgramID, myPreviousState, OutputDevice::openTag(), SUMO_ATTR_ID, SUMO_ATTR_NAME, SUMO_ATTR_PHASE, SUMO_ATTR_PROGRAMID, SUMO_ATTR_STATE, SUMO_ATTR_TIME, time2string(), and OutputDevice::writeAttr().

◆ operator=()

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

Invalidated assignment operator.

◆ 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.

Field Documentation

◆ myLogics

const MSTLLogicControl::TLSLogicVariants& Command_SaveTLSSwitchStates::myLogics
private

The traffic light logic to use.

Definition at line 83 of file Command_SaveTLSSwitchStates.h.

Referenced by execute().

◆ myOutputDevice

OutputDevice& Command_SaveTLSSwitchStates::myOutputDevice
private

The device to write to.

Definition at line 80 of file Command_SaveTLSSwitchStates.h.

Referenced by Command_SaveTLSSwitchStates(), and execute().

◆ myPreviousProgramID

std::string Command_SaveTLSSwitchStates::myPreviousProgramID
private

Storage for prior sub-id.

Definition at line 89 of file Command_SaveTLSSwitchStates.h.

Referenced by execute().

◆ myPreviousState

std::string Command_SaveTLSSwitchStates::myPreviousState
private

Storage for prior state.

Definition at line 86 of file Command_SaveTLSSwitchStates.h.

Referenced by execute().

◆ priority

int Command::priority = 0
inherited

Definition at line 87 of file Command.h.

Referenced by MSTrafficLightLogic::SwitchCommand::SwitchCommand().


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