![]() |
Eclipse 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 | |
typedef std::pair< Command *, SUMOTime > | Event |
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 >, 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 50 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 53 of file MSEventControl.h.
|
private |
Container for time-dependant events, e.g. traffic-light-change.
Definition at line 126 of file MSEventControl.h.
MSEventControl::MSEventControl | ( | ) |
Default constructor.
Definition at line 38 of file MSEventControl.cpp.
|
virtual |
|
private |
invalid copy constructor.
Adds an Event.
[in] | operation | The event to add |
[in] | execTimeStep | The time the event shall be executed at (-1 means at sim start) |
Reimplemented in GUIEventControl.
Definition at line 53 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_SaveTLSState::Command_SaveTLSState(), Command_SaveTLSSwitches::Command_SaveTLSSwitches(), Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates(), MSLaneSpeedTrigger::init(), MSCalibrator::init(), MSRoutingEngine::initWeightUpdate(), 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().
|
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 59 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 106 of file MSEventControl.cpp.
References currentTimeStep, MSNet::getCurrentTimeStep(), and MSNet::getInstance().
bool MSEventControl::isEmpty | ( | ) |
Returns whether events are in the que.
Definition at line 96 of file MSEventControl.cpp.
References myEvents.
|
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 101 of file MSEventControl.cpp.
References currentTimeStep.
|
private |
The current TimeStep.
Definition at line 129 of file MSEventControl.h.
Referenced by getCurrentTimeStep(), and setCurrentTimeStep().
|
private |
Event-container, holds executable events.
Definition at line 132 of file MSEventControl.h.
Referenced by addEvent(), execute(), isEmpty(), and ~MSEventControl().