49std::vector<std::string>
51 std::vector<std::string> ids;
59 return (
int)getIDList().size();
64Lane::getEdgeID(std::string laneID) {
65 return getLane(laneID)->getEdge().getID();
70Lane::getLength(std::string laneID) {
71 return getLane(laneID)->getLength();
76Lane::getMaxSpeed(std::string laneID) {
77 return getLane(laneID)->getSpeedLimit();
81Lane::getFriction(std::string laneID) {
82 return getLane(laneID)->getFrictionCoefficient();
86Lane::getLinkNumber(std::string laneID) {
87 return (
int)getLane(laneID)->getLinkCont().size();
91std::vector<TraCIConnection>
92Lane::getLinks(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(std::string laneID) {
116 if (permissions ==
SVCAll) {
123std::vector<std::string>
124Lane::getDisallowed(std::string laneID) {
130Lane::getShape(std::string laneID) {
131 TraCIPositionVector pv;
133 for (PositionVector::const_iterator pi = shp.begin(); pi != shp.end(); ++pi) {
138 pv.value.push_back(p);
145Lane::getWidth(std::string laneID) {
146 return getLane(laneID)->getWidth();
151Lane::getCO2Emission(std::string laneID) {
157Lane::getCOEmission(std::string laneID) {
163Lane::getHCEmission(std::string laneID) {
169Lane::getPMxEmission(std::string laneID) {
175Lane::getNOxEmission(std::string laneID) {
180Lane::getFuelConsumption(std::string laneID) {
186Lane::getNoiseEmission(std::string laneID) {
187 return getLane(laneID)->getHarmonoise_NoiseEmissions();
192Lane::getElectricityConsumption(std::string laneID) {
198Lane::getLastStepMeanSpeed(std::string laneID) {
199 return getLane(laneID)->getMeanSpeed();
204Lane::getLastStepOccupancy(std::string laneID) {
205 return getLane(laneID)->getNettoOccupancy();
210Lane::getLastStepLength(std::string laneID) {
211 const MSLane* lane = getLane(laneID);
214 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
215 length += (*j)->getVehicleType().getLength();
217 if (vehs.size() > 0) {
218 length = length / (double)vehs.size();
226Lane::getWaitingTime(std::string laneID) {
227 return getLane(laneID)->getWaitingSeconds();
232Lane::getTraveltime(std::string laneID) {
233 const MSLane* lane = getLane(laneID);
235 if (meanSpeed != 0) {
244Lane::getLastStepVehicleNumber(std::string laneID) {
245 return (
int)getLane(laneID)->getVehicleNumber();
250Lane::getLastStepHaltingNumber(std::string laneID) {
251 const MSLane* lane = getLane(laneID);
254 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
264std::vector<std::string>
265Lane::getLastStepVehicleIDs(std::string laneID) {
266 const MSLane* lane = getLane(laneID);
267 std::vector<std::string> vehIDs;
269 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
270 vehIDs.push_back((*j)->getID());
277std::vector<std::string>
278Lane::getFoes(
const std::string& laneID,
const std::string& toLaneID) {
279 std::vector<std::string> foeIDs;
280 const MSLink*
const link = getLane(laneID)->getLinkTo(getLane(toLaneID));
281 if (link ==
nullptr) {
282 throw TraCIException(
"No connection from lane '" + laneID +
"' to lane '" + toLaneID +
"'");
285 foeIDs.push_back(foe->getLaneBefore()->getID());
291std::vector<std::string>
292Lane::getInternalFoes(
const std::string& laneID) {
293 const MSLane* lane = getLane(laneID);
294 const std::vector<const MSLane*>* foeLanes;
295 std::vector<const MSLane*>::const_iterator it;
296 std::vector<std::string> foeIDs;
302 for (it = foeLanes->begin(); foeLanes->end() != it; ++it) {
303 foeIDs.push_back((*it)->getID());
310const std::vector<std::string>
311Lane::getPendingVehicles(
const std::string& laneID) {
312 MSLane*
const l = getLane(laneID);
313 std::vector<std::string> vehIDs;
315 if (veh->getLane() == l) {
316 vehIDs.push_back(veh->getID());
324Lane::setAllowed(std::string laneID, std::string allowedClass) {
325 setAllowed(laneID, std::vector<std::string>({allowedClass}));
330Lane::setAllowed(std::string laneID, std::vector<std::string> allowedClasses) {
331 MSLane*
const l = getLane(laneID);
338Lane::setDisallowed(std::string laneID, std::vector<std::string> disallowedClasses) {
339 MSLane*
const l = getLane(laneID);
346Lane::setMaxSpeed(std::string laneID,
double speed) {
347 getLane(laneID)->setMaxSpeed(speed);
352Lane::setLength(std::string laneID,
double length) {
353 getLane(laneID)->setLength(length);
358Lane::setFriction(std::string laneID,
double friction) {
359 getLane(laneID)->setFrictionCoefficient(friction);
364Lane::getParameter(
const std::string& laneID,
const std::string& param) {
365 return getLane(laneID)->getParameter(param,
"");
373Lane::setParameter(
const std::string& laneID,
const std::string& key,
const std::string& value) {
374 getLane(laneID)->setParameter(key, value);
382Lane::getLane(
const std::string&
id) {
384 if (lane ==
nullptr) {
385 throw TraCIException(
"Lane '" +
id +
"' is not known");
393 shape = getLane(
id)->getShape();
397std::shared_ptr<VariableWrapper>
399 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
404Lane::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
407 return wrapper->wrapStringList(objID, variable, getIDList());
409 return wrapper->wrapInt(objID, variable, getIDCount());
411 return wrapper->wrapInt(objID, variable, getLinkNumber(objID));
413 return wrapper->wrapString(objID, variable, getEdgeID(objID));
415 return wrapper->wrapDouble(objID, variable, getLength(objID));
417 return wrapper->wrapDouble(objID, variable, getMaxSpeed(objID));
419 return wrapper->wrapDouble(objID, variable, getFriction(objID));
421 return wrapper->wrapStringList(objID, variable, getAllowed(objID));
423 return wrapper->wrapStringList(objID, variable, getDisallowed(objID));
425 return wrapper->wrapDouble(objID, variable, getCO2Emission(objID));
427 return wrapper->wrapDouble(objID, variable, getCOEmission(objID));
429 return wrapper->wrapDouble(objID, variable, getHCEmission(objID));
431 return wrapper->wrapDouble(objID, variable, getPMxEmission(objID));
433 return wrapper->wrapDouble(objID, variable, getNOxEmission(objID));
435 return wrapper->wrapDouble(objID, variable, getFuelConsumption(objID));
437 return wrapper->wrapDouble(objID, variable, getNoiseEmission(objID));
439 return wrapper->wrapDouble(objID, variable, getElectricityConsumption(objID));
441 return wrapper->wrapInt(objID, variable, getLastStepVehicleNumber(objID));
443 return wrapper->wrapDouble(objID, variable, getLastStepMeanSpeed(objID));
445 return wrapper->wrapStringList(objID, variable, getLastStepVehicleIDs(objID));
447 return wrapper->wrapDouble(objID, variable, getLastStepOccupancy(objID));
449 return wrapper->wrapInt(objID, variable, getLastStepHaltingNumber(objID));
451 return wrapper->wrapDouble(objID, variable, getLastStepLength(objID));
453 return wrapper->wrapDouble(objID, variable, getWaitingTime(objID));
455 return wrapper->wrapDouble(objID, variable, getTraveltime(objID));
457 return wrapper->wrapDouble(objID, variable, getWidth(objID));
459 return wrapper->wrapPositionVector(objID, variable, getShape(objID));
461 return wrapper->wrapStringList(objID, variable, getPendingVehicles(objID));
464 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
467 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
#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.
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 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 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 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 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