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; }
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; }
bool MSDevice_Container::notifyLeave(SUMOVehicle& veh, SUMOReal /*lastPos*/, MSMoveReminder::Notification reason) { if (reason >= MSMoveReminder::NOTIFICATION_ARRIVED) { for (std::vector<MSTransportable*>::iterator i = myContainers.begin(); i != myContainers.end(); ++i) { MSTransportable* container = *i; if (&(container->getDestination()) != veh.getEdge()) { WRITE_WARNING("Teleporting container '" + container->getID() + "' from vehicle destination edge '" + veh.getEdge()->getID() + "' to intended destination edge '" + container->getDestination().getID() + "'"); } if (!container->proceed(MSNet::getInstance(), MSNet::getInstance()->getCurrentTimeStep())) { MSNet::getInstance()->getContainerControl().erase(container); }; } } return true; }