Eclipse SUMO - Simulation of Urban MObility
MSDevice_BTsender.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 BT sender
17 /****************************************************************************/
18 #ifndef MSDevice_BTsender_h
19 #define MSDevice_BTsender_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <set>
28 #include <string>
29 #include "MSVehicleDevice.h"
30 #include <utils/common/SUMOTime.h>
31 #include <utils/geom/Boundary.h>
32 
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class SUMOVehicle;
38 class SUMOTrafficObject;
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
51 public:
55  static void insertOptions(OptionsCont& oc);
56 
57 
68  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
69 
70 
73  static void cleanup();
74 
75 
77  friend class MSDevice_BTreceiver;
78 
79 
80 
81 public:
84 
85 
86 
89 
98  bool notifyEnter(SUMOTrafficObject& veh, Notification reason, const MSLane* enteredLane = 0);
99 
100 
114  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
115 
116 
127  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, Notification reason, const MSLane* enteredLane = 0);
129 
131  const std::string deviceName() const {
132  return "btsender";
133  }
134 
135 
139  class VehicleState {
140  public:
147  VehicleState(const double _speed, const Position& _position, const std::string& _laneID,
148  const double _lanePos, const int _routePos)
149  : speed(_speed), position(_position), laneID(_laneID), lanePos(_lanePos), routePos(_routePos) {}
150 
153 
155  double speed;
159  std::string laneID;
161  double lanePos;
163  int routePos;
164 
165  };
166 
167 
168 
172  class VehicleInformation : public Named {
173  public:
177  VehicleInformation(const std::string& id) : Named(id), amOnNet(true), haveArrived(false) {}
178 
180  virtual ~VehicleInformation() {}
181 
186  Boundary ret;
187  for (std::vector<VehicleState>::const_iterator i = updates.begin(); i != updates.end(); ++i) {
188  ret.add((*i).position);
189  }
190  return ret;
191  }
192 
194  std::vector<VehicleState> updates;
195 
197  bool amOnNet;
198 
201 
204 
205  };
206 
207 
208 
209 private:
215  MSDevice_BTsender(SUMOVehicle& holder, const std::string& id);
216 
217 
218 
219 protected:
221  static std::map<std::string, VehicleInformation*> sVehicles;
222 
223 
224 
225 private:
228 
231 
232 
233 };
234 
235 
236 #endif
237 
238 /****************************************************************************/
239 
bool amOnNet
Whether the vehicle is within the simulated network.
Position position
The position of the vehicle.
bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane=0)
Adds the vehicle to running vehicles if it (re-) enters the network.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
int routePos
The position in the route of the vehicle.
~MSDevice_BTsender()
Destructor.
std::string laneID
The lane the vehicle was at.
Notification
Definition of a vehicle state.
VehicleInformation(const std::string &id)
Constructor.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Moves (the known) vehicle from running to arrived vehicles&#39; list.
MSDevice_BTsender & operator=(const MSDevice_BTsender &)
Invalidated assignment operator.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:73
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
double lanePos
The position at the lane of the vehicle.
ConstMSEdgeVector route
List of edges travelled.
const std::string deviceName() const
return the name for this type of device
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice *> &into)
Build devices for the given vehicle, if needed.
Representation of a vehicle.
Definition: SUMOVehicle.h:61
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
A single movement state of the vehicle.
bool haveArrived
Whether the vehicle was removed from the simulation.
MSDevice_BTsender(SUMOVehicle &holder, const std::string &id)
Constructor.
VehicleState(const double _speed, const Position &_position, const std::string &_laneID, const double _lanePos, const int _routePos)
Constructor.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTsender-options.
Base class for objects which have an id.
Definition: Named.h:57
Representation of a vehicle or person.
double speed
The speed of the vehicle.
std::vector< VehicleState > updates
List of position updates during last step.
A storage for options typed value containers)
Definition: OptionsCont.h:90
static void cleanup()
removes remaining vehicleInformation in sVehicles
Abstract in-vehicle device.
Stores the information of a vehicle.
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived senders.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:79
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
Boundary getBoxBoundary() const
Returns the boundary of passed positions.