use of org.csstudio.trends.databrowser3.export.ValueWithInfoFormatter in project org.csstudio.display.builder by kasemir.
the class ExportTest method speadsheetExport.
/**
* Export channels in a spreadsheet
* @throws Exception on error
*/
@Test
public void speadsheetExport() throws Exception {
final Model model = getTestModel();
final ExportJob export = new SpreadsheetExportJob(model, model.getStartTime(), model.getEndTime(), Source.RAW_ARCHIVE, 10, new ValueWithInfoFormatter(Style.Exponential, 3), "/tmp/sheet.dat", this);
export.run(new SysoutProgressMonitor());
}
use of org.csstudio.trends.databrowser3.export.ValueWithInfoFormatter in project org.csstudio.display.builder by kasemir.
the class ExportView method startExportJob.
/**
* Start export job with parameters from GUI
*/
private void startExportJob() {
if (model == null)
return;
// Determine start/end time
final Instant start_time, end_time;
if (use_plot_times.getSelection()) {
start_time = model.getStartTime();
end_time = model.getEndTime();
} else {
try {
final StartEndTimeParser times = new StartEndTimeParser(start.getText(), end.getText());
start_time = times.getStart().toInstant();
end_time = times.getEnd().toInstant();
} catch (final Exception ex) {
handleExportError(ex);
return;
}
}
// Determine source: Plot, archive, ...
final Source source;
int optimize_parameter = -1;
if (source_raw.getSelection())
source = Source.RAW_ARCHIVE;
else if (source_opt.getSelection()) {
source = Source.OPTIMIZED_ARCHIVE;
try {
optimize_parameter = Integer.parseInt(optimize.getText());
} catch (Exception ex) {
MessageDialog.openError(optimize.getShell(), Messages.Error, Messages.ExportOptimizeCountError);
return;
}
} else if (source_lin.getSelection()) {
source = Source.LINEAR_INTERPOLATION;
try {
optimize_parameter = (int) (SecondsParser.parseSeconds(linear.getText()) + 0.5);
if (optimize_parameter < 1)
optimize_parameter = 1;
} catch (Exception ex) {
MessageDialog.openError(linear.getShell(), Messages.Error, Messages.ExportLinearIntervalError);
return;
}
} else
source = Source.PLOT;
// Get remaining export parameters
final String filename = this.filename.getText().trim();
if (filename.equalsIgnoreCase(Messages.ExportDefaultFilename)) {
MessageDialog.openConfirm(optimize.getShell(), Messages.Error, Messages.ExportEnterFilenameError);
this.filename.setFocus();
return;
}
if (new File(filename).exists()) {
if (!MessageDialog.openConfirm(optimize.getShell(), Messages.ExportFileExists, NLS.bind(Messages.ExportFileExistsFmt, filename)))
return;
}
// Construct appropriate export job
final Job export;
if (type_matlab.getSelection()) {
if (// $NON-NLS-1$
filename.endsWith(".m"))
export = new MatlabScriptExportJob(model, start_time, end_time, source, optimize_parameter, filename, this);
else if (// $NON-NLS-1$
filename.endsWith(".mat"))
export = new MatlabFileExportJob(model, start_time, end_time, source, optimize_parameter, filename, this);
else {
MessageDialog.openError(type_matlab.getShell(), Messages.Error, Messages.ExportMatlabFilenameError);
return;
}
} else {
// Spreadsheet file export
final Style style;
if (format_decimal.getSelection())
style = Style.Decimal;
else if (format_expo.getSelection())
style = Style.Exponential;
else
style = Style.Default;
final int precision;
if (style == Style.Default)
// Not used
precision = 0;
else {
try {
precision = Integer.parseInt(format_digits.getText().trim());
} catch (Exception ex) {
MessageDialog.openError(optimize.getShell(), Messages.Error, Messages.ExportDigitsError);
return;
}
}
final ValueFormatter formatter;
if (sev_stat.getSelection())
formatter = new ValueWithInfoFormatter(style, precision);
else
formatter = new ValueFormatter(style, precision);
formatter.useMinMaxColumn(minMaxAllowed() && min_max_col.getSelection());
if (tabular.getSelection())
export = new SpreadsheetExportJob(model, start_time, end_time, source, optimize_parameter, formatter, filename, this);
else
export = new PlainExportJob(model, start_time, end_time, source, optimize_parameter, formatter, filename, this);
}
export.schedule();
}
use of org.csstudio.trends.databrowser3.export.ValueWithInfoFormatter in project org.csstudio.display.builder by kasemir.
the class ExportTest method plainExport.
/**
* Export channels one-by-one
* @throws Exception on error
*/
@Test
public void plainExport() throws Exception {
final Model model = getTestModel();
final ExportJob export = new PlainExportJob(model, model.getStartTime(), model.getEndTime(), Source.OPTIMIZED_ARCHIVE, 60, new ValueWithInfoFormatter(Style.Exponential, 6), "/tmp/plain.dat", this);
export.run(new SysoutProgressMonitor());
}
Aggregations