Eclipse SUMO - Simulation of Urban MObility
Command Class Referenceabstract

Base (microsim) event class. More...

#include <Command.h>

Inheritance diagram for Command:
[legend]

Public Member Functions

 Command ()
 Constructor. More...
 
virtual SUMOTime execute (SUMOTime currentTime)=0
 Executes the command. More...
 
virtual SUMOTime shiftTime (SUMOTime, SUMOTime, SUMOTime)
 Reschedule or deschedule the command when quick-loading state. More...
 
virtual ~Command ()
 Destructor. More...
 

Data Fields

int priority = 0
 

Detailed Description

Base (microsim) event class.

Classes derived from Command may be added to MSEventControl instances in order to be executed at a certain time step.

As soon as the simulation reaches the desired time step, the command (event) is executed by calling "execute" with the current time step. The method must return either 0, if the event shall not be executed again or a positive value (in simulation seconds) that described when it shall be executed again. The method must not return a value below zero, the behaviour is undefined in this case.

Warning
The EventControl the Command is added to gets responsible for this command's deletion.
See also
Design Patterns, Gamma et al.
WrappingCommand
MSEventControl

Definition at line 50 of file Command.h.

Constructor & Destructor Documentation

◆ Command()

Command::Command ( )
inline

Constructor.

Definition at line 53 of file Command.h.

◆ ~Command()

virtual Command::~Command ( )
inlinevirtual

Destructor.

Definition at line 57 of file Command.h.

Member Function Documentation

◆ execute()

virtual SUMOTime Command::execute ( SUMOTime  currentTime)
pure virtual

Executes the command.

The implementations should return 0 if the command shall not be repeated, or a value larger than 0 that describe the time after which the command shall be executed again. Values below 0 must not be returned.

Parameters
[in]currentTimeThe current simulation time
Returns
The time after which the command shall be executed again, 0 if this command shall be descheduled.
Exceptions
ProcessErrorDerived actions may throw this exception

Implemented in MSTLLogicControl::SwitchInitCommand, MSPModel_JuPedSim::Event, WrappingCommand< T >, WrappingCommand< MSTransportable >, WrappingCommand< MSDevice_Routing >, WrappingCommand< MSDevice_ToC >, WrappingCommand< MSTransportableDevice_Routing >, WrappingCommand< MSDevice_StationFinder >, StaticCommand< T >, ParametrisedWrappingCommand< T, S >, MSCalibrator::CalibratorCommand, MSCalibrator, MSStageDriving::BookReservation, MSPModel_Striping::MovePedestrians, MSPModel_NonInteracting::MoveToNextEdge, MSPerson::MSPersonStage_Access::ProceedCmd, MSTrafficLightLogic::SwitchCommand, MSVTypeProbe, MSVehicleControl::DeleteKeptVehicle, MSTransportableDevice_FCDReplay::MovePedestrians, MSDevice_FCDReplay::MoveVehicles, MSDevice_BTreceiver::BTreceiverUpdate, Command_RouteReplacement, Command_SaveTLSSwitchStates, Command_SaveTLSSwitches, Command_SaveTLSState, Command_SaveTLSProgram, METriggeredCalibrator, Command_Hotkey_TrafficLight, and Command_Hotkey_InductionLoop.

Referenced by MSEventControl::execute().

Here is the caller graph for this function:

◆ shiftTime()

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

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

◆ priority

int Command::priority = 0

Definition at line 87 of file Command.h.

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


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