/** * Writes the data to the given writer. * * @param aDataSet the project to write the settings for, cannot be <code>null</code> ; * @param aWriter the writer to write the data to, cannot be <code>null</code>. * @throws IOException in case of I/O problems. */ public static void write(final StubDataSet aDataSet, final Writer aWriter) throws IOException { final BufferedWriter bw = new BufferedWriter(aWriter); final AcquisitionResult capturedData = aDataSet.getCapturedData(); final Cursor[] cursors = aDataSet.getCursors(); final boolean cursorsEnabled = aDataSet.isCursorsEnabled(); try { final int[] values = capturedData.getValues(); final long[] timestamps = capturedData.getTimestamps(); bw.write(";Size: "); bw.write(Integer.toString(values.length)); bw.newLine(); bw.write(";Rate: "); bw.write(Integer.toString(capturedData.getSampleRate())); bw.newLine(); bw.write(";Channels: "); bw.write(Integer.toString(capturedData.getChannels())); bw.newLine(); bw.write(";EnabledChannels: "); bw.write(Integer.toString(capturedData.getEnabledChannels())); bw.newLine(); if (capturedData.hasTriggerData()) { bw.write(";TriggerPosition: "); bw.write(Long.toString(capturedData.getTriggerPosition())); bw.newLine(); } bw.write(";Compressed: "); bw.write(Boolean.toString(true)); bw.newLine(); bw.write(";AbsoluteLength: "); bw.write(Long.toString(capturedData.getAbsoluteLength())); bw.newLine(); bw.write(";CursorEnabled: "); bw.write(Boolean.toString(cursorsEnabled)); bw.newLine(); for (int i = 0; cursorsEnabled && (i < cursors.length); i++) { if (cursors[i].isDefined()) { bw.write(String.format(";Cursor%d: ", Integer.valueOf(i))); bw.write(Long.toString(cursors[i].getTimestamp())); bw.newLine(); } } for (int i = 0; i < values.length; i++) { bw.write(formatSample(values[i], timestamps[i])); bw.newLine(); } } finally { bw.flush(); } }