Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDevice_Transportable.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-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/****************************************************************************/
22// A device which is used to keep track of persons and containers riding with a vehicle
23/****************************************************************************/
24#pragma once
25#include <config.h>
26
27#include <vector>
28#include "MSVehicleDevice.h"
30#include <microsim/MSVehicle.h>
32
33
34// ===========================================================================
35// class definitions
36// ===========================================================================
42public:
50 static MSDevice_Transportable* buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into, const bool isContainer);
51
52
53public:
56
57
60
70 bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
71
72
81 bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
82
83
93 bool notifyLeave(SUMOTrafficObject& veh, double lastPos,
94 MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
96
97
99 const std::string deviceName() const {
100 return myAmContainer ? "container" : "person";
101 }
102
104 std::string getParameter(const std::string& key) const;
105
110 void addTransportable(MSTransportable* transportable);
111
116 void removeTransportable(MSTransportable* transportable);
117
118
119 bool anyLeavingAtStop(const MSStop& stop) const;
120
122 void transferAtSplitOrJoin(MSBaseVehicle* otherVeh);
123
128 void saveState(OutputDevice& out) const;
129
134 void loadState(const SUMOSAXAttributes& attrs);
135
139 int size() const {
140 return (int)myTransportables.size();
141 }
142
143
147 const std::vector<MSTransportable*>& getTransportables() const {
148 return myTransportables;
149 }
150
151 std::vector<Position>& getUnboardingPositions() {
153 }
154
156 static bool willTransferAtJoin(const MSTransportable* t, const MSBaseVehicle* joinVeh);
157
158protected:
163 const double frontOnLane,
164 const double timeOnLane,
165 const double meanSpeedFrontOnLane,
166 const double meanSpeedVehicleOnLane,
167 const double travelledDistanceFrontOnLane,
168 const double travelledDistanceVehicleOnLane,
169 const double meanLengthOnLane);
170
171private:
177 MSDevice_Transportable(SUMOVehicle& holder, const std::string& id, const bool isContainer);
178
179
180private:
182 const bool myAmContainer;
183
185 std::vector<MSTransportable*> myTransportables;
186
187 /* @brief Whether the vehicle is at a stop and the stop is finished
188 * true means, all passengers that wish to debord at the current stop have left
189 */
191
193 std::vector<Position> myUnboardingPositions;
194
195
196private:
199
202
203
204};
The base class for microscopic and mesoscopic vehicles.
MSDevice_Transportable(const MSDevice_Transportable &)
Invalidated copy constructor.
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
void saveState(OutputDevice &out) const
Saves the state of the device.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the vehicle is at a stop and transportable action is needed.
static bool willTransferAtJoin(const MSTransportable *t, const MSBaseVehicle *joinVeh)
check if boardingDuration should be applied
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
MSDevice_Transportable & operator=(const MSDevice_Transportable &)
Invalidated assignment operator.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Passengers leaving on arrival.
bool anyLeavingAtStop(const MSStop &stop) const
static MSDevice_Transportable * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, const bool isContainer)
Build devices for the given vehicle, if needed.
std::vector< Position > & getUnboardingPositions()
void transferAtSplitOrJoin(MSBaseVehicle *otherVeh)
transfers transportables that want to continue in the other train part (without boarding/loading dela...
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Adds passengers on vehicle insertion.
std::vector< Position > myUnboardingPositions
unboarding positions of passengers if vehicle is a train
int size() const
Return the number of passengers / containers.
std::vector< MSTransportable * > myTransportables
The passengers of the vehicle.
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 meanLengthOnLane)
Internal notification about the vehicle moves, see MSMoveReminder::notifyMoveInternal()
void addTransportable(MSTransportable *transportable)
Add a passenger.
const bool myAmContainer
Whether it is a container device.
const std::string deviceName() const
return the name for this type of device
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
void removeTransportable(MSTransportable *transportable)
Remove a passenger (TraCI)
Representation of a lane in the micro simulation.
Definition MSLane.h:84
Notification
Definition of a vehicle state.
Abstract in-vehicle device.
Static storage of an output device and its base (abstract) implementation.
Encapsulated SAX-Attributes.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition SUMOVehicle.h:62