Skip to content

Commit

Permalink
add relation from charging station to parking ref #13596
Browse files Browse the repository at this point in the history
Signed-off-by: m-kro <[email protected]>
  • Loading branch information
m-kro committed Jan 29, 2024
1 parent 9513a6f commit 2b0208e
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions data/xsd/additional_file.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="waitingTime" type="nonNegativeFloatType" use="optional"/>
<xsd:attribute name="parkingArea" type="xsd:string" use="optional"/>
</xsd:complexType>

<xsd:complexType name="overheadWireSegmentType">
Expand Down
3 changes: 2 additions & 1 deletion src/microsim/devices/MSDevice_Battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ bool MSDevice_Battery::notifyMove(SUMOTrafficObject& tObject, double /* oldPos *
if (chargingStationID != "") {
// if the vehicle is almost stopped, or charge in transit is enabled, then charge vehicle
MSChargingStation* const cs = static_cast<MSChargingStation*>(MSNet::getInstance()->getStoppingPlace(chargingStationID, SUMO_TAG_CHARGING_STATION));
if ((veh.getSpeed() < myStoppingThreshold) || cs->getChargeInTransit()) {
const MSParkingArea* pa = cs->getParkingArea();
if (((veh.getSpeed() < myStoppingThreshold) || cs->getChargeInTransit()) && (pa == nullptr || veh.isParking())) {
// Set Flags Stopped/intransit to
if (veh.getSpeed() < myStoppingThreshold) {
// vehicle ist almost stopped, then is charging stopped
Expand Down
14 changes: 14 additions & 0 deletions src/microsim/trigger/MSChargingStation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <cassert>
#include <utils/common/StringUtils.h>
#include <utils/vehicle/SUMOVehicle.h>
#include <microsim/MSParkingArea.h>
#include <microsim/MSVehicleType.h>
#include <microsim/MSStoppingPlace.h>
#include <microsim/devices/MSDevice_Battery.h>
Expand Down Expand Up @@ -72,6 +73,14 @@ MSChargingStation::MSChargingStation(const std::string& chargingStationID, MSLan
}


MSChargingStation::MSChargingStation(const std::string& chargingStationID, const MSParkingArea* parkingArea, const std::string& name, double chargingPower,
double efficency, bool chargeInTransit, SUMOTime chargeDelay, const std::string& chargeType, SUMOTime waitingTime) :
MSChargingStation(chargingStationID, const_cast<MSLane&>(parkingArea->getLane()), parkingArea->getBeginLanePosition(), parkingArea->getEndLanePosition(),
name, chargingPower, efficency, chargeInTransit, chargeDelay, chargeType, waitingTime) {
myParkingArea = parkingArea;
}


MSChargingStation::~MSChargingStation() {
}

Expand Down Expand Up @@ -117,6 +126,11 @@ MSChargingStation::getWaitingTime() const {
}


const MSParkingArea* MSChargingStation::getParkingArea() const {
return myParkingArea;
}


void
MSChargingStation::setChargingVehicle(bool value) {
myChargingVehicle = value;
Expand Down
12 changes: 12 additions & 0 deletions src/microsim/trigger/MSChargingStation.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class MSChargingStation : public MSStoppingPlace {
const std::string& name, double chargingPower, double efficency, bool chargeInTransit,
SUMOTime chargeDelay, const std::string& chargeType, SUMOTime waitingTime);

MSChargingStation(const std::string& chargingStationID, const MSParkingArea* parkingArea, const std::string& name, double chargingPower,
double efficency, bool chargeInTransit, SUMOTime chargeDelay, const std::string& chargeType,
SUMOTime waitingTime);

/// @brief destructor
~MSChargingStation();

Expand All @@ -75,6 +79,11 @@ class MSChargingStation : public MSStoppingPlace {
/// @brief Get waiting time
SUMOTime getWaitingTime() const;

/** @brief Get the parking area the charging station is placed on
* @return pointer to the parking area or nullptr
*/
const MSParkingArea* getParkingArea() const;

/// @brief enable or disable charging vehicle
void setChargingVehicle(bool value);

Expand Down Expand Up @@ -164,6 +173,9 @@ class MSChargingStation : public MSStoppingPlace {
/// @brief total energy charged by this charging station
double myTotalCharge = 0;

/// @brief parkingArea the charging station is placed on
const MSParkingArea* myParkingArea;

/// @brief map with the charges of this charging station (key = vehicleID)
std::map<std::string, std::vector<Charge> > myChargeValues;
/// @brief order vehicles by time of first charge
Expand Down
5 changes: 5 additions & 0 deletions src/netedit/elements/GNEAttributeCarrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1874,6 +1874,11 @@ GNEAttributeCarrier::fillAdditionalElements() {
TL("Waiting time before start charging"),
"900.00");
myTagProperties[currentTag].addAttribute(attrProperty);

attrProperty = GNEAttributeProperties(SUMO_ATTR_PARKINGAREA,

This comment has been minimized.

Copy link
@namdre

namdre Feb 18, 2024

Contributor
GNEAttributeProperties::STRING | GNEAttributeProperties::UPDATEGEOMETRY,
TL("Parking area the charging station is located"));
myTagProperties[currentTag].addAttribute(attrProperty);
}
currentTag = SUMO_TAG_PARKING_AREA;
{
Expand Down
4 changes: 4 additions & 0 deletions src/utils/handlers/AdditionalHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ AdditionalHandler::parseSumoBaseObject(CommonXMLStructure::SumoBaseObject* obj)
obj->getStringAttribute(SUMO_ATTR_CHARGETYPE),
obj->getTimeAttribute(SUMO_ATTR_WAITINGTIME),
obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),
obj->getStringAttribute(SUMO_ATTR_PARKING_AREA),
obj->getParameters());
break;
case SUMO_TAG_PARKING_AREA:
Expand Down Expand Up @@ -867,6 +868,8 @@ AdditionalHandler::parseChargingStationAttributes(const SUMOSAXAttributes& attrs
const std::string chargeType = attrs.getOpt<std::string>(SUMO_ATTR_CHARGETYPE, id.c_str(), parsedOk, "normal");
const SUMOTime waitingTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_WAITINGTIME, id.c_str(), parsedOk, TIME2STEPS(900));
const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);
const std::string parkingAreaID = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, id.c_str(), parsedOk, "");

// check charge type
if ((chargeType != "normal") && (chargeType != "electric") && (chargeType != "fuel")) {
writeError(TLF("Invalid charge type '%' defined in chargingStation '%'.", chargeType, id));
Expand All @@ -890,6 +893,7 @@ AdditionalHandler::parseChargingStationAttributes(const SUMOSAXAttributes& attrs
myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_CHARGETYPE, chargeType);
myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_WAITINGTIME, waitingTime);
myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);
myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_PARKING_AREA, parkingAreaID);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/handlers/AdditionalHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class AdditionalHandler {
virtual void buildChargingStation(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
const double startPos, const double endPos, const std::string& name, const double chargingPower,
const double efficiency, const bool chargeInTransit, const SUMOTime chargeDelay, const std::string& chargeType,
const SUMOTime waitingTime, const bool friendlyPosition,
const SUMOTime waitingTime, const bool friendlyPosition, const std::string& parkingAreaID,
const Parameterised::Map& parameters) = 0;

/**@brief Builds a Parking Area
Expand Down

0 comments on commit 2b0208e

Please sign in to comment.