]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Still fixes history collection value band endTime setting and rendering 40/2740/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 9 Nov 2018 12:04:08 +0000 (14:04 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Fri, 1 Mar 2019 08:17:44 +0000 (08:17 +0000)
Previous changes set value band end time to be the same as the next
value band's start time. However this caused the problem that there is
no way of telling during rendering where exactly within the previous
value band did the band's value go out of dead band and since t_end does
not tell us this. This means that line-rendering (not stepped sample
rendering) will get drawn invalidly if t_end > t_begin within a value
band.

The fix was to set t_end to the last timestamp where the value was still
within deadband, i.e:
```
|t0    t0_end  |               VALUE BAND #0 t0 < t0_end
|      |       |t1      |      VALUE BAND #1 t1 = t1_end
|      |       |t1_end  |
|      |       |        |t2... VALUE BAND #2
ts0----ts1---- ts2------ts3---
v=0    v=0     v=1      v=2
```

gitlab #35

Change-Id: I073d1aed0d3ce0ffe30081937fdd7ff1c22dc107
(cherry picked from commit b885083762a43ec97162a5f77df4fd5f85e28979)

bundles/org.simantics.history/src/org/simantics/history/impl/CollectorImpl.java
bundles/org.simantics.trend/src/org/simantics/trend/impl/ItemNode.java

index 87062a9dabecae759aa0f5dffd442a496af156e5..e956b37117fcc365cbb85cf0e2b339752d814bcc 100644 (file)
@@ -815,11 +815,20 @@ public class CollectorImpl implements Collector {
 
                        /// Extend existing band
                        // Extend endTime value
-                       if (!i.hasEndTime) {
-                               i.current.setTime( time.getBinding(), time.getValue() );
-                       } else {
-                               i.current.setEndTime( time.getBinding(), time.getValue() );
+
+                       // This ensures that a value band's end time isn't the same
+                       // as the next band's start time which makes it possible to
+                       // know what are the timestamps between which the item value
+                       // changed from a to b. This allows us to more correctly render
+                       // steps and sloped lines accoring to the actual data.
+                       if (!i.itemState.ooDeadband || isMinMaxFormat) {
+                               if (!i.hasEndTime) {
+                                       i.current.setTime( time.getBinding(), time.getValue() );
+                               } else {
+                                       i.current.setEndTime( time.getBinding(), time.getValue() );
+                               }
                        }
+
                        if (i.itemState.ooDeadband || isMinMaxFormat) {
                                if (isValidValue) {
                                        // Set last value
index 699b441ca226c916aa6e725aa8c10a6df6c09b53..402d793f8cc4c34e4fbc15c5d4958f9a3635e26c 100644 (file)
@@ -429,7 +429,10 @@ public class ItemNode extends G2DNode implements TrendLayout {
                                                                }
                                                        }
 
-                                                       if (flat)
+                                                       // gitlab #35: t2 > t1 ensure that the value band is
+                                                       // rendered as a horizontal line until the the time when
+                                                       // the band's value went out of dead-band.
+                                                       if (flat || t2 > t1)
                                                                lineTo(x2, y2);
                                                        
 //                                                     if(showBand) {