X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.history%2Fsrc%2Forg%2Fsimantics%2Fhistory%2FHistorySampler.java;fp=bundles%2Forg.simantics.history%2Fsrc%2Forg%2Fsimantics%2Fhistory%2FHistorySampler.java;h=1c45a220fcf005ac80bf0e2b92f9c988127987fc;hb=fbe4ffbf25e0b35dcbd51f11b50e740bfe4c593d;hp=73df6dc618bbb99e84f3638f8dbff795ea80bc28;hpb=738abdf21b01a265c08f40c1e0f601406c58666e;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.history/src/org/simantics/history/HistorySampler.java b/bundles/org.simantics.history/src/org/simantics/history/HistorySampler.java index 73df6dc61..1c45a220f 100644 --- a/bundles/org.simantics.history/src/org/simantics/history/HistorySampler.java +++ b/bundles/org.simantics.history/src/org/simantics/history/HistorySampler.java @@ -15,9 +15,10 @@ public class HistorySampler { public synchronized static TDoubleArrayList sample( HistorySamplerItem item, double from, double end, double timeWindow, double timeStep, boolean resample ) throws HistoryException, IOException { try { - item.open(); + // If there is something pending at this point, flush before opening for read if(item.collector != null) item.collector.flush(); + item.open(); return sample(item.iter, from, end, timeWindow, timeStep, resample); } finally { item.close(); @@ -25,10 +26,18 @@ public class HistorySampler { } public static TDoubleArrayList sample( StreamIterator iter, double from, double end, double timeWindow, double timeStep, boolean resample ) throws HistoryException, IOException { + return sample(iter, from, end, timeWindow, timeStep, resample, 0.0); + } + + public static TDoubleArrayList sample( StreamIterator iter, double from, double end, double timeWindow, double timeStep, boolean resample, Double sampleFrom ) throws HistoryException, IOException { ExportInterpolation numberInterpolation = ExportInterpolation.LINEAR_INTERPOLATION; - double startTime = 0.0; + double startTime = from; + if(sampleFrom != null) { + // This option can be used do define the offset of sampling. Samples will be sampleFrom + n * timeStep + startTime = sampleFrom; + } TDoubleArrayList result = new TDoubleArrayList();