114 oc.
addDescription(
"device." + deviceName +
".probability", optionsTopic,
"The probability for a vehicle to have a '" + deviceName +
"' device");
117 oc.
addSynonyme(
"device." + deviceName +
".explicit",
"device." + deviceName +
".knownveh",
true);
118 oc.
addDescription(
"device." + deviceName +
".explicit", optionsTopic,
"Assign a '" + deviceName +
"' device to named vehicles");
121 oc.
addDescription(
"device." + deviceName +
".deterministic", optionsTopic,
"The '" + deviceName +
"' devices are set deterministic using a fraction of 1000");
128 bool haveByNumber =
false;
129 bool numberGiven =
false;
130 if (oc.
exists(
"device." + deviceName +
".deterministic") && oc.
getBool(
"device." + deviceName +
".deterministic")) {
134 if (oc.
exists(
"device." + deviceName +
".probability") && oc.
getFloat(
"device." + deviceName +
".probability") >= 0) {
140 bool haveByName =
false;
141 bool nameGiven =
false;
142 if (oc.
exists(
"device." + deviceName +
".explicit") && oc.
isSet(
"device." + deviceName +
".explicit")) {
152 bool haveByParameter =
false;
153 bool parameterGiven =
false;
154 const std::string key =
"has." + deviceName +
".device";
156 parameterGiven =
true;
159 parameterGiven =
true;
164 }
else if (parameterGiven) {
165 return haveByParameter;
166 }
else if (numberGiven) {
169 return !nameGiven && outputOptionSet;
176 const std::string key =
"has." + deviceName +
".device";
182 return outputOptionSet;
199 std::string result = deflt;
213 if (oc.
isSet(
"device." + paramName)) {
214 result = oc.
getString(
"device." + paramName);
217 throw ProcessError(
"Missing parameter 'device." + paramName +
"' for vehicle '" + v.
getID());
220 #ifdef DEBUG_DEVICE_PARAMS 221 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vehicle parameter 'device." + paramName +
"'. Using default of '" << result <<
"'\n";
232 double result = deflt;
246 if (oc.
isSet(
"device." + paramName)) {
247 result = oc.
getFloat(
"device." + paramName);
250 throw ProcessError(
"Missing parameter 'device." + paramName +
"' for vehicle '" + v.
getID());
253 #ifdef DEBUG_DEVICE_PARAMS 254 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vehicle parameter 'device." + paramName +
"'. Using default of '" << result <<
"'\n";
279 if (oc.
isSet(
"device." + paramName)) {
280 result = oc.
getBool(
"device." + paramName);
283 throw ProcessError(
"Missing parameter 'device." + paramName +
"' for vehicle '" + v.
getID());
286 #ifdef DEBUG_DEVICE_PARAMS 287 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vehicle parameter 'device." + paramName +
"'. Using default of '" << result <<
"'\n";
static bool getBoolParam(const SUMOVehicle &v, const OptionsCont &oc, std::string paramName, bool deflt, bool required)
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
static bool _2bool(const E *const data)
converts a 0-terminated char-type array into the boolean value described by it
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_DriverState-options.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_SSM-options.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_ToC-options.
static std::map< std::string, std::set< std::string > > myExplicitIDs
vehicles which explicitly carry a device, sorted by device, first
static void cleanup()
resets the edge filter
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
int getQuota(double frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_FCD-options.
const SUMOVehicleParameter & getParameter() const
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Example-options.
#define WRITE_WARNING(msg)
static OptionsCont & getOptions()
Retrieves the options.
static bool equippedByParameter(const MSTransportable *t, const std::string &deviceName, bool outputOptionSet)
Determines whether a transportable should get a certain device.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
virtual const std::string deviceName() const =0
return the name for this type of device
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Routing-options.
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
Representation of a vehicle.
Encapsulated SAX-Attributes.
virtual void saveState(OutputDevice &out) const
Saves the state of the device.
static std::mt19937 myEquipmentRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool exists(const std::string &name) const
Returns the information whether the named option is known.
static double getFloatParam(const SUMOVehicle &v, const OptionsCont &oc, std::string paramName, double deflt, bool required)
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc)
Adds common command options that allow to assign devices to vehicles.
static void cleanupAll()
perform cleanup for all devices
const SUMOVTypeParameter & getParameter() const
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTsender-options.
static void cleanup()
resets counters
static bool checkOptions(OptionsCont &oc)
check device-specific options
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Bluelight-options.
virtual void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
static std::string getStringParam(const SUMOVehicle &v, const OptionsCont &oc, std::string paramName, std::string deflt, bool required)
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Example-options.
static void insertOptions()
Inserts MSDevice_Emissions-options.
A storage for options typed value containers)
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
static double _2double(const E *const data)
converts a char-type array into the double value described by it
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, SUMOVehicle &v, bool outputOptionSet)
Determines whether a vehicle should get a certain device.
static void insertOptions(OptionsCont &oc)
Inserts options for building devices.
static MSDevice_Vehroutes * buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into, int maxRoutes=std::numeric_limits< int >::max())
Build devices for the given vehicle, if needed.
const MSVehicleType & getVehicleType() const
Static storage of an output device and its base (abstract) implementation.
static void cleanup()
deletes the router instance
static bool checkOptions(OptionsCont &oc)
checks MSDevice_Routing-options
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTreceiver-options.
virtual const std::string & getID() const =0
Get the vehicle's ID.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.