X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.history%2Fsrc%2Forg%2Fsimantics%2Fhistory%2Fimpl%2FCollectorImpl.java;h=87062a9dabecae759aa0f5dffd442a496af156e5;hp=d6dd6d9b33f19baf7bca38f773d99f9530508f6e;hb=fee871302ad4c53ca2c2307bd13366d99116d930;hpb=3f4efcd9edf8d1ba3a1bb8c842900cca1e6d30f3 diff --git a/bundles/org.simantics.history/src/org/simantics/history/impl/CollectorImpl.java b/bundles/org.simantics.history/src/org/simantics/history/impl/CollectorImpl.java index d6dd6d9b3..87062a9da 100644 --- a/bundles/org.simantics.history/src/org/simantics/history/impl/CollectorImpl.java +++ b/bundles/org.simantics.history/src/org/simantics/history/impl/CollectorImpl.java @@ -811,7 +811,7 @@ public class CollectorImpl implements Collector { boolean condition = makeNewBand || (!i.hasEndTime && i.itemState.count==2); - if(i.stream.size() > 0 ) { //!i.itemState.ooDeadband) { + if (i.stream.size() > 0) { /// Extend existing band // Extend endTime value @@ -820,49 +820,51 @@ public class CollectorImpl implements Collector { } else { i.current.setEndTime( time.getBinding(), time.getValue() ); } - if (i.itemState.ooDeadband) { + if (i.itemState.ooDeadband || isMinMaxFormat) { if (isValidValue) { // Set last value if (i.current.hasLastValue()) { i.current.setLastValue( value.getBinding(), value.getValue() ); } - // Add sum - if (i.current.hasAvg() && i.isNumeric && !isNanValue && !restep) { - double duration = (currentTime - i.itemState.firstTime); - if(duration < 1e-9) { - i.current.setAvg( Bindings.DOUBLE, 0.0 ); - } else { - i.current.setAvg( Bindings.DOUBLE, i.itemState.sum / duration); + if (i.isNumeric && !isNanValue) { + // Add sum + if (i.current.hasAvg() && !restep) { + double duration = (currentTime - i.itemState.firstTime); + if(duration < 1e-9) { + i.current.setAvg( Bindings.DOUBLE, 0.0 ); + } else { + i.current.setAvg( Bindings.DOUBLE, i.itemState.sum / duration); + } } - } - // Update min-max - if (i.current.hasMin() && i.isNumeric && !isNanValue) { - Binding minBinding = i.current.getMinBinding(); - Object prevMinValue = i.current.getMin(); - Object currentValueWithMinBinding = value.getValue( minBinding ); - int diff = minBinding.compare( prevMinValue, currentValueWithMinBinding ); - if (diff>0) i.current.setMin( minBinding, currentValueWithMinBinding ); - } - if (i.current.hasMax() && i.isNumeric && !isNanValue) { - Binding maxBinding = i.current.getMaxBinding(); - Object prevMaxValue = i.current.getMax(); - Object currentValueWithMaxBinding = value.getValue( maxBinding ); - int diff = maxBinding.compare( prevMaxValue, currentValueWithMaxBinding ); - if (diff<0) i.current.setMax( maxBinding, currentValueWithMaxBinding ); - } + // Update min-max + if (i.current.hasMin()) { + Binding minBinding = i.current.getMinBinding(); + Object prevMinValue = i.current.getMin(); + Object currentValueWithMinBinding = value.getValue( minBinding ); + int diff = minBinding.compare( prevMinValue, currentValueWithMinBinding ); + if (diff>0) i.current.setMin( minBinding, currentValueWithMinBinding ); + } + if (i.current.hasMax()) { + Binding maxBinding = i.current.getMaxBinding(); + Object prevMaxValue = i.current.getMax(); + Object currentValueWithMaxBinding = value.getValue( maxBinding ); + int diff = maxBinding.compare( prevMaxValue, currentValueWithMaxBinding ); + if (diff<0) i.current.setMax( maxBinding, currentValueWithMaxBinding ); + } - // Update median - if (i.current.hasMedian() && i.isNumeric && !isNanValue) { - Double median = i.itemState.median.getMedian(); - i.current.setMedian( Bindings.DOUBLE, median); + // Update median + if (i.current.hasMedian()) { + Double median = i.itemState.median.getMedian(); + i.current.setMedian( Bindings.DOUBLE, median); + } } } else { i.current.setValueNull(); } - // Add count + // Update count if (i.current.hasCount()) { i.current.setCount( i.itemState.count ); }