Skip to content

Commit

Permalink
hopefully final round of parameter names #6918
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Nov 15, 2023
1 parent ecd9c79 commit 7a4c998
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 65 deletions.
4 changes: 2 additions & 2 deletions src/libsumo/POI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(POI)


void
POI::setType(const std::string& poiID, const std::string& type) {
getPoI(poiID)->setShapeType(type);
POI::setType(const std::string& poiID, const std::string& poiType) {
getPoI(poiID)->setShapeType(poiType);
}


Expand Down
2 changes: 1 addition & 1 deletion src/libsumo/POI.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class POI {
LIBSUMO_ID_PARAMETER_API
LIBSUMO_SUBSCRIPTION_API

static void setType(const std::string& poiID, const std::string& setType);
static void setType(const std::string& poiID, const std::string& poiType);
static void setColor(const std::string& poiID, const libsumo::TraCIColor& color);
static void setPosition(const std::string& poiID, double x, double y);
static void setWidth(const std::string& poiID, double width);
Expand Down
12 changes: 6 additions & 6 deletions src/libsumo/Person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Person::getLanePosition(const std::string& personID) {
}

std::vector<TraCIReservation>
Person::getTaxiReservations(int stateFilter) {
Person::getTaxiReservations(int onlyNew) {
std::vector<TraCIReservation> result;
MSDispatch* dispatcher = MSDevice_Taxi::getDispatchAlgorithm();
if (dispatcher != nullptr) {
Expand All @@ -141,16 +141,16 @@ Person::getTaxiReservations(int stateFilter) {
throw TraCIException("device.taxi.dispatch-algorithm 'traci' has not been loaded");
}
for (Reservation* res : dispatcher->getReservations()) {
if (filterReservation(stateFilter, res, result)) {
if (filterReservation(onlyNew, res, result)) {
if (res->state == Reservation::NEW) {
res->state = Reservation::RETRIEVED;
}
}
}
const bool includeRunning = stateFilter == 0 || (stateFilter & (Reservation::ASSIGNED | Reservation::ONBOARD)) != 0;
const bool includeRunning = onlyNew == 0 || (onlyNew & (Reservation::ASSIGNED | Reservation::ONBOARD)) != 0;
if (includeRunning) {
for (const Reservation* res : dispatcher->getRunningReservations()) {
filterReservation(stateFilter, res, result);
filterReservation(onlyNew, res, result);
}
}
}
Expand All @@ -177,8 +177,8 @@ Person::splitTaxiReservation(std::string reservationID, const std::vector<std::s
}

bool
Person::filterReservation(int stateFilter, const Reservation* res, std::vector<libsumo::TraCIReservation>& reservations) {
if (stateFilter != 0 && (stateFilter & res->state) == 0) {
Person::filterReservation(int onlyNew, const Reservation* res, std::vector<libsumo::TraCIReservation>& reservations) {
if (onlyNew != 0 && (onlyNew & res->state) == 0) {
return false;
}
std::vector<std::string> personIDs;
Expand Down
2 changes: 1 addition & 1 deletion src/libsumo/Person.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Person {
static double getSlope(const std::string& personID);
static double getLanePosition(const std::string& personID);

static std::vector<libsumo::TraCIReservation> getTaxiReservations(int stateFilter = 0);
static std::vector<libsumo::TraCIReservation> getTaxiReservations(int onlyNew = 0);
static std::string splitTaxiReservation(std::string reservationID, const std::vector<std::string>& personIDs);

LIBSUMO_ID_PARAMETER_API
Expand Down
5 changes: 2 additions & 3 deletions src/libsumo/Polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(Polygon)


void
Polygon::setType(const std::string& polygonID, const std::string& setType) {
SUMOPolygon* p = getPolygon(polygonID);
p->setShapeType(setType);
Polygon::setType(const std::string& polygonID, const std::string& polygonType) {
getPolygon(polygonID)->setShapeType(polygonType);
}


Expand Down
2 changes: 1 addition & 1 deletion src/libsumo/Polygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Polygon {
LIBSUMO_ID_PARAMETER_API
LIBSUMO_SUBSCRIPTION_API

static void setType(const std::string& polygonID, const std::string& setType);
static void setType(const std::string& polygonID, const std::string& polygonType);
static void setShape(const std::string& polygonID, const libsumo::TraCIPositionVector& shape);
static void setColor(const std::string& polygonID, const libsumo::TraCIColor& color);
static void add(const std::string& polygonID, const libsumo::TraCIPositionVector& shape, const libsumo::TraCIColor& color, bool fill = false, const std::string& polygonType = "", int layer = 0, double lineWidth = 1);
Expand Down
6 changes: 3 additions & 3 deletions src/libsumo/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,11 @@ Simulation::getParameter(const std::string& objectID, const std::string& key) {
LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(Simulation)

void
Simulation::setParameter(const std::string& objectID, const std::string& param, const std::string& value) {
Simulation::setParameter(const std::string& objectID, const std::string& key, const std::string& value) {
if (objectID == "") {
MSNet::getInstance()->setParameter(param, value);
MSNet::getInstance()->setParameter(key, value);
} else {
throw TraCIException("Setting simulation parameter '" + param + "' is not supported for object id '" + objectID + "'. Use empty id for generic network parameters");
throw TraCIException("Setting simulation parameter '" + key + "' is not supported for object id '" + objectID + "'. Use empty id for generic network parameters");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libsumo/Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class Simulation {

static std::string getParameter(const std::string& objectID, const std::string& key);
static const std::pair<std::string, std::string> getParameterWithKey(const std::string& objectID, const std::string& key);
static void setParameter(const std::string& objectID, const std::string& param, const std::string& value);
static void setParameter(const std::string& objectID, const std::string& key, const std::string& value);

static void setScale(double value);
static void clearPending(const std::string& routeID = "");
Expand Down
14 changes: 7 additions & 7 deletions src/libsumo/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,12 +675,12 @@ Vehicle::getDistance(const std::string& vehID) {


double
Vehicle::getDrivingDistance(const std::string& vehID, const std::string& edgeID, double position, int /* laneIndex */) {
Vehicle::getDrivingDistance(const std::string& vehID, const std::string& edgeID, double pos, int /* laneIndex */) {
MSBaseVehicle* veh = Helper::getVehicle(vehID);
MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
if (veh->isOnRoad()) {
const MSEdge* edge = microVeh != nullptr ? &veh->getLane()->getEdge() : veh->getEdge();
double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), position,
double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), pos,
edge, Helper::getEdge(edgeID), true, veh->getRoutePosition());
if (distance == std::numeric_limits<double>::max()) {
return INVALID_DOUBLE_VALUE;
Expand Down Expand Up @@ -1857,15 +1857,15 @@ Vehicle::setSpeed(const std::string& vehID, double speed) {
}

void
Vehicle::setAcceleration(const std::string& vehID, double accel, double duration) {
Vehicle::setAcceleration(const std::string& vehID, double acceleration, double duration) {
MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
if (veh == nullptr) {
WRITE_WARNING("setAcceleration not yet implemented for meso");
return;
}

double targetSpeed = std::max(veh->getSpeed() + accel * duration, 0.0);
double targetSpeed = std::max(veh->getSpeed() + acceleration * duration, 0.0);
std::vector<std::pair<SUMOTime, double>> speedTimeLine;
speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh->getSpeed()));
speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), targetSpeed));
Expand Down Expand Up @@ -2287,16 +2287,16 @@ Vehicle::setLine(const std::string& vehID, const std::string& line) {


void
Vehicle::setVia(const std::string& vehID, const std::vector<std::string>& via) {
Vehicle::setVia(const std::string& vehID, const std::vector<std::string>& edgeList) {
MSBaseVehicle* veh = Helper::getVehicle(vehID);
try {
// ensure edges exist
ConstMSEdgeVector edges;
MSEdge::parseEdgesList(via, edges, "<via-edges>");
MSEdge::parseEdgesList(edgeList, edges, "<via-edges>");
} catch (ProcessError& e) {
throw TraCIException(e.what());
}
veh->getParameter().via = via;
veh->getParameter().via = edgeList;
}


Expand Down
6 changes: 3 additions & 3 deletions src/libsumo/Vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Vehicle {
static std::string getStopParameter(const std::string& vehID, int nextStopIndex, const std::string& param, bool customParam = false);

static double getDistance(const std::string& vehID);
static double getDrivingDistance(const std::string& vehID, const std::string& edgeID, double position, int laneIndex = 0);
static double getDrivingDistance(const std::string& vehID, const std::string& edgeID, double pos, int laneIndex = 0);
static double getDrivingDistance2D(const std::string& vehID, double x, double y);
static double getAllowedSpeed(const std::string& vehID);
static int getSpeedMode(const std::string& vehID);
Expand Down Expand Up @@ -189,7 +189,7 @@ class Vehicle {
static void deactivateGapControl(const std::string& vehID);
static void requestToC(const std::string& vehID, double leadTime);
static void setSpeed(const std::string& vehID, double speed);
static void setAcceleration(const std::string& vehID, double accel, double duration);
static void setAcceleration(const std::string& vehID, double acceleration, double duration);
static void setPreviousSpeed(const std::string& vehID, double prevSpeed, double prevAcceleration = libsumo::INVALID_DOUBLE_VALUE);
static void setSpeedMode(const std::string& vehID, int speedMode);
static void setLaneChangeMode(const std::string& vehID, int laneChangeMode);
Expand All @@ -211,7 +211,7 @@ class Vehicle {
static void moveToXY(const std::string& vehID, const std::string& edgeID, const int laneIndex, const double x, const double y, double angle = libsumo::INVALID_DOUBLE_VALUE, const int keepRoute = 1, double matchThreshold = 100);
static void remove(const std::string& vehID, char reason = libsumo::REMOVE_VAPORIZED);
static void setLine(const std::string& vehID, const std::string& line);
static void setVia(const std::string& vehID, const std::vector<std::string>& via);
static void setVia(const std::string& vehID, const std::vector<std::string>& edgeList);
static void highlight(const std::string& vehID, const libsumo::TraCIColor& col = libsumo::TraCIColor(255, 0, 0, 255), double size = -1, const int alphaMax = -1, const double duration = -1, const int type = 0);
static void dispatchTaxi(const std::string& vehID, const std::vector<std::string>& reservations);
/// @}
Expand Down
4 changes: 2 additions & 2 deletions src/libtraci/POI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ LIBTRACI_PARAMETER_IMPLEMENTATION(POI, POI)


void
POI::setType(const std::string& poiID, const std::string& type) {
Dom::setString(libsumo::VAR_TYPE, poiID, type);
POI::setType(const std::string& poiID, const std::string& poiType) {
Dom::setString(libsumo::VAR_TYPE, poiID, poiType);
}


Expand Down
4 changes: 2 additions & 2 deletions src/libtraci/Polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ LIBTRACI_PARAMETER_IMPLEMENTATION(Polygon, POLYGON)


void
Polygon::setType(const std::string& polygonID, const std::string& setType) {
Dom::setString(libsumo::VAR_TYPE, polygonID, setType);
Polygon::setType(const std::string& polygonID, const std::string& polygonType) {
Dom::setString(libsumo::VAR_TYPE, polygonID, polygonType);
}


Expand Down
12 changes: 6 additions & 6 deletions src/libtraci/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,12 @@ Vehicle::getDistance(const std::string& vehID) {


double
Vehicle::getDrivingDistance(const std::string& vehID, const std::string& edgeID, double position, int laneIndex) {
Vehicle::getDrivingDistance(const std::string& vehID, const std::string& edgeID, double pos, int laneIndex) {
tcpip::Storage content;
StoHelp::writeCompound(content, 2);
content.writeUnsignedByte(libsumo::POSITION_ROADMAP);
content.writeString(edgeID);
content.writeDouble(position);
content.writeDouble(pos);
content.writeUnsignedByte(laneIndex);
content.writeUnsignedByte(libsumo::REQUEST_DRIVINGDIST);
return Dom::getDouble(libsumo::DISTANCE_REQUEST, vehID, &content);
Expand Down Expand Up @@ -997,10 +997,10 @@ Vehicle::setSpeed(const std::string& vehID, double speed) {
}

void
Vehicle::setAcceleration(const std::string& vehID, double accel, double duration) {
Vehicle::setAcceleration(const std::string& vehID, double acceleration, double duration) {
tcpip::Storage content;
StoHelp::writeCompound(content, 2);
StoHelp::writeTypedDouble(content, accel);
StoHelp::writeTypedDouble(content, acceleration);
StoHelp::writeTypedDouble(content, duration);
Dom::set(libsumo::VAR_ACCELERATION, vehID, &content);
}
Expand Down Expand Up @@ -1183,8 +1183,8 @@ Vehicle::setLine(const std::string& vehID, const std::string& line) {


void
Vehicle::setVia(const std::string& vehID, const std::vector<std::string>& via) {
Dom::setStringVector(libsumo::VAR_VIA, vehID, via);
Vehicle::setVia(const std::string& vehID, const std::vector<std::string>& edgeList) {
Dom::setStringVector(libsumo::VAR_VIA, vehID, edgeList);
}


Expand Down
5 changes: 4 additions & 1 deletion tests/complex/traci/misc/signature/output.complex
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Retrying in 1 seconds
lane.getLinks traci: (laneID, extended=True) libsumo: (laneID)
person.getPosition traci: (personID) libsumo: (personID, includeZ=False)
poi.getPosition traci: (poiID) libsumo: (poiID, includeZ=False)
vehicle.getPosition traci: (vehID) libsumo: (vehID, includeZ=False)
6 changes: 3 additions & 3 deletions tools/libsumo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ def init(port):
_libsumo_step = simulation.step


def simulationStep(step=0):
_libsumo_step(step)
_stepManager.manageStepListeners(step)
def simulationStep(time=0.):
_libsumo_step(time)
_stepManager.manageStepListeners(time)


simulation.step = simulationStep
Expand Down
7 changes: 0 additions & 7 deletions tools/traci/_person.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,6 @@ def getLanePosition(self, personID):
"""
return self._getUniversal(tc.VAR_LANEPOSITION, personID)

def getSpeedFactor(self, personID):
"""getSpeedFactor(string) -> double
Returns the quotient of this persons maximum speed and the maximum speed of its type
"""
return self._getUniversal(tc.VAR_SPEED_FACTOR, personID)

def getWaitingTime(self, personID):
"""getWaitingTime(string) -> double
The waiting time of a person is defined as the time (in seconds) spent with a
Expand Down
10 changes: 5 additions & 5 deletions tools/traci/_trafficlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,15 @@ def setPhaseDuration(self, tlsID, phaseDuration):
"""
self._setCmd(tc.TL_PHASE_DURATION, tlsID, "d", phaseDuration)

def setProgramLogic(self, tlsID, tls):
def setProgramLogic(self, tlsID, logic):
"""setProgramLogic(string, Logic) -> None
Sets a new program for the given tlsID from a Logic object.
See getCompleteRedYellowGreenDefinition.
"""
format = "tsiit"
values = [5, tls.programID, tls.type, tls.currentPhaseIndex, len(tls.phases)]
for p in tls.phases:
values = [5, logic.programID, logic.type, logic.currentPhaseIndex, len(logic.phases)]
for p in logic.phases:
format += "tdsddt"
values += [6, p.duration, p.state, p.minDur, p.maxDur, len(p.next)]
for n in p.next:
Expand All @@ -413,8 +413,8 @@ def setProgramLogic(self, tlsID, tls):
values += [p.name]
# subparams
format += "t"
values += [len(tls.subParameter)]
for par in tls.subParameter.items():
values += [len(logic.subParameter)]
for par in logic.subParameter.items():
format += "l"
values += [par]
self._setCmd(tc.TL_COMPLETE_PROGRAM_RYG, tlsID, format, *values)
Expand Down
18 changes: 9 additions & 9 deletions tools/traci/_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,13 +758,13 @@ def getNextTLS(self, vehID):
"""
return self._getUniversal(tc.VAR_NEXT_TLS, vehID)

def getJunctionFoes(self, vehID, distance):
def getJunctionFoes(self, vehID, dist=0.):
"""getJunctionFoes(string, double) -> complex
Return list of junction foes [(foeId, egoDist, foeDist, egoExitDist, foeExitDist,
egoLane, foeLane, egoResponse, foeResponse), ...] within the given distance to the given vehicle.
"""
return self._getUniversal(tc.VAR_FOES, vehID, "d", distance)
return self._getUniversal(tc.VAR_FOES, vehID, "d", dist)

@deprecated()
def getNextStops(self, vehID):
Expand Down Expand Up @@ -972,14 +972,14 @@ def getRoutingMode(self, vehID):
"""
return self._getUniversal(tc.VAR_ROUTING_MODE, vehID)

def getTaxiFleet(self, flag):
def getTaxiFleet(self, taxiState=0):
"""getTaxiFleet(int) -> list(string)
Return the list of all taxis with the given mode:
Return the list of all taxis with the given taxiState:
0 : empty
1 : pickup
2 : occupied
"""
return self._getUniversal(tc.VAR_TAXI_FLEET, "", "i", flag)
return self._getUniversal(tc.VAR_TAXI_FLEET, "", "i", taxiState)

def getLoadedIDList(self):
"""getLoadedIDList() -> list(string)
Expand Down Expand Up @@ -1403,19 +1403,19 @@ def highlight(self, vehID, color=(255, 0, 0, 255), size=-1, alphaMax=-1, duratio
else:
self._setCmd(tc.VAR_HIGHLIGHT, vehID, "tcd", 2, color, size)

def setLaneChangeMode(self, vehID, lcm):
def setLaneChangeMode(self, vehID, laneChangeMode):
"""setLaneChangeMode(string, integer) -> None
Sets the vehicle's lane change mode as a bitset.
"""
self._setCmd(tc.VAR_LANECHANGE_MODE, vehID, "i", lcm)
self._setCmd(tc.VAR_LANECHANGE_MODE, vehID, "i", laneChangeMode)

def setSpeedMode(self, vehID, sm):
def setSpeedMode(self, vehID, speedMode):
"""setSpeedMode(string, integer) -> None
Sets the vehicle's speed mode as a bitset.
"""
self._setCmd(tc.VAR_SPEEDSETMODE, vehID, "i", sm)
self._setCmd(tc.VAR_SPEEDSETMODE, vehID, "i", speedMode)

def addLegacy(self, vehID, routeID, depart=tc.DEPARTFLAG_NOW, pos=0, speed=0,
lane=tc.DEPARTFLAG_LANE_FIRST_ALLOWED, typeID="DEFAULT_VEHTYPE"):
Expand Down
4 changes: 2 additions & 2 deletions tools/traci/_vehicletype.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,14 @@ def setEmissionClass(self, typeID, clazz):
"""
self._setCmd(tc.VAR_EMISSIONCLASS, typeID, "s", clazz)

def setShapeClass(self, typeID, clazz):
def setShapeClass(self, typeID, shapeClass):
"""setShapeClass(string, string) -> None
Sets the shape class of this type.
If called in the context of a person or vehicle, it will change the value just for the single instance.
Use the respective object ID as typeID value in said context.
"""
self._setCmd(tc.VAR_SHAPECLASS, typeID, "s", clazz)
self._setCmd(tc.VAR_SHAPECLASS, typeID, "s", shapeClass)

def setWidth(self, typeID, width):
"""setWidth(string, double) -> None
Expand Down

0 comments on commit 7a4c998

Please sign in to comment.