Eclipse SUMO - Simulation of Urban MObility
MSDevice_Example.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2013-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A device which stands as an implementation example and which outputs movereminder calls
16 /****************************************************************************/
17 #ifndef MSDevice_Example_h
18 #define MSDevice_Example_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include "MSVehicleDevice.h"
27 #include <utils/common/SUMOTime.h>
28 
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class SUMOTrafficObject;
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
48 public:
52  static void insertOptions(OptionsCont& oc);
53 
54 
65  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
66 
67 
68 
69 public:
72 
73 
74 
77 
87  bool notifyMove(SUMOTrafficObject& veh, double oldPos,
88  double newPos, double newSpeed);
89 
90 
99  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
100 
101 
110  bool notifyLeave(SUMOTrafficObject& veh, double lastPos,
111  MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
113 
114 
116  const std::string deviceName() const {
117  return "example";
118  }
119 
121  std::string getParameter(const std::string& key) const;
122 
124  void setParameter(const std::string& key, const std::string& value);
125 
132  void generateOutput() const;
133 
134 
135 
136 private:
142  MSDevice_Example(SUMOVehicle& holder, const std::string& id, double customValue1,
143  double customValue2, double customValue3);
144 
145 
146 
147 private:
148  // private state members of the Example device
149 
152 
155 
158 
159 
160 
161 private:
164 
167 
168 
169 };
170 
171 
172 #endif
173 
174 /****************************************************************************/
175 
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:47
SUMOTime.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSDevice_Example::insertOptions
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Example-options.
Definition: MSDevice_Example.cpp:43
MSVehicleDevice.h
MSDevice_Example::myCustomValue3
double myCustomValue3
a value which is initialised based on a vType parameter
Definition: MSDevice_Example.h:157
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:60
MSDevice_Example::myCustomValue2
double myCustomValue2
a value which is initialised based on a vehicle parameter
Definition: MSDevice_Example.h:154
MSDevice_Example::buildVehicleDevices
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
Definition: MSDevice_Example.cpp:53
MSDevice_Example::setParameter
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
Definition: MSDevice_Example.cpp:162
MSDevice_Example
A device which collects info on the vehicle trip (mainly on departure and arrival)
Definition: MSDevice_Example.h:47
MSDevice_Example::getParameter
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
Definition: MSDevice_Example.cpp:149
MSDevice_Example::MSDevice_Example
MSDevice_Example(SUMOVehicle &holder, const std::string &id, double customValue1, double customValue2, double customValue3)
Constructor.
Definition: MSDevice_Example.cpp:93
MSDevice_Example::notifyEnter
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
Definition: MSDevice_Example.cpp:124
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
MSDevice_Example::deviceName
const std::string deviceName() const
return the name for this type of device
Definition: MSDevice_Example.h:116
MSDevice_Example::notifyLeave
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
Definition: MSDevice_Example.cpp:131
MSDevice_Example::operator=
MSDevice_Example & operator=(const MSDevice_Example &)
Invalidated assignment operator.
MSDevice_Example::~MSDevice_Example
~MSDevice_Example()
Destructor.
Definition: MSDevice_Example.cpp:103
config.h
MSDevice_Example::myCustomValue1
double myCustomValue1
a value which is initialised based on a commandline/configuration option
Definition: MSDevice_Example.h:151
MSDevice_Example::notifyMove
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
Definition: MSDevice_Example.cpp:108
MSDevice_Example::generateOutput
void generateOutput() const
Called on writing tripinfo output.
Definition: MSDevice_Example.cpp:138
MSDevice_Example::MSDevice_Example
MSDevice_Example(const MSDevice_Example &)
Invalidated copy constructor.
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:91
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:54