Eclipse SUMO - Simulation of Urban MObility
MSEventControl Class Reference

Stores time-dependant events and executes them at the proper time. More...

#include <MSEventControl.h>

Inheritance diagram for MSEventControl:
Collaboration diagram for MSEventControl:

Data Structures

class  EventSortCrit
 Sort-criterion for events. More...
 

Public Types

typedef std::pair< Command *, SUMOTimeEvent
 Combination of an event and the time it shall be executed at. More...
 

Public Member Functions

virtual void addEvent (Command *operation, SUMOTime execTimeStep=-1)
 Adds an Event. More...
 
virtual void execute (SUMOTime time)
 Executes time-dependant commands. More...
 
bool isEmpty ()
 Returns whether events are in the que. More...
 
 MSEventControl ()
 Default constructor. More...
 
void setCurrentTimeStep (SUMOTime time)
 Set the current Time. More...
 
virtual ~MSEventControl ()
 Destructor. More...
 

Private Types

typedef std::priority_queue< Event, std::vector< Event >, EventSortCritEventCont
 Container for time-dependant events, e.g. traffic-light-change. More...
 

Private Member Functions

SUMOTime getCurrentTimeStep ()
 get the Current TimeStep used in addEvent. More...
 
 MSEventControl (const MSEventControl &)
 invalid copy constructor. More...
 
MSEventControloperator= (const MSEventControl &)
 invalid assignment operator. More...
 

Private Attributes

SUMOTime currentTimeStep
 The current TimeStep. More...
 
EventCont myEvents
 Event-container, holds executable events. More...
 

Detailed Description

Stores time-dependant events and executes them at the proper time.

Definition at line 49 of file MSEventControl.h.

Member Typedef Documentation

◆ Event

typedef std::pair< Command*, SUMOTime > MSEventControl::Event

Combination of an event and the time it shall be executed at.

Definition at line 52 of file MSEventControl.h.

◆ EventCont

typedef std::priority_queue< Event, std::vector< Event >, EventSortCrit > MSEventControl::EventCont
private

Container for time-dependant events, e.g. traffic-light-change.

Definition at line 125 of file MSEventControl.h.

Constructor & Destructor Documentation

◆ MSEventControl() [1/2]

MSEventControl::MSEventControl ( )

Default constructor.

Definition at line 37 of file MSEventControl.cpp.

◆ ~MSEventControl()

MSEventControl::~MSEventControl ( )
virtual

Destructor.

Definition at line 41 of file MSEventControl.cpp.

References myEvents.

◆ MSEventControl() [2/2]

MSEventControl::MSEventControl ( const MSEventControl )
private

invalid copy constructor.

Member Function Documentation

◆ addEvent()

void MSEventControl::addEvent ( Command operation,
SUMOTime  execTimeStep = -1 
)
virtual

Adds an Event.

Parameters
[in]operationThe event to add
[in]execTimeStepThe time the event shall be executed at (-1 means at sim start)
See also
Command

Reimplemented in GUIEventControl.

Definition at line 52 of file MSEventControl.cpp.

References myEvents.

Referenced by MSPModel_NonInteracting::add(), MSPModel_Striping::add(), MSCModel_NonInteracting::add(), libsumo::Polygon::addDynamics(), GUIEventControl::addEvent(), MSDevice_BTreceiver::BTreceiverUpdate::BTreceiverUpdate(), NLTriggerBuilder::buildVaporizer(), MSPhasedTrafficLightLogic::changeStepAndDuration(), MSSimpleTrafficLightLogic::changeStepAndDuration(), MSTLLogicControl::closeWAUT(), Command_SaveTLSProgram::Command_SaveTLSProgram(), Command_SaveTLSState::Command_SaveTLSState(), Command_SaveTLSSwitches::Command_SaveTLSSwitches(), Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates(), MSParkingArea::enter(), MSCalibrator::init(), MSLaneSpeedTrigger::init(), MSRoutingEngine::initWeightUpdate(), MSParkingArea::leaveFrom(), MSDevice_Routing::MSDevice_Routing(), MSPModel_Remote::MSPModel_Remote(), MSTrafficLightLogic::MSTrafficLightLogic(), MSTransportableDevice_Routing::MSTransportableDevice_Routing(), MSVTypeProbe::MSVTypeProbe(), MSTriggeredRerouter::myEndElement(), MSDevice_Routing::notifyEnter(), MSPerson::MSPersonStage_Access::proceed(), MSDevice_ToC::requestToC(), MSTransportableDevice_Routing::setParameter(), MSTriggeredRerouter::setPermissions(), MSDevice_ToC::triggerDownwardToC(), and MSDevice_ToC::triggerMRM().

◆ execute()

void MSEventControl::execute ( SUMOTime  time)
virtual

Executes time-dependant commands.

Loops over all stored events, continuing until the first event which execution time lies beyond the given time + deltaT. If the event had to be executed before the given time, a warning is generated and the event deleted. Otherwise (the event is valid), the event is executed.

Each executed event must return the time that has to pass until it shall be executed again. If the returned time is 0, the event is deleted. Otherwise it is readded, after the new execution time (returned + current) is computed.

ProcessErrors thrown by executed commands are rethrown.

Parameters
[in]timeThe current simulation time
Exceptions
ProcessErrorFrom an executed Command

Reimplemented in GUIEventControl.

Definition at line 58 of file MSEventControl.cpp.

References DELTA_T, Command::execute(), myEvents, and WRITE_WARNING.

Referenced by GUIEventControl::execute(), and MSNet::simulationStep().

◆ getCurrentTimeStep()

SUMOTime MSEventControl::getCurrentTimeStep ( )
private

get the Current TimeStep used in addEvent.

Definition at line 105 of file MSEventControl.cpp.

References currentTimeStep, MSNet::getCurrentTimeStep(), and MSNet::getInstance().

◆ isEmpty()

bool MSEventControl::isEmpty ( )

Returns whether events are in the que.

Returns
whether events are in the que

Definition at line 95 of file MSEventControl.cpp.

References myEvents.

◆ operator=()

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

invalid assignment operator.

◆ setCurrentTimeStep()

void MSEventControl::setCurrentTimeStep ( SUMOTime  time)

Set the current Time.

This method is only for Unit Testing. Set the current TimeStep used in addEvent. Normally the time is set automatically from an instance of MSNet.

Definition at line 100 of file MSEventControl.cpp.

References currentTimeStep.

Field Documentation

◆ currentTimeStep

SUMOTime MSEventControl::currentTimeStep
private

The current TimeStep.

Definition at line 128 of file MSEventControl.h.

Referenced by getCurrentTimeStep(), and setCurrentTimeStep().

◆ myEvents

EventCont MSEventControl::myEvents
private

Event-container, holds executable events.

Definition at line 131 of file MSEventControl.h.

Referenced by addEvent(), execute(), isEmpty(), and ~MSEventControl().


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