Skip to content

Commit

Permalink
Issue #99: ensure the shown channels are in the right group.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Willem Janssen committed May 7, 2012
1 parent 8aab103 commit 18aefe4
Showing 1 changed file with 16 additions and 8 deletions.
Expand Up @@ -59,7 +59,7 @@ public DataSetImpl( final AcquisitionResult aCapturedData, final DataSet aOld )

this.capturedData = aCapturedData;
this.cursorsEnabled = aOld.isCursorsEnabled();
this.channels = createChannels( aCapturedData.getChannels(), aOld.getChannels() );
this.channels = createChannels( aCapturedData.getChannels(), aCapturedData.getEnabledChannels(), aOld.getChannels() );
this.cursors = createCursors( Ols.MAX_CURSORS, aOld.getCursors() );
}

Expand All @@ -72,7 +72,7 @@ public DataSetImpl( final AcquisitionResult aCapturedData, final DataSet aOld )

this.capturedData = null;
this.cursors = createCursors( Ols.MAX_CURSORS );
this.channels = createChannels( Ols.MAX_CHANNELS );
this.channels = createChannels( Ols.MAX_CHANNELS, 0xFFFFFFFF );
this.cursorsEnabled = true;
}

Expand Down Expand Up @@ -209,25 +209,33 @@ final void mergeChannelLabels( final List<String> aLabels )
* the number of channels to create, >= 0.
* @return an array with channels, never <code>null</code>.
*/
private Channel[] createChannels( final int aCount, final Channel... aInitialValues )
private Channel[] createChannels( final int aCount, final int aMask, final Channel... aInitialValues )
{
final int chCount = this.capturedData == null ? aCount : this.capturedData.getChannels();
final int chCount = ( this.capturedData == null ) ? aCount : this.capturedData.getChannels();

Channel[] result = new Channel[aCount];
for ( int i = 0; i < aCount; i++ )
for ( int i = 0, j = 0; i < Ols.MAX_CHANNELS; i++ )
{
final int mask = ( 1 << i );
// Issue #99: demultiplex the channels to the right group...
if ( ( aMask & mask ) == 0 )
{
continue;
}

ChannelImpl channel;
if ( ( i < aInitialValues.length ) && ( i < chCount ) )
// Only use an initial version of channel if the channel indexes match...
if ( ( j < aInitialValues.length ) && ( j < chCount ) && ( aInitialValues[j].getIndex() == i ) )
{
channel = new ChannelImpl( aInitialValues[i] );
channel = new ChannelImpl( aInitialValues[j] );
}
else
{
channel = new ChannelImpl( i );
}
channel.addPropertyChangeListener( this );

result[i] = channel;
result[j++] = channel;
}
return result;
}
Expand Down

0 comments on commit 18aefe4

Please sign in to comment.