// =========================================================================== // method definitions // =========================================================================== MSTriggeredRerouter::MSTriggeredRerouter(const std::string& id, const std::vector<MSEdge*>& edges, SUMOReal prob, const std::string& file, bool off) : MSTrigger(id), MSMoveReminder(id), SUMOSAXHandler(file), myProbability(prob), myUserProbability(prob), myAmInUserMode(false) { // read in the trigger description if (file != "" && !XMLSubSys::runParser(*this, file)) { throw ProcessError(); } // build actors for (std::vector<MSEdge*>::const_iterator j = edges.begin(); j != edges.end(); ++j) { #ifdef HAVE_INTERNAL if (MSGlobals::gUseMesoSim) { MESegment* s = MSGlobals::gMesoNet->getSegmentForEdge(**j); s->addDetector(this); continue; } #endif const std::vector<MSLane*>& destLanes = (*j)->getLanes(); for (std::vector<MSLane*>::const_iterator i = destLanes.begin(); i != destLanes.end(); ++i) { (*i)->addMoveReminder(this); } } if (off) { setUserMode(true); setUserUsageProbability(0); } }
// =========================================================================== // method definitions // =========================================================================== MSRouteProbe::MSRouteProbe(const std::string& id, const MSEdge* edge, const std::string& distID, const std::string& lastID) : MSDetectorFileOutput(id), MSMoveReminder(id) { myCurrentRouteDistribution = std::make_pair(distID, MSRoute::distDictionary(distID)); if (myCurrentRouteDistribution.second == 0) { myCurrentRouteDistribution.second = new RandomDistributor<const MSRoute*>(); MSRoute::dictionary(distID, myCurrentRouteDistribution.second, false); } myLastRouteDistribution = std::make_pair(lastID, MSRoute::distDictionary(lastID)); #ifdef HAVE_INTERNAL if (MSGlobals::gUseMesoSim) { MESegment* seg = MSGlobals::gMesoNet->getSegmentForEdge(*edge); while (seg != 0) { seg->addDetector(this); seg = seg->getNextSegment(); } return; } #endif for (std::vector<MSLane*>::const_iterator it = edge->getLanes().begin(); it != edge->getLanes().end(); ++it) { (*it)->addMoveReminder(this); } }
// =========================================================================== // method definitions // =========================================================================== MSRouteProbe::MSRouteProbe(const std::string& id, const MSEdge* edge, SUMOTime begin) : MSDetectorFileOutput(id), myCurrentRouteDistribution(0) { const std::string distID = id + "_" + toString(begin); myCurrentRouteDistribution = MSRoute::distDictionary(distID); if (myCurrentRouteDistribution == 0) { myCurrentRouteDistribution = new RandomDistributor<const MSRoute*>(MSRoute::getMaxRouteDistSize(), &MSRoute::releaseRoute); MSRoute::dictionary(distID, myCurrentRouteDistribution); } #ifdef HAVE_INTERNAL if (MSGlobals::gUseMesoSim) { MESegment* seg = MSGlobals::gMesoNet->getSegmentForEdge(*edge); while (seg != 0) { seg->addDetector(this); seg = seg->getNextSegment(); } return; } #endif for (std::vector<MSLane*>::const_iterator it = edge->getLanes().begin(); it != edge->getLanes().end(); ++it) { (*it)->addMoveReminder(this); } }