SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSDevice_BTsender.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // A BT sender
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
10 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef MSDevice_BTsender_h
21 #define MSDevice_BTsender_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <set>
34 #include <string>
35 #include "MSDevice.h"
36 #include <utils/common/SUMOTime.h>
37 #include <utils/geom/Position.h>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class SUMOVehicle;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
55 class MSDevice_BTsender : public MSDevice {
56 public:
60  static void insertOptions(OptionsCont& oc);
61 
62 
73  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into);
74 
75 
77  friend class MSDevice_BTreceiver;
78 
79 
80 
81 public:
84 
85 
86 
89 
98  bool notifyEnter(SUMOVehicle& veh, Notification reason);
99 
100 
114  bool notifyMove(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed);
115 
116 
127  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, Notification reason);
129 
130 
131 
135  class VehicleState {
136  public:
145  VehicleState(SUMOReal _time, SUMOReal _speed, SUMOReal _angle, const Position& _position, const std::string& _laneID, SUMOReal _lanePos)
146  : time(_time), speed(_speed), angle(_angle), position(_position), laneID(_laneID), lanePos(_lanePos) {}
147 
150 
160  std::string laneID;
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 
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 
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 };
230 
231 
232 #endif
233 
234 /****************************************************************************/
235 
bool amOnNet
Whether the vehicle is within the simulated network.
Position position
The position of the vehicle.
SUMOReal angle
The angle of the vehicle.
SUMOReal lanePos
The position at the lane of the vehicle.
~MSDevice_BTsender()
Destructor.
bool notifyEnter(SUMOVehicle &veh, Notification reason)
Adds the vehicle to running vehicles if it (re-) enters the network.
SUMOReal time
The current time.
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.
Boundary getBoxBoundary() const
Returns the boundary of passed positions.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
VehicleState(SUMOReal _time, SUMOReal _speed, SUMOReal _angle, const Position &_position, const std::string &_laneID, SUMOReal _lanePos)
Constructor.
Representation of a vehicle.
Definition: SUMOVehicle.h:63
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:45
Abstract in-vehicle device.
Definition: MSDevice.h:68
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:108
#define SUMOReal
Definition: config.h:215
Stores the information of a vehicle.
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.