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-2018 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 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
50 public:
54  static void insertOptions(OptionsCont& oc);
55 
56 
67  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
68 
69 
72  static void cleanup();
73 
74 
76  friend class MSDevice_BTreceiver;
77 
78 
79 
80 public:
83 
84 
85 
88 
97  bool notifyEnter(SUMOVehicle& veh, Notification reason, const MSLane* enteredLane = 0);
98 
99 
113  bool notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double newSpeed);
114 
115 
126  bool notifyLeave(SUMOVehicle& veh, double lastPos, Notification reason, const MSLane* enteredLane = 0);
128 
130  const std::string deviceName() const {
131  return "btsender";
132  }
133 
134 
138  class VehicleState {
139  public:
146  VehicleState(const double _speed, const Position& _position, const std::string& _laneID,
147  const double _lanePos, const int _routePos)
148  : speed(_speed), position(_position), laneID(_laneID), lanePos(_lanePos), routePos(_routePos) {}
149 
152 
154  double speed;
158  std::string laneID;
160  double lanePos;
162  int routePos;
163 
164  };
165 
166 
167 
171  class VehicleInformation : public Named {
172  public:
176  VehicleInformation(const std::string& id) : Named(id), amOnNet(true), haveArrived(false) {}
177 
179  virtual ~VehicleInformation() {}
180 
185  Boundary ret;
186  for (std::vector<VehicleState>::const_iterator i = updates.begin(); i != updates.end(); ++i) {
187  ret.add((*i).position);
188  }
189  return ret;
190  }
191 
193  std::vector<VehicleState> updates;
194 
196  bool amOnNet;
197 
200 
203 
204  };
205 
206 
207 
208 private:
214  MSDevice_BTsender(SUMOVehicle& holder, const std::string& id);
215 
216 
217 
218 protected:
220  static std::map<std::string, VehicleInformation*> sVehicles;
221 
222 
223 
224 private:
227 
230 
231 
232 };
233 
234 
235 #endif
236 
237 /****************************************************************************/
238 
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:72
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:60
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:58
bool notifyLeave(SUMOVehicle &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Moves (the known) vehicle from running to arrived vehicles&#39; list.
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:92
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:78
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.