/**
   * Ends the reading of EEG data, and notification of <code>IRawSampleGenerator</code> listeners
   */
  public void stopReading() {
    if (isActive) {
      isActive = false;

      reader.stopReading();
      reader.removeAllPacketListeners();
      reader = null;

      demultiplexer.removeAllSampleListeners();
    }
  }
  /**
   * Begins the reading of EEG data, and notification of <code>IRawSampleGenerator</code> listeners.
   * Objects that call <code>startReading</code> should always call <code>stopReading</code> when
   * they are done reading EEG data.
   *
   * @throws IOException if we are unable to connect to the EEG device
   */
  public void startReading(boolean debugMode) throws IOException {
    if (!isActive) {
      // Wire together the wave acquisition and analysis components
      reader = new NeuroServerReader();
      reader.addPacketListener(demultiplexer);

      // Start up the reader
      reader.startReading(debugMode);
      reader.start();
      isActive = true;
    }
  }