SUMO - Simulation of Urban MObility
MSChargingStation.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Chargin Station for Electric vehicles
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-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 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <cassert>
36 #include <microsim/MSVehicleType.h>
38 #include "MSChargingStation.h"
39 #include "MSTrigger.h"
40 
41 
42 #ifdef CHECK_MEMORY_LEAKS
43 #include <foreign/nvwa/debug_new.h>
44 #endif // CHECK_MEMORY_LEAKS
45 
46 // ===========================================================================
47 // member method definitions
48 // ===========================================================================
49 
50 MSChargingStation::MSChargingStation(const std::string& chargingStationID, MSLane& lane, SUMOReal startPos, SUMOReal endPos,
51  SUMOReal chargingPower, SUMOReal efficency, bool chargeInTransit, int chargeDelay) :
52  MSStoppingPlace(chargingStationID, std::vector<std::string>(), lane, startPos, endPos),
53  myChargingPower(0),
54  myEfficiency(0),
55  myChargeInTransit(chargeInTransit),
56  myChargeDelay(0),
57  myChargingVehicle(false) {
58  if (chargingPower < 0)
59  WRITE_WARNING("Parameter 'charging power' for Charging Station with ID = " + getID() + " is invalid (" + TplConvert::_2str(getChargingPower()) + ").")
60  else {
61  myChargingPower = chargingPower;
62  }
63 
64  if (efficency < 0 || efficency > 1)
65  WRITE_WARNING("Parameter 'efficiency' for Charging Station with ID = " + getID() + " is invalid (" + TplConvert::_2str(getEfficency()) + ").")
66  else {
67  myEfficiency = efficency;
68  }
69 
70  if (chargeDelay < 0)
71  WRITE_WARNING("Parameter 'charge delay' for Charging Station with ID = " + getID() + " is invalid (" + TplConvert::_2str(getEfficency()) + ").")
72  else {
73  myChargeDelay = chargeDelay;
74  }
75 
77  WRITE_WARNING("Charging Station with ID = " + getID() + " don't have a valid range (" + TplConvert::_2str(getBeginLanePosition()) + " < " + TplConvert::_2str(getEndLanePosition()) + ").");
78  }
79 }
80 
81 
83 }
84 
85 
88  return myChargingPower;
89 }
90 
91 
94  return myEfficiency;
95 }
96 
97 
98 bool
100  return myChargeInTransit;
101 }
102 
103 
104 SUMOReal
106  return myChargeDelay;
107 }
108 
109 
110 void
112  if (chargingPower < 0)
113  WRITE_WARNING("new charging power for Chargin Station with ID = " + getID() + " not valid (" + TplConvert::_2str(chargingPower) + ").")
114  else {
115  myChargingPower = chargingPower;
116  }
117 }
118 
119 
120 void
122  if (efficency < 0 || efficency > 1)
123  WRITE_WARNING("new efficiency for Chargin Station with ID = " + getID() + " not valid (" + TplConvert::_2str(efficency) + ").")
124  else {
125  myEfficiency = efficency;
126  }
127 }
128 
129 
130 void
132  myChargeInTransit = chargeInTransit;
133 }
134 
135 
136 void
138  if (chargeDelay < 0)
139  WRITE_WARNING("new charge delay for Chargin Station with ID = " + getID() + " not valid (" + TplConvert::_2str(chargeDelay) + ").")
140  else {
141  myChargeDelay = chargeDelay;
142  }
143 }
144 
145 
146 void
148  myChargingVehicle = value;
149 }
150 
151 
152 bool
154  if ((position >= getBeginLanePosition()) && (position <= getEndLanePosition())) {
155  return true;
156  } else {
157  return false;
158  }
159 }
160 
161 
162 bool
164  return myChargingVehicle;
165 }
166 
167 
168 /****************************************************************************/
SUMOReal myChargingPower
Charging station&#39;s charging power.
SUMOReal getEfficency() const
Get efficiency of the charging station.
A lane area vehicles can halt at.
~MSChargingStation()
destructor
void setChargeDelay(int chargeDelay)
Set charge delay of the charging station.
SUMOReal getEndLanePosition() const
Returns the end position of this stop.
SUMOReal myEfficiency
Efficiency of the charging station.
const std::string & getID() const
Returns the id.
Definition: Named.h:66
bool isCharging() const
Return true if in the current time step charging station is charging a vehicle.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
SUMOReal getChargeDelay() const
Get Charge Delay.
bool getChargeInTransit() const
Get chargeInTransit.
bool myChargingVehicle
Check if in the current TimeStep chargingStation is charging a vehicle.
SUMOReal getBeginLanePosition() const
Returns the begin position of this stop.
bool vehicleIsInside(const SUMOReal position) const
Check if a vehicle is inside in the Charge Station.
MSChargingStation(const std::string &chargingStationID, MSLane &lane, SUMOReal startPos, SUMOReal endPos, SUMOReal chargingPower, SUMOReal efficency, bool chargeInTransit, int chargeDelay)
constructor
void setChargingPower(SUMOReal chargingPower)
Set charging station&#39;s charging power.
void setChargingVehicle(bool value)
enable or disable charging vehicle
void setChargeInTransit(bool chargeInTransit)
Set charge in transit of the charging station.
SUMOReal getChargingPower() const
Get charging station&#39;s charging power.
int myChargeDelay
Charge Delay.
bool myChargeInTransit
Allow charge in transit.
void setEfficency(SUMOReal efficency)
Set efficiency of the charging station.
#define SUMOReal
Definition: config.h:213
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
static std::string _2str(const int var)
convert int to string
Definition: TplConvert.h:57