Skip to content

Commit 569748d

Browse files
committed
addendum refs #17644 (fixed failure to update awaited and permitted)
1 parent 9e68341 commit 569748d

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/microsim/devices/MSDevice_Taxi.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -622,16 +622,23 @@ MSDevice_Taxi::cancelCustomer(const MSTransportable* t) {
622622
void
623623
MSDevice_Taxi::addCustomer(const MSTransportable* t, const Reservation* res) {
624624
myCustomers.insert(t);
625-
int stopIndex = 0;
626625
MSBaseVehicle& veh = dynamic_cast<MSBaseVehicle&>(myHolder);
627-
for (const Reservation* res2 : myCurrentReservations) {
628-
if (res == res2) {
629-
SUMOVehicleParameter::Stop& stop = const_cast<SUMOVehicleParameter::Stop&>(veh.getStop(stopIndex).pars);
630-
stop.awaitedPersons.insert(t->getID());
631-
stop.permitted.insert(t->getID());
626+
for (const MSStop& stop : veh.getStops()) {
627+
SUMOVehicleParameter::Stop& pars = const_cast<SUMOVehicleParameter::Stop&>(stop.pars);
628+
//std::cout << " sE=" << (*stop.edge)->getID() << " sStart=" << pars.startPos << " sEnd=" << pars.endPos << " rFrom=" <<
629+
// res->from->getID() << " rTo=" << res->to->getID() << " rFromPos=" << res->fromPos << " resToPos=" << res->toPos << "\n";
630+
if (*stop.edge == res->from
631+
&& pars.startPos <= res->fromPos
632+
&& pars.endPos >= res->fromPos) {
633+
pars.awaitedPersons.insert(t->getID());
634+
pars.permitted.insert(t->getID());
635+
pars.actType += " +" + t->getID();
636+
} else if (*stop.edge == res->to
637+
&& pars.startPos <= res->toPos
638+
&& pars.endPos >= res->toPos) {
639+
pars.actType += " +" + t->getID();
632640
break;
633641
}
634-
stopIndex++;
635642
}
636643
}
637644

@@ -904,6 +911,15 @@ MSDevice_Taxi::checkTaskSwap() {
904911
}
905912
}
906913
if (maxSaving > SWAP_THRESHOLD) {
914+
#ifdef DEBUG_DISPATCH
915+
if (DEBUG_CON) {
916+
std::cout << SIMTIME << " taxi=" << myHolder.getID() << " swapWith=" << bestSwap->getHolder().getID() << " saving=" << maxSaving << " lastDispatch=";
917+
for (const Reservation* res : bestSwap->myLastDispatch) {
918+
std::cout << toString(res->persons) << "; ";
919+
}
920+
std::cout << "\n";
921+
}
922+
#endif
907923
dispatchShared(bestSwap->myLastDispatch);
908924
bestSwap->myCurrentReservations.clear();
909925
bestSwap->myCustomers.clear();

0 commit comments

Comments
 (0)