Permalink
Browse files

Issue #99: ensure the shown channels are in the right group.

  • Loading branch information...
1 parent 8aab103 commit 18aefe41ba2650fa2acb3d2289d5ca06d73d9a5f @jawi committed May 7, 2012
Showing with 16 additions and 8 deletions.
  1. +16 −8 client.project/src/main/java/nl/lxtreme/ols/client/project/impl/DataSetImpl.java
@@ -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() );
}
@@ -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;
}
@@ -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;
}

0 comments on commit 18aefe4

Please sign in to comment.