43std::vector<std::string>
44VehicleType::getIDList() {
45 std::vector<std::string> ids;
52VehicleType::getIDCount() {
53 return (
int)getIDList().size();
58VehicleType::getLength(
const std::string& typeID) {
59 return getVType(typeID)->getLength();
64VehicleType::getMaxSpeed(
const std::string& typeID) {
65 return getVType(typeID)->getMaxSpeed();
70VehicleType::getActionStepLength(
const std::string& typeID) {
71 return getVType(typeID)->getActionStepLengthSecs();
76VehicleType::getSpeedFactor(
const std::string& typeID) {
77 return getVType(typeID)->getSpeedFactor().getParameter(0);
82VehicleType::getSpeedDeviation(
const std::string& typeID) {
83 return getVType(typeID)->getSpeedFactor().getParameter(1);
88VehicleType::getAccel(
const std::string& typeID) {
89 return getVType(typeID)->getCarFollowModel().getMaxAccel();
94VehicleType::getDecel(
const std::string& typeID) {
95 return getVType(typeID)->getCarFollowModel().getMaxDecel();
100VehicleType::getEmergencyDecel(
const std::string& typeID) {
101 return getVType(typeID)->getCarFollowModel().getEmergencyDecel();
106VehicleType::getApparentDecel(
const std::string& typeID) {
107 return getVType(typeID)->getCarFollowModel().getApparentDecel();
112VehicleType::getImperfection(
const std::string& typeID) {
113 return getVType(typeID)->getCarFollowModel().getImperfection();
118VehicleType::getTau(
const std::string& typeID) {
119 return getVType(typeID)->getCarFollowModel().getHeadwayTime();
124VehicleType::getVehicleClass(
const std::string& typeID) {
125 return toString(getVType(typeID)->getVehicleClass());
130VehicleType::getEmissionClass(
const std::string& typeID) {
131 return PollutantsInterface::getName(getVType(typeID)->getEmissionClass());
136VehicleType::getShapeClass(
const std::string& typeID) {
142VehicleType::getMinGap(
const std::string& typeID) {
143 return getVType(typeID)->getMinGap();
148VehicleType::getWidth(
const std::string& typeID) {
149 return getVType(typeID)->getWidth();
154VehicleType::getHeight(
const std::string& typeID) {
155 return getVType(typeID)->getHeight();
160VehicleType::getMass(
const std::string& typeID) {
161 return getVType(typeID)->getMass();
166VehicleType::getColor(
const std::string& typeID) {
172VehicleType::getMinGapLat(
const std::string& typeID) {
173 return getVType(typeID)->getMinGapLat();
178VehicleType::getMaxSpeedLat(
const std::string& typeID) {
179 return getVType(typeID)->getMaxSpeedLat();
184VehicleType::getLateralAlignment(
const std::string& typeID) {
186 return toString(getVType(typeID)->getPreferredLateralAlignment());
188 return toString(getVType(typeID)->getPreferredLateralAlignmentOffset());
194VehicleType::getParameter(
const std::string& typeID,
const std::string& key) {
196 const std::string attrName =
key.substr(14);
198 throw TraCIException(
"Invalid junctionModel parameter '" + key +
"' for type '" + typeID +
"'");
202 throw TraCIException(
"Invalid junctionModel parameter '" + key +
"' for type '" + typeID +
"'");
204 if (getVType(typeID)->getParameter().jmParameter.count(attr) != 0) {
205 return getVType(typeID)->getParameter().jmParameter.find(attr)->second;
210 return getVType(typeID)->getParameter().getParameter(key,
"");
217VehicleType::getPersonCapacity(
const std::string& typeID) {
218 return getVType(typeID)->getPersonCapacity();
223 return getVType(typeID)->getParameter().scale;
227VehicleType::getBoardingDuration(
const std::string& typeID) {
228 return STEPS2TIME(getVType(typeID)->getBoardingDuration(
true));
232VehicleType::getImpatience(
const std::string& typeID) {
233 return getVType(typeID)->getImpatience();
237VehicleType::setLength(
const std::string& typeID,
double length) {
238 getVType(typeID)->setLength(length);
243VehicleType::setMaxSpeed(
const std::string& typeID,
double speed) {
244 getVType(typeID)->setMaxSpeed(speed);
249VehicleType::setActionStepLength(
const std::string& typeID,
double actionStepLength,
bool resetActionOffset) {
255VehicleType::setBoardingDuration(
const std::string& typeID,
double boardingDuration) {
258 }
catch (ProcessError&) {
259 throw TraCIException(
"BoardingDuration parameter exceeds the time value range.");
261 getVType(typeID)->setBoardingDuration(
TIME2STEPS(boardingDuration),
true);
266VehicleType::setImpatience(
const std::string& typeID,
double impatience) {
267 getVType(typeID)->setImpatience(impatience);
272VehicleType::setVehicleClass(
const std::string& typeID,
const std::string& clazz) {
278VehicleType::setSpeedFactor(
const std::string& typeID,
double factor) {
279 getVType(typeID)->setSpeedFactor(factor);
285 getVType(typeID)->setSpeedDeviation(deviation);
290VehicleType::setEmissionClass(
const std::string& typeID,
const std::string& clazz) {
291 getVType(typeID)->setEmissionClass(PollutantsInterface::getClassByName(clazz));
296VehicleType::setShapeClass(
const std::string& typeID,
const std::string& shapeClass) {
302VehicleType::setWidth(
const std::string& typeID,
double width) {
303 getVType(typeID)->setWidth(width);
308VehicleType::setHeight(
const std::string& typeID,
double height) {
309 getVType(typeID)->setHeight(height);
314VehicleType::setMass(
const std::string& typeID,
double mass) {
315 getVType(typeID)->setMass(mass);
320VehicleType::setMinGap(
const std::string& typeID,
double minGap) {
321 getVType(typeID)->setMinGap(minGap);
326VehicleType::setAccel(
const std::string& typeID,
double accel) {
327 getVType(typeID)->setAccel(accel);
332VehicleType::setDecel(
const std::string& typeID,
double decel) {
333 MSVehicleType* v = getVType(typeID);
339 WRITE_WARNINGF(
TL(
"Automatically setting emergencyDecel to % for vType '%' to match decel."),
toString(decel), typeID);
347VehicleType::setEmergencyDecel(
const std::string& typeID,
double decel) {
348 MSVehicleType* v = getVType(typeID);
350 if (decel < v->getCarFollowModel().getMaxDecel()) {
357VehicleType::setApparentDecel(
const std::string& typeID,
double decel) {
358 getVType(typeID)->setApparentDecel(decel);
363VehicleType::setImperfection(
const std::string& typeID,
double imperfection) {
364 getVType(typeID)->setImperfection(imperfection);
369VehicleType::setTau(
const std::string& typeID,
double tau) {
370 getVType(typeID)->setTau(tau);
375VehicleType::setColor(
const std::string& typeID,
const TraCIColor& c) {
381VehicleType::setMinGapLat(
const std::string& typeID,
double minGapLat) {
382 getVType(typeID)->setMinGapLat(minGapLat);
387VehicleType::setMaxSpeedLat(
const std::string& typeID,
double speed) {
388 getVType(typeID)->setMaxSpeedLat(speed);
393VehicleType::setLateralAlignment(
const std::string& typeID,
const std::string& latAlignment) {
397 getVType(typeID)->setPreferredLateralAlignment(lad, lao);
399 throw TraCIException(
"Unknown value '" + latAlignment +
"' when setting latAlignment for vType '" + typeID +
"';\n must be one of (\"right\", \"center\", \"arbitrary\", \"nice\", \"compact\", \"left\" or a float)");
410 getVType(origTypeID)->duplicateType(newTypeID,
true);
415VehicleType::setParameter(
const std::string& typeID,
const std::string& name,
const std::string&
value) {
417 const std::string attrName = name.substr(14);
419 throw TraCIException(
"Invalid junctionModel parameter '" + name +
"' for type '" + typeID +
"'");
423 throw TraCIException(
"Invalid junctionModel parameter '" + name +
"' for type '" + typeID +
"'");
427 ((SUMOVTypeParameter&)getVType(typeID)->getParameter()).jmParameter[attr] =
value;
428 }
catch (NumberFormatException&) {
429 throw TraCIException(
"Invalid junctionModel parameter value '" +
value +
"' for type '" + typeID +
" (should be numeric)'");
432 ((SUMOVTypeParameter&)getVType(typeID)->getParameter()).setParameter(name,
value);
444 throw TraCIException(
"Vehicle type '" +
id +
"' is not known");
450std::shared_ptr<VariableWrapper>
466 return wrapper->wrapStringList(objID, variable, getIDList());
468 return wrapper->wrapInt(objID, variable, getIDCount());
470 return wrapper->wrapDouble(objID, variable, getLength(typeID));
472 return wrapper->wrapDouble(objID, variable, getHeight(typeID));
474 return wrapper->wrapDouble(objID, variable, getMass(typeID));
476 return wrapper->wrapDouble(objID, variable, getMinGap(typeID));
478 return wrapper->wrapDouble(objID, variable, getMaxSpeed(typeID));
480 return wrapper->wrapDouble(objID, variable, getAccel(typeID));
482 return wrapper->wrapDouble(objID, variable, getDecel(typeID));
484 return wrapper->wrapDouble(objID, variable, getEmergencyDecel(typeID));
486 return wrapper->wrapDouble(objID, variable, getApparentDecel(typeID));
488 return wrapper->wrapDouble(objID, variable, getActionStepLength(typeID));
490 return wrapper->wrapDouble(objID, variable, getImperfection(typeID));
492 return wrapper->wrapDouble(objID, variable, getTau(typeID));
494 return wrapper->wrapDouble(objID, variable, getSpeedFactor(typeID));
496 return wrapper->wrapDouble(objID, variable, getSpeedDeviation(typeID));
498 return wrapper->wrapString(objID, variable, getVehicleClass(typeID));
500 return wrapper->wrapString(objID, variable, getEmissionClass(typeID));
502 return wrapper->wrapString(objID, variable, getShapeClass(typeID));
504 return wrapper->wrapDouble(objID, variable, getWidth(typeID));
506 return wrapper->wrapColor(objID, variable, getColor(typeID));
508 return wrapper->wrapDouble(objID, variable, getMinGapLat(typeID));
510 return wrapper->wrapDouble(objID, variable, getMaxSpeedLat(typeID));
512 return wrapper->wrapString(objID, variable, getLateralAlignment(typeID));
514 return wrapper->wrapInt(objID, variable, getPersonCapacity(typeID));
516 return wrapper->wrapDouble(objID, variable, getBoardingDuration(typeID));
518 return wrapper->wrapDouble(objID, variable, getImpatience(typeID));
520 return wrapper->wrapDouble(objID, variable,
getScale(typeID));
523 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
526 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->
readString()));
#define WRITE_WARNINGF(...)
const std::string invalid_return< std::string >::value
void checkTimeBounds(const double time)
check the valid SUMOTime range of double input and throw an error if out of bounds
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
@ GIVEN
The alignment as offset is given.
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_EMERGENCYDECEL
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 void setSpeedDeviation(const std::string &typeID, double deviation)
static void setScale(const std::string &typeID, double value)
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper, tcpip::Storage *paramData)
static std::shared_ptr< VariableWrapper > makeWrapper()
static double getScale(const std::string &typeID)
static LIBSUMO_SUBSCRIPTION_API MSVehicleType * getVType(std::string id)
static SubscriptionResults mySubscriptionResults
LIBSUMO_VEHICLE_TYPE_GETTER LIBSUMO_ID_PARAMETER_API static LIBSUMO_VEHICLE_TYPE_SETTER void copy(const std::string &origTypeID, const std::string &newTypeID)
static ContextSubscriptionResults myContextSubscriptionResults
static bool handleVariableWithID(const std::string &objID, const std::string &typeID, const int variable, VariableWrapper *wrapper, tcpip::Storage *paramData)
double getEmergencyDecel() const
Get the vehicle type's maximal physically possible deceleration [m/s^2].
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
void insertVTypeIDs(std::vector< std::string > &into) const
Inserts ids of all known vehicle types and vehicle type distributions to the given vector.
The car-following model and parameter.
void setEmergencyDecel(double emergencyDecel)
Set a new value for this type's emergency deceleration.
void setDecel(double decel)
Set a new value for this type's deceleration.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version).
const SUMOVTypeParameter & getParameter() const
SubParams cfParameter
Car-following parameter.
static std::set< SumoXMLAttr > AllowedJMAttrs
allowed attrs for the junction model
static bool parseLatAlignment(const std::string &val, double &lao, LatAlignmentDefinition &lad)
Parses and validates a given latAlignment value.
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
static SequentialStringBijection Attrs
The names of SUMO-XML attributes for use in netbuild.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
static TraCIColor makeTraCIColor(const RGBColor &color)
static RGBColor makeRGBColor(const TraCIColor &color)
An error which allows to continue.
virtual std::string readString()
virtual int readUnsignedByte()
TRACI_CONST int VAR_VEHICLECLASS
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_IMPATIENCE
TRACI_CONST int VAR_LATALIGNMENT
TRACI_CONST int VAR_SCALE
TRACI_CONST int VAR_MINGAP
TRACI_CONST int VAR_SHAPECLASS
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int VAR_ACTIONSTEPLENGTH
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int VAR_BOARDING_DURATION
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_WIDTH
TRACI_CONST int VAR_PERSON_CAPACITY
TRACI_CONST int VAR_MAXSPEED
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_LENGTH
TRACI_CONST int VAR_MAXSPEED_LAT
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_IMPERFECTION
TRACI_CONST int VAR_HEIGHT
TRACI_CONST int VAR_APPARENT_DECEL
TRACI_CONST int VAR_DECEL
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int VAR_MINGAP_LAT
TRACI_CONST int VAR_EMERGENCY_DECEL
TRACI_CONST int VAR_EMISSIONCLASS
TRACI_CONST int VAR_ACCEL
TRACI_CONST int VAR_SPEED_DEVIATION
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
size_type count(const Key &key) const