60 myChargingVehicle(false),
62 myChargingVehicles({}),
64 myTractionSubstation(
nullptr),
65 myVoltageSource(voltageSource),
66 myCircuitElementPos(
nullptr),
67 myCircuitStartNodePos(
nullptr),
68myCircuitEndNodePos(
nullptr) {
69 if (getBeginLanePosition() > getEndLanePosition()) {
102 std::lock_guard<std::mutex> guard(
ow_mutex);
110 std::lock_guard<std::mutex> guard(
ow_mutex);
140 std::cout <<
"substation " <<
getID() <<
" constrols segments: \n";
142 std::cout <<
" " << (*it)->getOverheadWireSegmentName() <<
"\n";
205 std::string status =
"charging";
207 status =
"not-charging";
226 int chargingSteps = 0;
227 std::vector<SUMOTime> chargingSteps_list;
229 for (
auto it : item.second) {
230 if (std::find(chargingSteps_list.begin(), chargingSteps_list.end(), it.timeStep) == chargingSteps_list.end()) {
231 chargingSteps_list.push_back(it.timeStep);
235 chargingSteps = (int) chargingSteps_list.size();
258 while (iStart < (
int)chargeSteps.size()) {
259 int iEnd = iStart + 1;
260 double charged = chargeSteps[iStart].WCharged;
261 while (iEnd < (
int)chargeSteps.size() && chargeSteps[iEnd].timeStep == chargeSteps[iEnd - 1].timeStep +
DELTA_T) {
262 charged += chargeSteps[iEnd].WCharged;
265 writeVehicle(output, chargeSteps, iStart, iEnd, charged);
277 const Charge& first = chargeSteps[iStart];
285 for (
int i = iStart; i < iEnd; i++) {
286 const Charge& c = chargeSteps[i];
313 myChargingVehicle(false),
314 myElecHybridCount(0),
315 mySubstationVoltage(voltage),
316 myCircuit(new
Circuit(currentLimit)),
337 const std::string segmentID = newOverheadWireSegment->
getID();
339 if (circuit->
getNode(
"negNode_ground") ==
nullptr) {
340 circuit->
addNode(
"negNode_ground");
354 WRITE_WARNING(
TL(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in."));
358 const MSLane* connection =
nullptr;
359 std::string ovrhdSegmentID =
"";
369 const std::vector<std::pair<const MSLane*, const MSEdge*> > outgoingLanesAndEdges = lane.
getOutgoingViaLanes();
370 std::vector<const MSLane*> neigboringInnerLanes;
371 neigboringInnerLanes.reserve(outgoingLanesAndEdges.size());
372 for (
size_t it = 0; it < outgoingLanesAndEdges.size(); ++it) {
373 neigboringInnerLanes.push_back(outgoingLanesAndEdges[it].first);
378 for (std::vector<const MSLane*>::iterator it = neigboringInnerLanes.begin(); it != neigboringInnerLanes.end(); ++it) {
381 if (ovrhdSegmentID !=
"" && !(*it)->isInternal()) {
387 if (connection !=
nullptr) {
400 if (ows->getCircuitStartNodePos() == unusedNode) {
403 if (ows->getCircuitEndNodePos() == unusedNode) {
409 WRITE_WARNING(
TL(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in."));
424 for (std::vector<const MSLane*>::iterator it = neigboringInnerLanes.begin(); it != neigboringInnerLanes.end(); ++it) {
427 if (ovrhdSegmentID !=
"" && !(*it)->isInternal()) {
433 if (connection !=
nullptr) {
445 if (ows->getCircuitStartNodePos() == unusedNode) {
448 if (ows->getCircuitEndNodePos() == unusedNode) {
454 WRITE_WARNING(
TL(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in."));
465 "voltage_source_" + newOverheadWireSegment->
getID(),
471 WRITE_WARNING(
TL(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in."));
479 if (frontConnection ==
nullptr && behindConnection ==
nullptr) {
492 WRITE_WARNING(
TL(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in."));
495 }
else if (frontConnection !=
nullptr && behindConnection ==
nullptr) {
518 WRITE_WARNING(
TL(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in."));
521 }
else if (frontConnection ==
nullptr && behindConnection !=
nullptr) {
544 WRITE_WARNING(
TL(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in."));
547 }
else if (frontConnection !=
nullptr && behindConnection !=
nullptr) {
579 WRITE_WARNING(
TL(
"Overhead circuit solver requested, but solver support not compiled in."));
589 double distance = pos_start[0].distanceTo2D(pos_end.back());
648 if (it->id == clampId) {
700 Element* vehElem = it->getVehElem();
704 it->setCurrentFromOverheadWire(current);
705 it->setVoltageOfOverheadWire(voltage);
711 double energyCharged = it->computeChargedEnergy(energyIn);
714 double realEnergyCharged = it->storeEnergyToBattery(energyCharged);
716 it->setEnergyCharged(realEnergyCharged);
719 it->updateTotalEnergyWasted(energyCharged - realEnergyCharged);
721 it->getActOverheadWireSegment()->addChargeValueForOutput(energyIn, it);
729 std::string status =
"";
733 std::string vehicleIDs =
"";
735 vehicleIDs += (*it)->getID() +
" ";
739 if (!vehicleIDs.empty()) {
740 vehicleIDs.pop_back();
743 std::string currents =
"";
759 length += (*it)->getEndLanePosition() - (*it)->getBeginLanePosition();
774 output.
writeAttr(
"vehicleIDs", i->vehicleIDs);
775 output.
writeAttr(
"numVehicles", i->numVehicles);
782 output.
writeAttr(
"currents", i->currentsString);
786 output.
writeAttr(
"alphaFlag", i->alphaReason);
static std::mutex ow_mutex
const double WIRE_RESISTIVITY
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
@ SUMO_TAG_TRACTION_SUBSTATION
A traction substation.
@ SUMO_TAG_STEP
trigger: a step description
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
@ SUMO_ATTR_TRACTIONSUBSTATIONID
@ SUMO_ATTR_PARTIALCHARGE
energy provided by charging station at certain timestep
@ SUMO_ATTR_TOTALENERGYCHARGED
@ SUMO_ATTR_VOLTAGE
voltage of the traction substation [V]
@ SUMO_ATTR_MAXIMUMBATTERYCAPACITY
Maxium battery capacity.
@ SUMO_ATTR_TOTALENERGYCHARGED_VEHICLE
total energy charged into a single vehicle
@ SUMO_ATTR_ACTUALBATTERYCAPACITY
@ SUMO_ATTR_ENERGYCHARGED
tgotal of Energy charged
@ SUMO_ATTR_CHARGINGSTEPS
number of steps that a vehicle is charging
@ SUMO_ATTR_CHARGINGEND
timesteps in which charging ends
@ SUMO_ATTR_CHARGINGBEGIN
timestep in which charging begins
@ SUMO_ATTR_ALPHACIRCUITSOLVER
@ SUMO_ATTR_CURRENTFROMOVERHEADWIRE
@ SUMO_ATTR_TIME
trigger: the time of the step
@ SUMO_ATTR_CHARGING_STATUS
#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)
int getNumVoltageSources()
Element * addElement(std::string name, double value, Node *pNode, Node *nNode, Element::ElementType et)
void eraseNode(Node *node)
double getTotalCurrentOfCircuitSources()
The sum of voltage source currents in the circuit.
void replaceAndDeleteNode(Node *unusedNode, Node *newNode)
double getTotalPowerOfCircuitSources()
The sum of voltage source powers in the circuit.
alphaFlag
Flag of alpha scaling parameter.
alphaFlag getAlphaReason()
return the reason why alpha scaling value has been used
Node * getNode(std::string name)
std::string & getCurrentsOfCircuitSource(std::string ¤ts)
List of currents of voltage sources as a string.
void eraseElement(Element *element)
Base (microsim) event class.
@ VOLTAGE_SOURCE_traction_wire
A device which collects info on the vehicle trip (mainly on departure and arrival)
double getVoltageOfOverheadWire() const
Get actual voltage on the overhead wire segment.
double getMaximumBatteryCapacity() const
Get the total vehicle's Battery Capacity in kWh.
double getActualBatteryCapacity() const
Get the actual vehicle's Battery Capacity in kWh.
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static bool gOverheadWireSolver
Representation of a lane in the micro simulation.
double getLength() const
Returns the lane's length.
const MSLane * getInternalFollowingLane(const MSLane *const) const
returns the internal lane leading to the given lane or nullptr, if there is none
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
std::vector< const MSLane * > getNormalIncomingLanes() const
get the list of all direct (disregarding internal predecessors) non-internal predecessor lanes of thi...
virtual const PositionVector & getShape(bool) const
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
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.
A class for sorting vehicle on lane under the overhead wire segment.
Definition of overhead wire segment.
std::map< std::string, std::vector< Charge > > myChargeValues
map with the charges of this charging station (key = vehicleID)
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)
static void writeVehicle(OutputDevice &out, const std::vector< Charge > &chargeSteps, int iStart, int iEnd, double charged)
void writeOverheadWireSegmentOutput(OutputDevice &output)
write overhead wire segment values
Node * getCircuitStartNodePos() 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.
Node * getCircuitEndNodePos() const
MSOverheadWire(const std::string &overheadWireSegmentID, MSLane &lane, double startPos, double endPos, bool voltageSource)
constructor
void setCircuitStartNodePos(Node *node)
std::string getOverheadWireSegmentName()
double myTotalCharge
total energy charged by this charging station
Node * myCircuitStartNodePos
void setVoltage(double voltage)
Set overhead wire's voltage.
std::vector< std::string > myChargedVehicles
order vehicles by time of first charge
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.
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
double myVoltage
Overhead wire's voltage.
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
double getEndLanePosition() const
Returns the end position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
bool myChargingVehicle
Check if in the current TimeStep substation (overhead wire section) is charging a vehicle.
void decreaseElecHybridCount()
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
~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)
void addSolvingCircuitToEndOfTimestepEvents()
bool isCharging() const
Return true if in the current time step the substation (overhead wire section) is charging a vehicle.
bool isAnySectionPreviouslyDefined()
double mySubstationVoltage
void writeTractionSubstationOutput(OutputDevice &output)
write traction substation values
std::vector< MSDevice_ElecHybrid * > myElecHybrid
bool isForbidden(const MSLane *lane)
std::vector< MSLane * > myForbiddenLanes
Circuit * getCircuit() const
void increaseElecHybridCount()
void addVehicle(MSDevice_ElecHybrid *elecHybrid)
std::vector< chargeTS > myChargeValues
SUMOTime solveCircuit(SUMOTime currentTime)
void addOverheadWireSegmentToCircuit(MSOverheadWire *newOverheadWireSegment)
MSTractionSubstation(const std::string &substationId, double voltage, double currentLimit)
Constructor instantiates a substation providing certain voltage and a maximum current.
OverheadWireClamp * findClamp(std::string id)
Find an overhead wire clamp by its ID.
static Command * myCommandForSolvingCircuit
void addForbiddenLane(MSLane *lane)
void setChargingVehicle(bool value)
enable or disable charging vehicle
void addChargeValueForOutput(double energy, double current, double alpha, Circuit::alphaFlag alphaReason)
add charge value for output
SUMOVehicle & getHolder() const
Returns the vehicle that holds this device.
const std::string & getID() const
Returns the name of the vehicle type.
Base class for objects which have an id.
std::string myID
The name of the object.
const std::string & getID() const
Returns the id.
std::vector< Element * > * getElements()
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.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
Representation of a vehicle.
A wrapper for a Command function.
struct to save information for the overhead wire segment output
double maxBatteryCapacity
double actualBatteryCapacity
double totalEnergyCharged
struct to save information for the traction substation output