Skip to content

Commit

Permalink
fix #13412
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Jun 21, 2023
1 parent 221b5dc commit 6e9242a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
7 changes: 3 additions & 4 deletions src/microsim/traffic_lights/MSTrafficLightLogic.cpp
Expand Up @@ -264,10 +264,9 @@ MSTrafficLightLogic::init(NLDetectorBuilder&) {
for (MSPhaseDefinition* p : phases) {
if (minor.find(p->getState()[tlu]) != std::string::npos
&& minor.find(p->getState()[tlv]) != std::string::npos) {
WRITE_ERRORF(TL("Program '%' at tlLogic '%' is incompatible with logic at junction '%' (mutual conflict between link indices %,% tl indices %,% phase %).\n"
" Rebuild the network with option '--tls.ignore-internal-junction-jam' or include the program when building."),
getProgramID(), getID(), junction->getID(), u, v, tlu, tlv, phaseIndex);
return;
throw ProcessError(TLF("Program '%' at tlLogic '%' is incompatible with logic at junction '%' (mutual conflict between link indices %,% tl indices %,% phase %).\n"
" Rebuild the network with option '--tls.ignore-internal-junction-jam' or include the program when building.",
getProgramID(), getID(), junction->getID(), u, v, tlu, tlv, phaseIndex));
}
phaseIndex++;
}
Expand Down
2 changes: 2 additions & 0 deletions src/netload/NLBuilder.cpp
Expand Up @@ -220,6 +220,8 @@ NLBuilder::build() {
}
MSTriggeredRerouter::checkParkingRerouteConsistency();
}
// init tls after all detectors have been loaded
myJunctionBuilder.postLoadInitialization();
// declare meandata set by options
buildDefaultMeanData("edgedata-output", "DEFAULT_EDGEDATA", false);
buildDefaultMeanData("lanedata-output", "DEFAULT_LANEDATA", true);
Expand Down
18 changes: 12 additions & 6 deletions src/netload/NLJunctionControlBuilder.cpp
Expand Up @@ -255,7 +255,7 @@ NLJunctionControlBuilder::closeTrafficLightLogic(const std::string& basePath) {
// parameters that are used when initializing a logic will not take
// effect but parameters that are checked at runtime can be used
// here (i.e. device.glosa.range)
existing->updateParameters(myAdditionalParameter);
myLogicParams[existing] = myAdditionalParameter;
return;
}
}
Expand Down Expand Up @@ -336,9 +336,9 @@ NLJunctionControlBuilder::closeTrafficLightLogic(const std::string& basePath) {
if (tlLogic != nullptr) {
if (getTLLogicControlToUse().add(myActiveKey, myActiveProgram, tlLogic)) {
if (myNetIsLoaded) {
tlLogic->init(myDetectorBuilder);
myAdditionalLogics.push_back(tlLogic);
} else {
myLogics2PostLoadInit.push_back(tlLogic);
myNetworkLogics.push_back(tlLogic);
}
} else {
WRITE_ERRORF(TL("Another logic with id '%' and programID '%' exists."), myActiveKey, myActiveProgram);
Expand Down Expand Up @@ -466,11 +466,11 @@ NLJunctionControlBuilder::closeFunction() {

MSTLLogicControl*
NLJunctionControlBuilder::buildTLLogics() {
postLoadInitialization(); // must happen after edgeBuilder is finished
if (!myLogicControl->closeNetworkReading()) {
throw ProcessError(TL("Traffic lights could not be built."));
}
MSTLLogicControl* ret = myLogicControl;
myNetIsLoaded = true;
myLogicControl = nullptr;
return ret;
}
Expand Down Expand Up @@ -506,10 +506,16 @@ NLJunctionControlBuilder::getActiveSubKey() const {

void
NLJunctionControlBuilder::postLoadInitialization() {
for (MSTrafficLightLogic* const logic : myLogics2PostLoadInit) {
for (MSTrafficLightLogic* const logic : myNetworkLogics) {
logic->init(myDetectorBuilder);
}
myNetIsLoaded = true;
for (MSTrafficLightLogic* const logic : myAdditionalLogics) {
logic->init(myDetectorBuilder);
}
// delay parameter loading until initialization
for (auto item : myLogicParams) {
item.first->updateParameters(item.second);
}
}


Expand Down
15 changes: 11 additions & 4 deletions src/netload/NLJunctionControlBuilder.h
Expand Up @@ -259,6 +259,10 @@ class NLJunctionControlBuilder {
return myActivePhases;
}

void netIsLoaded() {
myNetIsLoaded = true;
}

protected:
/// @name Factory methods, virtual so that other versions of the structures can be built
/// @{
Expand Down Expand Up @@ -362,15 +366,17 @@ class NLJunctionControlBuilder {
/// @brief the name of the current junction
std::string myActiveName;

/// @brief Definition of a parameter map (key->value)
typedef Parameterised::Map StringParameterMap;

/// @brief The container for information which junctions shall be initialised using which values
std::vector<MSTrafficLightLogic*> myLogics2PostLoadInit;
std::vector<MSTrafficLightLogic*> myNetworkLogics;
std::vector<MSTrafficLightLogic*> myAdditionalLogics;
std::map<MSTrafficLightLogic*, StringParameterMap> myLogicParams;

/// @brief The tls control to use (0 if net's tls control shall be used)
mutable MSTLLogicControl* myLogicControl;

/// @brief Definition of a parameter map (key->value)
typedef Parameterised::Map StringParameterMap;

/// @brief Parameter map (key->value)
StringParameterMap myAdditionalParameter;

Expand All @@ -389,4 +395,5 @@ class NLJunctionControlBuilder {
/// @brief whether the network has been loaded
bool myNetIsLoaded;


};

0 comments on commit 6e9242a

Please sign in to comment.