61 myChargingVehicle(false),
63 myChargingVehicles({}),
65 myTractionSubstation(
nullptr),
66 myVoltageSource(voltageSource),
67 myCircuitElementPos(
nullptr),
68 myCircuitStartNodePos(
nullptr),
69 myCircuitEndNodePos(
nullptr) {
70 if (getBeginLanePosition() > getEndLanePosition()) {
103 std::lock_guard<std::mutex> guard(
ow_mutex);
111 std::lock_guard<std::mutex> guard(
ow_mutex);
141 std::cout <<
"substation " <<
getID() <<
" constrols segments: \n";
143 std::cout <<
" " << (*it)->getOverheadWireSegmentName() <<
"\n";
206 std::string status =
"charging";
208 status =
"not-charging";
227 int chargingSteps = 0;
228 std::vector<SUMOTime> chargingSteps_list;
230 for (
auto it : item.second) {
231 if (std::find(chargingSteps_list.begin(), chargingSteps_list.end(), it.timeStep) == chargingSteps_list.end()) {
232 chargingSteps_list.push_back(it.timeStep);
236 chargingSteps = (int) chargingSteps_list.size();
259 while (iStart < (
int)chargeSteps.size()) {
260 int iEnd = iStart + 1;
261 double charged = chargeSteps[iStart].WCharged;
262 while (iEnd < (
int)chargeSteps.size() && chargeSteps[iEnd].timeStep == chargeSteps[iEnd - 1].timeStep +
DELTA_T) {
263 charged += chargeSteps[iEnd].WCharged;
266 writeVehicle(output, chargeSteps, iStart, iEnd, charged);
278 const Charge& first = chargeSteps[iStart];
286 for (
int i = iStart; i < iEnd; i++) {
287 const Charge& c = chargeSteps[i];
314 myChargingVehicle(false),
315 myElecHybridCount(0),
316 mySubstationVoltage(voltage),
317 myCircuit(new
Circuit(currentLimit)),
338 const std::string segmentID = newOverheadWireSegment->
getID();
340 if (circuit->
getNode(
"negNode_ground") ==
nullptr) {
341 circuit->
addNode(
"negNode_ground");
353 Element::ElementType::RESISTOR_traction_wire));
355 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
359 const MSLane* connection =
nullptr;
360 std::string ovrhdSegmentID =
"";
370 const std::vector<std::pair<const MSLane*, const MSEdge*> > outgoingLanesAndEdges = lane.
getOutgoingViaLanes();
371 std::vector<const MSLane*> neigboringInnerLanes;
372 neigboringInnerLanes.reserve(outgoingLanesAndEdges.size());
373 for (
size_t it = 0; it < outgoingLanesAndEdges.size(); ++it) {
374 neigboringInnerLanes.push_back(outgoingLanesAndEdges[it].first);
379 for (std::vector<const MSLane*>::iterator it = neigboringInnerLanes.begin(); it != neigboringInnerLanes.end(); ++it) {
382 if (ovrhdSegmentID !=
"" && !(*it)->isInternal()) {
388 if (connection !=
nullptr) {
401 if (ows->getCircuitStartNodePos() == unusedNode) {
404 if (ows->getCircuitEndNodePos() == unusedNode) {
410 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
425 for (std::vector<const MSLane*>::iterator it = neigboringInnerLanes.begin(); it != neigboringInnerLanes.end(); ++it) {
428 if (ovrhdSegmentID !=
"" && !(*it)->isInternal()) {
434 if (connection !=
nullptr) {
446 if (ows->getCircuitStartNodePos() == unusedNode) {
449 if (ows->getCircuitEndNodePos() == unusedNode) {
455 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
466 "voltage_source_" + newOverheadWireSegment->
getID(),
470 Element::ElementType::VOLTAGE_SOURCE_traction_wire);
472 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
480 if (frontConnection ==
nullptr && behindConnection ==
nullptr) {
493 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
496 }
else if (frontConnection !=
nullptr && behindConnection ==
nullptr) {
519 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
522 }
else if (frontConnection ==
nullptr && behindConnection !=
nullptr) {
545 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
548 }
else if (frontConnection !=
nullptr && behindConnection !=
nullptr) {
580 WRITE_WARNING(
"Overhead circuit solver requested, but solver support not compiled in.");
590 double distance = pos_start[0].distanceTo2D(pos_end.back());
649 if (it->id == clampId) {
701 Element* vehElem = it->getVehElem();
705 it->setCurrentFromOverheadWire(current);
706 it->setVoltageOfOverheadWire(voltage);
712 double energyCharged = it->computeChargedEnergy(energyIn);
715 double realEnergyCharged = it->storeEnergyToBattery(energyCharged);
717 it->setEnergyCharged(realEnergyCharged);
720 it->updateTotalEnergyWasted(energyCharged - realEnergyCharged);
722 it->getActOverheadWireSegment()->addChargeValueForOutput(energyIn, it);
730 std::string status =
"";
734 std::string vehicleIDs =
"";
736 vehicleIDs += (*it)->getID() +
" ";
740 if (!vehicleIDs.empty()) {
741 vehicleIDs.pop_back();
744 std::string currents =
"";
760 length += (*it)->getEndLanePosition() - (*it)->getBeginLanePosition();
775 output.
writeAttr(
"vehicleIDs", i->vehicleIDs);
776 output.
writeAttr(
"numVehicles", i->numVehicles);
783 output.
writeAttr(
"currents", i->currentsString);
787 output.
writeAttr(
"alphaFlag", i->alphaReason);
static std::mutex ow_mutex
const double WIRE_RESISTIVITY
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t)
convert SUMOTime to string
@ 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 provied 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.
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
const PositionVector & getShape() const
Returns this lane's shape.
std::vector< const MSLane * > getNormalIncomingLanes() const
get the list of all direct (disregarding internal predecessors) non-internal predecessor lanes of thi...
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.
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
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)
Node * getCircuitEndNodePos() const
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
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.
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.
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
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)
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.
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
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 & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
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