Skip to content

Commit

Permalink
Merge pull request #377 from rl-institut/fix/multiple_simulations_by_…
Browse files Browse the repository at this point in the history
…user

Improve oemof simulation runs
  • Loading branch information
nesnoj authored Oct 6, 2023
2 parents 2385103 + ddb39d3 commit 8a15027
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project tries to adhere to [Semantic Versioning](https://semver.org/spe

### Changed
- Remove locale EN
- Abort simulation run when switching to settings tab

### Fixed
- various fixes in charts, texts and units
Expand Down
16 changes: 16 additions & 0 deletions digiplan/static/js/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ PubSub.subscribe(eventTopics.MENU_STATUS_QUO_SELECTED, hidePotentialLayers);
PubSub.subscribe(eventTopics.MENU_SETTINGS_SELECTED, setMapChartViewVisibility);
PubSub.subscribe(eventTopics.MENU_SETTINGS_SELECTED, showMapView);
PubSub.subscribe(eventTopics.MENU_SETTINGS_SELECTED, deactivateChoropleth);
PubSub.subscribe(eventTopics.MENU_SETTINGS_SELECTED, terminateSimulation);
PubSub.subscribe(eventTopics.MENU_RESULTS_SELECTED, setMapChartViewVisibility);
PubSub.subscribe(eventTopics.MENU_RESULTS_SELECTED, hidePotentialLayers);
PubSub.subscribe(eventTopics.MAP_VIEW_SELECTED, setResultsView);
Expand Down Expand Up @@ -103,3 +104,18 @@ function setResultsView(msg) {
}
return logMessage(msg);
}

function terminateSimulation(msg) {
if (store.cold.task_id != null) {
$.ajax({
url: "/oemof/terminate",
type: "POST",
data: {task_id: store.cold.task_id},
success: function () {
store.cold.task_id = null;
}
});
document.getElementById("simulation_spinner").hidden = true;
}
return logMessage(msg);
}
10 changes: 8 additions & 2 deletions digiplan/static/js/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ futureDropdown.addEventListener("change", function() {
PubSub.subscribe(eventTopics.MENU_RESULTS_SELECTED, simulate);
PubSub.subscribe(eventTopics.MENU_RESULTS_SELECTED, showSimulationSpinner);
PubSub.subscribe(eventTopics.SIMULATION_STARTED, checkResultsPeriodically);
// PubSub.subscribe(eventTopics.SIMULATION_STARTED, hideResultButtons);
// PubSub.subscribe(eventTopics.SIMULATION_FINISHED, showResultButtons);
PubSub.subscribe(eventTopics.SIMULATION_FINISHED, showResults);
PubSub.subscribe(eventTopics.SIMULATION_FINISHED, hideSimulationSpinner);
PubSub.subscribe(eventTopics.SIMULATION_FINISHED, showResultCharts);
Expand All @@ -63,6 +61,9 @@ function simulate(msg) {
url : "/oemof/terminate",
type : "POST",
data : {task_id: store.cold.task_id},
success: function() {
store.cold.task_id = null;
}
});
}
$.ajax({
Expand Down Expand Up @@ -97,6 +98,11 @@ function checkResults() {
map_store.cold.state.simulation_id = json.simulation_id;
PubSub.publish(eventTopics.SIMULATION_FINISHED);
}
},
error: function(json) {
store.cold.task_id = null;
map_store.cold.state.simulation_id = null;
PubSub.publish(eventTopics.SIMULATION_FINISHED);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8a15027

Please sign in to comment.