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 /****************************************************************************/
15 // C++ TraCI client API implementation
16 /****************************************************************************/
17 #ifndef Person_h
18 #define Person_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <vector>
27 #include <libsumo/TraCIDefs.h>
28 #include <libsumo/VehicleType.h>
29 #include <libsumo/TraCIConstants.h>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class MSPerson;
37 class PositionVector;
38 namespace libsumo {
39 class VariableWrapper;
40 }
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
50 namespace libsumo {
51 class Person {
52 public:
53  static std::vector<std::string> getIDList();
54  static int getIDCount();
55  static double getSpeed(const std::string& personID);
56  static TraCIPosition getPosition(const std::string& personID, const bool includeZ = false);
57  static TraCIPosition getPosition3D(const std::string& personID);
58  static std::string getRoadID(const std::string& personID);
59  static std::string getTypeID(const std::string& personID);
60  static double getWaitingTime(const std::string& personID);
61  static std::string getNextEdge(const std::string& personID);
62  static std::string getVehicle(const std::string& personID);
63  static int getRemainingStages(const std::string& personID);
64  static TraCIStage getStage(const std::string& personID, int nextStageIndex = 0);
65  static std::vector<std::string> getEdges(const std::string& personID, int nextStageIndex = 0);
66  static std::string getParameter(const std::string& routeID, const std::string& param);
67  static double getAngle(const std::string& personID);
68  static double getSlope(const std::string& personID);
69  static double getLanePosition(const std::string& personID);
70 
72 
73  static void add(const std::string& personID, const std::string& edgeID, double pos, double depart = DEPARTFLAG_NOW, const std::string typeID = "DEFAULT_PEDTYPE");
74  static void appendStage(const TraCIStage& stage, const std::string& personID);
75  static void replaceStage(const std::string& personID, const int stageIndex, const TraCIStage& stage);
76  static void appendWaitingStage(const std::string& personID, double duration, const std::string& description = "waiting", const std::string& stopID = "");
77  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 = "");
78  static void appendDrivingStage(const std::string& personID, const std::string& toEdge, const std::string& lines, const std::string& stopID = "");
79  static void removeStage(const std::string& personID, int nextStageIndex);
80  static void rerouteTraveltime(const std::string& personID);
81  static void moveTo(const std::string& personID, const std::string& edgeID, double position);
82  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);
83  static void setParameter(const std::string& personID, const std::string& key, const std::string& value);
84  static void setSpeed(const std::string& personID, double speed);
85  static void setType(const std::string& personID, const std::string& typeID);
86 
88 
90 
95  static void storeShape(const std::string& id, PositionVector& shape);
96 
97  static std::shared_ptr<VariableWrapper> makeWrapper();
98 
99  static bool handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper);
100 
101 private:
102  static MSPerson* getPerson(const std::string& id);
103  static MSTransportable::Stage* convertTraCIStage(const TraCIStage& stage, const std::string personID);
104 
105 private:
108 
109 private:
111  Person() = delete;
112 
113 };
114 
115 
116 }
117 
118 
119 #endif
120 
121 /****************************************************************************/
libsumo::Person::getLanePosition
static double getLanePosition(const std::string &personID)
Definition: Person.cpp:118
LIBSUMO_SUBSCRIPTION_API
#define LIBSUMO_SUBSCRIPTION_API
Definition: TraCIDefs.h:42
libsumo::INVALID_DOUBLE_VALUE
TRACI_CONST double INVALID_DOUBLE_VALUE
Definition: TraCIConstants.h:363
libsumo::Person::setSpeed
static void setSpeed(const std::string &personID, double speed)
Definition: Person.cpp:378
libsumo::Person::getPosition
static TraCIPosition getPosition(const std::string &personID, const bool includeZ=false)
Definition: Person.cpp:75
libsumo::TraCIPosition
A 3D-position.
Definition: TraCIDefs.h:110
libsumo::VariableWrapper
Definition: Subscription.h:114
libsumo::Person::getVehicle
static std::string getVehicle(const std::string &personID)
Definition: Person.cpp:238
MSPerson
Definition: MSPerson.h:64
MSTransportable::Stage
Definition: MSTransportable.h:74
libsumo::ContextSubscriptionResults
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:205
libsumo::Person::moveTo
static void moveTo(const std::string &personID, const std::string &edgeID, double position)
Definition: Person.cpp:689
VehicleType.h
PositionVector
A list of positions.
Definition: PositionVector.h:46
libsumo::Person::getEdges
static std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0)
Definition: Person.cpp:154
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:592
libsumo::DEPARTFLAG_NOW
TRACI_CONST int DEPARTFLAG_NOW
Definition: TraCIConstants.h:426
libsumo
Definition: Edge.cpp:30
libsumo::Person::getRoadID
static std::string getRoadID(const std::string &personID)
Definition: Person.cpp:112
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:976
LIBSUMO_VEHICLE_TYPE_GETTER
#define LIBSUMO_VEHICLE_TYPE_GETTER
Definition: VehicleType.h:30
libsumo::Person::getSpeed
static double getSpeed(const std::string &personID)
Definition: Person.cpp:106
libsumo::Person::getSlope
static double getSlope(const std::string &personID)
Definition: Person.cpp:93
TraCIConstants.h
LIBSUMO_VEHICLE_TYPE_SETTER
#define LIBSUMO_VEHICLE_TYPE_SETTER
Definition: VehicleType.h:54
libsumo::TraCIStage
Definition: TraCIDefs.h:345
libsumo::Person::handleVariable
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition: Person.cpp:988
libsumo::Person::getPerson
static MSPerson * getPerson(const std::string &id)
Definition: Person.cpp:965
libsumo::Person::getPosition3D
static TraCIPosition getPosition3D(const std::string &personID)
Definition: Person.cpp:81
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:714
libsumo::Person::getStage
static TraCIStage getStage(const std::string &personID, int nextStageIndex=0)
Definition: Person.cpp:173
libsumo::Person::getIDCount
static int getIDCount()
Definition: Person.cpp:69
libsumo::Person::makeWrapper
static std::shared_ptr< VariableWrapper > makeWrapper()
Definition: Person.cpp:982
libsumo::Person::getWaitingTime
static double getWaitingTime(const std::string &personID)
Definition: Person.cpp:142
libsumo::Person::getTypeID
static std::string getTypeID(const std::string &personID)
Definition: Person.cpp:136
libsumo::Person::mySubscriptionResults
static SubscriptionResults mySubscriptionResults
Definition: Person.h:106
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:394
libsumo::Person::setType
static void setType(const std::string &personID, const std::string &typeID)
Definition: Person.cpp:384
libsumo::Person::getNextEdge
static std::string getNextEdge(const std::string &personID)
Definition: Person.cpp:148
libsumo::Person::Person
Person()=delete
invalidated standard constructor
libsumo::Person::getRemainingStages
static int getRemainingStages(const std::string &personID)
Definition: Person.cpp:232
MSTransportable.h
libsumo::Person::removeStage
static void removeStage(const std::string &personID, int nextStageIndex)
Definition: Person.cpp:624
libsumo::Person::appendStage
static void appendStage(const TraCIStage &stage, const std::string &personID)
Definition: Person.cpp:533
libsumo::Person::rerouteTraveltime
static void rerouteTraveltime(const std::string &personID)
Definition: Person.cpp:637
libsumo::Person
Definition: Person.h:51
libsumo::Person::replaceStage
static void replaceStage(const std::string &personID, const int stageIndex, const TraCIStage &stage)
Definition: Person.cpp:540
config.h
libsumo::Person::getIDList
static std::vector< std::string > getIDList()
Definition: Person.cpp:56
libsumo::Person::appendWaitingStage
static void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: Person.cpp:575
TraCIDefs.h
libsumo::Person::myContextSubscriptionResults
static ContextSubscriptionResults myContextSubscriptionResults
Definition: Person.h:107
libsumo::Person::setParameter
static void setParameter(const std::string &personID, const std::string &key, const std::string &value)
Definition: Person.cpp:834
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:554
libsumo::SubscriptionResults
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:204
libsumo::Person::convertTraCIStage
static MSTransportable::Stage * convertTraCIStage(const TraCIStage &stage, const std::string personID)
Definition: Person.cpp:459
libsumo::Person::getParameter
static std::string getParameter(const std::string &routeID, const std::string &param)
Definition: Person.cpp:249
libsumo::Person::getAngle
static double getAngle(const std::string &personID)
Definition: Person.cpp:87