49std::vector<std::string>
51 std::vector<std::string> ids;
59 return (
int)getIDList().size();
64Lane::getEdgeID(
const std::string& laneID) {
65 return getLane(laneID)->getEdge().getID();
70Lane::getLength(
const std::string& laneID) {
71 return getLane(laneID)->getLength();
76Lane::getMaxSpeed(
const std::string& laneID) {
77 return getLane(laneID)->getSpeedLimit();
81Lane::getFriction(
const std::string& laneID) {
82 return getLane(laneID)->getFrictionCoefficient();
86Lane::getLinkNumber(
const std::string& laneID) {
87 return (
int)getLane(laneID)->getLinkCont().size();
91std::vector<TraCIConnection>
92Lane::getLinks(
const std::string& laneID) {
93 std::vector<TraCIConnection> v;
94 const MSLane*
const lane = getLane(laneID);
97 const std::string approachedLane = link->getLane() !=
nullptr ? link->getLane()->getID() :
"";
98 const bool hasPrio = link->havePriority();
99 const double speed =
MIN2(lane->
getSpeedLimit(), link->getLane()->getSpeedLimit());
103 const std::string approachedInternal = link->getViaLane() !=
nullptr ? link->getViaLane()->getID() :
"";
106 const double length = link->getLength();
107 v.push_back(TraCIConnection(approachedLane, hasPrio, isOpen, hasFoe, approachedInternal, state, direction, length));
113std::vector<std::string>
114Lane::getAllowed(
const std::string& laneID) {
116 if (permissions ==
SVCAll) {
123std::vector<std::string>
124Lane::getDisallowed(
const std::string& laneID) {
129std::vector<std::string>
130Lane::getChangePermissions(
const std::string& laneID,
const int direction) {
142Lane::getShape(
const std::string& laneID) {
143 TraCIPositionVector pv;
145 for (PositionVector::const_iterator pi = shp.begin(); pi != shp.end(); ++pi) {
150 pv.value.push_back(p);
157Lane::getWidth(
const std::string& laneID) {
158 return getLane(laneID)->getWidth();
163Lane::getCO2Emission(
const std::string& laneID) {
169Lane::getCOEmission(
const std::string& laneID) {
175Lane::getHCEmission(
const std::string& laneID) {
181Lane::getPMxEmission(
const std::string& laneID) {
187Lane::getNOxEmission(
const std::string& laneID) {
192Lane::getFuelConsumption(
const std::string& laneID) {
198Lane::getNoiseEmission(
const std::string& laneID) {
199 return getLane(laneID)->getHarmonoise_NoiseEmissions();
204Lane::getElectricityConsumption(
const std::string& laneID) {
210Lane::getLastStepMeanSpeed(
const std::string& laneID) {
211 return getLane(laneID)->getMeanSpeed();
216Lane::getLastStepOccupancy(
const std::string& laneID) {
217 return getLane(laneID)->getNettoOccupancy();
222Lane::getLastStepLength(
const std::string& laneID) {
223 const MSLane* lane = getLane(laneID);
226 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
227 length += (*j)->getVehicleType().getLength();
229 if (vehs.size() > 0) {
230 length = length / (double)vehs.size();
238Lane::getWaitingTime(
const std::string& laneID) {
239 return getLane(laneID)->getWaitingSeconds();
244Lane::getTraveltime(
const std::string& laneID) {
245 const MSLane* lane = getLane(laneID);
247 if (meanSpeed != 0) {
256Lane::getLastStepVehicleNumber(
const std::string& laneID) {
257 return (
int)getLane(laneID)->getVehicleNumber();
262Lane::getLastStepHaltingNumber(
const std::string& laneID) {
263 const MSLane* lane = getLane(laneID);
266 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
276std::vector<std::string>
277Lane::getLastStepVehicleIDs(
const std::string& laneID) {
278 const MSLane* lane = getLane(laneID);
279 std::vector<std::string> vehIDs;
281 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
282 vehIDs.push_back((*j)->getID());
289std::vector<std::string>
290Lane::getFoes(
const std::string& laneID,
const std::string& toLaneID) {
291 std::vector<std::string> foeIDs;
292 const MSLink*
const link = getLane(laneID)->getLinkTo(getLane(toLaneID));
293 if (link ==
nullptr) {
294 throw TraCIException(
"No connection from lane '" + laneID +
"' to lane '" + toLaneID +
"'");
297 foeIDs.push_back(foe->getLaneBefore()->getID());
303std::vector<std::string>
304Lane::getInternalFoes(
const std::string& laneID) {
305 const MSLane* lane = getLane(laneID);
306 const std::vector<const MSLane*>* foeLanes;
307 std::vector<const MSLane*>::const_iterator it;
308 std::vector<std::string> foeIDs;
314 for (it = foeLanes->begin(); foeLanes->end() != it; ++it) {
315 foeIDs.push_back((*it)->getID());
322const std::vector<std::string>
323Lane::getPendingVehicles(
const std::string& laneID) {
324 MSLane*
const l = getLane(laneID);
325 std::vector<std::string> vehIDs;
327 if (veh->getLane() == l) {
328 vehIDs.push_back(veh->getID());
336Lane::setAllowed(
const std::string& laneID, std::string allowedClass) {
337 setAllowed(laneID, std::vector<std::string>({allowedClass}));
342Lane::setAllowed(
const std::string& laneID, std::vector<std::string> allowedClasses) {
343 MSLane*
const l = getLane(laneID);
350Lane::setDisallowed(
const std::string& laneID, std::string disallowedClasses) {
351 setDisallowed(laneID, std::vector<std::string>({disallowedClasses}));
356Lane::setDisallowed(
const std::string& laneID, std::vector<std::string> disallowedClasses) {
357 MSLane*
const l = getLane(laneID);
364Lane::setChangePermissions(
const std::string& laneID, std::vector<std::string> allowedClasses,
const int direction) {
365 MSLane*
const l = getLane(laneID);
377Lane::setMaxSpeed(
const std::string& laneID,
double speed) {
378 getLane(laneID)->setMaxSpeed(speed);
383Lane::setLength(
const std::string& laneID,
double length) {
384 getLane(laneID)->setLength(length);
389Lane::setFriction(
const std::string& laneID,
double friction) {
390 getLane(laneID)->setFrictionCoefficient(friction);
395Lane::getParameter(
const std::string& laneID,
const std::string& param) {
396 return getLane(laneID)->getParameter(param,
"");
404Lane::setParameter(
const std::string& laneID,
const std::string& key,
const std::string& value) {
405 getLane(laneID)->setParameter(key, value);
413Lane::getLane(
const std::string&
id) {
415 if (lane ==
nullptr) {
416 throw TraCIException(
"Lane '" +
id +
"' is not known");
424 shape = getLane(
id)->getShape();
428std::shared_ptr<VariableWrapper>
430 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
435Lane::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
438 return wrapper->wrapStringList(objID, variable, getIDList());
440 return wrapper->wrapInt(objID, variable, getIDCount());
442 return wrapper->wrapInt(objID, variable, getLinkNumber(objID));
444 return wrapper->wrapString(objID, variable, getEdgeID(objID));
446 return wrapper->wrapDouble(objID, variable, getLength(objID));
448 return wrapper->wrapDouble(objID, variable, getMaxSpeed(objID));
450 return wrapper->wrapDouble(objID, variable, getFriction(objID));
452 return wrapper->wrapStringList(objID, variable, getAllowed(objID));
454 return wrapper->wrapStringList(objID, variable, getDisallowed(objID));
457 return wrapper->wrapStringList(objID, variable, getChangePermissions(objID, paramData->
readByte()));
459 return wrapper->wrapDouble(objID, variable, getCO2Emission(objID));
461 return wrapper->wrapDouble(objID, variable, getCOEmission(objID));
463 return wrapper->wrapDouble(objID, variable, getHCEmission(objID));
465 return wrapper->wrapDouble(objID, variable, getPMxEmission(objID));
467 return wrapper->wrapDouble(objID, variable, getNOxEmission(objID));
469 return wrapper->wrapDouble(objID, variable, getFuelConsumption(objID));
471 return wrapper->wrapDouble(objID, variable, getNoiseEmission(objID));
473 return wrapper->wrapDouble(objID, variable, getElectricityConsumption(objID));
475 return wrapper->wrapInt(objID, variable, getLastStepVehicleNumber(objID));
477 return wrapper->wrapDouble(objID, variable, getLastStepMeanSpeed(objID));
479 return wrapper->wrapStringList(objID, variable, getLastStepVehicleIDs(objID));
481 return wrapper->wrapDouble(objID, variable, getLastStepOccupancy(objID));
483 return wrapper->wrapInt(objID, variable, getLastStepHaltingNumber(objID));
485 return wrapper->wrapDouble(objID, variable, getLastStepLength(objID));
487 return wrapper->wrapDouble(objID, variable, getWaitingTime(objID));
489 return wrapper->wrapDouble(objID, variable, getTraveltime(objID));
491 return wrapper->wrapDouble(objID, variable, getWidth(objID));
493 return wrapper->wrapPositionVector(objID, variable, getShape(objID));
495 return wrapper->wrapStringList(objID, variable, getPendingVehicles(objID));
498 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
501 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)
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.
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.
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()
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 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