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 /****************************************************************************/
15 // A BT sender
16 /****************************************************************************/
17 #ifndef MSDevice_BTsender_h
18 #define MSDevice_BTsender_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <set>
27 #include <string>
28 #include "MSVehicleDevice.h"
29 #include <utils/common/SUMOTime.h>
30 #include <utils/geom/Boundary.h>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class SUMOVehicle;
37 class SUMOTrafficObject;
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(SUMOTrafficObject& veh, Notification reason, const MSLane* enteredLane = 0);
98 
99 
113  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
114 
115 
126  bool notifyLeave(SUMOTrafficObject& 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 
Boundary.h
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:47
MSDevice_BTsender::sVehicles
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived senders.
Definition: MSDevice_BTsender.h:220
MSDevice_BTreceiver
A BT receiver.
Definition: MSDevice_BTreceiver.h:49
SUMOTime.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Named
Base class for objects which have an id.
Definition: Named.h:56
MSVehicleDevice.h
MSDevice_BTsender::operator=
MSDevice_BTsender & operator=(const MSDevice_BTsender &)
Invalidated assignment operator.
MSDevice_BTsender::VehicleState::lanePos
double lanePos
The position at the lane of the vehicle.
Definition: MSDevice_BTsender.h:160
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:60
MSDevice_BTsender::VehicleInformation::route
ConstMSEdgeVector route
List of edges travelled.
Definition: MSDevice_BTsender.h:202
ConstMSEdgeVector
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:75
MSDevice_BTsender::VehicleInformation::amOnNet
bool amOnNet
Whether the vehicle is within the simulated network.
Definition: MSDevice_BTsender.h:196
MSDevice_BTsender::deviceName
const std::string deviceName() const
return the name for this type of device
Definition: MSDevice_BTsender.h:130
MSDevice_BTsender::MSDevice_BTsender
MSDevice_BTsender(SUMOVehicle &holder, const std::string &id)
Constructor.
Definition: MSDevice_BTsender.cpp:74
MSDevice_BTsender::VehicleState::routePos
int routePos
The position in the route of the vehicle.
Definition: MSDevice_BTsender.h:162
MSDevice_BTsender::VehicleState::position
Position position
The position of the vehicle.
Definition: MSDevice_BTsender.h:156
MSDevice_BTsender::VehicleState::VehicleState
VehicleState(const double _speed, const Position &_position, const std::string &_laneID, const double _lanePos, const int _routePos)
Constructor.
Definition: MSDevice_BTsender.h:146
MSDevice_BTsender::notifyLeave
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Moves (the known) vehicle from running to arrived vehicles' list.
Definition: MSDevice_BTsender.cpp:116
MSDevice_BTsender::notifyEnter
bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane=0)
Adds the vehicle to running vehicles if it (re-) enters the network.
Definition: MSDevice_BTsender.cpp:84
MSDevice_BTsender::VehicleInformation
Stores the information of a vehicle.
Definition: MSDevice_BTsender.h:171
MSDevice_BTsender::VehicleState::laneID
std::string laneID
The lane the vehicle was at.
Definition: MSDevice_BTsender.h:158
MSDevice_BTsender::VehicleState::~VehicleState
~VehicleState()
Destructor.
Definition: MSDevice_BTsender.h:151
MSDevice_BTsender::VehicleInformation::~VehicleInformation
virtual ~VehicleInformation()
Destructor.
Definition: MSDevice_BTsender.h:179
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
MSDevice_BTsender::insertOptions
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTsender-options.
Definition: MSDevice_BTsender.cpp:49
MSDevice_BTsender::VehicleInformation::updates
std::vector< VehicleState > updates
List of position updates during last step.
Definition: MSDevice_BTsender.h:193
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
Boundary::add
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:78
MSDevice_BTsender::VehicleState::speed
double speed
The speed of the vehicle.
Definition: MSDevice_BTsender.h:154
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
MSDevice_BTsender::cleanup
static void cleanup()
removes remaining vehicleInformation in sVehicles
Definition: MSDevice_BTsender.cpp:63
MSDevice_BTsender
A BT sender.
Definition: MSDevice_BTsender.h:49
MSDevice_BTsender::VehicleInformation::haveArrived
bool haveArrived
Whether the vehicle was removed from the simulation.
Definition: MSDevice_BTsender.h:199
MSDevice_BTsender::VehicleInformation::getBoxBoundary
Boundary getBoxBoundary() const
Returns the boundary of passed positions.
Definition: MSDevice_BTsender.h:184
config.h
MSDevice_BTsender::~MSDevice_BTsender
~MSDevice_BTsender()
Destructor.
Definition: MSDevice_BTsender.cpp:79
MSDevice_BTsender::buildVehicleDevices
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
Definition: MSDevice_BTsender.cpp:55
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:91
MSDevice_BTsender::VehicleState
A single movement state of the vehicle.
Definition: MSDevice_BTsender.h:138
MSDevice_BTsender::VehicleInformation::VehicleInformation
VehicleInformation(const std::string &id)
Constructor.
Definition: MSDevice_BTsender.h:176
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:54
MSDevice_BTsender::notifyMove
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
Definition: MSDevice_BTsender.cpp:103