45 const std::string
id = inputStorage.
readString();
48 if (!libsumo::Person::handleVariable(
id, variable, &server, &inputStorage)) {
63 std::string warning =
"";
95 if (p ==
nullptr && shouldExist) {
106 libsumo::Person::setType(
id,
StoHelp::readTypedString(inputStorage,
"The vehicle type id must be given as a string."));
110 libsumo::Person::setSpeedFactor(
id,
StoHelp::readTypedDouble(inputStorage,
"Setting SpeedFactor requires a double."));
114 libsumo::Person::setColor(
id,
StoHelp::readTypedColor(inputStorage,
"The color must be given using the according type."));
123 libsumo::Person::add(
id, edgeID, pos, depart, vTypeID);
127 libsumo::Person::remove(
id, (
char)
StoHelp::readTypedByte(inputStorage,
"Removing a person requires a byte."));
131 const int parameterCount =
StoHelp::readCompound(inputStorage, -1,
"Adding a person stage requires a compound object.");
132 if (parameterCount == 13) {
135 libsumo::Person::appendStage(
id, stage);
137 const int stageType =
StoHelp::readTypedInt(inputStorage,
"The first parameter for adding a stage must be the stage type given as int.");
140 if (parameterCount != 4) {
146 libsumo::Person::appendDrivingStage(
id, edgeID, lines, stopID);
149 if (parameterCount != 4) {
153 const std::string description =
StoHelp::readTypedString(inputStorage,
"Third parameter (description) requires a string.");
155 libsumo::Person::appendWaitingStage(
id, duration, description, stopID);
158 if (parameterCount != 6) {
161 const std::vector<std::string> edgeIDs =
StoHelp::readTypedStringList(inputStorage,
"Second parameter (edges) route must be defined as a list of edge ids.");
162 const double arrivalPos =
StoHelp::readTypedDouble(inputStorage,
"Third parameter (arrivalPos) requires a double.");
166 libsumo::Person::appendWalkingStage(
id, edgeIDs, arrivalPos, duration, speed, stopID);
174 StoHelp::readCompound(inputStorage, 2,
"Replacing a person stage requires a compound object of size 2.");
175 const int nextStageIndex =
StoHelp::readTypedInt(inputStorage,
"First parameter of replace stage should be an integer");
176 StoHelp::readCompound(inputStorage, 13,
"Second parameter of replace stage should be a compound object of size 13");
179 libsumo::Person::replaceStage(
id, nextStageIndex, stage);
183 libsumo::Person::removeStage(
id,
StoHelp::readTypedInt(inputStorage,
"The message must contain the stage index."));
188 libsumo::Person::rerouteTraveltime(
id);
192 StoHelp::readCompound(inputStorage, 3,
"Setting position should obtain the edge id, the position and the lateral position.");
193 const std::string laneID =
StoHelp::readTypedString(inputStorage,
"The first parameter for setting a position must be the laneID given as a string.");
194 const double position =
StoHelp::readTypedDouble(inputStorage,
"The second parameter for setting a position must be the position given as a double.");
195 const double posLat =
StoHelp::readTypedDouble(inputStorage,
"The third parameter for setting a position must be the lateral position given as a double.");
196 libsumo::Person::moveTo(
id, laneID, position, posLat);
200 const int parameterCount =
StoHelp::readCompound(inputStorage, -1,
"MoveToXY person requires a compound object.");
201 if (parameterCount != 5 && parameterCount != 6) {
204 const std::string edgeID =
StoHelp::readTypedString(inputStorage,
"The first parameter for moveToXY must be the edge ID given as a string.");
205 const double x =
StoHelp::readTypedDouble(inputStorage,
"The second parameter for moveToXY must be the x-position given as a double.");
206 const double y =
StoHelp::readTypedDouble(inputStorage,
"The third parameter for moveToXY must be the y-position given as a double.");
207 const double angle =
StoHelp::readTypedDouble(inputStorage,
"The fourth parameter for moveToXY must be the angle given as a double.");
208 const int keepRouteFlag =
StoHelp::readTypedByte(inputStorage,
"The fifth parameter for moveToXY must be the keepRouteFlag given as a byte.");
209 double matchThreshold = 100.;
210 if (parameterCount == 6) {
211 matchThreshold =
StoHelp::readTypedDouble(inputStorage,
"The sixth parameter for moveToXY must be the matchThreshold given as a double.");
213 libsumo::Person::moveToXY(
id, edgeID, x, y, angle, keepRouteFlag, matchThreshold);
217 StoHelp::readCompound(inputStorage, 2,
"A compound object of size 2 is needed for setting a parameter.");
218 const std::string name =
StoHelp::readTypedString(inputStorage,
"The name of the parameter must be given as a string.");
219 const std::string value =
StoHelp::readTypedString(inputStorage,
"The value of the parameter must be given as a string.");
220 libsumo::Person::setParameter(
id, name, value);
std::string toHex(const T i, std::streamsize numDigits=0)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual MSTransportableControl & getPersonControl()
Returns the person control.
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
const std::string & getID() const
Returns the name of the vehicle type.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xae: Get Person Variable)
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xce: Change Person State)
static bool setVariable(const int cmd, const int variable, const std::string &id, TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value for the given type.
TraCI server used to control sumo by a remote TraCI client.
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
tcpip::Storage & getWrapperStorage()
void initWrapper(const int domainID, const int variable, const std::string &objID)
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
static int readTypedByte(tcpip::Storage &ret, const std::string &error="")
static int readCompound(tcpip::Storage &ret, int expectedSize=-1, const std::string &error="")
static std::vector< std::string > readTypedStringList(tcpip::Storage &ret, const std::string &error="")
static int readTypedInt(tcpip::Storage &ret, const std::string &error="")
static std::string readTypedString(tcpip::Storage &ret, const std::string &error="")
static const libsumo::TraCIColor readTypedColor(tcpip::Storage &ret, const std::string &error="")
static void readStage(tcpip::Storage &inputStorage, libsumo::TraCIStage &stage, const std::string &error="")
static double readTypedDouble(tcpip::Storage &ret, const std::string &error="")
An error which allows to continue.
virtual std::string readString()
virtual int readUnsignedByte()
TRACI_CONST int VAR_MINGAP
TRACI_CONST int REPLACE_STAGE
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int MOVE_TO_XY
TRACI_CONST int CMD_GET_PERSON_VARIABLE
TRACI_CONST int VAR_MOVE_TO
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_WIDTH
TRACI_CONST int STAGE_WAITING
TRACI_CONST int CMD_REROUTE_TRAVELTIME
TRACI_CONST int APPEND_STAGE
TRACI_CONST int VAR_LENGTH
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int CMD_SET_PERSON_VARIABLE
TRACI_CONST int VAR_HEIGHT
TRACI_CONST int RESPONSE_GET_PERSON_VARIABLE
TRACI_CONST int STAGE_WALKING
TRACI_CONST int REMOVE_STAGE
TRACI_CONST int VAR_SPEED
TRACI_CONST int STAGE_DRIVING