From 94f6888c24dbcae9f6bfa16044114aae5ea37f59 Mon Sep 17 00:00:00 2001 From: miettinen Date: Mon, 10 Dec 2012 09:07:47 +0000 Subject: [PATCH] Optimized simulation result read: Fixing results saving bug (refs #3709) git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@26515 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../modelica/data/SimulationResult.java | 24 +++++++++++++++++++ .../sysdyn/manager/SysdynResult.java | 3 +++ 2 files changed, 27 insertions(+) diff --git a/org.simantics.modelica/src/org/simantics/modelica/data/SimulationResult.java b/org.simantics.modelica/src/org/simantics/modelica/data/SimulationResult.java index 35537877..33846537 100644 --- a/org.simantics.modelica/src/org/simantics/modelica/data/SimulationResult.java +++ b/org.simantics.modelica/src/org/simantics/modelica/data/SimulationResult.java @@ -453,6 +453,30 @@ public class SimulationResult { variables.add(ds); } } + + /** + * Read a all missing variable from the result file + * + * @param file result file + * @throws FileNotFoundException + * @throws IOException + */ + public void readMissingVariables(File file) throws FileNotFoundException, IOException { + List names = resultFileReader.getNames(); + for (String variable : names) { + boolean matchFound = false; + for (DataSet tempDs : variables) { + if (tempDs.name.equals(variable)) { + matchFound = true; + break; + } + } + if (matchFound) { + continue; + } + readVariable(variable, file); + } + } /** * Read time array from result file diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynResult.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynResult.java index 7a1b29c9..6dc7ee86 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynResult.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynResult.java @@ -256,6 +256,9 @@ public class SysdynResult { binding = Bindings.getBinding( accessor.type() ); value = accessor.getValue(binding); } + // Read the missing variables one by one. + simulationResult.readMissingVariables(this.resultFile); + addAllDataSets(progressMonitor); // Write to file if (progressMonitor != null) { -- 2.47.1