50std::vector<std::string>
53 std::vector<std::string> ids;
61 return (
int)getIDList().size();
66Lane::getEdgeID(
const std::string& laneID) {
67 return getLane(laneID)->getEdge().getID();
72Lane::getLength(
const std::string& laneID) {
73 return getLane(laneID)->getLength();
78Lane::getMaxSpeed(
const std::string& laneID) {
79 return getLane(laneID)->getSpeedLimit();
83Lane::getFriction(
const std::string& laneID) {
84 return getLane(laneID)->getFrictionCoefficient();
88Lane::getLinkNumber(
const std::string& laneID) {
89 return (
int)getLane(laneID)->getLinkCont().size();
93std::vector<TraCIConnection>
94Lane::getLinks(
const std::string& laneID) {
95 std::vector<TraCIConnection> v;
96 const MSLane*
const lane = getLane(laneID);
99 const std::string approachedLane = link->getLane() !=
nullptr ? link->getLane()->getID() :
"";
100 const bool hasPrio = link->havePriority();
101 const double speed =
MIN2(lane->
getSpeedLimit(), link->getLane()->getSpeedLimit());
105 const std::string approachedInternal = link->getViaLane() !=
nullptr ? link->getViaLane()->getID() :
"";
108 const double length = link->getLength();
109 v.push_back(TraCIConnection(approachedLane, hasPrio, isOpen, hasFoe, approachedInternal, state, direction, length));
115std::vector<std::string>
116Lane::getAllowed(
const std::string& laneID) {
118 if (permissions ==
SVCAll) {
125std::vector<std::string>
126Lane::getDisallowed(
const std::string& laneID) {
131std::vector<std::string>
132Lane::getChangePermissions(
const std::string& laneID,
const int direction) {
144Lane::getShape(
const std::string& laneID) {
145 TraCIPositionVector pv;
147 for (PositionVector::const_iterator pi = shp.begin(); pi != shp.end(); ++pi) {
152 pv.value.push_back(p);
159Lane::getWidth(
const std::string& laneID) {
160 return getLane(laneID)->getWidth();
165Lane::getCO2Emission(
const std::string& laneID) {
171Lane::getCOEmission(
const std::string& laneID) {
177Lane::getHCEmission(
const std::string& laneID) {
183Lane::getPMxEmission(
const std::string& laneID) {
189Lane::getNOxEmission(
const std::string& laneID) {
194Lane::getFuelConsumption(
const std::string& laneID) {
200Lane::getNoiseEmission(
const std::string& laneID) {
201 return getLane(laneID)->getHarmonoise_NoiseEmissions();
206Lane::getElectricityConsumption(
const std::string& laneID) {
212Lane::getLastStepMeanSpeed(
const std::string& laneID) {
213 return getLane(laneID)->getMeanSpeed();
218Lane::getLastStepOccupancy(
const std::string& laneID) {
219 return getLane(laneID)->getNettoOccupancy();
224Lane::getLastStepLength(
const std::string& laneID) {
225 const MSLane* lane = getLane(laneID);
228 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
229 length += (*j)->getVehicleType().getLength();
231 if (vehs.size() > 0) {
232 length = length / (double)vehs.size();
240Lane::getWaitingTime(
const std::string& laneID) {
241 return getLane(laneID)->getWaitingSeconds();
246Lane::getTraveltime(
const std::string& laneID) {
247 const MSLane* lane = getLane(laneID);
249 if (meanSpeed != 0) {
258Lane::getLastStepVehicleNumber(
const std::string& laneID) {
259 return (
int)getLane(laneID)->getVehicleNumber();
264Lane::getLastStepHaltingNumber(
const std::string& laneID) {
265 const MSLane* lane = getLane(laneID);
268 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
278std::vector<std::string>
279Lane::getLastStepVehicleIDs(
const std::string& laneID) {
280 const MSLane* lane = getLane(laneID);
281 std::vector<std::string> vehIDs;
283 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
284 vehIDs.push_back((*j)->getID());
291std::vector<std::string>
292Lane::getFoes(
const std::string& laneID,
const std::string& toLaneID) {
293 std::vector<std::string> foeIDs;
294 const MSLink*
const link = getLane(laneID)->getLinkTo(getLane(toLaneID));
295 if (link ==
nullptr) {
296 throw TraCIException(
"No connection from lane '" + laneID +
"' to lane '" + toLaneID +
"'");
299 foeIDs.push_back(foe->getLaneBefore()->getID());
305std::vector<std::string>
306Lane::getInternalFoes(
const std::string& laneID) {
307 const MSLane* lane = getLane(laneID);
308 const std::vector<const MSLane*>* foeLanes;
309 std::vector<const MSLane*>::const_iterator it;
310 std::vector<std::string> foeIDs;
316 for (it = foeLanes->begin(); foeLanes->end() != it; ++it) {
317 foeIDs.push_back((*it)->getID());
324const std::vector<std::string>
325Lane::getPendingVehicles(
const std::string& laneID) {
326 MSLane*
const l = getLane(laneID);
327 std::vector<std::string> vehIDs;
329 if (veh->getLane() == l) {
330 vehIDs.push_back(veh->getID());
338Lane::getAngle(
const std::string& laneID,
double relativePosition) {
340 MSLane* lane = getLane(laneID);
354Lane::getBidiLane(
const std::string& laneID) {
356 return bidi ==
nullptr ?
"" : bidi->
getID();
360Lane::setAllowed(
const std::string& laneID, std::string allowedClass) {
361 setAllowed(laneID, std::vector<std::string>({allowedClass}));
366Lane::setAllowed(
const std::string& laneID, std::vector<std::string> allowedClasses) {
367 MSLane*
const l = getLane(laneID);
374Lane::setDisallowed(
const std::string& laneID, std::string disallowedClasses) {
375 setDisallowed(laneID, std::vector<std::string>({disallowedClasses}));
380Lane::setDisallowed(
const std::string& laneID, std::vector<std::string> disallowedClasses) {
381 MSLane*
const l = getLane(laneID);
388Lane::setChangePermissions(
const std::string& laneID, std::vector<std::string> allowedClasses,
const int direction) {
389 MSLane*
const l = getLane(laneID);
401Lane::setMaxSpeed(
const std::string& laneID,
double speed) {
402 getLane(laneID)->setMaxSpeed(speed,
false,
true);
407Lane::setLength(
const std::string& laneID,
double length) {
408 getLane(laneID)->setLength(length);
413Lane::setFriction(
const std::string& laneID,
double friction) {
414 getLane(laneID)->setFrictionCoefficient(friction);
419Lane::getParameter(
const std::string& laneID,
const std::string& param) {
420 return getLane(laneID)->getParameter(param,
"");
428Lane::setParameter(
const std::string& laneID,
const std::string& key,
const std::string& value) {
429 getLane(laneID)->setParameter(key, value);
437Lane::getLane(
const std::string&
id) {
439 if (lane ==
nullptr) {
440 throw TraCIException(
"Lane '" +
id +
"' is not known");
448 shape = getLane(
id)->getShape();
452std::shared_ptr<VariableWrapper>
454 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
459Lane::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
462 return wrapper->wrapStringList(objID, variable, getIDList());
464 return wrapper->wrapInt(objID, variable, getIDCount());
466 return wrapper->wrapInt(objID, variable, getLinkNumber(objID));
468 return wrapper->wrapString(objID, variable, getEdgeID(objID));
470 return wrapper->wrapDouble(objID, variable, getLength(objID));
472 return wrapper->wrapDouble(objID, variable, getMaxSpeed(objID));
474 return wrapper->wrapDouble(objID, variable, getFriction(objID));
476 return wrapper->wrapStringList(objID, variable, getAllowed(objID));
478 return wrapper->wrapStringList(objID, variable, getDisallowed(objID));
481 return wrapper->wrapStringList(objID, variable, getChangePermissions(objID, paramData->
readByte()));
483 return wrapper->wrapDouble(objID, variable, getCO2Emission(objID));
485 return wrapper->wrapDouble(objID, variable, getCOEmission(objID));
487 return wrapper->wrapDouble(objID, variable, getHCEmission(objID));
489 return wrapper->wrapDouble(objID, variable, getPMxEmission(objID));
491 return wrapper->wrapDouble(objID, variable, getNOxEmission(objID));
493 return wrapper->wrapDouble(objID, variable, getFuelConsumption(objID));
495 return wrapper->wrapDouble(objID, variable, getNoiseEmission(objID));
497 return wrapper->wrapDouble(objID, variable, getElectricityConsumption(objID));
499 return wrapper->wrapInt(objID, variable, getLastStepVehicleNumber(objID));
501 return wrapper->wrapDouble(objID, variable, getLastStepMeanSpeed(objID));
503 return wrapper->wrapStringList(objID, variable, getLastStepVehicleIDs(objID));
505 return wrapper->wrapDouble(objID, variable, getLastStepOccupancy(objID));
507 return wrapper->wrapInt(objID, variable, getLastStepHaltingNumber(objID));
509 return wrapper->wrapDouble(objID, variable, getLastStepLength(objID));
511 return wrapper->wrapDouble(objID, variable, getWaitingTime(objID));
513 return wrapper->wrapDouble(objID, variable, getTraveltime(objID));
515 return wrapper->wrapDouble(objID, variable, getWidth(objID));
517 return wrapper->wrapPositionVector(objID, variable, getShape(objID));
519 return wrapper->wrapStringList(objID, variable, getPendingVehicles(objID));
522 return wrapper->wrapDouble(objID, variable, getAngle(objID, paramData->
readDouble()));
524 return wrapper->wrapString(objID, variable, getBidiLane(objID));
527 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
530 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...
long long 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)
const MSVehicleContainer::VehicleVector & getPendingVehicles() const
retrieve vehicles waiting for insertion
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
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
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.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
const std::string & getID() const
Returns the id.
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 (in radians bet...
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