147 virtual void setParameter(
const std::string& key,
const std::string& value) {
171 template<
class DEVICEHOLDER>
194template<
class DEVICEHOLDER>
bool
196 const std::string prefix = (isPerson ?
"person-device." :
"device.") +
deviceName;
198 bool haveByNumber =
false;
199 bool numberGiven =
false;
200 if (oc.
exists(prefix +
".deterministic") && oc.
getBool(prefix +
".deterministic")) {
204 if (oc.
exists(prefix +
".probability") && oc.
getFloat(prefix +
".probability") >= 0.) {
210 bool haveByName =
false;
211 bool nameGiven =
false;
212 if (oc.
exists(prefix +
".explicit") && oc.
isSet(prefix +
".explicit")) {
222 bool haveByParameter =
false;
223 bool parameterGiven =
false;
224 const std::string key =
"has." +
deviceName +
".device";
225 if (v.getParameter().hasParameter(key)) {
226 parameterGiven =
true;
228 }
else if (v.getVehicleType().getParameter().hasParameter(key)) {
229 parameterGiven =
true;
230 haveByParameter =
StringUtils::toBool(v.getVehicleType().getParameter().getParameter(key,
"false"));
231 }
else if (v.getVehicleType().getParameter().hasParameter(prefix +
".probability")) {
243 }
else if (parameterGiven) {
244 return haveByParameter;
245 }
else if (numberGiven) {
248 return !nameGiven && outputOptionSet;
#define UNUSED_PARAMETER(x)
Abstract in-vehicle / in-person device.
static SumoRNG * getEquipmentRNG()
virtual void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
virtual const std::string deviceName() const =0
return the name for this type of device
virtual void saveState(OutputDevice &out) const
Saves the state of the device.
virtual void generateOutput(OutputDevice *) const
Called on vehicle deletion to extend tripinfo and other outputs.
virtual ~MSDevice()
Destructor.
MSDevice(const MSDevice &)
Invalidated copy constructor.
virtual void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
static void insertOptions(OptionsCont &oc)
Inserts options for building devices.
static SumoRNG myEquipmentRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
MSDevice(const std::string &id)
Constructor.
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
virtual std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
static std::map< std::string, std::set< std::string > > myExplicitIDs
vehicles which explicitly carry a device, sorted by device, first
static void cleanupAll()
perform cleanup for all devices
MSDevice & operator=(const MSDevice &)
Invalidated assignment operator.
static void buildTransportableDevices(MSTransportable &p, std::vector< MSTransportableDevice * > &into)
Build devices for the given person, if needed.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Abstract in-person device.
int getQuota(double frac=-1, int loaded=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
Abstract in-vehicle device.
Base class for objects which have an id.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
bool exists(const std::string &name) const
Returns the information whether the named option is known.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Encapsulated SAX-Attributes.
Representation of a vehicle.
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 toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter