SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSChrgStn.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Chargin Station for Electric vehicles //REVISION NEEDED
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2015 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>
35 #include <microsim/MSVehicleType.h>
37 #include "MSChrgStn.h"
38 #include "MSTrigger.h"
39 
40 
41 #ifdef CHECK_MEMORY_LEAKS
42 #include <foreign/nvwa/debug_new.h>
43 #endif // CHECK_MEMORY_LEAKS
44 
45 // ===========================================================================
46 // member method definitions
47 // ===========================================================================
48 
49 MSChrgStn::MSChrgStn(const std::string& new_ChrgStnID,
50  const std::vector<std::string>& new_lines,
51  MSLane& new_Lane, SUMOReal new_StartPos, SUMOReal new_EndPos, SUMOReal new_ChrgPower,
52  SUMOReal new_Efficency, SUMOReal new_ChargeInTransit, SUMOReal new_ChargeDelay) :
53  MSStoppingPlace(new_ChrgStnID, new_lines, new_Lane, new_StartPos, new_EndPos),
54  ChrgPower(new_ChrgPower),
55  Efficency(new_Efficency),
56  ChargeInTransit(new_ChargeInTransit),
57  ChargeDelay(new_ChargeDelay) {
58  if (getChrgPower() < 0) {
59  std::cout << std::string("Warning: Charging Station with ID = " + getID() + " doesn't have a valid charging power(" + SUMOReal_str(getChrgPower()) + ").");
60  }
61 
62  if (getEfficency() < 0 || getEfficency() > 1) {
63  std::cout << std::string("Warning: Charging Station with ID = " + getID() + " doesn't have a valid Efficency (" + SUMOReal_str(getEfficency()) + ").");
64  }
65 
67  std::cout << std::string("Warning: Charging Station with ID = " + getID() + " doesn't have a valid range (" + SUMOReal_str(getBeginLanePosition()) + " < " + SUMOReal_str(getEndLanePosition()) + ").");
68  }
69 }
70 
71 
73 {}
74 
75 
76 // GET FUNCTIONS
77 
78 
81  return ChrgPower;
82 }
83 
86  return Efficency;
87 }
88 
91  return ChargeInTransit;
92 }
93 
96  return ChargeDelay;
97 }
98 
99 
100 // SET FUNCTIONS
101 
102 void MSChrgStn::setChrgPower(SUMOReal new_ChrgPower) {
103  ChrgPower = new_ChrgPower;
104 
105  if (new_ChrgPower < 0) {
106  std::cout << std::string("Warning: Chargin Station with ID = " + getID() + " doesn't have a valid charging power(" + SUMOReal_str(getChrgPower()) + ").");
107  }
108 }
109 
110 
111 void MSChrgStn::setEfficency(SUMOReal new_Efficency) {
112  if (new_Efficency < 0 || new_Efficency > 1) {
113  std::cout << std::string("Warning: Chargin Station with ID = " + getID() + " doesn't have a valid Efficency (" + SUMOReal_str(getEfficency()) + ").");
114  }
115 
116  Efficency = new_Efficency;
117 }
118 
119 bool MSChrgStn::vehicleIsInside(const SUMOReal position) {
120  if ((position >= getBeginLanePosition()) && (position <= getEndLanePosition())) {
121  return true;
122  } else {
123  return false;
124  }
125 }
126 
127 // Private methods
128 
129 std::string MSChrgStn::SUMOReal_str(const SUMOReal& var) {
130  std::ostringstream convert;
131  convert << var;
132  return convert.str();
133 }
void setEfficency(SUMOReal new_Efficency)
Set parameter 06, efficiency of the charging station.
Definition: MSChrgStn.cpp:111
SUMOReal getEfficency() const
Get parameter 02, efficiency of the charging station.
Definition: MSChrgStn.cpp:85
void setChrgPower(SUMOReal new_ChrgPower)
Set parameter 05, charging station&#39;s charging power.
Definition: MSChrgStn.cpp:102
A lane area vehicles can halt at.
SUMOReal getChargeDelay() const
Get parameter 03, get Charge Delay.
Definition: MSChrgStn.cpp:95
SUMOReal ChargeInTransit
Parameter 03, Allow charge in transit.
Definition: MSChrgStn.h:115
SUMOReal getEndLanePosition() const
Returns the end position of this stop.
SUMOReal getChrgPower() const
Get parameter 01, charging station&#39;s charging power.
Definition: MSChrgStn.cpp:80
SUMOReal ChargeDelay
Parameter 03, Charge Delay.
Definition: MSChrgStn.h:118
bool vehicleIsInside(const SUMOReal position)
Check if a vehicle is inside in the Charge Station.
Definition: MSChrgStn.cpp:119
MSChrgStn(const std::string &new_ChrgStnID, const std::vector< std::string > &new_lines, MSLane &new_Lane, SUMOReal new_StartPos, SUMOReal new_EndPos, SUMOReal new_ChrgPower, SUMOReal new_Efficency, SUMOReal new_ChargeInTransit, SUMOReal new_ChargeDelay)
Definition: MSChrgStn.cpp:49
const std::string & getID() const
Returns the id.
Definition: Named.h:60
SUMOReal getChargeInTransit() const
Get parameter 03, get chargeInTransit.
Definition: MSChrgStn.cpp:90
SUMOReal Efficency
Parameter 02, efficiency of the charging station.
Definition: MSChrgStn.h:112
virtual ~MSChrgStn()
Definition: MSChrgStn.cpp:72
SUMOReal getBeginLanePosition() const
Returns the begin position of this stop.
std::string SUMOReal_str(const SUMOReal &var)
convert from SUMOReal to String
Definition: MSChrgStn.cpp:129
#define SUMOReal
Definition: config.h:215
SUMOReal ChrgPower
Parameter 01, charging station&#39;s charging power.
Definition: MSChrgStn.h:109
Representation of a lane in the micro simulation.
Definition: MSLane.h:77