Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDevice_BTsender.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2013-2024 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>
27#include "MSVehicleDevice.h"
30#include <utils/geom/Boundary.h>
31
32
33// ===========================================================================
34// class declarations
35// ===========================================================================
36class SUMOVehicle;
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
50public:
51
54 static void cleanup();
55
57 static std::string getLocation(const SUMOTrafficObject& o);
58
60 friend class MSDevice_BTreceiver;
61
62public:
65
68
77 bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
78
79
93 bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
94
95
105 bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
107
112 public:
119 VehicleState(const double _speed, const Position& _position, const std::string& _laneID,
120 const double _lanePos, const int _routePos)
121 : speed(_speed), position(_position), laneID(_laneID), lanePos(_lanePos), routePos(_routePos) {}
122
125
127 double speed;
131 std::string laneID;
133 double lanePos;
136
137 };
138
139
140
144 class VehicleInformation : public Named {
145 public:
149 VehicleInformation(const std::string& id) : Named(id), amOnNet(true), haveArrived(false) {}
150
153
158 Boundary ret;
159 for (std::vector<VehicleState>::const_iterator i = updates.begin(); i != updates.end(); ++i) {
160 ret.add((*i).position);
161 }
162 return ret;
163 }
164
166 std::vector<VehicleState> updates;
167
170
173
176
177 };
178
179
180
181
182
183
184protected:
186 static std::map<std::string, VehicleInformation*> sVehicles;
187
191
192
193
194private:
197
200
201
202};
203
204
206public:
207
211 static void insertOptions(OptionsCont& oc);
212
213
224 static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
225
227 const std::string deviceName() const {
228 return "btsender";
229 }
230
231 bool notifyEnter(SUMOTrafficObject& veh, Notification reason, const MSLane* enteredLane = 0) {
232 return MSDevice_BTsender::notifyEnter(veh, reason, enteredLane);
233 }
234
235 bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed) {
236 return MSDevice_BTsender::notifyMove(veh, oldPos, newPos, newSpeed);
237 }
238
239 bool notifyLeave(SUMOTrafficObject& veh, double lastPos, Notification reason, const MSLane* enteredLane = 0) {
240 return MSDevice_BTsender::notifyLeave(veh, lastPos, reason, enteredLane);
241 }
242
243
244private:
250 MSVehicleDevice_BTsender(SUMOVehicle& holder, const std::string& id) :
251 MSVehicleDevice(holder, id) {
252 }
253
254};
255
257public:
258
262 static void insertOptions(OptionsCont& oc);
263
264
275 static void buildDevices(MSTransportable& t, std::vector<MSTransportableDevice*>& into);
276
278 const std::string deviceName() const {
279 return "btsender";
280 }
281
282 bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0) {
283 return MSDevice_BTsender::notifyEnter(veh, reason, enteredLane);
284 }
285
286 bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed) {
287 return MSDevice_BTsender::notifyMove(veh, oldPos, newPos, newSpeed);
288 }
289
290 bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0) {
291 return MSDevice_BTsender::notifyLeave(veh, lastPos, reason, enteredLane);
292 }
293
294
295private:
301 MSTransportableDevice_BTsender(MSTransportable& holder, const std::string& id) :
302 MSTransportableDevice(holder, id) {
303 }
304
305};
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:78
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.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Adds the vehicle to running vehicles if it (re-) enters the network.
MSDevice_BTsender & operator=(const MSDevice_BTsender &)
Invalidated assignment operator.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Moves (the known) vehicle from running to arrived vehicles' list.
static std::string getLocation(const SUMOTrafficObject &o)
return either lane or edge id (depending on availability)
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 cleanup()
removes remaining vehicleInformation in sVehicles
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived senders.
MSDevice_BTsender()
Constructor.
Representation of a lane in the micro simulation.
Definition MSLane.h:84
Notification
Definition of a vehicle state.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Checks whether the reminder is activated by a vehicle entering the lane.
const std::string deviceName() const
return the name for this type of device
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called if the vehicle leaves the reminder's lane.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTsender-options.
MSTransportableDevice_BTsender(MSTransportable &holder, const std::string &id)
Constructor.
static void buildDevices(MSTransportable &t, std::vector< MSTransportableDevice * > &into)
Build devices for the given vehicle, if needed.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
Abstract in-person device.
MSVehicleDevice_BTsender(SUMOVehicle &holder, const std::string &id)
Constructor.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTsender-options.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Called if the vehicle leaves the reminder's lane.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane=0)
Checks whether the reminder is activated by a vehicle entering the lane.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
const std::string deviceName() const
return the name for this type of device
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:62