55 #ifdef CHECK_MEMORY_LEAKS
57 #endif // CHECK_MEMORY_LEAKS
63 using namespace traci;
104 std::vector<std::string> ids;
107 if ((*i).second->isOnRoad()) {
108 ids.push_back((*i).first);
120 if (sumoVehicle == 0) {
127 RTYPE_ERR,
"Vehicle '" +
id +
"' is not a micro-simulation vehicle", outputStorage);
161 tempMsg.
writeInt((
int)std::distance(lanes.begin(), std::find(lanes.begin(), lanes.end(), v->
getLane())));
222 if (inputStorage.
readInt() != 2) {
237 std::string edgeID = inputStorage.
readString();
259 if (inputStorage.
readInt() != 2) {
274 std::string edgeID = inputStorage.
readString();
313 unsigned int cnt = 0;
315 const std::vector<MSVehicle::LaneQ>& bestLanes = onRoad ? v->
getBestLanes() : std::vector<MSVehicle::LaneQ>();
316 tempContent.
writeInt((
int) bestLanes.size());
318 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
335 std::vector<std::string> bestContIDs;
337 bestContIDs.push_back((*j)->getID());
348 if (!commandDistanceRequest(server, inputStorage, tempMsg, v)) {
366 std::string warning =
"";
389 const bool shouldExist = variable !=
ADD;
391 if (sumoVehicle == 0) {
398 if (v == 0 && shouldExist) {
400 RTYPE_ERR,
"Vehicle '" +
id +
"' is not a micro-simulation vehicle", outputStorage);
410 if (inputStorage.
readInt() != 4) {
420 std::string roadId = inputStorage.
readString();
432 int laneIndex = inputStorage.
readByte();
451 const std::vector<MSLane*>& allLanes = road->
getLanes();
452 if ((laneIndex < 0) || laneIndex >= (
int)(allLanes.size())) {
457 if (!v->
addTraciStop(allLanes[laneIndex], pos, 0, waitTime)) {
468 if (inputStorage.
readInt() != 2) {
478 int laneIndex = inputStorage.
readByte();
486 if ((laneIndex < 0) || (laneIndex >= (
int)(v->
getEdge()->
getLanes().size()))) {
491 std::vector<std::pair<SUMOTime, unsigned int> > laneTimeLine;
492 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
493 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep() + stickyTime, laneIndex));
505 if (inputStorage.
readInt() != 2) {
527 std::vector<std::pair<SUMOTime, SUMOReal> > speedTimeLine;
529 speedTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep() + duration, newSpeed));
538 std::string edgeID = inputStorage.
readString();
579 std::vector<const MSEdge*> edges;
592 int parameterCount = inputStorage.
readInt();
593 if (parameterCount == 4) {
611 std::string edgeID = inputStorage.
readString();
625 }
else if (parameterCount == 2) {
631 std::string edgeID = inputStorage.
readString();
648 }
else if (parameterCount == 1) {
654 std::string edgeID = inputStorage.
readString();
675 int parameterCount = inputStorage.
readInt();
676 if (parameterCount == 4) {
694 std::string edgeID = inputStorage.
readString();
708 }
else if (parameterCount == 2) {
714 std::string edgeID = inputStorage.
readString();
731 }
else if (parameterCount == 1) {
737 std::string edgeID = inputStorage.
readString();
758 if (inputStorage.
readInt() != 0) {
770 if (inputStorage.
readInt() != 0) {
790 if (inputStorage.
readInt() != 2) {
799 std::string laneID = inputStorage.
readString();
813 if (!v->
willPass(&destinationEdge)) {
819 while (v->
getEdge() != &destinationEdge) {
836 std::vector<std::pair<SUMOTime, SUMOReal> > speedTimeLine;
838 speedTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), speed));
839 speedTimeLine.push_back(std::make_pair(
SUMOTime_MAX, speed));
849 int speedMode = inputStorage.
readInt();
877 if (inputStorage.
readInt() != 6) {
882 vehicleParams.
id = id;
888 std::string vTypeID = inputStorage.
readString();
899 const std::string routeID = inputStorage.
readString();
911 if (vehicleParams.
depart < 0) {
912 const int proc =
static_cast<int>(-vehicleParams.
depart);
926 const int proc =
static_cast<int>(-vehicleParams.
departPos);
942 const int proc =
static_cast<int>(-vehicleParams.
departSpeed);
958 const int proc =
static_cast<int>(-vehicleParams.
departLane);
969 *params = vehicleParams;
1017 if (inputStorage.
readInt() != 4) {
1026 std::string edgeID = inputStorage.
readString();
1032 int laneNum = inputStorage.
readInt();
1054 std::string origID = edgeID +
" " +
toString(laneNum);
1056 edgeID =
'-' + edgeID;
1064 MSLane* nameMatchingLane = 0;
1065 SUMOReal minDistNameMatchingLane = 1 << (11);
1066 for (; minDistLane == 0 && r < 10 && nameMatchingLane == 0; ++r) {
1067 std::set<std::string> into;
1071 for (std::set<std::string>::const_iterator j = into.begin(); j != into.end(); ++j) {
1073 const std::vector<MSLane*>& lanes = e->
getLanes();
1074 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end(); ++k) {
1076 bool nameMatches =
false;
1081 if (dist < minDistNameMatchingLane) {
1082 minDistNameMatchingLane = dist;
1083 nameMatchingLane = lane;
1087 if (dist < minDist) {
1094 MSLane* lane = nameMatchingLane != 0 ? nameMatchingLane : minDistLane;
1097 MSEdge* routePos = &destinationEdge;
1099 routePos = &routePos->
getLanes()[0]->getLogicalPredecessorLane()->getEdge();
1105 unsigned int rindex = 0;
1107 while (!found && ((
int)(c - r) >= 0 || c + r < l)) {
1108 if ((
int)(c - r) >= 0 && route[c - r] == routePos) {
1112 if (c + r < l && route[c + r] == routePos) {
1124 MSLane* firstLane = lane;
1126 edges.push_back(&destinationEdge);
1129 edges.push_back(&firstLane->
getEdge());
1132 if (lc.size() != 0 && lc[0]->getLane() != 0) {
1133 edges.push_back(&lc[0]->getLane()->getEdge());
1162 getSingularType(v), server, inputStorage, outputStorage)) {
1183 if (inputStorage.
readInt() != 2) {
1189 std::pair<const MSLane*, SUMOReal> roadPos;
1196 std::string roadID = inputStorage.
readString();
1199 pos = roadPos.first->getShape().positionAtLengthPosition(roadPos.second);
1207 const double p1x = inputStorage.
readDouble();
1208 const double p1y = inputStorage.
readDouble();
1228 v->
getEdge(), &roadPos.first->getEdge());
1259 std::string newID = oType.
getID().find(
'@') == std::string::npos ? oType.
getID() +
"@" + veh->
getID() : oType.
getID();
1261 static_cast<MSVehicle*
>(veh)->replaceVehicleType(type);