void MSE3Collector::leave(SUMOVehicle& veh, SUMOReal leaveTimestep) { if (myEnteredContainer.find(&veh) == myEnteredContainer.end()) { WRITE_WARNING("Vehicle '" + veh.getID() + "' left " + toString(SUMO_TAG_E3DETECTOR) + " '" + getID() + "' before entering it."); } else { E3Values values = myEnteredContainer[&veh]; values.leaveTime = leaveTimestep; SUMOReal leaveTimestepFraction = leaveTimestep - (SUMOReal)((int) leaveTimestep); leaveTimestepFraction = fmod(leaveTimestep * 1000., 1000.) / (SUMOReal) DELTA_T; if (values.hadUpdate) { SUMOReal speedFraction = (veh.getSpeed() * leaveTimestepFraction); values.speedSum += speedFraction / (1000. / (SUMOReal) DELTA_T); values.intervalSpeedSum += speedFraction / (1000. / (SUMOReal) DELTA_T); if (veh.getSpeed() < myHaltingSpeedThreshold && values.haltingBegin != -1 && leaveTimestep - values.haltingBegin > myHaltingTimeThreshold) { values.haltings++; values.intervalHaltings++; } } else { SUMOReal speedFraction = (veh.getSpeed() * SUMOReal(1. - leaveTimestepFraction)); values.speedSum -= speedFraction / (1000. / (SUMOReal) DELTA_T); values.intervalSpeedSum -= speedFraction / (1000. / (SUMOReal) DELTA_T); } myEnteredContainer.erase(&veh); myLeftContainer[&veh] = values; } }
void MSMeanData_Emissions::MSLaneMeanDataValues::notifyMoveInternal(SUMOVehicle& veh, SUMOReal timeOnLane, SUMOReal speed) { sampleSeconds += timeOnLane; travelledDistance += speed * timeOnLane; const double a = veh.getAcceleration(); myEmissions.addScaled(PollutantsInterface::computeAll(veh.getVehicleType().getEmissionClass(), speed, a, veh.getSlope()), timeOnLane); }
void MSE3Collector::leave(SUMOVehicle& veh, SUMOReal leaveTimestep) throw() { if (myEnteredContainer.find(&veh)==myEnteredContainer.end()) { MsgHandler::getWarningInstance()->inform("Vehicle '" + veh.getID() + "' left E3-detector '" + getID() + "' before entering it."); } else { E3Values values = myEnteredContainer[&veh]; values.leaveTime = leaveTimestep; SUMOReal leaveTimestepFraction = leaveTimestep - (SUMOReal)((int) leaveTimestep); leaveTimestepFraction = fmod(leaveTimestep * 1000., 1000.) / (SUMOReal) DELTA_T; if (values.hadUpdate) { SUMOReal speedFraction = (veh.getSpeed() * leaveTimestepFraction); values.speedSum += speedFraction / (1000. / (SUMOReal) DELTA_T); values.intervalSpeedSum += speedFraction / (1000. / (SUMOReal) DELTA_T); if (veh.getSpeed() < myHaltingSpeedThreshold && values.haltingBegin!=-1 && leaveTimestep-values.haltingBegin>myHaltingTimeThreshold) { values.haltings++; values.intervalHaltings++; } } else { SUMOReal speedFraction = (veh.getSpeed() * SUMOReal(1. - leaveTimestepFraction)); values.speedSum -= speedFraction / (1000. / (SUMOReal) DELTA_T); values.intervalSpeedSum -= speedFraction / (1000. / (SUMOReal) DELTA_T); } myEnteredContainer.erase(&veh); myLeftContainer[&veh] = values; } }
void MSE3Collector::enter(const SUMOVehicle& veh, const double entryTimestep, const double fractionTimeOnDet) { if (!vehicleApplies(veh)) { return; } if (myEnteredContainer.find(&veh) != myEnteredContainer.end()) { WRITE_WARNING("Vehicle '" + veh.getID() + "' reentered " + toString(SUMO_TAG_E3DETECTOR) + " '" + getID() + "'."); return; } const double speedFraction = veh.getSpeed() * fractionTimeOnDet; E3Values v; v.entryTime = entryTimestep; v.frontLeaveTime = 0; v.backLeaveTime = 0; v.speedSum = speedFraction; v.haltingBegin = veh.getSpeed() < myHaltingSpeedThreshold ? entryTimestep : -1; v.intervalSpeedSum = entryTimestep >= STEPS2TIME(myLastResetTime) ? speedFraction : 0; v.haltings = 0; v.intervalHaltings = 0; if (veh.getSpeed() < myHaltingSpeedThreshold) { if (fractionTimeOnDet > myHaltingTimeThreshold) { v.haltings++; v.intervalHaltings++; } } v.hadUpdate = false; if (!MSGlobals::gUseMesoSim) { v.timeLoss = static_cast<const MSVehicle&>(veh).getTimeLoss(); v.intervalTimeLoss = v.timeLoss; } myEnteredContainer[&veh] = v; }
void MSE3Collector::enter(SUMOVehicle& veh, SUMOReal entryTimestep) throw() { if (myEnteredContainer.find(&veh)!=myEnteredContainer.end()) { MsgHandler::getWarningInstance()->inform("Vehicle '" + veh.getID() + "' reentered E3-detector '" + getID() + "'."); return; } SUMOReal entryTimestepFraction = ((SUMOReal) DELTA_T - fmod(entryTimestep * 1000., 1000.)) / (SUMOReal) DELTA_T; SUMOReal speedFraction = (veh.getSpeed() * entryTimestepFraction); E3Values v; v.entryTime = entryTimestep; v.leaveTime = 0; v.speedSum = speedFraction / (1000. / (SUMOReal) DELTA_T); v.haltingBegin = veh.getSpeed() < myHaltingSpeedThreshold ? entryTimestep : -1; v.intervalSpeedSum = speedFraction / (1000. / (SUMOReal) DELTA_T); v.haltings = 0; v.intervalHaltings = 0; if (veh.getSpeed() < myHaltingSpeedThreshold) { if (1.-entryTimestepFraction>myHaltingTimeThreshold) { v.haltings++; v.intervalHaltings++; } } v.hadUpdate = false; myEnteredContainer[&veh] = v; }
bool MSDevice_Person::notifyMove(SUMOVehicle& veh, SUMOReal /*oldPos*/, SUMOReal /*newPos*/, SUMOReal /*newSpeed*/) { if (myStopped) { if (!veh.isStopped()) { for (std::vector<MSTransportable*>::iterator i = myPersons.begin(); i != myPersons.end(); ++i) { (*i)->setDeparted(MSNet::getInstance()->getCurrentTimeStep()); } myStopped = false; } } else { if (veh.isStopped()) { for (std::vector<MSTransportable*>::iterator i = myPersons.begin(); i != myPersons.end();) { MSTransportable* person = *i; if (&(person->getDestination()) == veh.getEdge()) { if (!person->proceed(MSNet::getInstance(), MSNet::getInstance()->getCurrentTimeStep())) { MSNet::getInstance()->getPersonControl().erase(person); } i = myPersons.erase(i); } else { ++i; } } myStopped = true; } } return true; }
void MSMeanData_Amitran::MSLaneMeanDataValues::notifyMoveInternal(SUMOVehicle& veh, SUMOReal timeOnLane, SUMOReal speed) { sampleSeconds += timeOnLane; travelledDistance += speed * timeOnLane; typedSamples[&veh.getVehicleType()] += timeOnLane; typedTravelDistance[&veh.getVehicleType()] += speed * timeOnLane; }
bool MSMsgInductLoop::isStillActive(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed) throw() { if (newPos < myPosition) { // detector not reached yet return true; } if (myVehiclesOnDet.find(&veh) == myVehiclesOnDet.end()) { // entered the detector by move SUMOReal entryTimestep = (SUMOReal) ((SUMOReal) MSNet::getInstance()->getCurrentTimeStep() + ((myPosition - oldPos) / newSpeed)); if (newPos - veh.getVehicleType().getLength() > myPosition) { // entered and passed detector in a single timestep SUMOReal leaveTimestep = (SUMOReal) ((SUMOReal) MSNet::getInstance()->getCurrentTimeStep() + ((myPosition - oldPos + veh.getVehicleType().getLength()) / newSpeed)); enterDetectorByMove(veh, entryTimestep); leaveDetectorByMove(veh, leaveTimestep); return false; } // entered detector, but not passed enterDetectorByMove(veh, entryTimestep); return true; } else { // vehicle has been on the detector the previous timestep if (newPos - veh.getVehicleType().getLength() >= myPosition) { // vehicle passed the detector SUMOReal leaveTimestep = (SUMOReal) ((SUMOReal) MSNet::getInstance()->getCurrentTimeStep() + ((myPosition - oldPos + veh.getVehicleType().getLength()) / newSpeed)); leaveDetectorByMove(veh, leaveTimestep); return false; } // vehicle stays on the detector return true; } }
bool MSInductLoop::notifyMove(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed) { if (newPos < myPosition) { // detector not reached yet return true; } if (newPos >= myPosition && oldPos < myPosition) { // entered the detector by move SUMOReal entryTime = STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()); if (newSpeed != 0) { if (myPosition > oldPos) { entryTime += (myPosition - oldPos) / newSpeed; } } enterDetectorByMove(veh, entryTime); } if (newPos - veh.getVehicleType().getLength() > myPosition) { // vehicle passed the detector SUMOReal leaveTime = STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()); leaveTime += (myPosition - oldPos + veh.getVehicleType().getLength()) / newSpeed; leaveDetectorByMove(veh, leaveTime); return false; } // vehicle stays on the detector return true; }
void MSMsgInductLoop::notifyLeave(SUMOVehicle& veh, bool isArrival, bool isLaneChange) throw() { if (isArrival || isLaneChange || (veh.getPositionOnLane() > myPosition && veh.getPositionOnLane() - veh.getVehicleType().getLength() <= myPosition)) { // vehicle is on detector during lane change leaveDetectorByLaneChange(veh); } }
bool MSE3Collector::MSE3EntryReminder::notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double newSpeed) { if (myCollector.myEnteredContainer.find(&veh) == myCollector.myEnteredContainer.end() && newPos > myPosition) { if (oldPos > myPosition) { // was behind the detector already in the last step return false; } else { // entered in this step const double oldSpeed = veh.getPreviousSpeed(); const double entryTime = STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()); assert(!MSGlobals::gSemiImplicitEulerUpdate || newSpeed != 0); // how could it move across the detector otherwise const double timeBeforeEnter = MSCFModel::passingTime(oldPos, myPosition, newPos, oldSpeed, newSpeed); const double fractionTimeOnDet = TS - timeBeforeEnter; myCollector.enter(veh, entryTime - fractionTimeOnDet, fractionTimeOnDet); #ifdef DEBUG_E3_NOTIFY_MOVE if (DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) { std::cout << "\n" << SIMTIME << " MSE3EntryReminder::notifyMove() (" << getDescription() << "on lane '" << myLane->getID() << "')" << " vehicle '" << veh.getID() << "'" << " entered. oldPos=" << oldPos << " newPos=" << newPos << " newSpeed=" << newSpeed << "\n"; } #endif } } return true; }
bool MSDevice_Container::notifyMove(SUMOVehicle& veh, SUMOReal /*oldPos*/, SUMOReal /*newPos*/, SUMOReal /*newSpeed*/) { if (myStopped) { // if veh is not anymore at the stop if (!veh.isStopped()) { for (std::vector<MSTransportable*>::iterator i = myContainers.begin(); i != myContainers.end(); ++i) { (*i)->setDeparted(MSNet::getInstance()->getCurrentTimeStep()); } myStopped = false; } } else { if (veh.isStopped()) { for (std::vector<MSTransportable*>::iterator i = myContainers.begin(); i != myContainers.end();) { MSTransportable* container = *i; if (&(container->getDestination()) == veh.getEdge()) { if (!container->proceed(MSNet::getInstance(), MSNet::getInstance()->getCurrentTimeStep())) { MSNet::getInstance()->getContainerControl().erase(container); } i = myContainers.erase(i); } else { ++i; } } myStopped = true; } } return true; }
void MSE3Collector::enter(SUMOVehicle& veh, SUMOReal entryTimestep) { if (myEnteredContainer.find(&veh) != myEnteredContainer.end()) { WRITE_WARNING("Vehicle '" + veh.getID() + "' reentered " + toString(SUMO_TAG_E3DETECTOR) + " '" + getID() + "'."); return; } SUMOReal entryTimestepFraction = ((SUMOReal) DELTA_T - fmod(entryTimestep * 1000., 1000.)) / (SUMOReal) DELTA_T; SUMOReal speedFraction = (veh.getSpeed() * entryTimestepFraction); E3Values v; v.entryTime = entryTimestep; v.leaveTime = 0; v.speedSum = speedFraction / (1000. / (SUMOReal) DELTA_T); v.haltingBegin = veh.getSpeed() < myHaltingSpeedThreshold ? entryTimestep : -1; v.intervalSpeedSum = speedFraction / (1000. / (SUMOReal) DELTA_T); v.haltings = 0; v.intervalHaltings = 0; if (veh.getSpeed() < myHaltingSpeedThreshold) { if (1. - entryTimestepFraction > myHaltingTimeThreshold) { v.haltings++; v.intervalHaltings++; } } v.hadUpdate = false; myEnteredContainer[&veh] = v; }
void MSE3Collector::leave(const SUMOVehicle& veh, const double leaveTimestep, const double fractionTimeOnDet) { if (!vehicleApplies(veh)) { return; } if (myEnteredContainer.find(&veh) == myEnteredContainer.end()) { if (!myOpenEntry) { WRITE_WARNING("Vehicle '" + veh.getID() + "' left " + toString(SUMO_TAG_E3DETECTOR) + " '" + getID() + "' without entering it."); } } else { E3Values values = myEnteredContainer[&veh]; values.backLeaveTime = leaveTimestep; const double speedFraction = veh.getSpeed() * (TS - fractionTimeOnDet); values.speedSum -= speedFraction; values.intervalSpeedSum -= speedFraction; if (MSGlobals::gUseMesoSim) { // not yet supported values.timeLoss = 0; } else { // timeLoss was initialized when entering values.timeLoss = static_cast<const MSVehicle&>(veh).getTimeLoss() - values.timeLoss; } myEnteredContainer.erase(&veh); myLeftContainer.push_back(values); } }
void MSPerson::MSPersonStage_Driving::proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous) { if (previous->getDestinationStop() != 0) { // the arrival stop may have an access point myWaitingEdge = &previous->getDestinationStop()->getLane().getEdge(); myStopWaitPos = previous->getDestinationStop()->getWaitPosition(); } else { myWaitingEdge = previous->getEdge(); myStopWaitPos = Position::INVALID; } myWaitingPos = previous->getEdgePos(now); myWaitingSince = now; SUMOVehicle* availableVehicle = net->getVehicleControl().getWaitingVehicle(myWaitingEdge, myLines, myWaitingPos, person->getID()); if (availableVehicle != 0 && availableVehicle->getParameter().departProcedure == DEPART_TRIGGERED) { myVehicle = availableVehicle; myWaitingEdge->removePerson(person); myVehicle->addPerson(person); net->getInsertionControl().add(myVehicle); net->getVehicleControl().removeWaiting(myWaitingEdge, myVehicle); net->getVehicleControl().unregisterOneWaitingForPerson(); } else { net->getPersonControl().addWaiting(myWaitingEdge, person); myWaitingEdge->addPerson(person); } }
bool MSRouteProbe::notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason) { if (myCurrentRouteDistribution != 0 && reason != MSMoveReminder::NOTIFICATION_SEGMENT && reason != MSMoveReminder::NOTIFICATION_LANE_CHANGE) { veh.getRoute().addReference(); myCurrentRouteDistribution->add(1., &veh.getRoute()); } return false; }
void MSVehicleControl::vehicleDeparted(const SUMOVehicle& v) { ++myRunningVehNo; myTotalDepartureDelay += STEPS2TIME(v.getDeparture() - STEPFLOOR(v.getParameter().depart)); MSNet::getInstance()->informVehicleStateListener(&v, MSNet::VEHICLE_STATE_DEPARTED); myMaxSpeedFactor = MAX2(myMaxSpeedFactor, v.getChosenSpeedFactor()); myMinDeceleration = MIN2(myMinDeceleration, v.getVehicleType().getCarFollowModel().getMaxDecel()); }
void MSMeanData_Harmonoise::MSLaneMeanDataValues::notifyMoveInternal(SUMOVehicle& veh, SUMOReal timeOnLane, SUMOReal speed) { const SUMOReal sn = HelpersHarmonoise::computeNoise(veh.getVehicleType().getEmissionClass(), (double) speed, veh.getAcceleration()); currentTimeN += (SUMOReal) pow(10., (sn / 10.)); sampleSeconds += timeOnLane; travelledDistance += speed * timeOnLane; }
void MSVehicleControl::vehicleDeparted(const SUMOVehicle& v) { ++myRunningVehNo; myTotalDepartureDelay += STEPS2TIME(v.getDeparture() - STEPFLOOR(v.getParameter().depart)); MSNet::getInstance()->informVehicleStateListener(&v, MSNet::VEHICLE_STATE_DEPARTED); }
bool MSMsgInductLoop::notifyEnter(SUMOVehicle& veh, bool, bool) throw() { if (veh.getPositionOnLane() - veh.getVehicleType().getLength() > myPosition) { // vehicle-front is beyond detector. Ignore return false; } // vehicle is in front of detector return true; }
void MSE2Collector::notifyLeave(SUMOVehicle& veh, bool isArrival, bool isLaneChange) throw() { if (isArrival || isLaneChange || (veh.getPositionOnLane() >= myStartPos && veh.getPositionOnLane() - veh.getVehicleType().getLength() < myEndPos)) { std::list<SUMOVehicle*>::iterator i = find(myKnownVehicles.begin(), myKnownVehicles.end(), &veh); if (i!=myKnownVehicles.end()) { myKnownVehicles.erase(i); } } }
bool MSInstantInductLoop::notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification) { if (veh.getPositionOnLane() - veh.getVehicleType().getLengthWithGap() > myPosition) { // vehicle-front is beyond detector. Ignore return false; } // vehicle is in front of detector return true; }
bool MSDevice_BTsender::notifyEnter(SUMOVehicle& veh, Notification reason) { if (reason == MSMoveReminder::NOTIFICATION_DEPARTED && sVehicles.find(veh.getID()) == sVehicles.end()) { sVehicles[veh.getID()] = new VehicleInformation(veh.getID()); } sVehicles[veh.getID()]->updates.push_back(VehicleState( MSNet::getInstance()->getCurrentTimeStep(), veh.getSpeed(), static_cast<MSVehicle&>(veh).getAngle(), static_cast<MSVehicle&>(veh).getPosition(), static_cast<MSVehicle&>(veh).getLane()->getID(), veh.getPositionOnLane() )); return true; }
bool MSDevice_Battery::notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason) { // Set last Energy ONLY when the vehicle is introduced in the simulation if (reason == MSMoveReminder::NOTIFICATION_DEPARTED) { setLastEnergy(getMass() * veh.getSpeed() * veh.getSpeed() / 2 + getMass() * 9.81 * veh.getLane()->getShape().front().z() + getInternalMomentOfInertia() * 0.5 * veh.getSpeed() * veh.getSpeed()); setLastAngle(veh.getLane()->getShape().beginEndAngle()); } // This function return always true return true; }
bool MSDevice_BTreceiver::notifyMove(SUMOVehicle& veh, SUMOReal /* oldPos */, SUMOReal newPos, SUMOReal newSpeed) { if (sVehicles.find(veh.getID()) == sVehicles.end()) { WRITE_WARNING("btreceiver: Can not update position of vehicle '" + veh.getID() + "' which is not on the road."); return true; } const MSVehicle& v = static_cast<MSVehicle&>(veh); sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(newSpeed, veh.getPosition(), v.getLane()->getID(), newPos, v.getRoutePosition())); return true; }
bool MSE3Collector::MSE3EntryReminder::notifyEnter(SUMOVehicle& veh, Notification reason, const MSLane* enteredLane) { if (reason != NOTIFICATION_JUNCTION) { const double posOnLane = veh.getBackPositionOnLane(enteredLane) + veh.getVehicleType().getLength(); if (posOnLane > myPosition) { // if the vehicle changes into a covered section we assume it was already registred on another lane return false; } } return true; }
void MSVehicleControl::vehicleDeparted(const SUMOVehicle& v) { ++myRunningVehNo; myTotalDepartureDelay += STEPS2TIME(v.getDeparture() - STEPFLOOR(v.getParameter().depart)); MSNet::getInstance()->informVehicleStateListener(&v, MSNet::VEHICLE_STATE_DEPARTED); myMaxSpeedFactor = MAX2(myMaxSpeedFactor, v.getChosenSpeedFactor()); if ((v.getVClass() & (SVC_PEDESTRIAN | SVC_NON_ROAD)) == 0) { // only worry about deceleration of road users myMinDeceleration = MIN2(myMinDeceleration, v.getVehicleType().getCarFollowModel().getMaxDecel()); } }
bool MSDevice_Tripinfo::notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason) { if (reason == MSMoveReminder::NOTIFICATION_DEPARTED) { if (!MSGlobals::gUseMesoSim) { myDepartLane = static_cast<MSVehicle&>(veh).getLane()->getID(); } myDepartPos = veh.getPositionOnLane(); myDepartSpeed = veh.getSpeed(); } return true; }
void GUIMEVehicleControl::insertVehicleIDs(std::vector<GUIGlID>& into) { AbstractMutex::ScopedLocker locker(myLock); into.reserve(myVehicleDict.size()); for (VehicleDictType::iterator i = myVehicleDict.begin(); i != myVehicleDict.end(); ++i) { SUMOVehicle* veh = (*i).second; if (veh->isOnRoad()) { into.push_back(static_cast<GUIMEVehicle*>((*i).second)->getGlID()); } } }
bool MSDevice_BTsender::notifyMove(SUMOVehicle& veh, SUMOReal /* oldPos */, SUMOReal newPos, SUMOReal newSpeed) { if (sVehicles.find(veh.getID()) == sVehicles.end()) { WRITE_WARNING("btsender: Can not update position of a vehicle that is not within the road network (" + veh.getID() + ")."); return true; } sVehicles[veh.getID()]->updates.push_back(VehicleState( MSNet::getInstance()->getCurrentTimeStep(), newSpeed, static_cast<MSVehicle&>(veh).getAngle(), static_cast<MSVehicle&>(veh).getPosition(), static_cast<MSVehicle&>(veh).getLane()->getID(), newPos )); return true; }