Eclipse SUMO - Simulation of Urban MObility
Person.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2012-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 /****************************************************************************/
14 // C++ TraCI client API implementation
15 /****************************************************************************/
16 #ifndef Person_h
17 #define Person_h
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <vector>
26 #include <libsumo/TraCIDefs.h>
27 #include <libsumo/VehicleType.h>
28 #include <libsumo/TraCIConstants.h>
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class MSPerson;
36 class PositionVector;
37 namespace libsumo {
38 class VariableWrapper;
39 }
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
49 namespace libsumo {
50 class Person {
51 public:
52  static std::vector<std::string> getIDList();
53  static int getIDCount();
54  static double getSpeed(const std::string& personID);
55  static TraCIPosition getPosition(const std::string& personID, const bool includeZ = false);
56  static TraCIPosition getPosition3D(const std::string& personID);
57  static std::string getRoadID(const std::string& personID);
58  static std::string getTypeID(const std::string& personID);
59  static double getWaitingTime(const std::string& personID);
60  static std::string getNextEdge(const std::string& personID);
61  static std::string getVehicle(const std::string& personID);
62  static int getRemainingStages(const std::string& personID);
63  static TraCIStage getStage(const std::string& personID, int nextStageIndex = 0);
64  static std::vector<std::string> getEdges(const std::string& personID, int nextStageIndex = 0);
65  static std::string getParameter(const std::string& routeID, const std::string& param);
66  static double getAngle(const std::string& personID);
67  static double getSlope(const std::string& personID);
68  static double getLanePosition(const std::string& personID);
69 
71 
72  static void add(const std::string& personID, const std::string& edgeID, double pos, double depart = DEPARTFLAG_NOW, const std::string typeID = "DEFAULT_PEDTYPE");
73  static void appendStage(const TraCIStage& stage, const std::string& personID);
74  static void replaceStage(const std::string& personID, const int stageIndex, const TraCIStage& stage);
75  static void appendWaitingStage(const std::string& personID, double duration, const std::string& description = "waiting", const std::string& stopID = "");
76  static void appendWalkingStage(const std::string& personID, const std::vector<std::string>& edgeIDs, double arrivalPos, double duration = -1, double speed = -1, const std::string& stopID = "");
77  static void appendDrivingStage(const std::string& personID, const std::string& toEdge, const std::string& lines, const std::string& stopID = "");
78  static void removeStage(const std::string& personID, int nextStageIndex);
79  static void rerouteTraveltime(const std::string& personID);
80  static void moveTo(const std::string& personID, const std::string& edgeID, double position);
81  static void moveToXY(const std::string& personID, const std::string& edgeID, const double x, const double y, double angle = INVALID_DOUBLE_VALUE, const int keepRoute = 1);
82  static void setParameter(const std::string& personID, const std::string& key, const std::string& value);
83  static void setSpeed(const std::string& personID, double speed);
84  static void setType(const std::string& personID, const std::string& typeID);
85 
87 
89 
94  static void storeShape(const std::string& id, PositionVector& shape);
95 
96  static std::shared_ptr<VariableWrapper> makeWrapper();
97 
98  static bool handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper);
99 
100 private:
101  static MSPerson* getPerson(const std::string& id);
102  static MSTransportable::Stage* convertTraCIStage(const TraCIStage& stage, const std::string personID);
103 
104 private:
107 
108 private:
110  Person() = delete;
111 
112 };
113 
114 
115 }
116 
117 
118 #endif
119 
120 /****************************************************************************/
libsumo::Person::getLanePosition
static double getLanePosition(const std::string &personID)
Definition: Person.cpp:117
LIBSUMO_SUBSCRIPTION_API
#define LIBSUMO_SUBSCRIPTION_API
Definition: TraCIDefs.h:41
libsumo::INVALID_DOUBLE_VALUE
TRACI_CONST double INVALID_DOUBLE_VALUE
Definition: TraCIConstants.h:362
libsumo::Person::setSpeed
static void setSpeed(const std::string &personID, double speed)
Definition: Person.cpp:377
libsumo::Person::getPosition
static TraCIPosition getPosition(const std::string &personID, const bool includeZ=false)
Definition: Person.cpp:74
libsumo::TraCIPosition
A 3D-position.
Definition: TraCIDefs.h:109
libsumo::VariableWrapper
Definition: Subscription.h:132
libsumo::Person::getVehicle
static std::string getVehicle(const std::string &personID)
Definition: Person.cpp:237
MSPerson
Definition: MSPerson.h:63
MSTransportable::Stage
Definition: MSTransportable.h:73
libsumo::ContextSubscriptionResults
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:204
libsumo::Person::moveTo
static void moveTo(const std::string &personID, const std::string &edgeID, double position)
Definition: Person.cpp:688
VehicleType.h
PositionVector
A list of positions.
Definition: PositionVector.h:45
libsumo::Person::getEdges
static std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0)
Definition: Person.cpp:153
libsumo::Person::appendWalkingStage
static void appendWalkingStage(const std::string &personID, const std::vector< std::string > &edgeIDs, double arrivalPos, double duration=-1, double speed=-1, const std::string &stopID="")
Definition: Person.cpp:591
libsumo::DEPARTFLAG_NOW
TRACI_CONST int DEPARTFLAG_NOW
Definition: TraCIConstants.h:425
libsumo
Definition: Edge.cpp:29
libsumo::Person::getRoadID
static std::string getRoadID(const std::string &personID)
Definition: Person.cpp:111
libsumo::Person::storeShape
LIBSUMO_VEHICLE_TYPE_SETTER static LIBSUMO_SUBSCRIPTION_API void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
Definition: Person.cpp:975
LIBSUMO_VEHICLE_TYPE_GETTER
#define LIBSUMO_VEHICLE_TYPE_GETTER
Definition: VehicleType.h:29
libsumo::Person::getSpeed
static double getSpeed(const std::string &personID)
Definition: Person.cpp:105
libsumo::Person::getSlope
static double getSlope(const std::string &personID)
Definition: Person.cpp:92
TraCIConstants.h
LIBSUMO_VEHICLE_TYPE_SETTER
#define LIBSUMO_VEHICLE_TYPE_SETTER
Definition: VehicleType.h:53
libsumo::TraCIStage
Definition: TraCIDefs.h:344
libsumo::Person::handleVariable
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition: Person.cpp:987
libsumo::Person::getPerson
static MSPerson * getPerson(const std::string &id)
Definition: Person.cpp:964
libsumo::Person::getPosition3D
static TraCIPosition getPosition3D(const std::string &personID)
Definition: Person.cpp:80
libsumo::Person::moveToXY
static void moveToXY(const std::string &personID, const std::string &edgeID, const double x, const double y, double angle=INVALID_DOUBLE_VALUE, const int keepRoute=1)
Definition: Person.cpp:713
libsumo::Person::getStage
static TraCIStage getStage(const std::string &personID, int nextStageIndex=0)
Definition: Person.cpp:172
libsumo::Person::getIDCount
static int getIDCount()
Definition: Person.cpp:68
libsumo::Person::makeWrapper
static std::shared_ptr< VariableWrapper > makeWrapper()
Definition: Person.cpp:981
libsumo::Person::getWaitingTime
static double getWaitingTime(const std::string &personID)
Definition: Person.cpp:141
libsumo::Person::getTypeID
static std::string getTypeID(const std::string &personID)
Definition: Person.cpp:135
libsumo::Person::mySubscriptionResults
static SubscriptionResults mySubscriptionResults
Definition: Person.h:105
libsumo::Person::add
static LIBSUMO_VEHICLE_TYPE_GETTER void add(const std::string &personID, const std::string &edgeID, double pos, double depart=DEPARTFLAG_NOW, const std::string typeID="DEFAULT_PEDTYPE")
Definition: Person.cpp:393
libsumo::Person::setType
static void setType(const std::string &personID, const std::string &typeID)
Definition: Person.cpp:383
libsumo::Person::getNextEdge
static std::string getNextEdge(const std::string &personID)
Definition: Person.cpp:147
libsumo::Person::Person
Person()=delete
invalidated standard constructor
libsumo::Person::getRemainingStages
static int getRemainingStages(const std::string &personID)
Definition: Person.cpp:231
MSTransportable.h
libsumo::Person::removeStage
static void removeStage(const std::string &personID, int nextStageIndex)
Definition: Person.cpp:623
libsumo::Person::appendStage
static void appendStage(const TraCIStage &stage, const std::string &personID)
Definition: Person.cpp:532
libsumo::Person::rerouteTraveltime
static void rerouteTraveltime(const std::string &personID)
Definition: Person.cpp:636
libsumo::Person
Definition: Person.h:50
libsumo::Person::replaceStage
static void replaceStage(const std::string &personID, const int stageIndex, const TraCIStage &stage)
Definition: Person.cpp:539
config.h
libsumo::Person::getIDList
static std::vector< std::string > getIDList()
Definition: Person.cpp:55
libsumo::Person::appendWaitingStage
static void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: Person.cpp:574
TraCIDefs.h
libsumo::Person::myContextSubscriptionResults
static ContextSubscriptionResults myContextSubscriptionResults
Definition: Person.h:106
libsumo::Person::setParameter
static void setParameter(const std::string &personID, const std::string &key, const std::string &value)
Definition: Person.cpp:833
libsumo::Person::appendDrivingStage
static void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
Definition: Person.cpp:553
libsumo::SubscriptionResults
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:203
libsumo::Person::convertTraCIStage
static MSTransportable::Stage * convertTraCIStage(const TraCIStage &stage, const std::string personID)
Definition: Person.cpp:458
libsumo::Person::getParameter
static std::string getParameter(const std::string &routeID, const std::string &param)
Definition: Person.cpp:248
libsumo::Person::getAngle
static double getAngle(const std::string &personID)
Definition: Person.cpp:86