50std::vector<std::string>
52 std::vector<std::string> ids;
60 return (
int)getIDList().size();
65Lane::getEdgeID(
const std::string& laneID) {
66 return getLane(laneID)->getEdge().getID();
71Lane::getLength(
const std::string& laneID) {
72 return getLane(laneID)->getLength();
77Lane::getMaxSpeed(
const std::string& laneID) {
78 return getLane(laneID)->getSpeedLimit();
82Lane::getFriction(
const std::string& laneID) {
83 return getLane(laneID)->getFrictionCoefficient();
87Lane::getLinkNumber(
const std::string& laneID) {
88 return (
int)getLane(laneID)->getLinkCont().size();
92std::vector<TraCIConnection>
93Lane::getLinks(
const std::string& laneID) {
94 std::vector<TraCIConnection> v;
95 const MSLane*
const lane = getLane(laneID);
98 const std::string approachedLane = link->getLane() !=
nullptr ? link->getLane()->getID() :
"";
99 const bool hasPrio = link->havePriority();
100 const double speed =
MIN2(lane->
getSpeedLimit(), link->getLane()->getSpeedLimit());
104 const std::string approachedInternal = link->getViaLane() !=
nullptr ? link->getViaLane()->getID() :
"";
107 const double length = link->getLength();
108 v.push_back(TraCIConnection(approachedLane, hasPrio, isOpen, hasFoe, approachedInternal, state, direction, length));
114std::vector<std::string>
115Lane::getAllowed(
const std::string& laneID) {
117 if (permissions ==
SVCAll) {
124std::vector<std::string>
125Lane::getDisallowed(
const std::string& laneID) {
130std::vector<std::string>
131Lane::getChangePermissions(
const std::string& laneID,
const int direction) {
143Lane::getShape(
const std::string& laneID) {
144 TraCIPositionVector pv;
146 for (PositionVector::const_iterator pi = shp.begin(); pi != shp.end(); ++pi) {
151 pv.value.push_back(p);
158Lane::getWidth(
const std::string& laneID) {
159 return getLane(laneID)->getWidth();
164Lane::getCO2Emission(
const std::string& laneID) {
170Lane::getCOEmission(
const std::string& laneID) {
176Lane::getHCEmission(
const std::string& laneID) {
182Lane::getPMxEmission(
const std::string& laneID) {
188Lane::getNOxEmission(
const std::string& laneID) {
193Lane::getFuelConsumption(
const std::string& laneID) {
199Lane::getNoiseEmission(
const std::string& laneID) {
200 return getLane(laneID)->getHarmonoise_NoiseEmissions();
205Lane::getElectricityConsumption(
const std::string& laneID) {
211Lane::getLastStepMeanSpeed(
const std::string& laneID) {
212 return getLane(laneID)->getMeanSpeed();
217Lane::getLastStepOccupancy(
const std::string& laneID) {
218 return getLane(laneID)->getNettoOccupancy();
223Lane::getLastStepLength(
const std::string& laneID) {
224 const MSLane* lane = getLane(laneID);
227 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
228 length += (*j)->getVehicleType().getLength();
230 if (vehs.size() > 0) {
231 length = length / (double)vehs.size();
239Lane::getWaitingTime(
const std::string& laneID) {
240 return getLane(laneID)->getWaitingSeconds();
245Lane::getTraveltime(
const std::string& laneID) {
246 const MSLane* lane = getLane(laneID);
248 if (meanSpeed != 0) {
257Lane::getLastStepVehicleNumber(
const std::string& laneID) {
258 return (
int)getLane(laneID)->getVehicleNumber();
263Lane::getLastStepHaltingNumber(
const std::string& laneID) {
264 const MSLane* lane = getLane(laneID);
267 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
277std::vector<std::string>
278Lane::getLastStepVehicleIDs(
const std::string& laneID) {
279 const MSLane* lane = getLane(laneID);
280 std::vector<std::string> vehIDs;
282 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
283 vehIDs.push_back((*j)->getID());
290std::vector<std::string>
291Lane::getFoes(
const std::string& laneID,
const std::string& toLaneID) {
292 std::vector<std::string> foeIDs;
293 const MSLink*
const link = getLane(laneID)->getLinkTo(getLane(toLaneID));
294 if (link ==
nullptr) {
295 throw TraCIException(
"No connection from lane '" + laneID +
"' to lane '" + toLaneID +
"'");
298 foeIDs.push_back(foe->getLaneBefore()->getID());
304std::vector<std::string>
305Lane::getInternalFoes(
const std::string& laneID) {
306 const MSLane* lane = getLane(laneID);
307 const std::vector<const MSLane*>* foeLanes;
308 std::vector<const MSLane*>::const_iterator it;
309 std::vector<std::string> foeIDs;
315 for (it = foeLanes->begin(); foeLanes->end() != it; ++it) {
316 foeIDs.push_back((*it)->getID());
323const std::vector<std::string>
324Lane::getPendingVehicles(
const std::string& laneID) {
325 MSLane*
const l = getLane(laneID);
326 std::vector<std::string> vehIDs;
328 if (veh->getLane() == l) {
329 vehIDs.push_back(veh->getID());
337Lane::getAngle(
const std::string& laneID,
double relativePosition) {
339 MSLane* lane = getLane(laneID);
353Lane::setAllowed(
const std::string& laneID, std::string allowedClass) {
354 setAllowed(laneID, std::vector<std::string>({allowedClass}));
359Lane::setAllowed(
const std::string& laneID, std::vector<std::string> allowedClasses) {
360 MSLane*
const l = getLane(laneID);
367Lane::setDisallowed(
const std::string& laneID, std::string disallowedClasses) {
368 setDisallowed(laneID, std::vector<std::string>({disallowedClasses}));
373Lane::setDisallowed(
const std::string& laneID, std::vector<std::string> disallowedClasses) {
374 MSLane*
const l = getLane(laneID);
381Lane::setChangePermissions(
const std::string& laneID, std::vector<std::string> allowedClasses,
const int direction) {
382 MSLane*
const l = getLane(laneID);
394Lane::setMaxSpeed(
const std::string& laneID,
double speed) {
395 getLane(laneID)->setMaxSpeed(speed);
400Lane::setLength(
const std::string& laneID,
double length) {
401 getLane(laneID)->setLength(length);
406Lane::setFriction(
const std::string& laneID,
double friction) {
407 getLane(laneID)->setFrictionCoefficient(friction);
412Lane::getParameter(
const std::string& laneID,
const std::string& param) {
413 return getLane(laneID)->getParameter(param,
"");
421Lane::setParameter(
const std::string& laneID,
const std::string& key,
const std::string& value) {
422 getLane(laneID)->setParameter(key, value);
430Lane::getLane(
const std::string&
id) {
432 if (lane ==
nullptr) {
433 throw TraCIException(
"Lane '" +
id +
"' is not known");
441 shape = getLane(
id)->getShape();
445std::shared_ptr<VariableWrapper>
447 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
452Lane::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
455 return wrapper->wrapStringList(objID, variable, getIDList());
457 return wrapper->wrapInt(objID, variable, getIDCount());
459 return wrapper->wrapInt(objID, variable, getLinkNumber(objID));
461 return wrapper->wrapString(objID, variable, getEdgeID(objID));
463 return wrapper->wrapDouble(objID, variable, getLength(objID));
465 return wrapper->wrapDouble(objID, variable, getMaxSpeed(objID));
467 return wrapper->wrapDouble(objID, variable, getFriction(objID));
469 return wrapper->wrapStringList(objID, variable, getAllowed(objID));
471 return wrapper->wrapStringList(objID, variable, getDisallowed(objID));
474 return wrapper->wrapStringList(objID, variable, getChangePermissions(objID, paramData->
readByte()));
476 return wrapper->wrapDouble(objID, variable, getCO2Emission(objID));
478 return wrapper->wrapDouble(objID, variable, getCOEmission(objID));
480 return wrapper->wrapDouble(objID, variable, getHCEmission(objID));
482 return wrapper->wrapDouble(objID, variable, getPMxEmission(objID));
484 return wrapper->wrapDouble(objID, variable, getNOxEmission(objID));
486 return wrapper->wrapDouble(objID, variable, getFuelConsumption(objID));
488 return wrapper->wrapDouble(objID, variable, getNoiseEmission(objID));
490 return wrapper->wrapDouble(objID, variable, getElectricityConsumption(objID));
492 return wrapper->wrapInt(objID, variable, getLastStepVehicleNumber(objID));
494 return wrapper->wrapDouble(objID, variable, getLastStepMeanSpeed(objID));
496 return wrapper->wrapStringList(objID, variable, getLastStepVehicleIDs(objID));
498 return wrapper->wrapDouble(objID, variable, getLastStepOccupancy(objID));
500 return wrapper->wrapInt(objID, variable, getLastStepHaltingNumber(objID));
502 return wrapper->wrapDouble(objID, variable, getLastStepLength(objID));
504 return wrapper->wrapDouble(objID, variable, getWaitingTime(objID));
506 return wrapper->wrapDouble(objID, variable, getTraveltime(objID));
508 return wrapper->wrapDouble(objID, variable, getWidth(objID));
510 return wrapper->wrapPositionVector(objID, variable, getShape(objID));
512 return wrapper->wrapStringList(objID, variable, getPendingVehicles(objID));
515 return wrapper->wrapDouble(objID, variable, getAngle(objID, paramData->
readDouble()));
518 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
521 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->
readString()));
const SVCPermissions SVCAll
all VClasses are allowed
SVCPermissions invertPermissions(SVCPermissions permissions)
negate the given permissions and ensure that only relevant bits are set
const std::vector< std::string > & getVehicleClassNamesList(SVCPermissions permissions)
Returns the ids of the given classes, divided using a ' '.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
static double naviDegree(const double angle)
C++ TraCI client API implementation.
void rebuildAllowedLanes(const bool onInit=false)
Representation of a lane in the micro simulation.
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
void setChangeRight(SVCPermissions permissions)
Sets the permissions for changing to the right neighbour lane.
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
std::vector< MSVehicle * > VehCont
Container for vehicles.
static const long CHANGE_PERMISSIONS_PERMANENT
double getLength() const
Returns the lane's length.
void setChangeLeft(SVCPermissions permissions)
Sets the permissions for changing to the left neighbour lane.
void setPermissions(SVCPermissions permissions, long long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
double interpolateLanePosToGeometryPos(double lanePos) const
virtual const PositionVector & getShape(bool) const
MSEdge & getEdge() const
Returns the lane's edge.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
double getMeanSpeed() const
Returns the mean speed on this lane.
const std::vector< const MSLane * > & getFoeLanes() const
const std::vector< MSLink * > & getFoeLinks() const
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
A point in 2D or 3D with translation and scaling methods.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
static double getDefaultDecel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default deceleration for the given vehicle class This needs to be a function because the ...
static const SUMOVTypeParameter & getDefault()
return the default parameters, this is a function due to the http://www.parashift....
Representation of a vehicle.
static StringBijection< LinkState > LinkStates
link states
static StringBijection< LinkDirection > LinkDirections
link directions
const std::string & getString(const T key) const
virtual std::string readString()
virtual int readUnsignedByte()
virtual double readDouble()
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int LAST_STEP_VEHICLE_ID_LIST
TRACI_CONST int LAST_STEP_VEHICLE_NUMBER
TRACI_CONST int VAR_NOXEMISSION
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_WAITING_TIME
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int LANE_LINK_NUMBER
TRACI_CONST int LANE_CHANGES
TRACI_CONST int LAST_STEP_LENGTH
TRACI_CONST int VAR_ANGLE
TRACI_CONST int LANE_EDGE_ID
TRACI_CONST int VAR_PMXEMISSION
TRACI_CONST int VAR_COEMISSION
TRACI_CONST int VAR_WIDTH
TRACI_CONST int VAR_MAXSPEED
TRACI_CONST int LAST_STEP_MEAN_SPEED
TRACI_CONST int VAR_CO2EMISSION
TRACI_CONST int LANECHANGE_RIGHT
TRACI_CONST int VAR_PENDING_VEHICLES
TRACI_CONST int VAR_FUELCONSUMPTION
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_SHAPE
TRACI_CONST int LAST_STEP_VEHICLE_HALTING_NUMBER
TRACI_CONST int VAR_LENGTH
TRACI_CONST int VAR_HCEMISSION
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int LANECHANGE_LEFT
TRACI_CONST int LAST_STEP_OCCUPANCY
TRACI_CONST int VAR_NOISEEMISSION
TRACI_CONST int LANE_DISALLOWED
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int VAR_FRICTION
TRACI_CONST int VAR_CURRENT_TRAVELTIME
TRACI_CONST int LANE_ALLOWED
TRACI_CONST int VAR_ELECTRICITYCONSUMPTION