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 /****************************************************************************/
16 // A device which stands as an implementation example and which outputs movereminder calls
17 /****************************************************************************/
18 #ifndef MSDevice_Example_h
19 #define MSDevice_Example_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include "MSVehicleDevice.h"
28 #include <utils/common/SUMOTime.h>
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class SUMOTrafficObject;
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
49 public:
53  static void insertOptions(OptionsCont& oc);
54 
55 
66  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
67 
68 
69 
70 public:
73 
74 
75 
78 
88  bool notifyMove(SUMOTrafficObject& veh, double oldPos,
89  double newPos, double newSpeed);
90 
91 
100  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
101 
102 
111  bool notifyLeave(SUMOTrafficObject& veh, double lastPos,
112  MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
114 
115 
117  const std::string deviceName() const {
118  return "example";
119  }
120 
122  std::string getParameter(const std::string& key) const;
123 
125  void setParameter(const std::string& key, const std::string& value);
126 
133  void generateOutput() const;
134 
135 
136 
137 private:
143  MSDevice_Example(SUMOVehicle& holder, const std::string& id, double customValue1,
144  double customValue2, double customValue3);
145 
146 
147 
148 private:
149  // private state members of the Example device
150 
153 
156 
159 
160 
161 
162 private:
165 
168 
169 
170 };
171 
172 
173 #endif
174 
175 /****************************************************************************/
176 
~MSDevice_Example()
Destructor.
double myCustomValue1
a value which is initialised based on a commandline/configuration option
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) ...
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Example-options.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice *> &into)
Build devices for the given vehicle, if needed.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
MSDevice_Example & operator=(const MSDevice_Example &)
Invalidated assignment operator.
Representation of a vehicle.
Definition: SUMOVehicle.h:61
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key ...
Representation of a vehicle or person.
void generateOutput() const
Called on writing tripinfo output.
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)
Definition: OptionsCont.h:90
Abstract in-vehicle device.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
double myCustomValue2
a value which is initialised based on a vehicle parameter
const std::string deviceName() const
return the name for this type of device
double myCustomValue3
a value which is initialised based on a vType parameter