Eclipse SUMO - Simulation of Urban MObility
MSDevice_FCDReplay.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2013-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 // A device which replays recorded floating car data
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <utils/common/Command.h>
25 #include "MSVehicleDevice.h"
26 
27 
28 // ===========================================================================
29 // class definitions
30 // ===========================================================================
38 public:
42  static void insertOptions(OptionsCont& oc);
43 
44 
55  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
56 
59  static void init();
60 
61 public:
64 
65  void move(SUMOTime currentTime);
66 
68  const std::string deviceName() const {
69  return "fcd-replay";
70  }
71 
72  struct TrajectoryEntry {
75  std::string edgeOrLane;
76  double lanePos;
77  double speed;
78  double angle;
79  };
80 
81  typedef std::vector<TrajectoryEntry> Trajectory;
82 
83  void setTrajectory(Trajectory* const t) {
84  myTrajectory = t;
85  }
86 
87 private:
93  MSDevice_FCDReplay(SUMOVehicle& holder, const std::string& id);
94 
95  class MoveVehicles : public Command {
96  public:
97  SUMOTime execute(SUMOTime currentTime);
98  private:
101  };
102 
103  class FCDHandler : public SUMOSAXHandler {
104  public:
105  void reset();
106  void addTrafficObjects();
107 
108  protected:
110 
111 
119  void myStartElement(int element, const SUMOSAXAttributes& attrs);
121 
122  private:
124  std::map<std::string, Trajectory> myTrajectories;
125  std::map<std::string, std::tuple<SUMOTime, std::string, bool, ConstMSEdgeVector > > myRoutes;
126  };
127 
128 private:
131 
132 private:
135 
138 
139 };
long long int SUMOTime
Definition: GUI.h:35
Base (microsim) event class.
Definition: Command.h:50
std::map< std::string, Trajectory > myTrajectories
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag.
std::map< std::string, std::tuple< SUMOTime, std::string, bool, ConstMSEdgeVector > > myRoutes
SUMOTime execute(SUMOTime currentTime)
Executes the command.
MoveVehicles & operator=(const MoveVehicles &)=delete
Invalidated assignment operator.
A device which replays a vehicle trajectory from an fcd file.
MSDevice_FCDReplay(const MSDevice_FCDReplay &)=delete
Invalidated copy constructor.
~MSDevice_FCDReplay()
Destructor.
static FCDHandler myHandler
static void init()
Static intialization.
std::vector< TrajectoryEntry > Trajectory
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
MSDevice_FCDReplay(SUMOVehicle &holder, const std::string &id)
Constructor.
void move(SUMOTime currentTime)
const std::string deviceName() const
return the name for this type of device
void setTrajectory(Trajectory *const t)
MSDevice_FCDReplay & operator=(const MSDevice_FCDReplay &)=delete
Invalidated assignment operator.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_FCDReplay-options.
Abstract in-vehicle device.
A storage for options typed value containers)
Definition: OptionsCont.h:89
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
Encapsulated SAX-Attributes.
SAX-handler base for SUMO-files.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
SUMOTime time
double angle
std::string edgeOrLane
Position pos
double speed
double lanePos