Skip to content

Commit

Permalink
fix #7454
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Aug 25, 2020
1 parent 60c8221 commit 0d83f7e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/libsumo/Simulation.cpp
Expand Up @@ -702,6 +702,7 @@ Simulation::loadState(const std::string& fileName) {
if (MsgHandler::getErrorInstance()->wasInformed()) {
throw TraCIException("Loading state from '" + fileName + "' failed.");
}
Helper::clearVehicleStates();
PROGRESS_TIME_MESSAGE(before);
return STEPS2TIME(newTime);
}
Expand Down
2 changes: 1 addition & 1 deletion src/netload/NLBuilder.cpp
Expand Up @@ -220,7 +220,7 @@ NLBuilder::build() {
if (myOptions.isDefault("begin")) {
myOptions.set("begin", time2string(h.getTime()));
if (TraCIServer::getInstance() != nullptr) {
TraCIServer::getInstance()->setTargetTime(h.getTime());
TraCIServer::getInstance()->stateLoaded(h.getTime());
}
}
if (MsgHandler::getErrorInstance()->wasInformed()) {
Expand Down
5 changes: 4 additions & 1 deletion src/traci-server/TraCIServer.cpp
Expand Up @@ -1558,10 +1558,13 @@ TraCIServer::readTypeCheckingPolygon(tcpip::Storage& inputStorage, PositionVecto


void
TraCIServer::setTargetTime(SUMOTime targetTime) {
TraCIServer::stateLoaded(SUMOTime targetTime) {
myTargetTime = targetTime;
for (auto& s : mySockets) {
s.second->targetTime = targetTime;
for (auto& stateChange : s.second->vehicleStateChanges) {
stateChange.second.clear();
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/traci-server/TraCIServer.h
Expand Up @@ -239,9 +239,9 @@ class TraCIServer final : public MSNet::VehicleStateListener, public libsumo::Va
/// @}


/// @brief Sets myTargetTime on server and sockets to the given value
/// @brief updates myTargetTime and resets vehicle state changes after loading a simulation state
/// @note Used in MSStateHandler to update the server's time after loading a state
void setTargetTime(SUMOTime targetTime);
void stateLoaded(SUMOTime targetTime);

std::vector<std::string>& getLoadArgs() {
return myLoadArgs;
Expand Down
2 changes: 1 addition & 1 deletion src/traci-server/TraCIServerAPI_Simulation.cpp
Expand Up @@ -344,7 +344,7 @@ TraCIServerAPI_Simulation::processSet(TraCIServer& server, tcpip::Storage& input
return server.writeErrorStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, "A string is needed for loading simulation state.", outputStorage);
}
double time = libsumo::Simulation::loadState(file);
TraCIServer::getInstance()->setTargetTime(TIME2STEPS(time));
TraCIServer::getInstance()->stateLoaded(TIME2STEPS(time));
}
break;
case libsumo::CMD_MESSAGE: {
Expand Down

0 comments on commit 0d83f7e

Please sign in to comment.