65 assert(time > tMax -
DELTA_T || vehs.size() == 0);
70 for (std::vector<MEVehicle*>::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
86 if (onSegment !=
nullptr) {
87 onSegment->
send(veh, toSegment, qIdx, leaveTime, reason);
97 if (entry == leaveTime && (ignoreLink || veh->
mayProceed())) {
98 if (onSegment !=
nullptr) {
107 toSegment->
receive(veh, qIdx, leaveTime,
false, ignoreLink, &onSegment->
getEdge() != &toSegment->
getEdge());
117 toSegment->
receive(veh, qIdx, leaveTime,
false,
true,
true);
121 if (entry == leaveTime && !ignoreLink) {
133 const bool teleporting = (onSegment ==
nullptr);
136 if (nextEntry == leaveTime) {
145 if ((r1 && !disconnected) || (r3 && disconnected)) {
175 WRITE_WARNINGF(
TL(
"Teleporting vehicle '%'; waited too long, from edge '%':%, time=%."),
185 const bool teleporting = (onSegment ==
nullptr);
192 if (teleSegment !=
nullptr) {
195 WRITE_WARNINGF(
TL(
"Teleporting vehicle '%'; waited too long, from edge '%':% to edge '%':%, time=%."),
205 WRITE_WARNINGF(
TL(
"Teleporting vehicle '%'; waited too long, from edge '%':%, time=%."),
247 std::vector<MEVehicle*>& cands = candIt->second;
248 auto it = find(cands.begin(), cands.end(), v);
249 if (it != cands.end()) {
270 if (next !=
nullptr) {
277 if (nextEdge ==
nullptr) {
287 int no = (int)floor(length / sLength + 0.5);
301 const double slength = length / (double)numSegments;
304 const bool laneQueue = oc.
getBool(
"meso-lane-queue");
306 for (
int s = numSegments - 1; s >= 0; s--) {
309 multiQueue = laneQueue;
324 while (s !=
nullptr) {
352 if (succ->isRoundabout()) {
#define WRITE_WARNINGF(...)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
MESegment * nextSegment(MESegment *s, MEVehicle *v)
Retrieve next segment.
static bool isEnteringRoundabout(const MSEdge &e)
whether the given edge is entering a roundabout
void updateSegmentsForEdge(const MSEdge &e)
Update segments after loading meso edge type parameters from additional file.
MELoop(const SUMOTime recheckInterval)
SUMO constructor.
SUMOTime changeSegment(MEVehicle *veh, SUMOTime leaveTime, MESegment *const toSegment, MSMoveReminder::Notification reason, const bool ignoreLink=false) const
change to the next segment this handles combinations of the following cases: (ending / continuing rou...
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
const SUMOTime myLinkRecheckInterval
the interval at which to recheck at blocked junctions (<=0 means asap)
void simulate(SUMOTime tMax)
Perform simulation up to the given time.
bool removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
const SUMOTime myFullRecheckInterval
the interval at which to recheck at full segments (<=0 means asap)
void vaporizeCar(MEVehicle *v, MSMoveReminder::Notification reason)
remove the given car and clean up the relevant data structures
void teleportVehicle(MEVehicle *veh, MESegment *const toSegment)
teleports a vehicle or continues a teleport
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
void clearState()
Remove all vehicles before quick-loading state.
std::vector< MESegment * > myEdges2FirstSegments
mapping from internal edge ids to their initial segments
std::map< SUMOTime, std::vector< MEVehicle * > > myLeaderCars
leader cars in the segments sorted by exit time
void checkCar(MEVehicle *veh)
Check whether the vehicle may move.
static int numSegmentsFor(const double length, const double slength)
Compute number of segments per edge (best value stay close to the configured segment length)
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
A single mesoscopic segment (cell)
void addReminders(MEVehicle *veh) const
add this lanes MoveReminders to the given vehicle
static const int PARKING_QUEUE
void receive(MEVehicle *veh, const int qIdx, SUMOTime time, const bool isDepart=false, const bool isTeleport=false, const bool newEdge=false)
Adds the vehicle to the segment, adapting its parameters.
MSLink * getLink(const MEVehicle *veh, bool tlsPenalty=false) const
Returns the link the given car will use when passing the next junction.
double getLength() const
Returns the length of the segment in meters.
SUMOTime hasSpaceFor(const MEVehicle *const veh, const SUMOTime entryTime, int &qIdx, const bool init=false) const
Returns whether the given vehicle would still fit into the segment.
void initSegment(const MesoEdgeType &edgeType, const MSEdge &parent, const double capacity)
set model parameters (may be updated from additional file after network loading is complete)
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
void send(MEVehicle *veh, MESegment *const next, const int nextQIdx, SUMOTime time, const MSMoveReminder::Notification reason)
Removes the vehicle from the segment, adapting its parameters.
SUMOTime getEventTime() const
Returns the (planned) time at which the next vehicle leaves this segment.
double getCapacity() const
Returns the sum of the lengths of all usable lanes of the segment in meters.
int getIndex() const
Returns the running index of the segment in the edge (0 is the most upstream).
static bool isInvalid(const MESegment *segment)
whether the given segment is 0 or encodes vaporization
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
A vehicle from the mesoscopic point of view.
bool mayProceed()
Returns whether the vehicle is allowed to pass the next junction, checks also for triggered stops.
void processStop()
ends the current stop and performs loading/unloading
SUMOTime getWaitingTime(const bool accumulated=false) const
Returns the duration for which the vehicle was blocked.
bool moveRoutePointer()
Update when the vehicle enters a new edge in the move step.
void updateDetectors(SUMOTime currentTime, const bool isLeave, const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_JUNCTION)
Updates all vehicle detectors.
SUMOTime getLastEntryTime() const
Returns the time the vehicle entered the current segment.
void setEventTime(SUMOTime t, bool hasDelay=true)
Sets the (planned) time at which the vehicle leaves its current segment.
void setApproaching(MSLink *link)
registers vehicle with the given link
MESegment * getSegment() const
Returns the current segment the vehicle is on.
int getQueIndex() const
Returns the index of the que the vehicle is in.
virtual void setSegment(MESegment *s, int idx=0)
Sets the current segment the vehicle is at together with its que.
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves its current segment.
void setBlockTime(const SUMOTime t)
Sets the time at which the vehicle was blocked.
SUMOTime getBlockTime() const
Returns the time at which the vehicle was blocked.
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
bool isParking() const
Returns whether the vehicle is parking.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
virtual void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
bool isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
bool isStopped() const
Returns whether the vehicle is at a stop.
A road/street connecting two junctions.
int getNumSuccessors() const
Returns the number of edges that may be reached from this edge.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING, bool ignoreTransientPermissions=false) const
Get the allowed lanes to reach the destination-edge.
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is retured; should pro...
double getLength() const
return the length of the edge
int getNumericalID() const
Returns the numerical id of the edge.
const std::string & getEdgeType() const
Returns the type of the edge.
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
static SUMOTime gTimeToTeleportDisconnected
static bool gRemoveGridlocked
static SUMOTime gTimeToGridlock
Notification
Definition of a vehicle state.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
@ NOTIFICATION_TELEPORT_ARRIVED
The vehicle was teleported out of the net.
@ NOTIFICATION_SEGMENT
The vehicle changes the segment (meso only)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
const MESegment::MesoEdgeType & getMesoType(const std::string &typeID)
Returns edge type specific meso parameters if no type specific parameters have been loaded,...
void registerTeleportJam()
register one non-collision-related teleport
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
edge type specific meso parameters