Search in sources :

Example 1 with SpreadsheetIterator

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;
    }
}
Also used : VType(org.diirt.vtype.VType) SpreadsheetIterator(org.csstudio.archive.reader.SpreadsheetIterator) Instant(java.time.Instant) ArrayList(java.util.ArrayList) ModelItem(org.csstudio.trends.databrowser3.model.ModelItem) ValueIterator(org.csstudio.archive.reader.ValueIterator)

Aggregations

Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 SpreadsheetIterator (org.csstudio.archive.reader.SpreadsheetIterator)1 ValueIterator (org.csstudio.archive.reader.ValueIterator)1 ModelItem (org.csstudio.trends.databrowser3.model.ModelItem)1 VType (org.diirt.vtype.VType)1