use of org.csstudio.archive.reader.SpreadsheetIterator in project org.csstudio.display.builder by kasemir.
the class SpreadsheetExportJob method performExport.
/**
* {@inheritDoc}
*/
@Override
protected void performExport(final IProgressMonitor monitor, final PrintStream out) throws Exception {
// Item header
for (ModelItem item : model.getItems()) printItemInfo(out, item);
out.println();
// Spreadsheet Header
out.print("# " + Messages.TimeColumn);
for (ModelItem item : model.getItems()) out.print(Messages.Export_Delimiter + item.getName() + " " + formatter.getHeader());
out.println();
// Create speadsheet interpolation
final List<ValueIterator> iters = new ArrayList<>();
for (ModelItem item : model.getItems()) {
monitor.subTask(NLS.bind("Fetching data for {0}", item.getName()));
iters.add(createValueIterator(item));
}
final SpreadsheetIterator sheet = new SpreadsheetIterator(iters.toArray(new ValueIterator[iters.size()]));
// Dump the spreadsheet lines
long line_count = 0;
while (sheet.hasNext() && !monitor.isCanceled()) {
final Instant time = sheet.getTime();
final VType[] line = sheet.next();
out.print(TimestampHelper.format(time));
for (int i = 0; i < line.length; ++i) out.print(Messages.Export_Delimiter + formatter.format(line[i]));
out.println();
++line_count;
if ((line_count % PROGRESS_UPDATE_LINES) == 0)
monitor.subTask(NLS.bind("Wrote {0} samples", line_count));
if (monitor.isCanceled())
break;
}
}
Aggregations