48 oc.
addDescription(
"device.example.parameter",
"Example Device",
TL(
"An exemplary parameter which can be used by all instances of the example device"));
58 double customParameter2 = -1;
67 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vehicle parameter 'example'. Using default of " << customParameter2 <<
"\n";
70 double customParameter3 = -1;
79 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vType parameter 'example'. Using default of " << customParameter3 <<
"\n";
82 oc.
getFloat(
"device.example.parameter"),
85 into.push_back(device);
98 double customValue1,
double customValue2,
double customValue3) :
100 myCustomValue1(customValue1),
101 myCustomValue2(customValue2),
102 myCustomValue3(customValue3) {
113 double ,
double newSpeed) {
114 std::cout <<
"device '" <<
getID() <<
"' notifyMove: newSpeed=" << newSpeed <<
"\n";
119 if (otherDevice !=
nullptr) {
120 std::cout <<
" veh '" << veh.
getID() <<
" has device '" << otherDevice->
getID() <<
"'\n";
129 std::cout <<
"device '" <<
getID() <<
"' notifyEnter: reason=" << reason <<
" currentEdge=" << veh.
getEdge()->
getID() <<
"\n";
136 std::cout <<
"device '" <<
getID() <<
"' notifyLeave: reason=" << reason <<
" currentEdge=" << veh.
getEdge()->
getID() <<
"\n";
143 if (tripinfoOut !=
nullptr) {
144 tripinfoOut->
openTag(
"example_device");
153 if (key ==
"customValue1") {
155 }
else if (key ==
"customValue2") {
157 }
else if (key ==
"meaningOfLife") {
172 if (key ==
"customValue1") {
#define WRITE_WARNINGF(...)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A device which collects info on the vehicle trip (mainly on departure and arrival)
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
~MSDevice_Example()
Destructor.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
const std::string deviceName() const
return the name for this type of device
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Example-options.
double myCustomValue1
a value which is initialised based on a commandline/configuration option
static void cleanup()
resets counters
double myCustomValue3
a value which is initialised based on a vType parameter
MSDevice_Example(SUMOVehicle &holder, const std::string &id, double customValue1, double customValue2, double customValue3)
Constructor.
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing tripinfo output.
double myCustomValue2
a value which is initialised based on a vehicle parameter
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
A device which collects info on the vehicle trip (mainly on departure and arrival)
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.
Representation of a lane in the micro simulation.
Notification
Definition of a vehicle state.
Abstract in-vehicle device.
const SUMOVTypeParameter & getParameter() const
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
void doRegister(const std::string &name, Option *o)
Adds an option under the given name.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
bool hasParameter(const std::string &key) const
Returns whether the parameter is set.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
Representation of a vehicle, person, or container.
virtual bool isVehicle() const
Whether it is a vehicle.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual MSDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or nullptr if not.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
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