 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
96 virtual const std::string
deviceName()
const = 0;
149 virtual void setParameter(
const std::string& key,
const std::string& value) {
173 template<
class DEVICEHOLDER>
203 template<
class DEVICEHOLDER>
bool
205 const std::string prefix = (isPerson ?
"person-device." :
"device.") +
deviceName;
207 bool haveByNumber =
false;
208 bool numberGiven =
false;
209 if (oc.
exists(prefix +
".deterministic") && oc.
getBool(prefix +
".deterministic")) {
213 if (oc.
exists(prefix +
".probability") && oc.
getFloat(prefix +
".probability") >= 0) {
219 bool haveByName =
false;
220 bool nameGiven =
false;
221 if (oc.
exists(prefix +
".explicit") && oc.
isSet(prefix +
".explicit")) {
231 bool haveByParameter =
false;
232 bool parameterGiven =
false;
233 const std::string key =
"has." +
deviceName +
".device";
234 if (v.getParameter().knowsParameter(key)) {
235 parameterGiven =
true;
237 }
else if (v.getVehicleType().getParameter().knowsParameter(key)) {
238 parameterGiven =
true;
239 haveByParameter =
StringUtils::toBool(v.getVehicleType().getParameter().getParameter(key,
"false"));
243 }
else if (parameterGiven) {
244 return haveByParameter;
245 }
else if (numberGiven) {
248 return !nameGiven && outputOptionSet;
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
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
#define UNUSED_PARAMETER(x)
static void buildTransportableDevices(MSTransportable &p, std::vector< MSTransportableDevice * > &into)
Build devices for the given person, if needed.
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
Base class for objects which have an id.
virtual void generateOutput() const
Called on writing tripinfo output.
MSDevice(const std::string &id)
Constructor.
Static storage of an output device and its base (abstract) implementation.
static std::mt19937 * getEquipmentRNG()
Representation of a vehicle.
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)
static OptionsCont & getOptions()
Retrieves the options.
static std::map< std::string, std::set< std::string > > myExplicitIDs
vehicles which explicitly carry a device, sorted by device, first
virtual void saveState(OutputDevice &out) const
Saves the state of the 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 double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
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 void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
static bool checkOptions(OptionsCont &oc)
check device-specific options
Abstract in-vehicle / in-person device.
static void cleanupAll()
perform cleanup for all devices
static std::mt19937 myEquipmentRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
A storage for options typed value containers)
virtual const std::string deviceName() const =0
return the name for this type of device
int getQuota(double frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
static double getFloatParam(const SUMOVehicle &v, const OptionsCont &oc, std::string paramName, double deflt, bool required)
Abstract in-person device.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
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.
static std::string getStringParam(const SUMOVehicle &v, const OptionsCont &oc, std::string paramName, std::string deflt, bool required)
MSDevice & operator=(const MSDevice &)
Invalidated assignment operator.
virtual void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
static void insertOptions(OptionsCont &oc)
Inserts options for building devices.
Encapsulated SAX-Attributes.
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)
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
static bool getBoolParam(const SUMOVehicle &v, const OptionsCont &oc, std::string paramName, bool deflt, bool required)
virtual ~MSDevice()
Destructor.
Abstract in-vehicle device.