152 virtual void setParameter(
const std::string& key,
const std::string& value) {
176 template<
class DEVICEHOLDER>
212template<
class DEVICEHOLDER>
bool
215 const std::string& prefix = defaults.
prefix;
220 bool haveByName =
false;
221 const bool nameGiven = defaults.
nameGiven;
231 bool haveByParameter =
false;
232 bool parameterGiven =
false;
234 if (v.getParameter().hasParameter(key)) {
235 parameterGiven =
true;
237 }
else if (v.getVehicleType().getParameter().hasParameter(key)) {
238 parameterGiven =
true;
239 haveByParameter =
StringUtils::toBool(v.getVehicleType().getParameter().getParameter(key,
"false"));
240 }
else if (v.getVehicleType().getParameter().hasParameter(defaults.
probabilityKey)) {
252 }
else if (parameterGiven) {
253 return haveByParameter;
254 }
else if (numberGiven) {
257 }
else if (probability > 0) {
261 return std::find(lsdn.begin(), lsdn.end(),
deviceName) != lsdn.end();
269 return !nameGiven && outputOptionSet;
Abstract in-vehicle / in-person device.
static const std::string LOADSTATE_DEVICENAMES
static const DefaultAssignment & getDefaultAssignment(const OptionsCont &oc, const std::string &deviceName, const bool isPerson)
static SumoRNG * getEquipmentRNG()
virtual void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
static std::map< std::string, DefaultAssignment > myDefaultAssignments[2]
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 std::string getDeviceName(const std::string &id)
extracts the deviceName from the id (which includes holder id) and is subject to special cases
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)
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.
std::vector< std::string > getVector()
return vector of strings
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
#define UNUSED_PARAMETER(x)
the option values of a device's default assignment (all callers pass the global options,...
std::string probabilityKey