Eclipse SUMO - Simulation of Urban MObility
MSOverheadWire.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2020 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 /****************************************************************************/
19 // Overhead wires for Electric (equipped with elecHybrid device) vehicles (Overhead wire segments, overhead wire sections, traction substations)
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
24 #include <list>
25 #include <string>
26 #include <iostream>
27 #include <fstream>
28 #include <sstream>
30 #include <utils/common/Named.h>
34 
35 // Resistivity of Cu is 1.69*10^-8 Ohm*m. A cross-section S of the overhead wire used in Pilsen is 150 mm^2. So the "resistivity/S" is 0.000113 Ohm/m.
36 const double WIRE_RESISTIVITY = (double)2 * 0.000113;
37 
38 // Conversion macros
39 #define WATTHR2JOULE(_x) ((_x)*3600.0)
40 #define JOULE2WATTHR(_x) ((_x)/3600.0)
41 #define WATTHR2WATT(_x) ((_x)*3600.0/TS)
42 #define WATT2WATTHR(_x) ((_x)*TS/3600.0)
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class MSLane;
48 class MSBusStop;
49 class OptionsCont;
52 class Named;
53 
54 
55 // ===========================================================================
56 // class definitions
57 // ===========================================================================
64 public:
65 
67  MSOverheadWire(const std::string& overheadWireSegmentID, MSLane& lane, double startPos, double endPos,
68  bool voltageSource);
69 
72 
74  double getVoltage() const;
75 
77  void setVoltage(double voltage);
78 
80  void setChargingVehicle(bool value);
81 
86  bool vehicleIsInside(const double position) const;
87 
89  bool isCharging() const;
90 
91  void addVehicle(SUMOVehicle& veh);
92 
93  void eraseVehicle(SUMOVehicle& veh);
94 
95  int getElecHybridCount() const {
96  return (int)myChargingVehicles.size();
97  }
98 
99  const std::vector<SUMOVehicle*>& getChargingVehicles() const {
100  return myChargingVehicles;
101  }
102 
103  double getTotalCharged() const {
104  return myTotalCharge;
105  }
106 
108  void addChargeValueForOutput(double WCharged, MSDevice_ElecHybrid* elecHybrid, bool ischarging = 1);
109 
112 
113  std::string getOverheadWireSegmentName();
114 
116  return myTractionSubstation;
117  }
118 
120  myTractionSubstation = substation;
121  }
122 
123  Circuit* getCircuit() const;
124 
126  myCircuitStartNodePos = node;
127  }
128 
130  myCircuitEndNodePos = node;
131  }
132 
133  void setCircuitElementPos(Element* element) {
134  myCircuitElementPos = element;
135  }
136 
138  return myCircuitStartNodePos;
139  }
140 
142  return myCircuitEndNodePos;
143  }
144 
146  return myCircuitElementPos;
147  }
148 
149  bool isThereVoltageSource() const {
150  return myVoltageSource;
151  }
152 
153  void lock() const;
154  void unlock() const;
155 
156 protected:
157 
159  struct charge {
161  charge(SUMOTime _timeStep, std::string _vehicleID, std::string _vehicleType, std::string _status,
162  double _WCharged, double _actualBatteryCapacity, double _maxBatteryCapacity, double _voltage,
163  double _totalEnergyCharged) :
164  timeStep(_timeStep),
165  vehicleID(_vehicleID),
166  vehicleType(_vehicleType),
167  status(_status),
168  WCharged(_WCharged),
169  actualBatteryCapacity(_actualBatteryCapacity),
170  maxBatteryCapacity(_maxBatteryCapacity),
171  voltage(_voltage),
172  totalEnergyCharged(_totalEnergyCharged) {}
173 
174  // @brief vehicle TimeStep
176  // @brief vehicle ID
177  std::string vehicleID;
178  // @brief vehicle Type
179  std::string vehicleType;
181  std::string status;
182  // @brief W charged
183  double WCharged;
184  // @brief actual battery capacity AFTER charging
186  // @brief battery max capacity
188  // @brief current charging power of charging station
189  double voltage;
190  // @brief current efficiency of charging station
192  // @brief current energy charged by charging stations AFTER charging
194 
195 
196 
197  };
198 
201  public:
203  explicit vehicle_position_sorter() { }
204 
207  return v1->getPositionOnLane() > v2->getPositionOnLane();
208  }
209  };
210 
212  double myVoltage;
213 
216 
219 
221  std::vector<charge> myChargeValues;
222 
223  std::vector<SUMOVehicle*> myChargingVehicles;
224 
227 
229 
233 
234 private:
237 
240 };
241 
242 
243 class MSTractionSubstation : public Named {
244 public:
245 
247  MSTractionSubstation(const std::string& substationId, double voltage);
248 
251 
252  Circuit* getCircuit() const {
253  return myCircuit;
254  }
255  void addOverheadWireSegmentToCircuit(MSOverheadWire* newOverheadWireSegment);
256 
257  void addOverheadWireClampToCircuit(const std::string id, MSOverheadWire* startSegment, MSOverheadWire* endSegment);
258 
260  void writeOut();
261  std::size_t numberOfOverheadSegments() const {
262  return myOverheadWireSegments.size();
263  }
264 
266  void setChargingVehicle(bool value);
267 
269  bool isCharging() const;
270 
272 
274 
275  void addForbiddenLane(MSLane* lane);
276 
277  bool isForbidden(const MSLane* lane);
278 
279  void addClamp(const std::string& id, MSOverheadWire* startPos, MSOverheadWire* endPos);
280 
281  int getElecHybridCount() const {
282  return myElecHybridCount;
283  }
284 
285  void addVehicle(MSDevice_ElecHybrid* elecHybrid);
286 
287  void eraseVehicle(MSDevice_ElecHybrid* elecHybrid);
288 
289  double getSubstationVoltage() const {
290  return mySubstationVoltage;
291  }
292 
294 
296  SUMOTime solveCircuit(SUMOTime currentTime);
297 
298 private:
299  void addOverheadWireInnerSegmentToCircuit(MSOverheadWire* incomingSegment, MSOverheadWire* outgoingSegment, const MSLane* connection, const MSLane* frontConnection, const MSLane* behindConnection);
300 
301 private:
303 
304 protected:
308 
309 private:
310  std::vector<MSOverheadWire*> myOverheadWireSegments;
311  std::vector<MSDevice_ElecHybrid*> myElecHybrid;
313  std::vector<MSLane*> myForbiddenLanes;
315 
316 public:
317  //preparation of overhead wire clamp
319  // @todo: 'MSTractionSubstation::overheadWireClamp' : no appropriate default constructor available
320  // provide default constructor for vector construction below
322  id("undefined"),
323  start(nullptr),
324  end(nullptr),
325  usage(false) {}
326 
327  OverheadWireClamp(const std::string _id, MSOverheadWire* _start, MSOverheadWire* _end, bool _usage):
328  id(_id),
329  start(_start),
330  end(_end),
331  usage(_usage) {}
332 
333  const std::string id;
336  bool usage;
337 
339  };
340 
341 private:
342  std::vector<OverheadWireClamp> myOverheadWireClamps;
343 
344 public:
345  OverheadWireClamp* findClamp(std::string id);
346  //bool findClamp(std::string id);
347 };
const double WIRE_RESISTIVITY
long long int SUMOTime
Definition: SUMOTime.h:31
Base (microsim) event class.
Definition: Command.h:49
A device which collects info on the vehicle trip (mainly on departure and arrival)
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
A class for sorting vehicle on lane under the overhead wire segment.
int operator()(SUMOVehicle *v1, SUMOVehicle *v2)
Sorting function; compares RODFRouteDesc::distance2Last.
Definition of overhead wire segment.
void unlock() const
void setCircuitEndNodePos(Node *node)
bool myChargingVehicle
Check if in the current TimeStep overheadWireSegment is charging a vehicle.
Element * myCircuitElementPos
Node * myCircuitEndNodePos
void setCircuitElementPos(Element *element)
Node * getCircuitEndNodePos() const
void writeOverheadWireSegmentOutput(OutputDevice &output)
write charging station values
Element * getCircuitElementPos() const
void setChargingVehicle(bool value)
enable or disable charging vehicle
bool vehicleIsInside(const double position) const
Check if a vehicle is inside in the Charge Station.
const std::vector< SUMOVehicle * > & getChargingVehicles() const
MSOverheadWire & operator=(const MSOverheadWire &)
Invalidated assignment operator.
double getTotalCharged() const
MSOverheadWire(const std::string &overheadWireSegmentID, MSLane &lane, double startPos, double endPos, bool voltageSource)
constructor
void setCircuitStartNodePos(Node *node)
std::string getOverheadWireSegmentName()
int getElecHybridCount() const
double myTotalCharge
total energy charged by this charging station
Node * myCircuitStartNodePos
void lock() const
void setVoltage(double voltage)
Set overhead wire's voltage.
std::vector< charge > myChargeValues
vector with the charges of this charging station
bool isThereVoltageSource() const
bool isCharging() const
Return true if in the current time step charging station is charging a vehicle.
Circuit * getCircuit() const
double getVoltage() const
Get overhead wire's voltage.
Node * getCircuitStartNodePos() const
void addChargeValueForOutput(double WCharged, MSDevice_ElecHybrid *elecHybrid, bool ischarging=1)
add charge value for output
MSTractionSubstation * getTractionSubstation() const
void eraseVehicle(SUMOVehicle &veh)
void setTractionSubstation(MSTractionSubstation *substation)
MSTractionSubstation * myTractionSubstation
Parameter, Pointer to the electrical substation (by default is nullptr)
std::vector< SUMOVehicle * > myChargingVehicles
void addVehicle(SUMOVehicle &veh)
~MSOverheadWire()
destructor
MSOverheadWire(const MSOverheadWire &)
Invalidated copy constructor.
double myVoltage
Overhead wire's voltage.
A lane area vehicles can halt at.
bool myChargingVehicle
Check if in the current TimeStep substation (overhead wire section) is charging a vehicle.
void eraseVehicle(MSDevice_ElecHybrid *elecHybrid)
void addOverheadWireInnerSegmentToCircuit(MSOverheadWire *incomingSegment, MSOverheadWire *outgoingSegment, const MSLane *connection, const MSLane *frontConnection, const MSLane *behindConnection)
std::size_t numberOfOverheadSegments() const
double getSubstationVoltage() const
~MSTractionSubstation()
destructor
void eraseOverheadWireSegmentFromCircuit(MSOverheadWire *oldWireSegment)
std::vector< OverheadWireClamp > myOverheadWireClamps
std::vector< MSOverheadWire * > myOverheadWireSegments
void addOverheadWireClampToCircuit(const std::string id, MSOverheadWire *startSegment, MSOverheadWire *endSegment)
void addClamp(const std::string &id, MSOverheadWire *startPos, MSOverheadWire *endPos)
Circuit * getCircuit() const
void addSolvingCirucitToEndOfTimestepEvents()
bool isCharging() const
Return true if in the current time step the substation (overhead wire section) is charging a vehicle.
std::vector< MSDevice_ElecHybrid * > myElecHybrid
bool isForbidden(const MSLane *lane)
std::vector< MSLane * > myForbiddenLanes
void addVehicle(MSDevice_ElecHybrid *elecHybrid)
SUMOTime solveCircuit(SUMOTime currentTime)
void addOverheadWireSegmentToCircuit(MSOverheadWire *newOverheadWireSegment)
int getElecHybridCount() const
OverheadWireClamp * findClamp(std::string id)
MSTractionSubstation(const std::string &substationId, double voltage)
constructor
static Command * myCommandForSolvingCircuit
void addForbiddenLane(MSLane *lane)
void setChargingVehicle(bool value)
enable or disable charging vehicle
Base class for objects which have an id.
Definition: Named.h:53
Definition: Node.h:31
A storage for options typed value containers)
Definition: OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
Definition: SUMOVehicle.h:58
struct to save information for the overhead wire segment output
charge(SUMOTime _timeStep, std::string _vehicleID, std::string _vehicleType, std::string _status, double _WCharged, double _actualBatteryCapacity, double _maxBatteryCapacity, double _voltage, double _totalEnergyCharged)
constructor
std::string status
status
OverheadWireClamp & operator=(const OverheadWireClamp &)=delete
OverheadWireClamp(const std::string _id, MSOverheadWire *_start, MSOverheadWire *_end, bool _usage)