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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
19 // A BT sender
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
24 #include <set>
25 #include <string>
26 #include "MSVehicleDevice.h"
27 #include <utils/common/SUMOTime.h>
28 #include <utils/geom/Boundary.h>
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class SUMOVehicle;
35 class SUMOTrafficObject;
36 
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
48 public:
52  static void insertOptions(OptionsCont& oc);
53 
54 
65  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
66 
67 
70  static void cleanup();
71 
72 
74  friend class MSDevice_BTreceiver;
75 
76 
77 
78 public:
81 
82 
83 
86 
95  bool notifyEnter(SUMOTrafficObject& veh, Notification reason, const MSLane* enteredLane = 0);
96 
97 
111  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
112 
113 
123  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, Notification reason, const MSLane* enteredLane = 0);
125 
127  const std::string deviceName() const {
128  return "btsender";
129  }
130 
131 
135  class VehicleState {
136  public:
143  VehicleState(const double _speed, const Position& _position, const std::string& _laneID,
144  const double _lanePos, const int _routePos)
145  : speed(_speed), position(_position), laneID(_laneID), lanePos(_lanePos), routePos(_routePos) {}
146 
149 
151  double speed;
155  std::string laneID;
157  double lanePos;
159  int routePos;
160 
161  };
162 
163 
164 
168  class VehicleInformation : public Named {
169  public:
173  VehicleInformation(const std::string& id) : Named(id), amOnNet(true), haveArrived(false) {}
174 
176  virtual ~VehicleInformation() {}
177 
182  Boundary ret;
183  for (std::vector<VehicleState>::const_iterator i = updates.begin(); i != updates.end(); ++i) {
184  ret.add((*i).position);
185  }
186  return ret;
187  }
188 
190  std::vector<VehicleState> updates;
191 
193  bool amOnNet;
194 
197 
200 
201  };
202 
203 
204 
205 private:
211  MSDevice_BTsender(SUMOVehicle& holder, const std::string& id);
212 
213 
214 
215 protected:
217  static std::map<std::string, VehicleInformation*> sVehicles;
218 
219 
220 
221 private:
224 
227 
228 
229 };
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:77
Stores the information of a vehicle.
bool amOnNet
Whether the vehicle is within the simulated network.
bool haveArrived
Whether the vehicle was removed from the simulation.
ConstMSEdgeVector route
List of edges travelled.
VehicleInformation(const std::string &id)
Constructor.
Boundary getBoxBoundary() const
Returns the boundary of passed positions.
std::vector< VehicleState > updates
List of position updates during last step.
A single movement state of the vehicle.
int routePos
The position in the route of the vehicle.
double speed
The speed of the vehicle.
Position position
The position of the vehicle.
VehicleState(const double _speed, const Position &_position, const std::string &_laneID, const double _lanePos, const int _routePos)
Constructor.
double lanePos
The position at the lane of the vehicle.
std::string laneID
The lane the vehicle was at.
MSDevice_BTsender(SUMOVehicle &holder, const std::string &id)
Constructor.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Moves (the known) vehicle from running to arrived vehicles' list.
bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane=0)
Adds the vehicle to running vehicles if it (re-) enters the network.
const std::string deviceName() const
return the name for this type of device
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTsender-options.
MSDevice_BTsender(const MSDevice_BTsender &)
Invalidated copy constructor.
~MSDevice_BTsender()
Destructor.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
MSDevice_BTsender & operator=(const MSDevice_BTsender &)
Invalidated assignment operator.
static void cleanup()
removes remaining vehicleInformation in sVehicles
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived senders.
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Notification
Definition of a vehicle state.
Abstract in-vehicle device.
Base class for objects which have an id.
Definition: Named.h:54
A storage for options typed value containers)
Definition: OptionsCont.h:89
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition: SUMOVehicle.h:60