From: Tuukka Lehtonen Date: Fri, 19 Oct 2018 12:22:27 +0000 (+0300) Subject: Fixed history data collection minmax stream updates and plot rendering X-Git-Tag: v1.43.0~136^2~319 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F39%2F2339%2F1;p=simantics%2Fplatform.git Fixed history data collection minmax stream updates and plot rendering After commit 30ca6dab the chart was rendering all plots as SAMPLING instead of LINE because the commit changed all stream items' endTime update logic to actually for all streams instead of just the minmax stream. The fix was to change the plot rendering to still render diagonal lines instead of step functions regardless of of the start and end time of each history stream value band are. The lines vs. sampling settings is now solely based on the chart rendering preferences. gitlab #35 Change-Id: I9f8872994870bdedbf0708bb77beceab1c884313 --- 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 ); } diff --git a/bundles/org.simantics.trend/src/org/simantics/trend/impl/ItemNode.java b/bundles/org.simantics.trend/src/org/simantics/trend/impl/ItemNode.java index c866d2cc2..699b441ca 100644 --- a/bundles/org.simantics.trend/src/org/simantics/trend/impl/ItemNode.java +++ b/bundles/org.simantics.trend/src/org/simantics/trend/impl/ItemNode.java @@ -248,7 +248,9 @@ public class ItemNode extends G2DNode implements TrendLayout { line.lineTo(maxX, ny); line.moveTo(x, y); } else { - line.lineTo(x, y); + if (x != currentX || y != currentY) { + line.lineTo(x, y); + } } } @@ -427,7 +429,8 @@ public class ItemNode extends G2DNode implements TrendLayout { } } - lineTo(x2, y2); + if (flat) + lineTo(x2, y2); // if(showBand) { // lineTo(x2, y2); @@ -468,7 +471,7 @@ public class ItemNode extends G2DNode implements TrendLayout { } // Binary signal - if (item.renderer == Renderer.Binary) { + else if (item.renderer == Renderer.Binary) { byte value = 0; if (vb.getValueBinding() instanceof BooleanBinding) { value = ((Boolean) vb.getValue(Bindings.BOOLEAN)) ? (byte)0 : (byte)1;