]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Switch to Databoard 0.6.0
authorkalajainen <kalajainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 7 Dec 2010 12:32:39 +0000 (12:32 +0000)
committerkalajainen <kalajainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 7 Dec 2010 12:32:39 +0000 (12:32 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@18994 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynResult.java

index cb2a57895a800427ba4b6832cfc54041ebfb99ed..3acbccc63e2a40962ea0b89d3016718682cf1a38 100644 (file)
@@ -30,21 +30,17 @@ import org.simantics.databoard.accessor.binary.BinaryVariant;
 import org.simantics.databoard.accessor.error.AccessorConstructionException;\r
 import org.simantics.databoard.accessor.error.AccessorException;\r
 import org.simantics.databoard.accessor.java.JavaRecord;\r
-import org.simantics.databoard.accessor.reference.AccessorReference;\r
-import org.simantics.databoard.accessor.reference.ArrayIndexReference;\r
-import org.simantics.databoard.accessor.reference.FieldNameReference;\r
+import org.simantics.databoard.accessor.reference.ChildReference;\r
+import org.simantics.databoard.accessor.reference.ComponentReference;\r
+import org.simantics.databoard.accessor.reference.IndexReference;\r
 import org.simantics.databoard.accessor.reference.KeyReference;\r
-import org.simantics.databoard.accessor.reference.VariantValueReference;\r
-import org.simantics.databoard.annotations.KeyType;\r
-import org.simantics.databoard.annotations.ValueType;\r
+import org.simantics.databoard.accessor.reference.NameReference;\r
+import org.simantics.databoard.annotations.Arguments;\r
 import org.simantics.databoard.binding.Binding;\r
 import org.simantics.databoard.binding.RecordBinding;\r
 import org.simantics.databoard.binding.error.BindingException;\r
-import org.simantics.databoard.binding.java.DoubleBindingDefault;\r
-import org.simantics.databoard.binding.mutable.ImmutableVariantBinding;\r
 import org.simantics.databoard.binding.mutable.Variant;\r
-import org.simantics.databoard.serialization.SerializationException;\r
-import org.simantics.databoard.type.DataType;\r
+import org.simantics.databoard.type.Datatype;\r
 import org.simantics.modelica.data.DataSet;\r
 import org.simantics.modelica.data.SimulationResult;\r
 \r
@@ -87,7 +83,7 @@ public class SysdynResult {
     public void setResult(SimulationResult result) {\r
         try {\r
             // Create Memory Historian\r
-            DataType recordingSessionType = Historian.getRecordingSessionType();\r
+            Datatype recordingSessionType = Historian.getRecordingSessionType();\r
             RecordBinding sessionBinding = (RecordBinding) Bindings.getBinding( recordingSessionType );\r
             RecordBinding recordingBinding = (RecordBinding) Bindings.getBinding( Recording.class );\r
             Object session = sessionBinding.createDefault();  \r
@@ -101,16 +97,16 @@ public class SysdynResult {
             for(DataSet ds : datasets){\r
                 // Add recording to session\r
                 Recording recording = createRecording(ds);\r
-                recordings.put(ImmutableVariantBinding.INSTANCE, recording.nodeId, ImmutableVariantBinding.INSTANCE, new Variant(recordingBinding, recording));\r
+                recordings.put(Bindings.VARIANT, recording.nodeId, Bindings.VARIANT, new Variant(recordingBinding, recording));\r
             }\r
 \r
             // Add initial values\r
             for(DataSet ds : result.getInitialValueDataSets()){\r
                 Variant nodeId = Variant.ofInstance( ds.name );\r
-                if (recordings.containsKey(ImmutableVariantBinding.INSTANCE, nodeId)) continue;\r
+                if (recordings.containsKey(Bindings.VARIANT, nodeId)) continue;\r
                 // Add recording to session\r
                 Recording recording = createRecording(ds);\r
-                recordings.put(ImmutableVariantBinding.INSTANCE, recording.nodeId, ImmutableVariantBinding.INSTANCE, new Variant(recordingBinding, recording));\r
+                recordings.put(Bindings.VARIANT, recording.nodeId, Bindings.VARIANT, new Variant(recordingBinding, recording));\r
             }\r
 \r
         } catch (Exception e) {\r
@@ -158,10 +154,6 @@ public class SysdynResult {
             Files.createFile(file, binding, value);\r
         } catch (IOException e) {\r
             e.printStackTrace();\r
-        } catch (SerializationException e) {\r
-            e.printStackTrace();\r
-        } catch (BindingException e) {\r
-            e.printStackTrace();\r
         } catch (AccessorException e) {\r
             e.printStackTrace();\r
         }\r
@@ -170,27 +162,27 @@ public class SysdynResult {
 \r
     public static class Recording {\r
         public Variant nodeId;\r
-        public @KeyType(String.class) @ValueType(String.class) TreeMap<String, String> labels;\r
-        public @KeyType(Double.class) @ValueType(Double.class) TreeMap<Double, Double>[] segments;\r
+        public @Arguments({String.class, String.class}) TreeMap<String, String> labels;\r
+        public @Arguments({Double.class, Double.class}) TreeMap<Double, Double>[] segments;\r
     }\r
 \r
     public SysdynDataSet getDataSet(String variable) {\r
         if(accessor != null) {\r
             try {\r
-                AccessorReference ref = AccessorReference.compile(\r
-                        new FieldNameReference("recordings"),\r
-                        new KeyReference( ImmutableVariantBinding.INSTANCE, Variant.ofInstance(variable) ),\r
-                        new VariantValueReference(),\r
-                        new FieldNameReference("segments"),\r
-                        new ArrayIndexReference(0)\r
+                ChildReference ref = ChildReference.compile(\r
+                        new NameReference("recordings"),\r
+                        new KeyReference( Bindings.VARIANT, Variant.ofInstance(variable) ),\r
+                        new ComponentReference(),\r
+                        new NameReference("segments"),\r
+                        new IndexReference(0)\r
                 );\r
 \r
-                MapAccessor ma = accessor.getAccessor( ref );\r
+                MapAccessor ma = accessor.getComponent( ref );\r
                 int size = ma.size();\r
                 Double[] times = new Double[size];\r
                 Double[] values = new Double[size];\r
 \r
-                ma.getAll(DoubleBindingDefault.INSTANCE, DoubleBindingDefault.INSTANCE, times, values);\r
+                ma.getAll(Bindings.DOUBLE, Bindings.DOUBLE, times, values);\r
 \r
                 List<Double> times_ = new ArrayList<Double>(size);\r
                 List<Double> values_ = new ArrayList<Double>(size);\r