Skip to content
Snippets Groups Projects
Commit 98f73145 authored by Tim Übelhör's avatar Tim Übelhör
Browse files

Fixed loading .modeli file (at least for a fresh start)

parent 33b66b74
No related branches found
No related tags found
No related merge requests found
......@@ -125,9 +125,15 @@ namespace ModeliChart.UI
CreateModelInstanceArea(modelInstances);
}
// Cleanup old simulation
try
{
await simulation.Stop();
await dataRepository.ClearAsync();
simulation.Dispose();
}catch(Exception e)
{
ConsoleLogger.WriteLine("MainWindow", "Failed to clean old simulation: " + e.Message);
}
// Replace the simulation
simulation = newSimulation;
dataStorer = new SimulationDataStorer(simulation, dataRepository);
......@@ -624,11 +630,13 @@ namespace ModeliChart.UI
// Swap the simulation only if loading the simulation was successfull
var newSimulation = await workspace.SimulationConfig.LoadSimulationAsync(workspace.ModelRepository);
await ReplaceSimulation(newSimulation);
ConsoleLogger.WriteLine("MainWindow", "Replaced the simulation");
StatusLogger.Progress = 50;
// Reload parameters from workspace
await workspace.ParameterRepository.LoadAsync(simulation,
simulation.ModelInstances.SelectMany(instance => instance.Channels));
StatusLogger.Progress = 70;
ConsoleLogger.WriteLine("MainWindow", "Loaded parametrized channels");
// Create instruments
workspace.UiConfig.LoadConfig(simulation, dataRepository);
foreach (var (AreaTitle, Instruments) in workspace.UiConfig.InstrumentAreas)
......@@ -636,6 +644,7 @@ namespace ModeliChart.UI
AddInstrumentArea(new InstrumentArea(AreaTitle, Instruments));
}
StatusLogger.Progress = 90;
ConsoleLogger.WriteLine("MainWindow", "Updated instruments");
// Load time values
// TODO use properties
ribTxtSimInterval.TextBoxText = (1.0 / simulation.GetStepSize()).ToString();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment