Skip to content

Commit

Permalink
merging branch 7578 into main refs #7578
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Oct 17, 2024
2 parents 40d747d + aca9409 commit 699e3c2
Show file tree
Hide file tree
Showing 1,019 changed files with 44,635 additions and 3,640 deletions.
7 changes: 7 additions & 0 deletions data/xsd/additional_file.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<xsd:element name="calibrator" type="calibratorType" minOccurs="0"/>
<xsd:element name="vaporizer" type="vaporizerType" minOccurs="0"/>
<xsd:element name="railSignalConstraints" type="railSignalConstraintsType" minOccurs="0"/>
<xsd:element name="deadlock" type="deadlockType" minOccurs="0"/>

<xsd:element name="vTypeDistribution" type="vTypeDistributionType" minOccurs="0"/>
<xsd:element name="routeDistribution" type="routeDistributionType" minOccurs="0"/>
Expand Down Expand Up @@ -614,6 +615,12 @@
<xsd:attribute name="active" use="optional" type="boolType"/>
</xsd:complexType>

<xsd:complexType name="deadlockType">
<xsd:attribute name="time" type="timeType" use="optional"/>
<xsd:attribute name="vehicles" type="xsd:string" use="optional"/>
<xsd:attribute name="signals" type="xsd:string" use="required"/>
</xsd:complexType>

<xsd:complexType name="polygonType">
<xsd:sequence>
<xsd:element name="param" type="paramType" minOccurs="0" maxOccurs="unbounded"/>
Expand Down
9 changes: 9 additions & 0 deletions data/xsd/state_file.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
<xsd:element name="railSignalConstraintTracker" type="railSignalConstraintTrackerType" minOccurs="0"/>
<xsd:element name="railSignalConstraints" type="railSignalConstraintsType" minOccurs="0"/>
<xsd:element name="tlLogic" type="tlStateType" minOccurs="0"/>
<xsd:element name="driveWay" type="driveWayStateType" minOccurs="0"/>
<xsd:element name="subDriveWay" type="driveWayStateType" minOccurs="0"/>
</xsd:choice>
<xsd:attribute name="version" type="xsd:string"/>
<xsd:attribute name="time" type="timeType"/>
<xsd:attribute name="type" type="xsd:string"/>
<xsd:attribute name="constraints" type="boolType"/>
<xsd:attribute name="rail" type="boolType"/>
</xsd:complexType>
</xsd:element>

Expand Down Expand Up @@ -232,4 +235,10 @@
<xsd:attribute name="duration" type="xsd:integer" use="required"/>
</xsd:complexType>

<xsd:complexType name="driveWayStateType">
<xsd:attribute name="id" type="idType" use="required"/>
<xsd:attribute name="edges" type="xsd:string" use="required"/>
<xsd:attribute name="vehicles" type="xsd:string" use="required"/>
</xsd:complexType>

</xsd:schema>
2 changes: 2 additions & 0 deletions src/guisim/GUITrafficLightLogicWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ GUITrafficLightLogicWrapper::getParameterWindow(GUIMainWindow& app,
ret->mkItem(TL("cycle time"), true, new FunctionBinding<GUITrafficLightLogicWrapper, int>(this, &GUITrafficLightLogicWrapper::getDefaultCycleTimeSeconds));
MSRailSignal* rs = dynamic_cast<MSRailSignal*>(&myTLLogic);
if (rs != nullptr) {
ret->mkItem(TL("req driveway"), true, new FunctionBindingString<MSRailSignal>(rs, &MSRailSignal::getRequestedDriveWay));
ret->mkItem(TL("blocking"), true, new FunctionBindingString<MSRailSignal>(rs, &MSRailSignal::getBlockingVehicleIDs));
ret->mkItem(TL("blocking driveways"), true, new FunctionBindingString<MSRailSignal>(rs, &MSRailSignal::getBlockingDriveWayIDs));
ret->mkItem(TL("rival"), true, new FunctionBindingString<MSRailSignal>(rs, &MSRailSignal::getRivalVehicleIDs));
ret->mkItem(TL("priority"), true, new FunctionBindingString<MSRailSignal>(rs, &MSRailSignal::getPriorityVehicleIDs));
ret->mkItem(TL("constraint"), true, new FunctionBindingString<MSRailSignal>(rs, &MSRailSignal::getConstraintInfo));
Expand Down
17 changes: 17 additions & 0 deletions src/guisim/GUIVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include <microsim/devices/MSDevice_BTreceiver.h>
#include <microsim/devices/MSDevice_ElecHybrid.h>
#include <microsim/devices/MSDevice_Battery.h>
#include <microsim/traffic_lights/MSDriveWay.h>
#include <gui/GUIApplicationWindow.h>
#include <gui/GUIGlobals.h>
#include "GUIVehicle.h"
Expand Down Expand Up @@ -193,6 +194,9 @@ GUIVehicle::getParameterWindow(GUIMainWindow& app,
ret->mkItem(TL("leftmost edge sublane [#]"), true, new FunctionBinding<GUIVehicle, int>(this, &GUIVehicle::getLeftSublaneOnEdge));
ret->mkItem(TL("lane change maneuver distance [m]"), true, new FunctionBinding<GUIVehicle, double>(this, &GUIVehicle::getManeuverDist));
}
if (isRailway(getVClass())) {
ret->mkItem(TL("driveways"), true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getDriveWays));
}
if (hasBattery || isElecHybrid) {
ret->mkItem(TL("present state of charge [Wh]"), true,
new FunctionBinding<GUIVehicle, double>(this, &MSVehicle::getStateOfCharge));
Expand Down Expand Up @@ -950,6 +954,19 @@ GUIVehicle::getTargetLaneID() const {
return Named::getIDSecure(getLaneChangeModel().getTargetLane(), "");
}


std::string
GUIVehicle::getDriveWays() const {
std::vector<std::string> result;
for (auto item : myMoveReminders) {
const MSDriveWay* dw = dynamic_cast<const MSDriveWay*>(item.first);
if (dw) {
result.push_back(dw->getID());
}
}
return joinToStringSorting(result, " ");
}

double
GUIVehicle::getManeuverDist() const {
return getLaneChangeModel().getManeuverDist();
Expand Down
2 changes: 2 additions & 0 deletions src/guisim/GUIVehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ class GUIVehicle : public MSVehicle, public GUIBaseVehicle {
std::string getShadowLaneID() const;
std::string getTargetLaneID() const;

std::string getDriveWays() const;

/// @brief return the lane-change maneuver distance
double getManeuverDist() const;
/// @brief return the speed mode as bit string
Expand Down
4 changes: 4 additions & 0 deletions src/mesosim/MEVehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class MEVehicle : public MSBaseVehicle {
return nullptr;
}

const MSLane* getBackLane() const {
return nullptr;
}

/** @brief Return current position (x/y, cartesian)
*
* If the vehicle's myLane is 0, Position::INVALID.
Expand Down
4 changes: 4 additions & 0 deletions src/microsim/MSBaseVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <microsim/transportables/MSStageDriving.h>
#include <microsim/trigger/MSChargingStation.h>
#include <microsim/trigger/MSStoppingPlaceRerouter.h>
#include <microsim/traffic_lights/MSRailSignalConstraint.h>
#include "MSGlobals.h"
#include "MSVehicleControl.h"
#include "MSVehicleType.h"
Expand Down Expand Up @@ -1426,6 +1427,9 @@ MSBaseVehicle::addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& e
}
setSkips(stop, (int)myStops.size());
myStops.insert(iter, stop);
if (stopPar.tripId != "") {
MSRailSignalConstraint::storeTripId(stopPar.tripId, getID());
}
//std::cout << " added stop " << errorMsgStart << " totalStops=" << myStops.size() << " searchStart=" << (*searchStart - myRoute->begin())
// << " routeIndex=" << (stop.edge - myRoute->begin())
// << " stopIndex=" << std::distance(myStops.begin(), iter)
Expand Down
19 changes: 19 additions & 0 deletions src/microsim/MSFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ MSFrame::fillOptions() {
oc.doRegister("railsignal-block-output", new Option_FileName());
oc.addDescription("railsignal-block-output", "Output", TL("Save railsignal-blocks into FILE"));

oc.doRegister("railsignal-vehicle-output", new Option_FileName());
oc.addDescription("railsignal-vehicle-output", "Output", TL("Record entry and exit times of vehicles for railsignal blocks into FILE"));

oc.doRegister("bt-output", new Option_FileName());
oc.addDescription("bt-output", "Output", TL("Save bluetooth visibilities into FILE (in conjunction with device.btreceiver and device.btsender)"));

Expand Down Expand Up @@ -314,6 +317,9 @@ MSFrame::fillOptions() {
oc.addSynonyme("statistic-output", "statistics-output");
oc.addDescription("statistic-output", "Output", TL("Write overall statistics into FILE"));

oc.doRegister("deadlock-output", new Option_FileName());
oc.addDescription("deadlock-output", "Output", TL("Write reports on deadlocks FILE"));

#ifdef _DEBUG
oc.doRegister("movereminder-output", new Option_FileName());
oc.addDescription("movereminder-output", "Output", TL("Save movereminder states of selected vehicles into FILE"));
Expand Down Expand Up @@ -434,12 +440,18 @@ MSFrame::fillOptions() {
oc.doRegister("time-to-teleport.remove", new Option_Bool(false));
oc.addDescription("time-to-teleport.remove", "Processing", TL("Whether vehicles shall be removed after waiting too long instead of being teleported"));

oc.doRegister("time-to-teleport.remove-constraint", new Option_Bool(false));
oc.addDescription("time-to-teleport.remove-constraint", "Processing", TL("Whether rail-signal-constraint based deadlocks shall be cleared by removing a constraint"));

oc.doRegister("time-to-teleport.ride", new Option_String("-1", "TIME"));
oc.addDescription("time-to-teleport.ride", "Processing", TL("The waiting time after which persons / containers waiting for a pickup are teleported. Negative values disable teleporting"));

oc.doRegister("time-to-teleport.bidi", new Option_String("-1", "TIME"));
oc.addDescription("time-to-teleport.bidi", "Processing", TL("The waiting time after which vehicles on bidirectional edges are teleported"));

oc.doRegister("time-to-teleport.railsignal-deadlock", new Option_String("-1", "TIME"));
oc.addDescription("time-to-teleport.railsignal-deadlock", "Processing", TL("The waiting time after which vehicles in a rail-signal based deadlock are teleported"));

oc.doRegister("waiting-time-memory", new Option_String("100", "TIME"));
oc.addDescription("waiting-time-memory", "Processing", TL("Length of time interval, over which accumulated waiting time is taken into account (default is 100s.)"));

Expand All @@ -458,6 +470,9 @@ MSFrame::fillOptions() {
oc.doRegister("emergency-insert", new Option_Bool(false));
oc.addDescription("emergency-insert", "Processing", TL("Allow inserting a vehicle in a situation which requires emergency braking"));

oc.doRegister("insertion-checks", new Option_String("all"));
oc.addDescription("insertion-checks", "Processing", TL("Override default value for vehicle attribute insertionChecks"));

oc.doRegister("random-depart-offset", new Option_String("0", "TIME"));
oc.addDescription("random-depart-offset", "Processing", TL("Each vehicle receives a random offset to its depart value drawn uniformly from [0, TIME]"));

Expand Down Expand Up @@ -838,11 +853,13 @@ MSFrame::buildStreams() {
//OutputDevice::createDeviceByOption("vtk-output", "vtk-export");
OutputDevice::createDeviceByOption("link-output", "link-output");
OutputDevice::createDeviceByOption("railsignal-block-output", "railsignal-block-output");
OutputDevice::createDeviceByOption("railsignal-vehicle-output", "railsignal-vehicle-output");
OutputDevice::createDeviceByOption("bt-output", "bt-output");
OutputDevice::createDeviceByOption("lanechange-output", "lanechanges");
OutputDevice::createDeviceByOption("stop-output", "stops", "stopinfo_file.xsd");
OutputDevice::createDeviceByOption("collision-output", "collisions", "collision_file.xsd");
OutputDevice::createDeviceByOption("statistic-output", "statistics", "statistic_file.xsd");
OutputDevice::createDeviceByOption("deadlock-output", "additional", "additional_file.xsd");

#ifdef _DEBUG
OutputDevice::createDeviceByOption("movereminder-output", "movereminder-output");
Expand Down Expand Up @@ -1079,6 +1096,7 @@ MSFrame::setMSGlobals(OptionsCont& oc) {
MSGlobals::gGridlockHighwaysSpeed = oc.getFloat("time-to-teleport.highways.min-speed");
MSGlobals::gTimeToTeleportDisconnected = string2time(oc.getString("time-to-teleport.disconnected"));
MSGlobals::gTimeToTeleportBidi = string2time(oc.getString("time-to-teleport.bidi"));
MSGlobals::gTimeToTeleportRSDeadlock = string2time(oc.getString("time-to-teleport.railsignal-deadlock"));
MSGlobals::gRemoveGridlocked = oc.getBool("time-to-teleport.remove");
MSGlobals::gCheck4Accidents = !oc.getBool("ignore-accidents");
MSGlobals::gCheckRoutes = !oc.getBool("ignore-route-errors");
Expand All @@ -1099,6 +1117,7 @@ MSFrame::setMSGlobals(OptionsCont& oc) {
MSGlobals::gOverheadWireSolver = oc.getBool("overhead-wire.solver");
MSGlobals::gOverheadWireRecuperation = oc.getBool("overhead-wire.recuperation");
MSGlobals::gOverheadWireCurrentLimits = oc.getBool("overhead-wire.substation-current-limits");
MSGlobals::gInsertionChecks = SUMOVehicleParameter::parseInsertionChecks(oc.getString("insertion-checks"));

MSLane::initCollisionOptions(oc);

Expand Down
3 changes: 3 additions & 0 deletions src/microsim/MSGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ SUMOTime MSGlobals::gTimeToGridlockHighways;
double MSGlobals::gGridlockHighwaysSpeed;
SUMOTime MSGlobals::gTimeToTeleportDisconnected;
SUMOTime MSGlobals::gTimeToTeleportBidi;
SUMOTime MSGlobals::gTimeToTeleportRSDeadlock;
bool MSGlobals::gRemoveGridlocked;

SUMOTime MSGlobals::gTimeToImpatience;
Expand Down Expand Up @@ -100,4 +101,6 @@ SUMOTime MSGlobals::gStartupWaitThreshold(0);

bool MSGlobals::gHaveEmissions(false);

int MSGlobals::gInsertionChecks(0);

/****************************************************************************/
6 changes: 6 additions & 0 deletions src/microsim/MSGlobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class MSGlobals {
/** The time to wait for teleport on bidi edges */
static SUMOTime gTimeToTeleportBidi;

/** The time to wait for teleport when rail signals cause deadlock */
static SUMOTime gTimeToTeleportRSDeadlock;

/** Whether gridlocked vehicles shall be removed instead of teleporting */
static bool gRemoveGridlocked;

Expand Down Expand Up @@ -178,4 +181,7 @@ class MSGlobals {

/// @brief Whether emission output of some type is needed (files or GUI)
static bool gHaveEmissions;

/// @brief The default value for insertion checks
static int gInsertionChecks;
};
2 changes: 1 addition & 1 deletion src/microsim/MSInsertionControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ MSInsertionControl::tryInsert(SUMOTime time, SUMOVehicle* veh,
return 1;
}
if ((myMaxVehicleNumber < 0 || (int)MSNet::getInstance()->getVehicleControl().getRunningVehicleNo() < myMaxVehicleNumber)
&& edge.insertVehicle(*veh, time, false, myEagerInsertionCheck)) {
&& edge.insertVehicle(*veh, time, false, myEagerInsertionCheck || veh->getParameter().departProcedure == DepartDefinition::SPLIT)) {
// Successful insertion
return 1;
}
Expand Down
Loading

0 comments on commit 699e3c2

Please sign in to comment.