58 MSStoppingPlace(overheadWireSegmentID, std::vector<std::string>(), lane, startPos, endPos),
60 myChargingVehicle(false),
62 myChargingVehicles({}),
64 myTractionSubstation(
nullptr),
65 myVoltageSource(voltageSource),
66 myCircuitElementPos(
nullptr),
67 myCircuitStartNodePos(
nullptr),
68 myCircuitEndNodePos(
nullptr) {
69 if (getBeginLanePosition() > getEndLanePosition()) {
103 mySubstationVoltage(voltage),
104 myChargingVehicle(false),
105 myElecHybridCount(0),
106 myOverheadWireSegments(),
110 myOverheadWireClamps() {
126 if (newOverheadWireSegment->
getCircuit()->
getNode(
"negNode_ground") ==
nullptr) {
135 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
139 const MSLane* connection =
nullptr;
140 std::string ovrhdSegmentID =
"";
146 const std::vector<std::pair<const MSLane*, const MSEdge*> > outgoingLanesAndEdges = lane.
getOutgoingViaLanes();
147 std::vector<const MSLane*> neigboringInnerLanes;
148 neigboringInnerLanes.reserve(outgoingLanesAndEdges.size());
149 for (
size_t it = 0; it < outgoingLanesAndEdges.size(); ++it) {
150 neigboringInnerLanes.push_back(outgoingLanesAndEdges[it].first);
155 for (std::vector<const MSLane*>::iterator it = neigboringInnerLanes.begin(); it != neigboringInnerLanes.end(); ++it) {
158 if (ovrhdSegmentID !=
"" && !(*it)->isInternal()) {
163 if (connection !=
nullptr) {
176 if (wire->getCircuitStartNodePos() == unusedNode) {
179 if (wire->getCircuitEndNodePos() == unusedNode) {
188 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
199 for (std::vector<const MSLane*>::iterator it = neigboringInnerLanes.begin(); it != neigboringInnerLanes.end(); ++it) {
202 if (ovrhdSegmentID !=
"" && !(*it)->isInternal()) {
207 if (connection !=
nullptr) {
219 if (ows->getCircuitStartNodePos() == unusedNode) {
222 if (ows->getCircuitEndNodePos() == unusedNode) {
231 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
242 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
250 if (frontConnection ==
nullptr && behindConnection ==
nullptr) {
267 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
270 }
else if (frontConnection !=
nullptr && behindConnection ==
nullptr) {
293 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
296 }
else if (frontConnection ==
nullptr && behindConnection !=
nullptr) {
319 WRITE_WARNING(
"Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
322 }
else if (frontConnection !=
nullptr && behindConnection !=
nullptr) {
354 WRITE_WARNING(
"Overhead circuit solver requested, but solver support not compiled in.");
363 double distance = pos_start[0].distanceTo2D(pos_end.back());
379 std::lock_guard<std::mutex> guard(
ow_mutex);
387 std::lock_guard<std::mutex> guard(
ow_mutex);
417 std::cout <<
"substation " <<
getID() <<
" constrols segments: \n";
419 std::cout <<
" " << (*it)->getOverheadWireSegmentName() <<
"\n";
516 if (it->id == clampId) {
552 for (
auto* it : *elecHybridSources) {
553 if (!
ISNAN(it->getPowerWanted())) {
554 err =
MAX2(abs(
myCircuit->
alphaBest * (it->getPowerWanted() - (-it->getCurrent()) * it->getVoltage())), err);
563 WRITE_WARNING(
"The requested total power could not be delivered by the overhead wire. Only " +
toString(
getCircuit()->alphaBest) +
" of originally requested power was provided.");
569 Element* vehElem = it->getVehElem();
573 it->setCurrentFromOverheadWire(current);
574 it->setVoltageOfOverheadWire(voltage);
585 double energyCharged = energyIn - it->getConsum();
588 it->setEnergyCharged(energyCharged);
591 it->setActualBatteryCapacity(it->getActualBatteryCapacity() + energyCharged);
593 it->getActOverheadWireSegment()->addChargeValueForOutput(energyCharged + it->getConsum(), it);
601 std::string status =
"charging";
603 status =
"not-charging";
630 std::vector<double>
charge;
631 std::vector<std::tuple<SUMOTime, SUMOTime, std::string> > vectorBeginEndCharge;
635 vectorBeginEndCharge.push_back(std::tuple<SUMOTime, SUMOTime, std::string>(firsTimeStep, 0,
myChargeValues.at(0).vehicleID));
641 std::get<1>(vectorBeginEndCharge.back()) = i->timeStep;
643 firsTimeStep += 1000;
645 if (((i + 1) !=
myChargeValues.end()) && (((i + 1)->timeStep) != firsTimeStep)) {
647 firsTimeStep = (i + 1)->timeStep;
649 vectorBeginEndCharge.push_back(std::tuple<SUMOTime, SUMOTime, std::string>(firsTimeStep, 0, (i + 1)->vehicleID));
654 int vehicleCounter = 0;
679 firsTimeStep += 1000;
681 if (((i + 1) !=
myChargeValues.end()) && (((i + 1)->timeStep) != firsTimeStep)) {
683 firsTimeStep = (i + 1)->timeStep;
const double WIRE_RESISTIVITY
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t)
convert SUMOTime to string
@ 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_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)
vector< Element * > * getCurrentSources()
Element * addElement(string name, double value, Node *pNode, Node *nNode, Element::ElementType et)
void eraseNode(Node *node)
void replaceAndDeleteNode(Node *unusedNode, Node *newNode)
Node * getNode(string name)
double alphaBest
Best alpha scaling value.
Node * addNode(string name)
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.
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
void writeOverheadWireSegmentOutput(OutputDevice &output)
write charging station 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< charge > myChargeValues
vector with the charges of this charging station
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
std::vector< MSDevice_ElecHybrid * > myElecHybrid
bool isForbidden(const MSLane *lane)
std::vector< MSLane * > myForbiddenLanes
void increaseElecHybridCount()
void addVehicle(MSDevice_ElecHybrid *elecHybrid)
SUMOTime solveCircuit(SUMOTime currentTime)
void addOverheadWireSegmentToCircuit(MSOverheadWire *newOverheadWireSegment)
OverheadWireClamp * findClamp(std::string id)
MSTractionSubstation(const std::string &substationId, double voltage)
constructor
static Command * myCommandForSolvingCircuit
void addForbiddenLane(MSLane *lane)
void setChargingVehicle(bool value)
enable or disable charging vehicle
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.
vector< Element * > * getElements()
void eraseElement(Element *element)
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