56 oc.
addDescription(
"device.example.parameter",
"Example Device",
"An exemplary parameter which can be used by all instances of the example device");
66 double customParameter2 = -1;
75 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vehicle parameter 'example'. Using default of " << customParameter2 <<
"\n";
78 double customParameter3 = -1;
87 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vType parameter 'example'. Using default of " << customParameter3 <<
"\n";
90 oc.
getFloat(
"device.example.parameter"),
93 into.push_back(device);
102 double customValue1,
double customValue2,
double customValue3) :
117 double ,
double newSpeed) {
118 std::cout <<
"device '" <<
getID() <<
"' notifyMove: newSpeed=" << newSpeed <<
"\n";
121 if (otherDevice != 0) {
122 std::cout <<
" veh '" << veh.
getID() <<
" has device '" << otherDevice->
getID() <<
"'\n";
130 std::cout <<
"device '" <<
getID() <<
"' notifyEnter: reason=" << reason <<
" currentEdge=" << veh.
getEdge()->
getID() <<
"\n";
137 std::cout <<
"device '" <<
getID() <<
"' notifyLeave: reason=" << reason <<
" currentEdge=" << veh.
getEdge()->
getID() <<
"\n";
155 if (key ==
"customValue1") {
157 }
else if (key ==
"customValue2") {
159 }
else if (key ==
"meaningOfLife") {
174 if (key ==
"customValue1") {
~MSDevice_Example()
Destructor.
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
double myCustomValue1
a value which is initialised based on a commandline/configuration option
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
Notification
Definition of a vehicle state.
MSDevice_Example(SUMOVehicle &holder, const std::string &id, double customValue1, double customValue2, double customValue3)
Constructor.
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
const std::string & getID() const
Returns the id.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Example-options.
#define WRITE_WARNING(msg)
static OptionsCont & getOptions()
Retrieves the options.
bool notifyLeave(SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
bool notifyMove(SUMOVehicle &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
Representation of a vehicle.
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 insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc)
Adds common command options that allow to assign devices to vehicles.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
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.
Abstract in-vehicle device.
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, SUMOVehicle &v)
Determines whether a vehicle should get a certain device.
void generateOutput() const
Called on writing tripinfo output.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key ...
A storage for options typed value containers)
static double _2double(const E *const data)
converts a char-type array into the double value described by it
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
virtual MSDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
Representation of a lane in the micro simulation.
double myCustomValue2
a value which is initialised based on a vehicle parameter
virtual const std::string & getID() const =0
Get the vehicle's ID.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
const std::string deviceName() const
return the name for this type of device
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
double myCustomValue3
a value which is initialised based on a vType parameter