Eclipse SUMO - Simulation of Urban MObility
TraCIServerAPI_Person.cpp
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 /****************************************************************************/
18 // APIs for getting/setting person values via TraCI
19 /****************************************************************************/
20 #include <config.h>
21 
26 #include <microsim/MSNet.h>
27 #include <microsim/MSEdge.h>
28 #include <libsumo/Person.h>
29 #include <libsumo/StorageHelper.h>
30 #include <libsumo/TraCIConstants.h>
31 #include <libsumo/VehicleType.h>
32 #include "TraCIServer.h"
34 #include "TraCIServerAPI_Person.h"
36 
37 
38 // ===========================================================================
39 // method definitions
40 // ===========================================================================
41 bool
43  tcpip::Storage& outputStorage) {
44  const int variable = inputStorage.readUnsignedByte();
45  const std::string id = inputStorage.readString();
47  try {
48  // in case of SPLIT_TAXI_RESERVATIONS id is a reservation id and handleVariable would throw an "unknown person" error
49  if (variable == libsumo::SPLIT_TAXI_RESERVATIONS || !libsumo::Person::handleVariable(id, variable, &server, &inputStorage)) {
50  switch (variable) {
51  case libsumo::VAR_EDGES: {
52  int nextStageIndex = 0;
53  if (!server.readTypeCheckingInt(inputStorage, nextStageIndex)) {
54  return server.writeErrorStatusCmd(libsumo::CMD_GET_PERSON_VARIABLE, "The message must contain the stage index.", outputStorage);
55  }
57  server.getWrapperStorage().writeStringList(libsumo::Person::getEdges(id, nextStageIndex));
58  break;
59  }
60  case libsumo::VAR_STAGE: {
61  int nextStageIndex = 0;
62  if (!server.readTypeCheckingInt(inputStorage, nextStageIndex)) {
63  return server.writeErrorStatusCmd(libsumo::CMD_GET_PERSON_VARIABLE, "The message must contain the stage index.", outputStorage);
64  }
65  libsumo::StorageHelper::writeStage(server.getWrapperStorage(), libsumo::Person::getStage(id, nextStageIndex));
66  break;
67  }
69  int onlyNew = 0;
70  if (!server.readTypeCheckingInt(inputStorage, onlyNew)) {
71  return server.writeErrorStatusCmd(libsumo::CMD_GET_PERSON_VARIABLE, "Retrieval of reservations requires an integer flag.", outputStorage);
72  }
73  const std::vector<libsumo::TraCIReservation> result = libsumo::Person::getTaxiReservations(onlyNew);
75  server.getWrapperStorage().writeInt((int)result.size());
76  for (const libsumo::TraCIReservation& r : result) {
78  server.getWrapperStorage().writeInt(10);
80  server.getWrapperStorage().writeString(r.id);
82  server.getWrapperStorage().writeStringList(r.persons);
84  server.getWrapperStorage().writeString(r.group);
86  server.getWrapperStorage().writeString(r.fromEdge);
88  server.getWrapperStorage().writeString(r.toEdge);
90  server.getWrapperStorage().writeDouble(r.departPos);
92  server.getWrapperStorage().writeDouble(r.arrivalPos);
94  server.getWrapperStorage().writeDouble(r.depart);
96  server.getWrapperStorage().writeDouble(r.reservationTime);
98  server.getWrapperStorage().writeInt(r.state);
99  }
100  break;
101  }
103  std::vector<std::string> persons;
104  if (!server.readTypeCheckingStringList(inputStorage, persons)) {
105  return server.writeErrorStatusCmd(libsumo::CMD_GET_PERSON_VARIABLE, "Splitting of reservations requires an string list.", outputStorage);
106  }
107  std::string splitID = libsumo::Person::splitTaxiReservation(id, persons);
109  server.getWrapperStorage().writeString(splitID);
110  break;
111  }
112  default:
113  return server.writeErrorStatusCmd(libsumo::CMD_GET_PERSON_VARIABLE, "Get Person Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
114  }
115  }
116  } catch (libsumo::TraCIException& e) {
117  return server.writeErrorStatusCmd(libsumo::CMD_GET_PERSON_VARIABLE, e.what(), outputStorage);
118  }
120  server.writeResponseWithLength(outputStorage, server.getWrapperStorage());
121  return true;
122 }
123 
124 
125 bool
127  tcpip::Storage& outputStorage) {
128  std::string warning = ""; // additional description for response
129  // variable
130  int variable = inputStorage.readUnsignedByte();
131  if (variable != libsumo::VAR_PARAMETER
132  && variable != libsumo::ADD
133  && variable != libsumo::REMOVE
134  && variable != libsumo::APPEND_STAGE
135  && variable != libsumo::REPLACE_STAGE
136  && variable != libsumo::REMOVE_STAGE
137  && variable != libsumo::CMD_REROUTE_TRAVELTIME
138  && variable != libsumo::VAR_MOVE_TO
139  && variable != libsumo::MOVE_TO_XY
140  && variable != libsumo::VAR_SPEED
141  && variable != libsumo::VAR_TYPE
142  && variable != libsumo::VAR_SPEED_FACTOR
143  && variable != libsumo::VAR_LENGTH
144  && variable != libsumo::VAR_WIDTH
145  && variable != libsumo::VAR_HEIGHT
146  && variable != libsumo::VAR_MINGAP
147  && variable != libsumo::VAR_COLOR
148  ) {
149  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Change Person State: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
150  }
151 
152  try {
153  // TODO: remove declaration of c after completion
155  // id
156  std::string id = inputStorage.readString();
157  // TODO: remove declaration of p after completion
158  const bool shouldExist = variable != libsumo::ADD;
159  MSTransportable* p = c.get(id);
160  if (p == nullptr && shouldExist) {
161  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Person '" + id + "' is not known", outputStorage);
162  }
163  // process
164  switch (variable) {
165  case libsumo::VAR_SPEED: {
166  double speed = 0;
167  if (!server.readTypeCheckingDouble(inputStorage, speed)) {
168  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Setting speed requires a double.", outputStorage);
169  }
170  // set the speed for all present and future (walking) stages and modify the vType so that stages added later are also affected
171  libsumo::Person::setSpeed(id, speed);
172  }
173  break;
174  case libsumo::VAR_TYPE: {
175  std::string vTypeID;
176  if (!server.readTypeCheckingString(inputStorage, vTypeID)) {
177  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "The vehicle type id must be given as a string.", outputStorage);
178  }
179  libsumo::Person::setType(id, vTypeID);
180  break;
181  }
183  double speedfactor = 0;
184  if (!server.readTypeCheckingDouble(inputStorage, speedfactor)) {
185  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Setting SpeedFactor requires a double.", outputStorage);
186  }
187  libsumo::Person::setSpeedFactor(id, speedfactor);
188  }
189  break;
190  case libsumo::VAR_COLOR: {
192  if (!server.readTypeCheckingColor(inputStorage, col)) {
193  return server.writeErrorStatusCmd(libsumo::CMD_SET_VEHICLE_VARIABLE, "The color must be given using the according type.", outputStorage);
194  }
195  libsumo::Person::setColor(id, col);
196  break;
197  }
198  case libsumo::ADD: {
199  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
200  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Adding a person requires a compound object.", outputStorage);
201  }
202  if (inputStorage.readInt() != 4) {
203  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Adding a person needs four parameters.", outputStorage);
204  }
205  std::string vTypeID;
206  if (!server.readTypeCheckingString(inputStorage, vTypeID)) {
207  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "First parameter (type) requires a string.", outputStorage);
208  }
209  std::string edgeID;
210  if (!server.readTypeCheckingString(inputStorage, edgeID)) {
211  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Second parameter (edge) requires a string.", outputStorage);
212  }
213  double depart;
214  if (!server.readTypeCheckingDouble(inputStorage, depart)) {
215  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Third parameter (depart) requires a double.", outputStorage);
216  }
217  double pos;
218  if (!server.readTypeCheckingDouble(inputStorage, pos)) {
219  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Fourth parameter (position) requires a double.", outputStorage);
220  }
221  libsumo::Person::add(id, edgeID, pos, depart, vTypeID);
222  }
223  break;
224  case libsumo::REMOVE: {
225  int why = 0;
226  if (!server.readTypeCheckingByte(inputStorage, why)) {
227  return server.writeErrorStatusCmd(libsumo::CMD_SET_VEHICLE_VARIABLE, "Removing a person requires a byte.", outputStorage);
228  }
229  libsumo::Person::remove(id, (char)why);
230  }
231  break;
232  case libsumo::APPEND_STAGE: {
233  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
234  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Adding a person stage requires a compound object.", outputStorage);
235  }
236  int numParameters = inputStorage.readInt();
237  if (numParameters == 13) {
238  libsumo::TraCIStage stage;
239  libsumo::StorageHelper::readStage(inputStorage, stage);
240  libsumo::Person::appendStage(id, stage);
241  } else {
242  int stageType;
243  if (!server.readTypeCheckingInt(inputStorage, stageType)) {
244  return server.writeErrorStatusCmd(libsumo::CMD_SET_VEHICLE_VARIABLE, "The first parameter for adding a stage must be the stage type given as int.", outputStorage);
245  }
246  if (stageType == libsumo::STAGE_DRIVING) {
247  // append driving stage
248  if (numParameters != 4) {
249  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Adding a driving stage needs four parameters.", outputStorage);
250  }
251  std::string edgeID;
252  if (!server.readTypeCheckingString(inputStorage, edgeID)) {
253  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Second parameter (edge) requires a string.", outputStorage);
254  }
255  std::string lines;
256  if (!server.readTypeCheckingString(inputStorage, lines)) {
257  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Third parameter (lines) requires a string.", outputStorage);
258  }
259  std::string stopID;
260  if (!server.readTypeCheckingString(inputStorage, stopID)) {
261  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Fourth parameter (stopID) requires a string.", outputStorage);
262  }
263  libsumo::Person::appendDrivingStage(id, edgeID, lines, stopID);
264  } else if (stageType == libsumo::STAGE_WAITING) {
265  // append waiting stage
266  if (numParameters != 4) {
267  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Adding a waiting stage needs four parameters.", outputStorage);
268  }
269  double duration;
270  if (!server.readTypeCheckingDouble(inputStorage, duration)) {
271  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Second parameter (duration) requires a double.", outputStorage);
272  }
273  std::string description;
274  if (!server.readTypeCheckingString(inputStorage, description)) {
275  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Third parameter (description) requires a string.", outputStorage);
276  }
277  std::string stopID;
278  if (!server.readTypeCheckingString(inputStorage, stopID)) {
279  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Fourth parameter (stopID) requires a string.", outputStorage);
280  }
281  libsumo::Person::appendWaitingStage(id, duration, description, stopID);
282  } else if (stageType == libsumo::STAGE_WALKING) {
283  // append walking stage
284  if (numParameters != 6) {
285  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Adding a walking stage needs six parameters.", outputStorage);
286  }
287  std::vector<std::string> edgeIDs;
288  if (!server.readTypeCheckingStringList(inputStorage, edgeIDs)) {
289  return server.writeErrorStatusCmd(libsumo::CMD_SET_VEHICLE_VARIABLE, "Second parameter (edges) route must be defined as a list of edge ids.", outputStorage);
290  }
291  double arrivalPos;
292  if (!server.readTypeCheckingDouble(inputStorage, arrivalPos)) {
293  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Third parameter (arrivalPos) requires a double.", outputStorage);
294  }
295  double duration;
296  if (!server.readTypeCheckingDouble(inputStorage, duration)) {
297  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Fourth parameter (duration) requires a double.", outputStorage);
298  }
299  double speed;
300  if (!server.readTypeCheckingDouble(inputStorage, speed)) {
301  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Fifth parameter (speed) requires a double.", outputStorage);
302  }
303  std::string stopID;
304  if (!server.readTypeCheckingString(inputStorage, stopID)) {
305  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Fourth parameter (stopID) requires a string.", outputStorage);
306  }
307  libsumo::Person::appendWalkingStage(id, edgeIDs, arrivalPos, duration, speed, stopID);
308  } else {
309  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Invalid stage type for person '" + id + "'", outputStorage);
310  }
311  }
312 
313  }
314  break;
315 
316  case libsumo::REPLACE_STAGE : {
317  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
318  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Replacing a person stage requires a compound object.", outputStorage);
319  }
320  if (inputStorage.readInt() != 2) {
321  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Replacing a person stage requires a compound object of size 2.", outputStorage);
322  }
323  int nextStageIndex = 0;
324  if (!server.readTypeCheckingInt(inputStorage, nextStageIndex)) {
325  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "First parameter of replace stage should be an integer", outputStorage);
326  }
327  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
328  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Second parameter of replace stage should be a compound object", outputStorage);
329  }
330  if (inputStorage.readInt() != 13) {
331  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Second parameter of replace stage should be a compound object of size 13", outputStorage);
332  }
333  libsumo::TraCIStage stage;
334  libsumo::StorageHelper::readStage(inputStorage, stage);
335  libsumo::Person::replaceStage(id, nextStageIndex, stage);
336  }
337  break;
338 
339  case libsumo::REMOVE_STAGE: {
340  int nextStageIndex = 0;
341  if (!server.readTypeCheckingInt(inputStorage, nextStageIndex)) {
342  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "The message must contain the stage index.", outputStorage);
343  }
344  libsumo::Person::removeStage(id, nextStageIndex);
345  }
346  break;
348  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
349  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Rerouting requires a compound object.", outputStorage);
350  }
351  if (inputStorage.readInt() != 0) {
352  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Rerouting should obtain an empty compound object.", outputStorage);
353  }
354  libsumo::Person::rerouteTraveltime(id);
355  }
356  break;
357  case libsumo::VAR_MOVE_TO: {
358  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
359  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Setting position requires a compound object.", outputStorage);
360  }
361  const int numArgs = inputStorage.readInt();
362  if (numArgs != 3) {
363  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "Setting position should obtain the edge id, the position and the lateral position.", outputStorage);
364  }
365  std::string laneID;
366  if (!server.readTypeCheckingString(inputStorage, laneID)) {
367  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "The first parameter for setting a position must be the laneID given as a string.", outputStorage);
368  }
369  double position = 0;
370  if (!server.readTypeCheckingDouble(inputStorage, position)) {
371  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "The second parameter for setting a position must be the position given as a double.", outputStorage);
372  }
373  double posLat = 0;
374  if (!server.readTypeCheckingDouble(inputStorage, posLat)) {
375  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "The third parameter for setting a position must be the lateral position given as a double.", outputStorage);
376  }
377  // process
378  libsumo::Person::moveTo(id, laneID, position, posLat);
379  }
380  break;
381  case libsumo::MOVE_TO_XY: {
382  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
383  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "MoveToXY person requires a compound object.", outputStorage);
384  }
385  const int numArgs = inputStorage.readInt();
386  if (numArgs != 5 && numArgs != 6) {
387  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "MoveToXY person should obtain: edgeID, x, y, angle, keepRouteFlag and optionally matchThreshold.", outputStorage);
388  }
389  // edge ID
390  std::string edgeID;
391  if (!server.readTypeCheckingString(inputStorage, edgeID)) {
392  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "The first parameter for moveToXY must be the edge ID given as a string.", outputStorage);
393  }
394  // x
395  double x = 0;
396  if (!server.readTypeCheckingDouble(inputStorage, x)) {
397  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "The second parameter for moveToXY must be the x-position given as a double.", outputStorage);
398  }
399  // y
400  double y = 0;
401  if (!server.readTypeCheckingDouble(inputStorage, y)) {
402  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "The third parameter for moveToXY must be the y-position given as a double.", outputStorage);
403  }
404  // angle
405  double angle = 0;
406  if (!server.readTypeCheckingDouble(inputStorage, angle)) {
407  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "The fourth parameter for moveToXY must be the angle given as a double.", outputStorage);
408  }
409  int keepRouteFlag = 1;
410  if (!server.readTypeCheckingByte(inputStorage, keepRouteFlag)) {
411  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "The fifth parameter for moveToXY must be the keepRouteFlag given as a byte.", outputStorage);
412  }
413  double matchThreshold = 100;
414  if (numArgs == 6) {
415  if (!server.readTypeCheckingDouble(inputStorage, matchThreshold)) {
416  return server.writeErrorStatusCmd(libsumo::CMD_SET_VEHICLE_VARIABLE, "The sixth parameter for moveToXY must be the matchThreshold given as a double.", outputStorage);
417  }
418  }
419  libsumo::Person::moveToXY(id, edgeID, x, y, angle, keepRouteFlag, matchThreshold);
420  }
421  break;
422  case libsumo::VAR_PARAMETER: {
423  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
424  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "A compound object is needed for setting a parameter.", outputStorage);
425  }
426  //read itemNo
427  inputStorage.readInt();
428  std::string name;
429  if (!server.readTypeCheckingString(inputStorage, name)) {
430  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "The name of the parameter must be given as a string.", outputStorage);
431  }
432  std::string value;
433  if (!server.readTypeCheckingString(inputStorage, value)) {
434  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, "The value of the parameter must be given as a string.", outputStorage);
435  }
436  libsumo::Person::setParameter(id, name, value);
437  }
438  break;
439  default:
440  try {
441  if (!TraCIServerAPI_VehicleType::setVariable(libsumo::CMD_SET_PERSON_VARIABLE, variable, p->getSingularType().getID(), server, inputStorage, outputStorage)) {
442  return false;
443  }
444  } catch (ProcessError& e) {
445  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, e.what(), outputStorage);
446  }
447  break;
448  }
449  } catch (libsumo::TraCIException& e) {
450  return server.writeErrorStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, e.what(), outputStorage);
451  }
452  server.writeStatusCmd(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::RTYPE_OK, warning, outputStorage);
453  return true;
454 }
455 
456 
457 /****************************************************************************/
std::string toHex(const T i, std::streamsize numDigits=0)
Definition: ToString.h:56
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:182
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:1173
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.
Definition: MSVehicleType.h:91
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.
Definition: TraCIServer.h:59
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
bool readTypeCheckingByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and a byte, verifying the type.
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.
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
bool readTypeCheckingColor(tcpip::Storage &inputStorage, libsumo::TraCIColor &into)
Reads the value type and a color, verifying the type.
static void writeStage(tcpip::Storage &outputStorage, const libsumo::TraCIStage &stage)
static void readStage(tcpip::Storage &inputStorage, libsumo::TraCIStage &stage, const std::string &error="")
An error which allows to continue.
Definition: TraCIDefs.h:144
virtual std::string readString()
Definition: storage.cpp:180
virtual void writeString(const std::string &s)
Definition: storage.cpp:197
virtual void writeInt(int)
Definition: storage.cpp:321
virtual void writeDouble(double)
Definition: storage.cpp:354
virtual int readUnsignedByte()
Definition: storage.cpp:155
virtual void writeStringList(const std::vector< std::string > &s)
Definition: storage.cpp:247
virtual void writeUnsignedByte(int)
Definition: storage.cpp:165
virtual int readInt()
Definition: storage.cpp:311
TRACI_CONST int VAR_EDGES
TRACI_CONST int VAR_TYPE
TRACI_CONST int VAR_MINGAP
TRACI_CONST int REPLACE_STAGE
TRACI_CONST int VAR_TAXI_RESERVATIONS
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int MOVE_TO_XY
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int CMD_GET_PERSON_VARIABLE
TRACI_CONST int VAR_STAGE
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 TYPE_STRINGLIST
TRACI_CONST int APPEND_STAGE
TRACI_CONST int TYPE_INTEGER
TRACI_CONST int CMD_SET_VEHICLE_VARIABLE
TRACI_CONST int VAR_LENGTH
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int REMOVE
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 TYPE_DOUBLE
TRACI_CONST int STAGE_DRIVING
TRACI_CONST int RTYPE_OK
TRACI_CONST int ADD
TRACI_CONST int SPLIT_TAXI_RESERVATIONS
TRACI_CONST int TYPE_STRING