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.dev/sumo
3 // Copyright (C) 2013-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
19 // A device which stands as an implementation example and which outputs movereminder calls
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
24 #include "MSVehicleDevice.h"
25 #include <utils/common/SUMOTime.h>
26 
27 
28 // ===========================================================================
29 // class declarations
30 // ===========================================================================
31 class SUMOTrafficObject;
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
46 public:
50  static void insertOptions(OptionsCont& oc);
51 
52 
63  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
64 
66  static void cleanup();
67 
68 public:
71 
72 
73 
76 
86  bool notifyMove(SUMOTrafficObject& veh, double oldPos,
87  double newPos, double newSpeed);
88 
89 
98  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
99 
100 
109  bool notifyLeave(SUMOTrafficObject& veh, double lastPos,
110  MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
112 
113 
115  const std::string deviceName() const {
116  return "example";
117  }
118 
120  std::string getParameter(const std::string& key) const;
121 
123  void setParameter(const std::string& key, const std::string& value);
124 
131  void generateOutput(OutputDevice* tripinfoOut) const;
132 
133 
134 
135 private:
141  MSDevice_Example(SUMOVehicle& holder, const std::string& id, double customValue1,
142  double customValue2, double customValue3);
143 
144 
145 
146 private:
147  // private state members of the Example device
148 
151 
154 
157 
158 
159 
160 private:
163 
166 
167 
168 };
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.
MSDevice_Example(const MSDevice_Example &)
Invalidated copy constructor.
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
MSDevice_Example & operator=(const MSDevice_Example &)
Invalidated assignment operator.
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.
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
Notification
Definition of a vehicle state.
Abstract in-vehicle device.
A storage for options typed value containers)
Definition: OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition: SUMOVehicle.h:60