SUMO - Simulation of Urban MObility
|
Stores time-dependant events and executes them at the proper time. More...
#include <MSEventControl.h>
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. More... | |
Public Member Functions | |
virtual SUMOTime | addEvent (Command *operation, SUMOTime execTimeStep, AdaptType type) |
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 > , EventSortCrit > | EventCont |
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... | |
MSEventControl & | operator= (const MSEventControl &) |
invalid assignment operator. More... | |
Private Attributes | |
SUMOTime | currentTimeStep |
The Current TimeStep. More... | |
EventCont | myEvents |
Event-container, holds executable events. More... | |
Stores time-dependant events and executes them at the proper time.
Definition at line 57 of file MSEventControl.h.
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.
|
private |
Container for time-dependant events, e.g. traffic-light-change.
Definition at line 154 of file MSEventControl.h.
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.
MSEventControl::MSEventControl | ( | ) |
Default constructor.
Definition at line 49 of file MSEventControl.cpp.
|
virtual |
|
private |
invalid copy constructor.
|
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.
[in] | operation | The event to add |
[in] | execTimeStep | The time the event shall be executed at |
[in] | type | The adaptation type |
Reimplemented in GUIEventControl.
Definition at line 64 of file MSEventControl.cpp.
References ADAPT_AFTER_EXECUTION, getCurrentTimeStep(), and myEvents.
Referenced by GUIEventControl::addEvent(), NLTriggerBuilder::buildVaporizer(), MSDevice_Routing::buildVehicleDevices(), MSSimpleTrafficLightLogic::changeStepAndDuration(), MSTLLogicControl::closeWAUT(), Command_SaveTLSState::Command_SaveTLSState(), Command_SaveTLSSwitches::Command_SaveTLSSwitches(), Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates(), MSLaneSpeedTrigger::init(), MSDevice_Routing::MSDevice_Routing(), MSTrafficLightLogic::MSTrafficLightLogic(), MSTriggeredXMLReader::MSTriggeredXMLReader(), MSVTypeProbe::MSVTypeProbe(), MSDevice_Routing::notifyEnter(), and MSPerson::MSPersonStage_Walking::proceed().
|
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.
[in] | time | The current simulation time |
ProcessError | From 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 GUIEventControl::execute(), and MSNet::simulationStep().
|
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.
Definition at line 119 of file MSEventControl.cpp.
References myEvents.
Referenced by MSNet::simulationState().
|
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.
|
private |
The Current TimeStep.
Definition at line 157 of file MSEventControl.h.
Referenced by getCurrentTimeStep(), and setCurrentTimeStep().
|
private |
Event-container, holds executable events.
Definition at line 160 of file MSEventControl.h.
Referenced by addEvent(), execute(), isEmpty(), and ~MSEventControl().