SUMO - Simulation of Urban MObility
MSDevice_BTsender.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // A BT sender
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2013-2017 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef MSDevice_BTsender_h
22 #define MSDevice_BTsender_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <set>
35 #include <string>
36 #include "MSDevice.h"
37 #include <utils/common/SUMOTime.h>
38 #include <utils/geom/Boundary.h>
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class SUMOVehicle;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
56 class MSDevice_BTsender : public MSDevice {
57 public:
61  static void insertOptions(OptionsCont& oc);
62 
63 
74  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into);
75 
76 
79  static void cleanup();
80 
81 
83  friend class MSDevice_BTreceiver;
84 
85 
86 
87 public:
90 
91 
92 
95 
104  bool notifyEnter(SUMOVehicle& veh, Notification reason, const MSLane* enteredLane = 0);
105 
106 
120  bool notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double newSpeed);
121 
122 
133  bool notifyLeave(SUMOVehicle& veh, double lastPos, Notification reason, const MSLane* enteredLane = 0);
135 
137  const std::string deviceName() const {
138  return "btsender";
139  }
140 
141 
145  class VehicleState {
146  public:
153  VehicleState(const double _speed, const Position& _position, const std::string& _laneID,
154  const double _lanePos, const int _routePos)
155  : speed(_speed), position(_position), laneID(_laneID), lanePos(_lanePos), routePos(_routePos) {}
156 
159 
161  double speed;
165  std::string laneID;
167  double lanePos;
169  int routePos;
170 
171  };
172 
173 
174 
178  class VehicleInformation : public Named {
179  public:
183  VehicleInformation(const std::string& id) : Named(id), amOnNet(true), haveArrived(false) {}
184 
186  virtual ~VehicleInformation() {}
187 
192  Boundary ret;
193  for (std::vector<VehicleState>::const_iterator i = updates.begin(); i != updates.end(); ++i) {
194  ret.add((*i).position);
195  }
196  return ret;
197  }
198 
200  std::vector<VehicleState> updates;
201 
203  bool amOnNet;
204 
207 
210 
211  };
212 
213 
214 
215 private:
221  MSDevice_BTsender(SUMOVehicle& holder, const std::string& id);
222 
223 
224 
225 protected:
227  static std::map<std::string, VehicleInformation*> sVehicles;
228 
229 
230 
231 private:
234 
237 
238 
239 };
240 
241 
242 #endif
243 
244 /****************************************************************************/
245 
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:48
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:67
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
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:46
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:71
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:99
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:86
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
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.