From 9c9797a85f01c0a62fab926a2f5f4079b29c052f Mon Sep 17 00:00:00 2001 From: kalajainen Date: Tue, 7 Dec 2010 12:32:39 +0000 Subject: [PATCH] Switch to Databoard 0.6.0 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@18994 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/manager/SysdynResult.java | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) 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 cb2a5789..3acbccc6 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynResult.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynResult.java @@ -30,21 +30,17 @@ import org.simantics.databoard.accessor.binary.BinaryVariant; import org.simantics.databoard.accessor.error.AccessorConstructionException; import org.simantics.databoard.accessor.error.AccessorException; import org.simantics.databoard.accessor.java.JavaRecord; -import org.simantics.databoard.accessor.reference.AccessorReference; -import org.simantics.databoard.accessor.reference.ArrayIndexReference; -import org.simantics.databoard.accessor.reference.FieldNameReference; +import org.simantics.databoard.accessor.reference.ChildReference; +import org.simantics.databoard.accessor.reference.ComponentReference; +import org.simantics.databoard.accessor.reference.IndexReference; import org.simantics.databoard.accessor.reference.KeyReference; -import org.simantics.databoard.accessor.reference.VariantValueReference; -import org.simantics.databoard.annotations.KeyType; -import org.simantics.databoard.annotations.ValueType; +import org.simantics.databoard.accessor.reference.NameReference; +import org.simantics.databoard.annotations.Arguments; import org.simantics.databoard.binding.Binding; import org.simantics.databoard.binding.RecordBinding; import org.simantics.databoard.binding.error.BindingException; -import org.simantics.databoard.binding.java.DoubleBindingDefault; -import org.simantics.databoard.binding.mutable.ImmutableVariantBinding; import org.simantics.databoard.binding.mutable.Variant; -import org.simantics.databoard.serialization.SerializationException; -import org.simantics.databoard.type.DataType; +import org.simantics.databoard.type.Datatype; import org.simantics.modelica.data.DataSet; import org.simantics.modelica.data.SimulationResult; @@ -87,7 +83,7 @@ public class SysdynResult { public void setResult(SimulationResult result) { try { // Create Memory Historian - DataType recordingSessionType = Historian.getRecordingSessionType(); + Datatype recordingSessionType = Historian.getRecordingSessionType(); RecordBinding sessionBinding = (RecordBinding) Bindings.getBinding( recordingSessionType ); RecordBinding recordingBinding = (RecordBinding) Bindings.getBinding( Recording.class ); Object session = sessionBinding.createDefault(); @@ -101,16 +97,16 @@ public class SysdynResult { for(DataSet ds : datasets){ // Add recording to session Recording recording = createRecording(ds); - recordings.put(ImmutableVariantBinding.INSTANCE, recording.nodeId, ImmutableVariantBinding.INSTANCE, new Variant(recordingBinding, recording)); + recordings.put(Bindings.VARIANT, recording.nodeId, Bindings.VARIANT, new Variant(recordingBinding, recording)); } // Add initial values for(DataSet ds : result.getInitialValueDataSets()){ Variant nodeId = Variant.ofInstance( ds.name ); - if (recordings.containsKey(ImmutableVariantBinding.INSTANCE, nodeId)) continue; + if (recordings.containsKey(Bindings.VARIANT, nodeId)) continue; // Add recording to session Recording recording = createRecording(ds); - recordings.put(ImmutableVariantBinding.INSTANCE, recording.nodeId, ImmutableVariantBinding.INSTANCE, new Variant(recordingBinding, recording)); + recordings.put(Bindings.VARIANT, recording.nodeId, Bindings.VARIANT, new Variant(recordingBinding, recording)); } } catch (Exception e) { @@ -158,10 +154,6 @@ public class SysdynResult { Files.createFile(file, binding, value); } catch (IOException e) { e.printStackTrace(); - } catch (SerializationException e) { - e.printStackTrace(); - } catch (BindingException e) { - e.printStackTrace(); } catch (AccessorException e) { e.printStackTrace(); } @@ -170,27 +162,27 @@ public class SysdynResult { public static class Recording { public Variant nodeId; - public @KeyType(String.class) @ValueType(String.class) TreeMap labels; - public @KeyType(Double.class) @ValueType(Double.class) TreeMap[] segments; + public @Arguments({String.class, String.class}) TreeMap labels; + public @Arguments({Double.class, Double.class}) TreeMap[] segments; } public SysdynDataSet getDataSet(String variable) { if(accessor != null) { try { - AccessorReference ref = AccessorReference.compile( - new FieldNameReference("recordings"), - new KeyReference( ImmutableVariantBinding.INSTANCE, Variant.ofInstance(variable) ), - new VariantValueReference(), - new FieldNameReference("segments"), - new ArrayIndexReference(0) + ChildReference ref = ChildReference.compile( + new NameReference("recordings"), + new KeyReference( Bindings.VARIANT, Variant.ofInstance(variable) ), + new ComponentReference(), + new NameReference("segments"), + new IndexReference(0) ); - MapAccessor ma = accessor.getAccessor( ref ); + MapAccessor ma = accessor.getComponent( ref ); int size = ma.size(); Double[] times = new Double[size]; Double[] values = new Double[size]; - ma.getAll(DoubleBindingDefault.INSTANCE, DoubleBindingDefault.INSTANCE, times, values); + ma.getAll(Bindings.DOUBLE, Bindings.DOUBLE, times, values); List times_ = new ArrayList(size); List values_ = new ArrayList(size); -- 2.47.1