]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Fixed history datasets to display values in the case where dataset contains "Variable...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 24 Oct 2013 11:28:55 +0000 (11:28 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 24 Oct 2013 11:28:55 +0000 (11:28 +0000)
refs #4494

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28114 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ActiveDatasetsIndexVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/HistoryDatasetResult.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/MemoryResult.java

index c8df2821029a3a3ef17122f868105eecf3b5c47f..176fd467d99f2dc10721c9f371b7c1aab4f05d3c 100644 (file)
@@ -33,7 +33,25 @@ public class ActiveDatasetsIndexVariable extends IndexVariable< ArrayList<DataSe
                    for(SysdynResult result : results) {\r
                        SysdynDataSet ds = result.getDataSet(variableNamesWithIndexes.get(i));\r
                        if(ds != null) {\r
-                           ds.name = variableNames.get(i);\r
+                           \r
+                           /* Change the name if necessary\r
+                            Name needs to be changed if it contains indexes. Dataset names\r
+                            contains indexes as numbers, asked names as index names.\r
+                            \r
+                            There are cases where dataset names could actually be different \r
+                            from asked names. HistoryDatasets are one example. In that case, show the \r
+                            datasetname.\r
+                            */\r
+                           String askedName = variableNames.get(i);\r
+                           if(askedName.contains("["))\r
+                               askedName = askedName.substring(0, askedName.indexOf("["));\r
+                           String datasetname = ds.name;\r
+                           if(datasetname.contains("["))\r
+                               datasetname = datasetname.substring(0, datasetname.indexOf("["));\r
+                           \r
+                           if(askedName.equals(datasetname))\r
+                               ds.name = askedName;\r
+                           \r
                            datasets.add(ds);\r
                        }\r
                    }\r
index 700ae07a66a652582d5ced7e36b364d0b85329e1..a4963b8bd4aacbc128182eb3790366999734e0d6 100644 (file)
@@ -308,4 +308,14 @@ public class HistoryDatasetResult extends SimulationResult {
         }\r
         return value;\r
     }\r
+\r
+    @Override\r
+    public DataSet getDataSet(String name) {\r
+        DataSet ds = super.getDataSet(name);\r
+        if(ds == null && name.contains(".")) {\r
+            ds = super.getDataSet(name.substring(name.lastIndexOf(".") + 1));\r
+        }\r
+        return ds;\r
+    }\r
+\r
 }\r
index 774d404bd8d26797d4a20741de3b3989036b8125..ded4dd63f56e60ef157455d2fab75f27962a51cd 100644 (file)
@@ -53,10 +53,11 @@ public class MemoryResult extends SysdynResult {
     public MemoryResult(SimulationResult result, String resultName) {\r
         super(resultName);\r
         \r
+        results = new THashMap<String, SysdynDataSet>();\r
+\r
         if(result != null)\r
             setResult(result);\r
         \r
-        results = new THashMap<String, SysdynDataSet>();\r
     }\r
     \r
     @Override\r
@@ -75,7 +76,7 @@ public class MemoryResult extends SysdynResult {
                     ds = simulationResult.readVariable(variable, resultFile);\r
 \r
                 if(ds != null) {\r
-                    SysdynDataSet sds = new SysdynDataSet(variable, getResultName(), ds.times, ds.values, resultIndex);\r
+                    SysdynDataSet sds = new SysdynDataSet(ds.name, getResultName(), ds.times, ds.values, resultIndex);\r
                     results.put(variable, sds);\r
                     return sds;\r
                 }\r