SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSEventControl Class Reference

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

#include <MSEventControl.h>

Inheritance diagram for MSEventControl:
GUIEventControl

Data Structures

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

Public Types

enum  AdaptType { ADAPT_AFTER_EXECUTION = 1, NO_CHANGE = 2 }
 Defines what to do if the insertion time lies before the current simulation time. More...
typedef std::pair< Command
*, SUMOTime
Event
 Combination of an event and the time it shall be executed at.

Public Member Functions

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

Private Types

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

Private Member Functions

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

Private Attributes

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

Detailed Description

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

Definition at line 57 of file MSEventControl.h.

Member Typedef Documentation

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

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

Definition at line 60 of file MSEventControl.h.

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 154 of file MSEventControl.h.

Member Enumeration Documentation

Defines what to do if the insertion time lies before the current simulation time.

Enumerator:
ADAPT_AFTER_EXECUTION 

Patch the time in a way that it is at least as high as the simulation begin time.

NO_CHANGE 

Do nothing.

Definition at line 67 of file MSEventControl.h.

Constructor & Destructor Documentation

MSEventControl::MSEventControl ( )

Default constructor.

Definition at line 49 of file MSEventControl.cpp.

MSEventControl::~MSEventControl ( )
virtual

Destructor.

Definition at line 53 of file MSEventControl.cpp.

References myEvents.

MSEventControl::MSEventControl ( const MSEventControl )
private

invalid copy constructor.

Member Function Documentation

SUMOTime MSEventControl::addEvent ( Command operation,
SUMOTime  execTimeStep,
AdaptType  type 
)
virtual

Adds an Event.

If the given execution time step lies before the current and ADAPT_AFTER_EXECUTION is passed for adaptation type, the execution time step will be set to the current time step.

Returns the time the event will be executed, really.

Parameters
[in]operationThe event to add
[in]execTimeStepThe time the event shall be executed at
[in]typeThe adaptation type
See Also
Command
AdaptType

Reimplemented in GUIEventControl.

Definition at line 64 of file MSEventControl.cpp.

References ADAPT_AFTER_EXECUTION, getCurrentTimeStep(), and myEvents.

Referenced by NLTriggerBuilder::buildVaporizer(), MSDevice_Routing::buildVehicleDevices(), MSSimpleTrafficLightLogic::changeStepAndDuration(), MSTLLogicControl::closeWAUT(), Command_SaveTLSState::Command_SaveTLSState(), Command_SaveTLSSwitches::Command_SaveTLSSwitches(), Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates(), MSCalibrator::init(), MSLaneSpeedTrigger::init(), MSDevice_Routing::MSDevice_Routing(), MSTrafficLightLogic::MSTrafficLightLogic(), MSTriggeredXMLReader::MSTriggeredXMLReader(), MSVTypeProbe::MSVTypeProbe(), MSDevice_Routing::notifyEnter(), and MSPerson::MSPersonStage_Walking::proceed().

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 78 of file MSEventControl.cpp.

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

Referenced by MSNet::simulationStep().

SUMOTime MSEventControl::getCurrentTimeStep ( )
private

get the Current TimeStep used in addEvent.

Definition at line 129 of file MSEventControl.cpp.

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

Referenced by addEvent().

bool MSEventControl::isEmpty ( )

Returns whether events are in the que.

Returns
whether events are in the que

Definition at line 119 of file MSEventControl.cpp.

References myEvents.

Referenced by MSNet::simulationState().

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

invalid assignment operator.

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 124 of file MSEventControl.cpp.

References currentTimeStep.

Field Documentation

SUMOTime MSEventControl::currentTimeStep
private

The Current TimeStep.

Definition at line 157 of file MSEventControl.h.

Referenced by getCurrentTimeStep(), and setCurrentTimeStep().

EventCont MSEventControl::myEvents
private

Event-container, holds executable events.

Definition at line 160 of file MSEventControl.h.

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


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