-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.history.impl;\r
-\r
-import java.util.Map;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.annotations.Identifier;\r
-import org.simantics.databoard.binding.Binding;\r
-import org.simantics.databoard.binding.error.BindingConstructionException;\r
-import org.simantics.databoard.binding.mutable.MutableVariant;\r
-import org.simantics.databoard.binding.reflection.BindingRequest;\r
-import org.simantics.databoard.type.Datatype;\r
-import org.simantics.databoard.util.Bean;\r
-import org.simantics.history.util.MedianBindingProvider;\r
-import org.simantics.history.util.WeightedMedian;\r
-\r
-/**\r
- * This is the state that s persisted.\r
- * \r
- * @author toni.kalajainen\r
- */\r
-public class CollectorState extends Bean {\r
-\r
- public static final Binding BINDING = Bindings.getBindingUnchecked( CollectorState.class );\r
- public static final Binding BINDING_ITEM = Bindings.getBindingUnchecked( CollectorState.Item.class );\r
- \r
- public @Identifier String id;\r
- \r
- /** Last known time value */\r
- public MutableVariant time;\r
-\r
- /** Time stepped between the two last collector steps. Used for time stamp epsilon calculations. */\r
- public double dT = 1.0;\r
-\r
- /** Last known values for each variable */\r
- public Map<String, VariableState> values;\r
- \r
- /** Item states - corresponds to subscription.items */\r
- public Map<String, Item> itemStates;\r
-\r
- public static class VariableState {\r
- \r
- /** The actual value, type is Void is no value */\r
- public MutableVariant value;\r
- \r
- /** Set to true if is valid value */\r
- public boolean isValid; \r
- \r
- /** True, if double or float and is NaN */\r
- public boolean isNan;\r
- }\r
- \r
- public static class Item extends Bean {\r
- \r
- // Subscription info\r
- /** History item reference */\r
- public @Identifier String id;\r
- /** Datasource reference */\r
- public String variableId;\r
- /** Dataformat */\r
- public Datatype format;\r
- /** Deadband */\r
- public double deadband = Double.NaN;\r
- /** Interval */\r
- public double interval = Double.NaN;\r
- /** Gain */\r
- public double gain = 1.0;\r
- /** Bias */\r
- public double bias = 0.0;\r
- /** Enabled */\r
- public boolean enabled = true;\r
- /** Format id, group id */\r
- public String groupId = "", groupItemId = "", formatId = "";\r
- \r
- // - Valueband \r
- /** Time of the first sample in the value band. NAN, if there is no value */\r
- public double firstTime = Double.NaN;\r
- /** Value of the first sample in the value band. null, if there is no value */\r
- public MutableVariant firstValue;\r
- /** Time of the prev added sample. NAN, if there is no value */\r
- public double currentTime;\r
- /** Value of the prev added sample. null, if there is no value */\r
- public MutableVariant currentValue;\r
- /** Current value is NaN */\r
- public boolean isNaN;\r
- /** Current value is valid */\r
- public boolean isValid;\r
- /** Time weighted sum (area), NAN, if not accumulated */\r
- public double sum;\r
- /** Sample Count of acquired samples in current band */\r
- public int count;\r
- /** Out of dead band, set true if a sample has crossed the deadband region in this value band */\r
- public boolean ooDeadband = false;\r
- /** First time after disabled */\r
- public double firstDisabledTime;\r
- /** Last time while disabled*/\r
- public double lastDisabledTime;\r
- /** Is item currently disabled */\r
- public boolean isDisabled;\r
- \r
- /** Median values of the value band */\r
- public WeightedMedian median;\r
- \r
- /**\r
- * Interval is the time between two samples, a step length. \r
- * Distribution contains classification of their variation. It is of \r
- * interest if the datasource contains varying sizes and a mipmap interval \r
- * needs to be decided. Null, if not breakdown is not constructed. \r
- */ \r
- //public @Optional ClassDistribution intervalDistribution;\r
- \r
- /**\r
- * Value distribution contains clasification of values. \r
- */\r
- //public @Optional ClassDistribution valueDistribution;\r
-\r
- }\r
- \r
- public CollectorState() {\r
- super(BINDING);\r
- }\r
- \r
- static {\r
- Bindings.classBindingFactory.addFactory( MedianBindingProvider.INSTANCE );\r
- \r
- try {\r
- BindingRequest br = new BindingRequest( CollectorState.Item.class ); \r
- Binding datatypeBinding = Bindings.getBinding( br );\r
- Bindings.typeClassFactory.getRepository().put(datatypeBinding.type(), br); \r
- \r
- br = new BindingRequest( CollectorState.class ); \r
- datatypeBinding = Bindings.getBinding( br );\r
- Bindings.typeClassFactory.getRepository().put(datatypeBinding.type(), br);\r
- \r
- } catch (BindingConstructionException e) {\r
- System.err.println(e);\r
- }\r
- }\r
- \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.history.impl;
+
+import java.util.Map;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.annotations.Identifier;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.binding.error.BindingConstructionException;
+import org.simantics.databoard.binding.mutable.MutableVariant;
+import org.simantics.databoard.binding.reflection.BindingRequest;
+import org.simantics.databoard.type.Datatype;
+import org.simantics.databoard.util.Bean;
+import org.simantics.history.util.MedianBindingProvider;
+import org.simantics.history.util.WeightedMedian;
+
+/**
+ * This is the state that s persisted.
+ *
+ * @author toni.kalajainen
+ */
+public class CollectorState extends Bean {
+
+ public static final Binding BINDING = Bindings.getBindingUnchecked( CollectorState.class );
+ public static final Binding BINDING_ITEM = Bindings.getBindingUnchecked( CollectorState.Item.class );
+
+ public @Identifier String id;
+
+ /** Last known time value */
+ public MutableVariant time;
+
+ /** Time stepped between the two last collector steps. Used for time stamp epsilon calculations. */
+ public double dT = 1.0;
+
+ /** Last known values for each variable */
+ public Map<String, VariableState> values;
+
+ /** Item states - corresponds to subscription.items */
+ public Map<String, Item> itemStates;
+
+ public static class VariableState {
+
+ /** The actual value, type is Void if no value */
+ public MutableVariant value;
+
+ /** Set to true if is valid value */
+ public boolean isValid;
+
+ /** True, if double or float and is NaN */
+ public boolean isNan;
+ }
+
+ public static class Item extends Bean {
+
+ // Subscription info
+ /** History item reference */
+ public @Identifier String id;
+ /** Datasource reference */
+ public String variableId;
+ /** Dataformat */
+ public Datatype format;
+ /** Deadband */
+ public double deadband = Double.NaN;
+ /** Interval */
+ public double interval = Double.NaN;
+ /** Gain */
+ public double gain = 1.0;
+ /** Bias */
+ public double bias = 0.0;
+ /** Enabled */
+ public boolean enabled = true;
+ /** Format id, group id */
+ public String groupId = "", groupItemId = "", formatId = "";
+
+ // - Valueband
+ /** Time of the first sample in the value band. NAN, if there is no value */
+ public double firstTime = Double.NaN;
+ /** Value of the first sample in the value band. null, if there is no value */
+ public MutableVariant firstValue;
+ /** Time of the prev added sample. NAN, if there is no value */
+ public double currentTime;
+ /** Value of the prev added sample. null, if there is no value */
+ public MutableVariant currentValue;
+ /** Current value is NaN */
+ public boolean isNaN;
+ /** Current value is valid */
+ public boolean isValid;
+ /** Time weighted sum (area), NAN, if not accumulated */
+ public double sum;
+ /** Sample Count of acquired samples in current band */
+ public int count;
+ /** Out of dead band, set true if a sample has crossed the deadband region in this value band */
+ public boolean ooDeadband = false;
+ /** First time after disabled */
+ public double firstDisabledTime;
+ /** Last time while disabled*/
+ public double lastDisabledTime;
+ /** Is item currently disabled */
+ public boolean isDisabled;
+
+ /** Median values of the value band */
+ public WeightedMedian median;
+
+ /**
+ * Interval is the time between two samples, a step length.
+ * Distribution contains classification of their variation. It is of
+ * interest if the datasource contains varying sizes and a mipmap interval
+ * needs to be decided. Null, if not breakdown is not constructed.
+ */
+ //public @Optional ClassDistribution intervalDistribution;
+
+ /**
+ * Value distribution contains clasification of values.
+ */
+ //public @Optional ClassDistribution valueDistribution;
+
+ }
+
+ public CollectorState() {
+ super(BINDING);
+ }
+
+ static {
+ Bindings.classBindingFactory.addFactory( MedianBindingProvider.INSTANCE );
+
+ try {
+ BindingRequest br = new BindingRequest( CollectorState.Item.class );
+ Binding datatypeBinding = Bindings.getBinding( br );
+ Bindings.typeClassFactory.getRepository().put(datatypeBinding.type(), br);
+
+ br = new BindingRequest( CollectorState.class );
+ datatypeBinding = Bindings.getBinding( br );
+ Bindings.typeClassFactory.getRepository().put(datatypeBinding.type(), br);
+
+ } catch (BindingConstructionException e) {
+ System.err.println(e);
+ }
+ }
+
+}