public static HistorySamplerItem createHistorySamplerItem(ReadGraph graph, Resource subscriptionItem, ChartData data) throws DatabaseException {
try {
- Resource model = graph.syncRequest(new PossibleIndexRoot(subscriptionItem));
- if (model == null) {
- throw new DatabaseException("There is no model for " + subscriptionItem);
+ Resource indexRoot = graph.syncRequest(new PossibleIndexRoot(subscriptionItem));
+ if (indexRoot == null) {
+ throw new DatabaseException("There is no index root for " + subscriptionItem);
}
ItemManager im = new ItemManager(data.history.getItems());
*
* @author Tuukka Lehtonen
*/
-public class TrendSupport {
+public class TrendSupport implements ITrendSupport {
// Input
private IDynamicExperiment experiment;
return finalPath.toFile();
}
+ @Override
+ public void setChartData(ReadGraph graph) throws DatabaseException {
+ }
+
+ @Override
+ public ChartData getChartData() {
+ return chartData;
+ }
+
}
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();
}
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();