SUMO - Simulation of Urban MObility
TraCIAPI.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // C++ TraCI client API implementation
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2012-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef TraCIAPI_h
23 #define TraCIAPI_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <vector>
36 #include <string>
37 #include <foreign/tcpip/socket.h>
38 #include <utils/common/SUMOTime.h>
39 
40 
41 // ===========================================================================
42 // global definitions
43 // ===========================================================================
44 #define DEFAULT_VIEW "View #0"
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
54 class TraCIAPI {
55 public:
58 
62  struct TraCIPosition {
63  double x, y, z;
64  };
65 
69  struct TraCIColor {
70  int r, g, b, a;
71  };
72 
76  typedef std::vector<TraCIPosition> TraCIPositionVector;
77 
81  struct TraCIBoundary {
82  double xMin, yMin, zMin;
83  double xMax, yMax, zMax;
84  };
85 
86 
87 
88  class TraCIPhase {
89  public:
90  TraCIPhase(const SUMOTime _duration, const SUMOTime _duration1, const SUMOTime _duration2, const std::string& _phase)
91  : duration(_duration), duration1(_duration1), duration2(_duration2), phase(_phase) {}
93 
94  SUMOTime duration, duration1, duration2;
95  std::string phase;
96  };
97 
98 
99  class TraCILogic {
100  public:
101  TraCILogic(const std::string& _subID, int _type, const std::map<std::string, SUMOReal>& _subParameter, unsigned int _currentPhaseIndex, const std::vector<TraCIPhase>& _phases)
102  : subID(_subID), type(_type), subParameter(_subParameter), currentPhaseIndex(_currentPhaseIndex), phases(_phases) {}
104 
105  std::string subID;
106  int type;
107  std::map<std::string, SUMOReal> subParameter;
108  unsigned int currentPhaseIndex;
109  std::vector<TraCIPhase> phases;
110  };
111 
112  class TraCILink {
113  public:
114  TraCILink(const std::string& _from, const std::string& _via, const std::string& _to)
115  : from(_from), via(_via), to(_to) {}
117 
118  std::string from;
119  std::string via;
120  std::string to;
121  };
122 
124 
125 
126 
129  TraCIAPI();
130 
131 
133  ~TraCIAPI();
134 
135 
138 
144  void connect(const std::string& host, int port);
145 
146 
148  void close();
150 
152  void simulationStep(SUMOTime time = 0);
153 
154 
157 
158  SUMOTime getSUMOTime(int cmd, int var, const std::string& id, tcpip::Storage* add = 0);
159  int getUnsignedByte(int cmd, int var, const std::string& id, tcpip::Storage* add = 0);
160  int getByte(int cmd, int var, const std::string& id, tcpip::Storage* add = 0);
161  int getInt(int cmd, int var, const std::string& id, tcpip::Storage* add = 0);
162  SUMOReal getFloat(int cmd, int var, const std::string& id, tcpip::Storage* add = 0);
163  SUMOReal getDouble(int cmd, int var, const std::string& id, tcpip::Storage* add = 0);
164  TraCIBoundary getBoundingBox(int cmd, int var, const std::string& id, tcpip::Storage* add = 0);
165  TraCIPositionVector getPolygon(int cmd, int var, const std::string& id, tcpip::Storage* add = 0);
166  TraCIPosition getPosition(int cmd, int var, const std::string& id, tcpip::Storage* add = 0);
167  std::string getString(int cmd, int var, const std::string& id, tcpip::Storage* add = 0);
168  std::vector<std::string> getStringVector(int cmd, int var, const std::string& id, tcpip::Storage* add = 0);
169  TraCIColor getColor(int cmd, int var, const std::string& id, tcpip::Storage* add = 0);
171 
172 
173 
180  public:
184  TraCIScopeWrapper(TraCIAPI& parent) : myParent(parent) {}
185 
187  virtual ~TraCIScopeWrapper() {}
188 
189 
190  protected:
193 
194 
195  private:
198 
200  TraCIScopeWrapper& operator=(const TraCIScopeWrapper& src);
201 
202  };
203 
204 
205 
206 
207 
211  class EdgeScope : public TraCIScopeWrapper {
212  public:
213  EdgeScope(TraCIAPI& parent) : TraCIScopeWrapper(parent) {}
214  virtual ~EdgeScope() {}
215 
216  std::vector<std::string> getIDList() const;
217  unsigned int getIDCount() const;
218  SUMOReal getAdaptedTraveltime(const std::string& edgeID, SUMOTime time) const;
219  SUMOReal getEffort(const std::string& edgeID, SUMOTime time) const;
220  SUMOReal getCO2Emission(const std::string& edgeID) const;
221  SUMOReal getCOEmission(const std::string& edgeID) const;
222  SUMOReal getHCEmission(const std::string& edgeID) const;
223  SUMOReal getPMxEmission(const std::string& edgeID) const;
224  SUMOReal getNOxEmission(const std::string& edgeID) const;
225  SUMOReal getFuelConsumption(const std::string& edgeID) const;
226  SUMOReal getNoiseEmission(const std::string& edgeID) const;
227  SUMOReal getLastStepMeanSpeed(const std::string& edgeID) const;
228  SUMOReal getLastStepOccupancy(const std::string& edgeID) const;
229  SUMOReal getLastStepLength(const std::string& edgeID) const;
230  SUMOReal getTraveltime(const std::string& edgeID) const;
231  unsigned int getLastStepVehicleNumber(const std::string& edgeID) const;
232  SUMOReal getLastStepHaltingNumber(const std::string& edgeID) const;
233  std::vector<std::string> getLastStepVehicleIDs(const std::string& edgeID) const;
234 
235  void adaptTraveltime(const std::string& edgeID, SUMOReal time) const;
236  void setEffort(const std::string& edgeID, SUMOReal effort) const;
237  void setMaxSpeed(const std::string& edgeID, SUMOReal speed) const;
238 
239  private:
241  EdgeScope(const EdgeScope& src);
242 
244  EdgeScope& operator=(const EdgeScope& src);
245 
246  };
247 
248 
249 
250 
251 
255  class GUIScope : public TraCIScopeWrapper {
256  public:
257  GUIScope(TraCIAPI& parent) : TraCIScopeWrapper(parent) {}
258  virtual ~GUIScope() {}
259 
260  std::vector<std::string> getIDList() const;
261  SUMOReal getZoom(const std::string& viewID = DEFAULT_VIEW) const;
262  TraCIPosition getOffset(const std::string& viewID = DEFAULT_VIEW) const;
263  std::string getSchema(const std::string& viewID = DEFAULT_VIEW) const;
264  TraCIBoundary getBoundary(const std::string& viewID = DEFAULT_VIEW) const;
265  void setZoom(const std::string& viewID, SUMOReal zoom) const;
266  void setOffset(const std::string& viewID, SUMOReal x, SUMOReal y) const;
267  void setSchema(const std::string& viewID, const std::string& schemeName) const;
268  void setBoundary(const std::string& viewID, SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax) const;
269  void screenshot(const std::string& viewID, const std::string& filename) const;
270  void trackVehicle(const std::string& viewID, const std::string& vehID) const;
271 
272  private:
274  GUIScope(const GUIScope& src);
275 
277  GUIScope& operator=(const GUIScope& src);
278 
279  };
280 
281 
282 
283 
284 
289  public:
291  virtual ~InductionLoopScope() {}
292 
293  struct VehicleData {
294  /* @brief Constructor
295  (mirrors MSInductLoop::VehicleData) */
298  std::string id;
306  std::string typeID;
307  };
308 
309  std::vector<std::string> getIDList() const;
310  SUMOReal getPosition(const std::string& loopID) const;
311  std::string getLaneID(const std::string& loopID) const;
312  unsigned int getLastStepVehicleNumber(const std::string& loopID) const;
313  SUMOReal getLastStepMeanSpeed(const std::string& loopID) const;
314  std::vector<std::string> getLastStepVehicleIDs(const std::string& loopID) const;
315  SUMOReal getLastStepOccupancy(const std::string& loopID) const;
316  SUMOReal getLastStepMeanLength(const std::string& loopID) const;
317  SUMOReal getTimeSinceDetection(const std::string& loopID) const;
318  std::vector<VehicleData> getVehicleData(const std::string& loopID) const;
319 
320 
321  private:
324 
326  InductionLoopScope& operator=(const InductionLoopScope& src);
327 
328  };
329 
330 
331 
332 
333 
338  public:
340  virtual ~JunctionScope() {}
341 
342  std::vector<std::string> getIDList() const;
343  TraCIPosition getPosition(const std::string& junctionID) const;
344 
345  private:
347  JunctionScope(const JunctionScope& src);
348 
350  JunctionScope& operator=(const JunctionScope& src);
351 
352  };
353 
354 
355 
356 
357 
361  class LaneScope : public TraCIScopeWrapper {
362  public:
363  LaneScope(TraCIAPI& parent) : TraCIScopeWrapper(parent) {}
364  virtual ~LaneScope() {}
365 
366  std::vector<std::string> getIDList() const;
367  SUMOReal getLength(const std::string& laneID) const;
368  SUMOReal getMaxSpeed(const std::string& laneID) const;
369  SUMOReal getWidth(const std::string& laneID) const;
370  std::vector<std::string> getAllowed(const std::string& laneID) const;
371  std::vector<std::string> getDisallowed(const std::string& laneID) const;
372  unsigned int getLinkNumber(const std::string& laneID) const;
373  TraCIPositionVector getShape(const std::string& laneID) const;
374  std::string getEdgeID(const std::string& laneID) const;
375  SUMOReal getCO2Emission(const std::string& laneID) const;
376  SUMOReal getCOEmission(const std::string& laneID) const;
377  SUMOReal getHCEmission(const std::string& laneID) const;
378  SUMOReal getPMxEmission(const std::string& laneID) const;
379  SUMOReal getNOxEmission(const std::string& laneID) const;
380  SUMOReal getFuelConsumption(const std::string& laneID) const;
381  SUMOReal getNoiseEmission(const std::string& laneID) const;
382  SUMOReal getLastStepMeanSpeed(const std::string& laneID) const;
383  SUMOReal getLastStepOccupancy(const std::string& laneID) const;
384  SUMOReal getLastStepLength(const std::string& laneID) const;
385  SUMOReal getTraveltime(const std::string& laneID) const;
386  unsigned int getLastStepVehicleNumber(const std::string& laneID) const;
387  unsigned int getLastStepHaltingNumber(const std::string& laneID) const;
388  std::vector<std::string> getLastStepVehicleIDs(const std::string& laneID) const;
389 
390  void setAllowed(const std::string& laneID, const std::vector<std::string>& allowedClasses) const;
391  void setDisallowed(const std::string& laneID, const std::vector<std::string>& disallowedClasses) const;
392  void setMaxSpeed(const std::string& laneID, SUMOReal speed) const;
393  void setLength(const std::string& laneID, SUMOReal length) const;
394 
395  private:
397  LaneScope(const LaneScope& src);
398 
400  LaneScope& operator=(const LaneScope& src);
401 
402  };
403 
404 
408  class AreaScope : public TraCIScopeWrapper {
409  public:
410  AreaScope(TraCIAPI& parent) : TraCIScopeWrapper(parent) {}
411  virtual ~AreaScope() {}
412 
413  std::vector<std::string> getIDList() const;
414  int getJamLengthVehicle(const std::string& laneID) const;
415  SUMOReal getJamLengthMeters(const std::string& laneID) const;
416 
417  private:
419  AreaScope(const AreaScope& src);
420 
422  AreaScope& operator=(const AreaScope& src);
423 
424  };
425 
426 
430  class MeMeScope : public TraCIScopeWrapper {
431  public:
432  MeMeScope(TraCIAPI& parent) : TraCIScopeWrapper(parent) {}
433  virtual ~MeMeScope() {}
434 
435  std::vector<std::string> getIDList() const;
436  unsigned int getLastStepVehicleNumber(const std::string& detID) const;
437  SUMOReal getLastStepMeanSpeed(const std::string& detID) const;
438  std::vector<std::string> getLastStepVehicleIDs(const std::string& detID) const;
439  unsigned int getLastStepHaltingNumber(const std::string& detID) const;
440 
441  private:
443  MeMeScope(const MeMeScope& src);
444 
446  MeMeScope& operator=(const MeMeScope& src);
447 
448  };
449 
450 
451 
452 
453 
457  class POIScope : public TraCIScopeWrapper {
458  public:
459  POIScope(TraCIAPI& parent) : TraCIScopeWrapper(parent) {}
460  virtual ~POIScope() {}
461 
462  std::vector<std::string> getIDList() const;
463  std::string getType(const std::string& poiID) const;
464  TraCIPosition getPosition(const std::string& poiID) const;
465  TraCIColor getColor(const std::string& poiID) const;
466 
467  void setType(const std::string& poiID, const std::string& setType) const;
468  void setPosition(const std::string& poiID, SUMOReal x, SUMOReal y) const;
469  void setColor(const std::string& poiID, const TraCIColor& c) const;
470  void add(const std::string& poiID, SUMOReal x, SUMOReal y, const TraCIColor& c, const std::string& type, int layer) const;
471  void remove(const std::string& poiID, int layer = 0) const;
472 
473  private:
475  POIScope(const POIScope& src);
476 
478  POIScope& operator=(const POIScope& src);
479 
480  };
481 
482 
483 
484 
485 
490  public:
492  virtual ~PolygonScope() {}
493 
494  std::vector<std::string> getIDList() const;
495  std::string getType(const std::string& polygonID) const;
496  TraCIPositionVector getShape(const std::string& polygonID) const;
497  TraCIColor getColor(const std::string& polygonID) const;
498  void setType(const std::string& polygonID, const std::string& setType) const;
499  void setShape(const std::string& polygonID, const TraCIPositionVector& shape) const;
500  void setColor(const std::string& polygonID, const TraCIColor& c) const;
501  void add(const std::string& polygonID, const TraCIPositionVector& shape, const TraCIColor& c, bool fill, const std::string& type, int layer) const;
502  void remove(const std::string& polygonID, int layer = 0) const;
503 
504  private:
506  PolygonScope(const PolygonScope& src);
507 
509  PolygonScope& operator=(const PolygonScope& src);
510 
511  };
512 
513 
514 
515 
516 
520  class RouteScope : public TraCIScopeWrapper {
521  public:
522  RouteScope(TraCIAPI& parent) : TraCIScopeWrapper(parent) {}
523  virtual ~RouteScope() {}
524 
525  std::vector<std::string> getIDList() const;
526  std::vector<std::string> getEdges(const std::string& routeID) const;
527 
528  void add(const std::string& routeID, const std::vector<std::string>& edges) const;
529 
530  private:
532  RouteScope(const RouteScope& src);
533 
535  RouteScope& operator=(const RouteScope& src);
536 
537  };
538 
539 
540 
541 
542 
547  public:
549  virtual ~SimulationScope() {}
550 
551  SUMOTime getCurrentTime() const;
552  unsigned int getLoadedNumber() const;
553  std::vector<std::string> getLoadedIDList() const;
554  unsigned int getDepartedNumber() const;
555  std::vector<std::string> getDepartedIDList() const;
556  unsigned int getArrivedNumber() const;
557  std::vector<std::string> getArrivedIDList() const;
558  unsigned int getStartingTeleportNumber() const;
559  std::vector<std::string> getStartingTeleportIDList() const;
560  unsigned int getEndingTeleportNumber() const;
561  std::vector<std::string> getEndingTeleportIDList() const;
562  SUMOTime getDeltaT() const;
563  TraCIBoundary getNetBoundary() const;
564  unsigned int getMinExpectedNumber() const;
565 
566  private:
568  SimulationScope(const SimulationScope& src);
569 
571  SimulationScope& operator=(const SimulationScope& src);
572 
573  };
574 
575 
576 
577 
578 
583  public:
585  virtual ~TrafficLightScope() {}
586 
587  std::vector<std::string> getIDList() const;
588  std::string getRedYellowGreenState(const std::string& tlsID) const;
589  std::vector<TraCIAPI::TraCILogic> getCompleteRedYellowGreenDefinition(const std::string& tlsID) const;
590  std::vector<std::string> getControlledLanes(const std::string& tlsID) const;
591  std::vector<TraCIAPI::TraCILink> getControlledLinks(const std::string& tlsID) const;
592  std::string getProgram(const std::string& tlsID) const;
593  unsigned int getPhase(const std::string& tlsID) const;
594  unsigned int getNextSwitch(const std::string& tlsID) const;
595 
596  void setRedYellowGreenState(const std::string& tlsID, const std::string& state) const;
597  void setPhase(const std::string& tlsID, unsigned int index) const;
598  void setProgram(const std::string& tlsID, const std::string& programID) const;
599  void setPhaseDuration(const std::string& tlsID, unsigned int phaseDuration) const;
600  void setCompleteRedYellowGreenDefinition(const std::string& tlsID, const TraCIAPI::TraCILogic& logic) const;
601 
602  private:
605 
607  TrafficLightScope& operator=(const TrafficLightScope& src);
608 
609  };
610 
611 
612 
613 
614 
619  public:
621  virtual ~VehicleTypeScope() {}
622 
623  std::vector<std::string> getIDList() const;
624  SUMOReal getLength(const std::string& typeID) const;
625  SUMOReal getMaxSpeed(const std::string& typeID) const;
626  SUMOReal getSpeedFactor(const std::string& typeID) const;
627  SUMOReal getSpeedDeviation(const std::string& typeID) const;
628  SUMOReal getAccel(const std::string& typeID) const;
629  SUMOReal getDecel(const std::string& typeID) const;
630  SUMOReal getImperfection(const std::string& typeID) const;
631  SUMOReal getTau(const std::string& typeID) const;
632  std::string getVehicleClass(const std::string& typeID) const;
633  std::string getEmissionClass(const std::string& typeID) const;
634  std::string getShapeClass(const std::string& typeID) const;
635  SUMOReal getMinGap(const std::string& typeID) const;
636  SUMOReal getWidth(const std::string& typeID) const;
637  TraCIColor getColor(const std::string& typeID) const;
638 
639  void setLength(const std::string& typeID, SUMOReal length) const;
640  void setMaxSpeed(const std::string& typeID, SUMOReal speed) const;
641  void setVehicleClass(const std::string& typeID, const std::string& clazz) const;
642  void setSpeedFactor(const std::string& typeID, SUMOReal factor) const;
643  void setSpeedDeviation(const std::string& typeID, SUMOReal deviation) const;
644  void setEmissionClass(const std::string& typeID, const std::string& clazz) const;
645  void setWidth(const std::string& typeID, SUMOReal width) const;
646  void setMinGap(const std::string& typeID, SUMOReal minGap) const;
647  void setShapeClass(const std::string& typeID, const std::string& clazz) const;
648  void setAccel(const std::string& typeID, SUMOReal accel) const;
649  void setDecel(const std::string& typeID, SUMOReal decel) const;
650  void setImperfection(const std::string& typeID, SUMOReal imperfection) const;
651  void setTau(const std::string& typeID, SUMOReal tau) const;
652  void setColor(const std::string& typeID, const TraCIColor& c) const;
653 
654  private:
657 
659  VehicleTypeScope& operator=(const VehicleTypeScope& src);
660 
661  };
662 
663 
664 
665 
666 
671  public:
673  virtual ~VehicleScope() {}
674 
675  std::vector<std::string> getIDList() const;
676  unsigned int getIDCount() const;
677  SUMOReal getSpeed(const std::string& typeID) const;
678  TraCIPosition getPosition(const std::string& typeID) const;
679  SUMOReal getAngle(const std::string& typeID) const;
680  std::string getRoadID(const std::string& typeID) const;
681  std::string getLaneID(const std::string& typeID) const;
682  unsigned int getLaneIndex(const std::string& typeID) const;
683  std::string getTypeID(const std::string& typeID) const;
684  std::string getRouteID(const std::string& typeID) const;
685  unsigned int getRouteIndex(const std::string& typeID) const;
686  std::vector<std::string> getEdges(const std::string& typeID) const;
687  TraCIColor getColor(const std::string& typeID) const;
688  SUMOReal getLanePosition(const std::string& typeID) const;
689  unsigned int getSignalStates(const std::string& typeID) const;
690  SUMOReal getCO2Emissions(const std::string& typeID) const;
691  SUMOReal getCOEmissions(const std::string& typeID) const;
692  SUMOReal getHCEmissions(const std::string& typeID) const;
693  SUMOReal getPMxEmissions(const std::string& typeID) const;
694  SUMOReal getNOxEmissions(const std::string& typeID) const;
695  SUMOReal getFuelConsumption(const std::string& typeID) const;
696  SUMOReal getNoiseEmission(const std::string& typeID) const;
697  unsigned int getBestLanes(const std::string& typeID) const;
698  unsigned int getStopState(const std::string& typeID) const;
699  SUMOReal getLength(const std::string& typeID) const;
700  SUMOReal getMaxSpeed(const std::string& typeID) const;
701  SUMOReal getAccel(const std::string& typeID) const;
702  SUMOReal getDecel(const std::string& typeID) const;
703  SUMOReal getTau(const std::string& typeID) const;
704  SUMOReal getImperfection(const std::string& typeID) const;
705  SUMOReal getSpeedFactor(const std::string& typeID) const;
706  SUMOReal getSpeedDeviation(const std::string& typeID) const;
707  std::string getVClass(const std::string& typeID) const;
708  std::string getEmissionClass(const std::string& typeID) const;
709  std::string getShapeClass(const std::string& typeID) const;
710  SUMOReal getMinGap(const std::string& typeID) const;
711  SUMOReal getWidth(const std::string& typeID) const;
712  SUMOReal getWaitingTime(const std::string& typeID) const;
713 
714  void moveTo(const std::string& typeID, const std::string& laneID, SUMOReal position) const;
715  void slowDown(const std::string& typeID, SUMOReal speed, int duration) const;
716  void setSpeed(const std::string& typeID, SUMOReal speed) const;
717 
718  private:
720  VehicleScope(const VehicleScope& src);
721 
723  VehicleScope& operator=(const VehicleScope& src);
724 
725  };
726 
727 public:
754 
755 
756 protected:
759 
762  void send_commandSimulationStep(SUMOTime time) const;
763 
764 
767  void send_commandClose() const;
768 
769 
776  void send_commandGetVariable(int domID, int varID, const std::string& objID, tcpip::Storage* add = 0) const;
777 
778 
785  void send_commandSetValue(int domID, int varID, const std::string& objID, tcpip::Storage& content) const;
786 
787 
795  void send_commandSubscribeObjectVariable(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime, const std::vector<int>& vars) const;
796 
797 
807  void send_commandSubscribeObjectContext(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime,
808  int domain, SUMOReal range, const std::vector<int>& vars) const;
810 
811 
812 
815 
822  void check_resultState(tcpip::Storage& inMsg, int command, bool ignoreCommandId = false, std::string* acknowledgement = 0) const;
823 
824  void check_commandGetResult(tcpip::Storage& inMsg, int command, int expectedType = -1, bool ignoreCommandId = false) const;
825 
826  void processGET(tcpip::Storage& inMsg, int command, int expectedType, bool ignoreCommandId = false) const;
828 
829 
830 protected:
833 
834 
835 };
836 
837 
838 #endif
839 
840 /****************************************************************************/
841 
EdgeScope edge
Scope for interaction with edges.
Definition: TraCIAPI.h:729
TraCIPosition getPosition(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:385
SUMOReal entryTime
Entry-time of the vehicle in [s].
Definition: TraCIAPI.h:302
LaneScope(TraCIAPI &parent)
Definition: TraCIAPI.h:363
long long int SUMOTime
Definition: SUMOTime.h:43
tcpip::Socket * mySocket
The socket.
Definition: TraCIAPI.h:832
C++ TraCI client API implementation.
Definition: TraCIAPI.h:54
void close()
Closes the connection.
Definition: TraCIAPI.cpp:82
Scope for interaction with edges.
Definition: TraCIAPI.h:211
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
Definition: TraCIAPI.cpp:69
TraCILogic(const std::string &_subID, int _type, const std::map< std::string, SUMOReal > &_subParameter, unsigned int _currentPhaseIndex, const std::vector< TraCIPhase > &_phases)
Definition: TraCIAPI.h:101
MeMeScope(TraCIAPI &parent)
Definition: TraCIAPI.h:432
std::string typeID
Type of the vehicle in.
Definition: TraCIAPI.h:306
virtual ~PolygonScope()
Definition: TraCIAPI.h:492
GUIScope(TraCIAPI &parent)
Definition: TraCIAPI.h:257
SUMOReal getDouble(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:342
void send_commandClose() const
Sends a Close command.
Definition: TraCIAPI.cpp:106
JunctionScope junction
Scope for interaction with junctions.
Definition: TraCIAPI.h:735
TraCIPhase(const SUMOTime _duration, const SUMOTime _duration1, const SUMOTime _duration2, const std::string &_phase)
Definition: TraCIAPI.h:90
LaneScope lane
Scope for interaction with lanes.
Definition: TraCIAPI.h:737
unsigned int currentPhaseIndex
Definition: TraCIAPI.h:108
#define DEFAULT_VIEW
Definition: TraCIAPI.h:44
void processGET(tcpip::Storage &inMsg, int command, int expectedType, bool ignoreCommandId=false) const
Definition: TraCIAPI.cpp:288
Scope for interaction with vehicles.
Definition: TraCIAPI.h:670
virtual ~RouteScope()
Definition: TraCIAPI.h:523
Scope for interaction with traffic lights.
Definition: TraCIAPI.h:582
virtual ~LaneScope()
Definition: TraCIAPI.h:364
void simulationStep(SUMOTime time=0)
Advances by one step (or up to the given time)
Definition: TraCIAPI.cpp:435
Scope for interaction with the gui.
Definition: TraCIAPI.h:255
TrafficLightScope trafficlights
Scope for interaction with traffic lights.
Definition: TraCIAPI.h:749
TraCIPositionVector getPolygon(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:367
Scope for interaction with routes.
Definition: TraCIAPI.h:520
SUMOTime duration2
Definition: TraCIAPI.h:94
TraCIBoundary getBoundingBox(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:351
InductionLoopScope inductionloop
Scope for interaction with inductive loops.
Definition: TraCIAPI.h:733
SUMOReal leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIAPI.h:304
Scope for interaction with inductive loops.
Definition: TraCIAPI.h:288
POIScope(TraCIAPI &parent)
Definition: TraCIAPI.h:459
virtual ~MeMeScope()
Definition: TraCIAPI.h:433
AreaScope(TraCIAPI &parent)
Definition: TraCIAPI.h:410
Scope for interaction with POIs.
Definition: TraCIAPI.h:457
void send_commandSubscribeObjectContext(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, int domain, SUMOReal range, const std::vector< int > &vars) const
Sends a SubscribeContext request.
Definition: TraCIAPI.cpp:193
Scope for interaction with the simulation.
Definition: TraCIAPI.h:546
Scope for interaction with multi entry/-exit detectors.
Definition: TraCIAPI.h:430
virtual ~AreaScope()
Definition: TraCIAPI.h:411
virtual ~EdgeScope()
Definition: TraCIAPI.h:214
void send_commandSimulationStep(SUMOTime time) const
Sends a SimulationStep command.
Definition: TraCIAPI.cpp:93
InductionLoopScope(TraCIAPI &parent)
Definition: TraCIAPI.h:290
SUMOReal length
Length of the vehicle.
Definition: TraCIAPI.h:300
MeMeScope multientryexit
Scope for interaction with multi-entry/-exit detectors.
Definition: TraCIAPI.h:739
Scope for interaction with vehicle types.
Definition: TraCIAPI.h:618
PolygonScope(TraCIAPI &parent)
Definition: TraCIAPI.h:491
void send_commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *add=0) const
Sends a GetVariable request.
Definition: TraCIAPI.cpp:117
TraCIColor getColor(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:421
virtual ~JunctionScope()
Definition: TraCIAPI.h:340
~TraCIAPI()
Destructor.
Definition: TraCIAPI.cpp:63
RouteScope route
Scope for interaction with routes.
Definition: TraCIAPI.h:745
Scope for interaction with polygons.
Definition: TraCIAPI.h:489
A 3D-bounding box.
Definition: TraCIAPI.h:81
std::vector< TraCIPhase > phases
Definition: TraCIAPI.h:109
int getInt(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:324
int getByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:315
int getUnsignedByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:306
Scope for interaction with junctions.
Definition: TraCIAPI.h:337
TrafficLightScope(TraCIAPI &parent)
Definition: TraCIAPI.h:584
virtual ~VehicleScope()
Definition: TraCIAPI.h:673
virtual ~SimulationScope()
Definition: TraCIAPI.h:549
std::vector< std::string > getStringVector(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:407
EdgeScope(TraCIAPI &parent)
Definition: TraCIAPI.h:213
Scope for interaction with areal detectors.
Definition: TraCIAPI.h:408
POIScope poi
Scope for interaction with POIs.
Definition: TraCIAPI.h:741
virtual ~POIScope()
Definition: TraCIAPI.h:460
void send_commandSubscribeObjectVariable(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, const std::vector< int > &vars) const
Sends a SubscribeVariable request.
Definition: TraCIAPI.cpp:165
SimulationScope simulation
Scope for interaction with the simulation.
Definition: TraCIAPI.h:747
Scope for interaction with lanes.
Definition: TraCIAPI.h:361
TraCIScopeWrapper(TraCIAPI &parent)
Constructor.
Definition: TraCIAPI.h:184
RouteScope(TraCIAPI &parent)
Definition: TraCIAPI.h:522
VehicleScope vehicle
Scope for interaction with vehicles.
Definition: TraCIAPI.h:753
SUMOTime getSUMOTime(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:297
PolygonScope polygon
Scope for interaction with polygons.
Definition: TraCIAPI.h:743
virtual ~TraCIScopeWrapper()
Destructor.
Definition: TraCIAPI.h:187
void check_resultState(tcpip::Storage &inMsg, int command, bool ignoreCommandId=false, std::string *acknowledgement=0) const
Validates the result state of a command.
Definition: TraCIAPI.cpp:226
VehicleTypeScope(TraCIAPI &parent)
Definition: TraCIAPI.h:620
virtual ~GUIScope()
Definition: TraCIAPI.h:258
std::map< std::string, SUMOReal > subParameter
Definition: TraCIAPI.h:107
TraCIAPI & myParent
The parent TraCI client which offers the connection.
Definition: TraCIAPI.h:192
std::string subID
Definition: TraCIAPI.h:105
GUIScope gui
Scope for interaction with the gui.
Definition: TraCIAPI.h:731
void send_commandSetValue(int domID, int varID, const std::string &objID, tcpip::Storage &content) const
Sends a SetVariable request.
Definition: TraCIAPI.cpp:144
#define SUMOReal
Definition: config.h:213
void check_commandGetResult(tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const
Definition: TraCIAPI.cpp:265
std::string getString(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:398
VehicleScope(TraCIAPI &parent)
Definition: TraCIAPI.h:672
SimulationScope(TraCIAPI &parent)
Definition: TraCIAPI.h:548
An abstract interface for accessing type-dependent values.
Definition: TraCIAPI.h:179
TraCIAPI()
Constructor.
Definition: TraCIAPI.cpp:52
std::vector< TraCIPosition > TraCIPositionVector
Definition: TraCIAPI.h:76
SUMOReal getFloat(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:333
std::string id
The id of the vehicle.
Definition: TraCIAPI.h:298
JunctionScope(TraCIAPI &parent)
Definition: TraCIAPI.h:339
A 3D-position.
Definition: TraCIAPI.h:62
std::string phase
Definition: TraCIAPI.h:95
VehicleTypeScope vehicletype
Scope for interaction with vehicle types.
Definition: TraCIAPI.h:751