|
22 | 22 | #include <limits> |
23 | 23 | #include <microsim/MSNet.h> |
24 | 24 | #include <microsim/MSEdge.h> |
| 25 | +#include <microsim/MSGlobals.h> |
25 | 26 | #include <microsim/transportables/MSTransportable.h> |
26 | 27 | #include "MSRoutingEngine.h" |
27 | 28 | #include "MSDispatch.h" |
|
36 | 37 | // Reservation methods |
37 | 38 | // =========================================================================== |
38 | 39 |
|
39 | | -std::string |
40 | | -Reservation::getID() const { |
41 | | - return toString(persons); |
42 | | -} |
43 | | - |
44 | 40 | // =========================================================================== |
45 | 41 | // MSDispatch methods |
46 | 42 | // =========================================================================== |
@@ -87,6 +83,28 @@ MSDispatch::addReservation(MSTransportable* person, |
87 | 83 | // the default empty group implies, no grouping is wanted (and |
88 | 84 | // transportable ids are unique) |
89 | 85 | group = person->getID(); |
| 86 | + } else { |
| 87 | + auto it2 = myRunningReservations.find(group); |
| 88 | + if (it2 != myRunningReservations.end()) { |
| 89 | + for (auto item : it2->second) { |
| 90 | + Reservation* res = const_cast<Reservation*>(item.first); |
| 91 | + if (res->persons.count(person) == 0 |
| 92 | + && res->from == from |
| 93 | + && res->to == to |
| 94 | + && res->fromPos == fromPos |
| 95 | + && res->toPos == toPos) { |
| 96 | + MSDevice_Taxi* taxi = item.second; |
| 97 | + if (taxi->getState() == taxi->PICKUP |
| 98 | + && remainingCapacity(taxi, res) > 0 |
| 99 | + && taxi->compatibleLine(taxi->getHolder().getParameter().line, line)) { |
| 100 | + //std::cout << SIMTIME << " addPerson=" << person->getID() << " extendRes=" << toString(res->persons) << " taxi=" << taxi->getHolder().getID() << " state=" << taxi->getState() << "\n"; |
| 101 | + res->persons.insert(person); |
| 102 | + taxi->addCustomer(person, res); |
| 103 | + return res; |
| 104 | + } |
| 105 | + } |
| 106 | + } |
| 107 | + } |
90 | 108 | } |
91 | 109 | Reservation* result = nullptr; |
92 | 110 | bool added = false; |
@@ -294,6 +312,12 @@ MSDispatch::servedReservation(const Reservation* res, MSDevice_Taxi* taxi) { |
294 | 312 | } |
295 | 313 |
|
296 | 314 |
|
| 315 | +void |
| 316 | +MSDispatch::swappedRunning(const Reservation* res, MSDevice_Taxi* taxi) { |
| 317 | + myRunningReservations[res->group][res] = taxi; |
| 318 | +} |
| 319 | + |
| 320 | + |
297 | 321 | void |
298 | 322 | MSDispatch::fulfilledReservation(const Reservation* res) { |
299 | 323 | myRunningReservations[res->group].erase(res); |
|
0 commit comments