Eclipse SUMO - Simulation of Urban MObility
MSDevice_Transportable.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
19 // A device which is used to keep track of persons and containers riding with a vehicle
20 /****************************************************************************/
21 #ifndef MSDevice_Transportable_h
22 #define MSDevice_Transportable_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #include <config.h>
29 
30 #include <vector>
31 #include "MSVehicleDevice.h"
32 #include <utils/common/SUMOTime.h>
33 #include <microsim/MSVehicle.h>
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
45 public:
53  static MSDevice_Transportable* buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into, const bool isContainer);
54 
55 
56 
57 public:
60 
61 
64 
74  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
75 
76 
85  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
86 
87 
97  bool notifyLeave(SUMOTrafficObject& veh, double lastPos,
98  MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
100 
101 
103  const std::string deviceName() const {
104  return myAmContainer ? "container" : "person";
105  }
106 
108  std::string getParameter(const std::string& key) const;
109 
114  void addTransportable(MSTransportable* transportable);
115 
116 
121  void removeTransportable(MSTransportable* transportable);
122 
123 
127  int size() const {
128  return (int)myTransportables.size();
129  }
130 
131 
135  const std::vector<MSTransportable*>& getTransportables() const {
136  return myTransportables;
137  }
138 
139 protected:
143  void notifyMoveInternal(const SUMOTrafficObject& veh,
144  const double frontOnLane,
145  const double timeOnLane,
146  const double meanSpeedFrontOnLane,
147  const double meanSpeedVehicleOnLane,
148  const double travelledDistanceFrontOnLane,
149  const double travelledDistanceVehicleOnLane,
150  const double /* meanLengthOnLane */);
151 
152 private:
158  MSDevice_Transportable(SUMOVehicle& holder, const std::string& id, const bool isContainer);
159 
160 
161 
162 private:
165 
167  std::vector<MSTransportable*> myTransportables;
168 
170  bool myStopped;
171 
172 
173 private:
176 
179 
180 
181 };
182 
183 
184 #endif
185 
186 /****************************************************************************/
187 
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:48
MSDevice_Transportable::getTransportables
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
Definition: MSDevice_Transportable.h:135
MSDevice_Transportable::myTransportables
std::vector< MSTransportable * > myTransportables
The passengers of the vehicle.
Definition: MSDevice_Transportable.h:167
SUMOTime.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
MSVehicleDevice.h
MSDevice_Transportable
Definition: MSDevice_Transportable.h:44
WrappingCommand.h
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:61
MSTransportable
Definition: MSTransportable.h:59
MSVehicle.h
MSDevice_Transportable::myAmContainer
bool myAmContainer
Whether it is a container device.
Definition: MSDevice_Transportable.h:164
MSDevice_Transportable::myStopped
bool myStopped
Whether the vehicle is at a stop.
Definition: MSDevice_Transportable.h:170
MSDevice_Transportable::MSDevice_Transportable
MSDevice_Transportable(SUMOVehicle &holder, const std::string &id, const bool isContainer)
Constructor.
Definition: MSDevice_Transportable.cpp:54
MSDevice_Transportable::deviceName
const std::string deviceName() const
return the name for this type of device
Definition: MSDevice_Transportable.h:103
MSDevice_Transportable::getParameter
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
Definition: MSDevice_Transportable.cpp:193
MSDevice_Transportable::buildVehicleDevices
static MSDevice_Transportable * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, const bool isContainer)
Build devices for the given vehicle, if needed.
Definition: MSDevice_Transportable.cpp:44
MSDevice_Transportable::operator=
MSDevice_Transportable & operator=(const MSDevice_Transportable &)
Invalidated assignment operator.
MSDevice_Transportable::notifyMove
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the vehicle is at a stop and transportable action is needed.
Definition: MSDevice_Transportable.cpp:87
MSDevice_Transportable::removeTransportable
void removeTransportable(MSTransportable *transportable)
Remove a passenger (TraCI)
Definition: MSDevice_Transportable.cpp:177
MSDevice_Transportable::~MSDevice_Transportable
~MSDevice_Transportable()
Destructor.
Definition: MSDevice_Transportable.cpp:59
MSDevice_Transportable::addTransportable
void addTransportable(MSTransportable *transportable)
Add a passenger.
Definition: MSDevice_Transportable.cpp:164
MSDevice_Transportable::notifyLeave
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Passengers leaving on arrival.
Definition: MSDevice_Transportable.cpp:139
MSDevice_Transportable::size
int size() const
Return the number of passengers / containers.
Definition: MSDevice_Transportable.h:127
MSDevice_Transportable::notifyMoveInternal
void notifyMoveInternal(const SUMOTrafficObject &veh, const double frontOnLane, const double timeOnLane, const double meanSpeedFrontOnLane, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double)
Internal notification about the vehicle moves, see MSMoveReminder::notifyMoveInternal()
Definition: MSDevice_Transportable.cpp:74
config.h
MSDevice_Transportable::notifyEnter
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Adds passengers on vehicle insertion.
Definition: MSDevice_Transportable.cpp:128
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:89
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:55