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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // A BT sender
19 /****************************************************************************/
20 #ifndef MSDevice_BTsender_h
21 #define MSDevice_BTsender_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <set>
34 #include <string>
35 #include "MSDevice.h"
36 #include <utils/common/SUMOTime.h>
37 #include <utils/geom/Boundary.h>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class SUMOVehicle;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
55 class MSDevice_BTsender : public MSDevice {
56 public:
60  static void insertOptions(OptionsCont& oc);
61 
62 
73  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into);
74 
75 
78  static void cleanup();
79 
80 
82  friend class MSDevice_BTreceiver;
83 
84 
85 
86 public:
89 
90 
91 
94 
103  bool notifyEnter(SUMOVehicle& veh, Notification reason, const MSLane* enteredLane = 0);
104 
105 
119  bool notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double newSpeed);
120 
121 
132  bool notifyLeave(SUMOVehicle& veh, double lastPos, Notification reason, const MSLane* enteredLane = 0);
134 
136  const std::string deviceName() const {
137  return "btsender";
138  }
139 
140 
144  class VehicleState {
145  public:
152  VehicleState(const double _speed, const Position& _position, const std::string& _laneID,
153  const double _lanePos, const int _routePos)
154  : speed(_speed), position(_position), laneID(_laneID), lanePos(_lanePos), routePos(_routePos) {}
155 
158 
160  double speed;
164  std::string laneID;
166  double lanePos;
168  int routePos;
169 
170  };
171 
172 
173 
177  class VehicleInformation : public Named {
178  public:
182  VehicleInformation(const std::string& id) : Named(id), amOnNet(true), haveArrived(false) {}
183 
185  virtual ~VehicleInformation() {}
186 
191  Boundary ret;
192  for (std::vector<VehicleState>::const_iterator i = updates.begin(); i != updates.end(); ++i) {
193  ret.add((*i).position);
194  }
195  return ret;
196  }
197 
199  std::vector<VehicleState> updates;
200 
202  bool amOnNet;
203 
206 
209 
210  };
211 
212 
213 
214 private:
220  MSDevice_BTsender(SUMOVehicle& holder, const std::string& id);
221 
222 
223 
224 protected:
226  static std::map<std::string, VehicleInformation*> sVehicles;
227 
228 
229 
230 private:
233 
236 
237 
238 };
239 
240 
241 #endif
242 
243 /****************************************************************************/
244 
bool amOnNet
Whether the vehicle is within the simulated network.
Position position
The position of the vehicle.
int routePos
The position in the route of the vehicle.
~MSDevice_BTsender()
Destructor.
std::string laneID
The lane the vehicle was at.
bool notifyMove(SUMOVehicle &veh, double oldPos, double newPos, double newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
Notification
Definition of a vehicle state.
VehicleInformation(const std::string &id)
Constructor.
MSDevice_BTsender & operator=(const MSDevice_BTsender &)
Invalidated assignment operator.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
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< MSDevice *> &into)
Build devices for the given vehicle, if needed.
Representation of a vehicle.
Definition: SUMOVehicle.h:66
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
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:54
bool notifyLeave(SUMOVehicle &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Moves (the known) vehicle from running to arrived vehicles&#39; list.
Abstract in-vehicle device.
Definition: MSDevice.h:70
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:98
static void cleanup()
removes remaining vehicleInformation in sVehicles
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:85
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
Boundary getBoxBoundary() const
Returns the boundary of passed positions.
bool notifyEnter(SUMOVehicle &veh, Notification reason, const MSLane *enteredLane=0)
Adds the vehicle to running vehicles if it (re-) enters the network.