69 double actualBatteryCapacity = 0;
74 const std::string abc = vehicleParams.
getParameter(attrName,
"-1");
78 WRITE_WARNING(
"Invalid value '" + abc +
"'for vehicle parameter '" + attrName +
"'. Using the default of " + std::to_string(actualBatteryCapacity));
82 const std::string abc = typeParams.
getParameter(attrName,
"-1");
85 WRITE_WARNING(
"Vehicle '" + v.
getID() +
"' does not provide vehicle parameter '" + attrName +
"'. Using the vehicle type value of " + std::to_string(actualBatteryCapacity));
87 WRITE_WARNING(
"Invalid value '" + abc +
"'for vehicle type parameter '" + attrName +
"'. Using the default of " + std::to_string(actualBatteryCapacity));
90 WRITE_WARNING(
"Vehicle '" + v.
getID() +
"' does not provide vehicle or vehicle type parameter '" + attrName +
"'. Using the default of " + std::to_string(actualBatteryCapacity));
95 double maximumBatteryCapacity = 0;
98 const std::string mbc = typeParams.
getParameter(attrName,
"-1");
102 WRITE_WARNINGF(
TL(
"Invalid value '%'for vType parameter '%'"), mbc, attrName);
105 WRITE_WARNING(
"Vehicle '" + v.
getID() +
"' is missing the vType parameter '" + attrName +
"'. Using the default of " + std::to_string(maximumBatteryCapacity));
109 double overheadWireChargingPower = 0;
112 const std::string ocp = typeParams.
getParameter(attrName,
"-1");
116 WRITE_WARNINGF(
TL(
"Invalid value '%'for vType parameter '%'"), ocp, attrName);
119 WRITE_WARNING(
"Vehicle '" + v.
getID() +
"' is missing the vType parameter '" + attrName +
"'. Using the default of " + std::to_string(overheadWireChargingPower));
124 actualBatteryCapacity, maximumBatteryCapacity, overheadWireChargingPower);
127 into.push_back(device);
136 const double actualBatteryCapacity,
const double maximumBatteryCapacity,
const double overheadWireChargingPower) :
138 myActualBatteryCapacity(0),
139 myMaximumBatteryCapacity(0),
140 myOverheadWireChargingPower(0),
142 myBatteryDischargedLogic(false),
145 myCircuitCurrent(NAN),
146 myCircuitVoltage(NAN),
147 myMaxBatteryCharge(NAN),
148 myMinBatteryCharge(NAN),
149 myTotalEnergyConsumed(0),
150 myTotalEnergyRegenerated(0),
151 myTotalEnergyWasted(0),
155 myActOverheadWireSegment(nullptr),
156 myPreviousOverheadWireSegment(nullptr),
158 veh_pos_tail_elem(nullptr),
159 pos_veh_node(nullptr) {
161 if (maximumBatteryCapacity < 0) {
167 if (actualBatteryCapacity > maximumBatteryCapacity) {
174 if (overheadWireChargingPower < 0) {
213 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
219 speedTimeLine.push_back(
223 speedTimeLine.push_back(
228 static_cast<MSVehicle*
>(&veh)->getInfluencer().setSpeedTimeLine(speedTimeLine);
247 double energyWasted = 0.0;
249 if (overheadWireSegmentID !=
"") {
273 if (actualSubstation !=
nullptr) {
290 if (actualSubstation !=
nullptr) {
301 WRITE_WARNING(
"pos_veh_node or neg_veh_node or veh_elem is not NULL (and they should be at the beginning of adding elecHybrid to the circuit)");
329 double relativePosOnSegment =
337 if (strncmp(element_pos->
getName().c_str(),
"pos_tail_", 9) != 0) {
358 WRITE_WARNINGF(
TL(
"The resistivity of overhead wire segment connected to vehicle % is < 0. Set to 1e-6."), veh.
getID());
388 if (voltage < 10.0 || voltage > 1500.0 || std::isnan(voltage)) {
416 WRITE_ERROR(
TL(
"Overhead wire solver is on, but the Eigen library has not been compiled in!"))
424 double voltage = 0.0;
425 if (actualSubstation !=
nullptr) {
512 WRITE_ERROR(
TL(
"Overhead wire solver is on, but the Eigen library has not been compiled in!"))
560 const double frontOnLane,
561 const double timeOnLane,
562 const double meanSpeedFrontOnLane,
563 const double meanSpeedVehicleOnLane,
564 const double travelledDistanceFrontOnLane,
565 const double travelledDistanceVehicleOnLane,
566 const double meanLengthOnLane) {
583 WRITE_ERRORF(
"During deleting vehicle '%' from circuit some init previous Nodes or Elements was not assigned.", veh.
getID());
587 WRITE_ERRORF(
"During deleting vehicle '%' from circuit the size of element-vector of pNode or nNode was not 3. It should be 3 by Jakub's opinion.", veh.
getID());
599 WRITE_ERRORF(
"During deleting vehicle '%' from circuit the size of element-vector of pNode or nNode was not 1. It should be 1 by Jakub's opinion.", veh.
getID());
624 if (node_last !=
nullptr) {
628 if (elem_last !=
nullptr) {
631 WRITE_ERROR(
TL(
"The element or node with the last Id was not found in the circuit!"));
650#ifdef ELECHYBRID_MESOSCOPIC_DEBUG
652 std::cout <<
"device '" <<
getID() <<
"' notifyEnter: reason=" << reason <<
" currentEdge=" << veh.
getEdge()->
getID() <<
"\n";
668#ifdef ELECHYBRID_MESOSCOPIC_DEBUG
670 std::cout <<
"device '" <<
getID() <<
"' notifyLeave: reason=" << reason <<
" currentEdge=" << veh.
getEdge()->
getID() <<
"\n";
674 std::cout <<
"***************** MESO - notifyLeave*** START ****************** '" << v.
getID() <<
"' \n";
676 std::cout <<
"getSpeed: '" << v.
getSpeed() <<
"' | getAverageSpeed: '" << v.
getAverageSpeed() <<
"' | getStoptime: '" << v.getStoptime(v.
getSegment(), 0) <<
"' \n";
679 std::cout <<
"***************** MESO - notifyLeave*** END ****************** '" << v.
getID() <<
"' \n";
694 WRITE_ERROR(
TL(
"Overhead wire solver is on, but the Eigen library has not been compiled in!"))
701 if (prevSubstation !=
nullptr) {
713 if (tripinfoOut !=
nullptr) {
715 tripinfoOut->
openTag(
"elechybrid");
753 WRITE_WARNING(
TL(
"Getting the vehicle mass via parameters is deprecated, please use getMass for the vehicle or its type."));
761 double energyCharged = energyIn -
myConsum;
769 if (energyIn > 0.0 && energyCharged > 0.0) {
776 }
else if (energyIn < 0.0 && energyCharged < 0.0) {
784 return energyCharged;
817 if (owc !=
nullptr) {
821 WRITE_ERROR(
TL(
"Overhead wire solver is on, but the Eigen library has not been compiled in!"))
const double WIRE_RESISTIVITY
#define WRITE_WARNINGF(...)
#define WRITE_ERRORF(...)
#define WRITE_WARNING(msg)
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
@ SUMO_ATTR_ENERGYCONSUMED
Energy consumed.
@ SUMO_ATTR_SUBSTATIONID
id of a traction substation substation
@ SUMO_ATTR_MAXIMUMBATTERYCAPACITY
Maxium battery capacity.
@ SUMO_ATTR_RECUPERATIONEFFICIENCY
Recuperation efficiency (constant)
@ SUMO_ATTR_ACTUALBATTERYCAPACITY
@ SUMO_ATTR_VEHICLEMASS
Vehicle mass.
@ SUMO_ATTR_ENERGYCHARGED
tgotal of Energy charged
@ SUMO_ATTR_OVERHEADWIREID
@ SUMO_ATTR_PROPULSIONEFFICIENCY
Propulsion efficiency.
@ SUMO_ATTR_OVERHEADWIRECHARGINGPOWER
#define UNUSED_PARAMETER(x)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double getAlphaBest()
return alphaBest variable, the best alpha scaling value
Node * addNode(std::string name)
Element * addElement(std::string name, double value, Node *pNode, Node *nNode, Element::ElementType et)
void eraseNode(Node *node)
Element * getElement(std::string name)
Element * getVoltageSource(int id)
Node * getNode(std::string name)
void eraseElement(Element *element)
void setCurrent(double current)
void setPosNode(Node *node)
void setResistance(double resistance)
void setPowerWanted(double powerWanted)
@ CURRENT_SOURCE_traction_wire
double getDouble(SumoXMLAttr attr) const
Returns the value for a given key.
double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const EnergyParams *param) const
Computes the emitted pollutant amount using the given speed and acceleration.
double acceleration(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double P, const double slope, const EnergyParams *param) const
Computes the achievable acceleration using the given speed and amount of consumed electric power.
A vehicle from the mesoscopic point of view.
double getLastEntryTimeSeconds() const
Returns the entry time for the current segment.
double getBlockTimeSeconds() const
Returns the time at which the vehicle was blocked on the current segment.
double getAverageSpeed() const
Returns the vehicle's estimated average speed on the segment assuming no further delays.
SUMOTime getWaitingTime(const bool accumulated=false) const
Returns the duration for which the vehicle was blocked.
SUMOTime getLastEntryTime() const
Returns the time the vehicle entered the current segment.
MESegment * getSegment() const
Returns the current segment the vehicle is on.
double getSpeed() const
Returns the vehicle's estimated speed assuming no delays.
A device which collects info on the vehicle trip (mainly on departure and arrival)
void setEnergyCharged(double energyCharged)
double myMinBatteryCharge
bool myCharging
Parameter, Flag: Vehicle is charging (by default is false)
MSDevice_ElecHybrid(SUMOVehicle &holder, const std::string &id, const double actualBatteryCapacity, const double maximumBatteryCapacity, const double overheadWireChargingPower)
Constructor.
void setCurrentFromOverheadWire(double current)
double myMaximumBatteryCapacity
Parameter, The total vehicles's Battery Capacity in Wh, [myMaximumBatteryCapacity >= 0].
double myMaxBatteryCharge
double getCircuitAlpha() const
MSOverheadWire * myPreviousOverheadWireSegment
Parameter, Pointer to the act overhead wire segment in previous step (by default is nullptr),...
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
void deleteVehicleFromCircuit(SUMOVehicle &veh)
double getVoltageOfOverheadWire() const
Get actual voltage on the overhead wire segment.
double myEnergyCharged
Energy flowing into (+) or from (-) the battery pack in the given timestep.
bool notifyLeave(SUMOTrafficObject &tObject, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
double mySOCMax
Maximal SOC of the battery pack, battery will not be charged above this level. (But the buffer may st...
double getMaximumBatteryCapacity() const
Get the total vehicle's Battery Capacity in kWh.
double consumption(SUMOVehicle &veh, double a, double newSpeed)
return energy consumption in Wh (power multiplied by TS)
double computeChargedEnergy(double energyIn)
compute charged energy properly considering recuperation and propulsion efficiency during charging ba...
double myTotalEnergyWasted
Energy that could not be stored back to the battery or traction station and was wasted on resistors....
double getPowerWanted() const
void setConsum(const double consumption)
bool isBatteryDischarged() const
Get consum.
double myTotalEnergyRegenerated
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing tripinfo output.
double myConsum
Parameter, Vehicle consumption during a time step (by default is 0.)
void setActualBatteryCapacity(const double actualBatteryCapacity)
Set actual vehicle's Battery Capacity in kWh.
double myTotalEnergyConsumed
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
double acceleration(SUMOVehicle &veh, double power, double oldSpeed)
double storeEnergyToBattery(const double energy)
Attempt to store energy into battery pack and return the energy that could not be accommodated due to...
void updateTotalEnergyWasted(const double energyWasted)
Add energyWasted to the total sum myTotalEnergyWasted.
double getCurrentFromOverheadWire() const
Get actual current in the overhead wire segment.
bool myBatteryDischargedLogic
Parameter, Flag: Battery of Vehicle is fully discharged (by default is false)
const std::string deviceName() const
return the name for this type of device
bool notifyMove(SUMOTrafficObject &tObject, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
double myOverheadWireChargingPower
Parameter, overhead wire charging power to battery, if the battery SoC is not full (in Watt)
void setVoltageOfOverheadWire(double voltage)
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_ElecHybrid-options.
~MSDevice_ElecHybrid()
Destructor.
MSOverheadWire * myActOverheadWireSegment
Parameter, Pointer to the actual overhead wire segment in which vehicle is placed (by default is null...
double myActualBatteryCapacity
Parameter, The actual vehicles's Battery Capacity in Wh, [myActualBatteryCapacity <= myMaximumBattery...
double getEnergyCharged() const
Get charged energy.
std::string getTractionSubstationID() const
Get actual traction substation ID.
virtual void notifyMoveInternal(const SUMOTrafficObject &tObject, const double frontOnLane, const double timeOnLane, const double meanSpeedFrontOnLane, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double meanLengthOnLane)
Internal notification about the vehicle moves.
bool notifyEnter(SUMOTrafficObject &tObject, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
double getActualBatteryCapacity() const
Get the actual vehicle's Battery Capacity in kWh.
double getConsum() const
Get consum.
Element * veh_pos_tail_elem
double myCircuitCurrent
Parameter, Current wanted at overhead wire in next timestep.
std::string getOverheadWireSegmentID() const
Get actual overhead wire segment ID.
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
MSLane * leftLane(const MSLane *const lane) const
Returns the lane left to the one given, 0 if the given lane is leftmost.
MSLane * rightLane(const MSLane *const lane) const
Returns the lane right to the one given, 0 if the given lane is rightmost.
static bool gOverheadWireRecuperation
static bool gOverheadWireSolver
Representation of a lane in the micro simulation.
double getLength() const
Returns the lane's length.
Notification
Definition of a vehicle state.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
std::string getStoppingPlaceID(const MSLane *lane, const double pos, const SumoXMLTag category) const
Returns the stop of the given category close to the given position.
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition of overhead wire segment.
Circuit * getCircuit() const
void addChargeValueForOutput(double WCharged, MSDevice_ElecHybrid *elecHybrid, bool ischarging=1)
add charge value for output
MSTractionSubstation * getTractionSubstation() const
void eraseVehicle(SUMOVehicle &veh)
void addVehicle(SUMOVehicle &veh)
const MSLane & getLane() const
Returns the lane this stop is located at.
Traction substation powering one or more overhead wire sections.
void decreaseElecHybridCount()
void eraseVehicle(MSDevice_ElecHybrid *elecHybrid)
double getSubstationVoltage() const
void addSolvingCircuitToEndOfTimestepEvents()
void increaseElecHybridCount()
void addVehicle(MSDevice_ElecHybrid *elecHybrid)
Abstract in-vehicle device.
SUMOVehicle & myHolder
The vehicle that stores the device.
Representation of a vehicle in the micro simulation.
const SUMOVTypeParameter & getParameter() const
const std::string & getID() const
Returns the id.
void addElement(Element *element)
void eraseElement(Element *element)
std::vector< Element * > * getElements()
A storage for options typed value containers)
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
bool hasParameter(const std::string &key) const
Returns whether the parameter is set.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
static const HelpersEnergy & getEnergyHelper()
get energy helper
Representation of a vehicle, person, or container.
virtual bool isVehicle() const
Whether it is a vehicle.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual double getSlope() const =0
Returns the slope of the road at object's position in degrees.
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Structure representing possible vehicle parameter.
Representation of a vehicle.
virtual EnergyParams * getEmissionParameters() const =0
Returns the vehicle's emission model parameter.
Structure representing possible vehicle parameter.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter