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-2016 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);
105 
106 
120  bool notifyMove(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed);
121 
122 
133  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, Notification reason);
135 
136 
137 
141  class VehicleState {
142  public:
149  VehicleState(const SUMOReal _speed, const Position& _position, const std::string& _laneID,
150  const SUMOReal _lanePos, const int _routePos)
151  : speed(_speed), position(_position), laneID(_laneID), lanePos(_lanePos), routePos(_routePos) {}
152 
155 
161  std::string laneID;
165  int routePos;
166 
167  };
168 
169 
170 
174  class VehicleInformation : public Named {
175  public:
179  VehicleInformation(const std::string& id) : Named(id), amOnNet(true), haveArrived(false) {}
180 
182  virtual ~VehicleInformation() {}
183 
188  Boundary ret;
189  for (std::vector<VehicleState>::const_iterator i = updates.begin(); i != updates.end(); ++i) {
190  ret.add((*i).position);
191  }
192  return ret;
193  }
194 
196  std::vector<VehicleState> updates;
197 
199  bool amOnNet;
200 
203 
206 
207  };
208 
209 
210 
211 private:
217  MSDevice_BTsender(SUMOVehicle& holder, const std::string& id);
218 
219 
220 
221 protected:
223  static std::map<std::string, VehicleInformation*> sVehicles;
224 
225 
226 
227 private:
230 
233 
234 
235 };
236 
237 
238 #endif
239 
240 /****************************************************************************/
241 
bool amOnNet
Whether the vehicle is within the simulated network.
Position position
The position of the vehicle.
SUMOReal lanePos
The position at the lane of the vehicle.
int routePos
The position in the route of the vehicle.
~MSDevice_BTsender()
Destructor.
bool notifyEnter(SUMOVehicle &veh, Notification reason)
Adds the vehicle to running vehicles if it (re-) enters the network.
std::string laneID
The lane the vehicle was at.
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
Boundary getBoxBoundary() const
Returns the boundary of passed positions.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
ConstMSEdgeVector route
List of edges travelled.
Representation of a vehicle.
Definition: SUMOVehicle.h:66
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A single movement state of the vehicle.
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, Notification reason)
Moves (the known) vehicle from running to arrived vehicles&#39; list.
bool haveArrived
Whether the vehicle was removed from the simulation.
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
SUMOReal speed
The speed of the vehicle.
MSDevice_BTsender(SUMOVehicle &holder, const std::string &id)
Constructor.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTsender-options.
Base class for objects which have an id.
Definition: Named.h:46
Abstract in-vehicle device.
Definition: MSDevice.h:69
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:76
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
#define SUMOReal
Definition: config.h:213
Stores the information of a vehicle.
VehicleState(const SUMOReal _speed, const Position &_position, const std::string &_laneID, const SUMOReal _lanePos, const int _routePos)
Constructor.
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived senders.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into)
Build devices for the given vehicle, if needed.