*/
private void storeToCsvFile( final File aFile, final JTAGDataSet aDataSet )
{
try
{
final CsvExporter exporter = ExportUtils.createCsvExporter( aFile );
exporter.setHeaders( "index", "time", "state", "TDI data", "TDO data" );
final List<JTAGData> dataSet = aDataSet.getData();
for ( int i = 0; i < dataSet.size(); i++ )
{
final JTAGData data = dataSet.get( i );
final String time = Unit.Time.format( aDataSet.getTime( data.getStartSampleIndex() ) );
final String event = data.isEvent() ? data.getEventName() : null;
BigInteger tdiData = null;
BigInteger tdoData = null;
// Try to coalesce equal timestamps...
if ( ( i + 1 ) < dataSet.size() )
{
final JTAGData next = dataSet.get( i + 1 );
if ( next.getStartSampleIndex() == data.getStartSampleIndex() )
{
tdiData = ( BigInteger )( next.isTdiData() ? next.getDataValue() : data.getDataValue() );
tdoData = ( BigInteger )( next.isTdoData() ? next.getDataValue() : data.getDataValue() );
// Make sure to skip this entry in the next iteration...
i++;
}
}
if ( ( tdiData == null ) && data.isTdiData() )
{
tdiData = ( BigInteger )data.getDataValue();
tdoData = null;
}
else if ( ( tdoData == null ) && data.isTdoData() )
{
tdiData = null;
tdoData = ( BigInteger )data.getDataValue();
}
final String tdiDataValue = tdiData != null ? "0x" + tdiData.toString( 16 ) : null;
final String tdoDataValue = tdoData != null ? "0x" + tdoData.toString( 16 ) : null;
exporter.addRow( Integer.valueOf( i ), time, event, tdiDataValue, tdoDataValue );
}
exporter.close();
}
catch ( final IOException exception )
{
// Make sure to handle IO-interrupted exceptions properly!
if ( !HostUtils.handleInterruptedException( exception ) )