Acquisition
Class DaqSystem

java.lang.Object
  extended by Acquisition.DaqSystem
Direct Known Subclasses:
ASIOSoundSystem, FileInputSystem, NIDAQProcess, SimProcess, SoundCardSystem

public abstract class DaqSystem
extends java.lang.Object

Abstraction to multiple data acquisition devices. This interface performs the following tasks:

1. Provides information about the device such as min and max sample rates, number of channelse, etc. 2. Provides a dialog panel with specific options. This automatically gets incorporated into a more general data acquisition panel 3. Provides threads and any other functions necessary to create packets of raw audio data in PamDataUnit's. 4. Each concrete class should, if needed, save it's own setting using the PamSettings package.

Current examples are in SoundCardSystem and FileInputSystem

Author:
Doug Gillespie

Field Summary
static int PARAMETER_FIXED
           
static int PARAMETER_UNKNOWN
           
static int STREAM_CLOSED
           
static int STREAM_ENDED
           
static int STREAM_OPEN
           
static int STREAM_PAUSED
           
static int STREAM_RUNNING
           
private  int streamStatus
           
 
Constructor Summary
DaqSystem()
           
 
Method Summary
 boolean areSampleSettingsOk(int numInputsRequested, float sampleRateRequested)
           
abstract  boolean canPlayBack(float sampleRate)
           
abstract  void daqHasEnded()
          Called after DAQ has stopped - for whatever reason.
abstract  boolean dialogGetParams()
          Called by AcquisitionDialog.GetParams so that parameters can be extracted from the dialog component.
abstract  void dialogSetParams()
          Called by AcquisitionDialog.SetParams so that the dialog componenet can update it's fields
 ChannelListPanel getDaqSpecificChannelListPanel(AcquisitionDialog acquisitionDialog)
          GEt a channel list panel (invented for NI cards which have many more options)
abstract  javax.swing.JComponent getDaqSpecificDialogComponent(AcquisitionDialog acquisitionDialog)
          The AcquisitionDialog has been designed to that each data source type can plug in it's own panel of device specific controls.
abstract  int getDataUnitSamples()
           
abstract  java.lang.String getDeviceName()
          Gets a name for the acquisition device (may just be a number but need to generalise).
 int getInputChannelMap(AcquisitionParameters acquisitionParameters)
           
abstract  int getMaxChannels()
           
abstract  int getMaxSampleRate()
           
abstract  double getPeak2PeakVoltage(int swChannel)
           
 PlaybackSystem getPlaybackSystem()
          Gets a playback system for playing sound back out through headphones / speakers, etc.
 java.awt.Component getStatusBarComponent()
           
 int getStreamStatus()
          Status of the intput stream
abstract  java.lang.String getSystemName()
           
abstract  java.lang.String getSystemType()
           
abstract  boolean isRealTime()
           
abstract  boolean prepareSystem(AcquisitionControl daqControl)
          Prepare the DaqSystem.
 void setSelected(boolean select)
          Tell a DAQ system it's been selected or deselected.
 void setStreamStatus(int streamStatus)
           
 void showSampleSettingsDialog(AcquisitionDialog acquisitionDialog)
           
abstract  boolean startSystem(AcquisitionControl daqControl)
          Start the DaqSystem.
abstract  void stopSystem(AcquisitionControl daqControl)
          Stop the DaqSystem.
 boolean supportsChannelLists()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAMETER_UNKNOWN

public static final int PARAMETER_UNKNOWN
See Also:
Constant Field Values

PARAMETER_FIXED

public static final int PARAMETER_FIXED
See Also:
Constant Field Values

streamStatus

private int streamStatus

STREAM_CLOSED

public static final int STREAM_CLOSED
See Also:
Constant Field Values

STREAM_OPEN

public static final int STREAM_OPEN
See Also:
Constant Field Values

STREAM_RUNNING

public static final int STREAM_RUNNING
See Also:
Constant Field Values

STREAM_PAUSED

public static final int STREAM_PAUSED
See Also:
Constant Field Values

STREAM_ENDED

public static final int STREAM_ENDED
See Also:
Constant Field Values
Constructor Detail

DaqSystem

public DaqSystem()
Method Detail

getSystemType

public abstract java.lang.String getSystemType()
Returns:
The 'type' of data source for display in the Data Source dialog

Calling functions should be able to handle 'null'


getSystemName

public abstract java.lang.String getSystemName()
Returns:
A string describing the data source, e.g. the sound card name, file name, udp port, etc.

getDaqSpecificDialogComponent

public abstract javax.swing.JComponent getDaqSpecificDialogComponent(AcquisitionDialog acquisitionDialog)
The AcquisitionDialog has been designed to that each data source type can plug in it's own panel of device specific controls. These could be things like a file name, gain settings, channel lists, whatever is available for the specific device

The AcquisitionDialog will handle placing this component on the dialog when a particular DaqSystem is selected. The component will be placed between a drop down list of available DaqSystem's and a section of the dialog showing the sample rate and number of channels.

Parameters:
acquisitionDialog - the AcquisitionDialog this component will be added to
Returns:
dialog component specific to this DAQ device

getDaqSpecificChannelListPanel

public ChannelListPanel getDaqSpecificChannelListPanel(AcquisitionDialog acquisitionDialog)
GEt a channel list panel (invented for NI cards which have many more options)

Parameters:
acquisitionDialog - reference to main acquisition dialog
Returns:
ChannelListPanel component.

dialogSetParams

public abstract void dialogSetParams()
Called by AcquisitionDialog.SetParams so that the dialog componenet can update it's fields


dialogGetParams

public abstract boolean dialogGetParams()
Called by AcquisitionDialog.GetParams so that parameters can be extracted from the dialog component. The DaqSystem should also implement PamSettings and handle storage of parameters between runs.

Returns:
true if the parameters and selections are OK. If false is returned the Acquisition dialog will not respond to its Ok button.

setSelected

public void setSelected(boolean select)
Tell a DAQ system it's been selected or deselected.

Parameters:
select -

getMaxSampleRate

public abstract int getMaxSampleRate()
Returns:
the maximum sample rate supporrted by the selected device, or PARAMETER_UNKNOWN

getMaxChannels

public abstract int getMaxChannels()
Returns:
the maximum number of channels supporrted by the selected device, or PARAMETER_UNKNOWN

getPeak2PeakVoltage

public abstract double getPeak2PeakVoltage(int swChannel)
Returns:
peak to peak voltage for the device or PARAMETER_UNKNOWN

prepareSystem

public abstract boolean prepareSystem(AcquisitionControl daqControl)
Prepare the DaqSystem.

Usually this is the time for opening files, preparing data buffers, etc.

Parameters:
daqControl - AcquisitionControl unit.
Returns:
true if OK, false otherwise.

startSystem

public abstract boolean startSystem(AcquisitionControl daqControl)
Start the DaqSystem. This is called immediately after PrepareSystem

Most things should be ready from the call to PrepareSystem. In StartSystem you will generally need to start a thread which will read in the data and place PamDataUnits in a buffer from where they are read by the main thred and passed on to other Pam modules for processing (see SoundCardSystem for an example)

Parameters:
daqControl - AcquisitionControl unit.
Returns:
true if OK, false otherwise

stopSystem

public abstract void stopSystem(AcquisitionControl daqControl)
Stop the DaqSystem.

Parameters:
daqControl -

isRealTime

public abstract boolean isRealTime()
Returns:
true for real time systems (e.g. sound cards, NI cards, wav files which are being played back over speakers. false for reading files which are to be processed as fast as possible with no playback.

canPlayBack

public abstract boolean canPlayBack(float sampleRate)
Returns:
true if the system can also play back sound - likely to be true for sound cards and ASIO, and some NI cards, false for wav files. Simulator ?

getDataUnitSamples

public abstract int getDataUnitSamples()
Returns:
the number of samples expected in each data unit.

getPlaybackSystem

public PlaybackSystem getPlaybackSystem()
Gets a playback system for playing sound back out through headphones / speakers, etc.

Generally, anything acquiring data in real time should play the sound back through itself so that clocks are correctly synchronised. i.e. A sound card input will go to the same sound card output, etc. At a later date, we may try to support output through different devices at different speeds - but this will be problematic !

If data are being read from a file, then playback is through a sound card which sits in a standalone implementation of PlaybackSystem

Returns:
null if no playback available or a PlaybackSystem object.
See Also:
PlaybackSystem, FilePlayback

daqHasEnded

public abstract void daqHasEnded()
Called after DAQ has stopped - for whatever reason. Nost DAQ systems will not need to do anything here, but they could potentially clean up memory The motivation for putting this here now is for the folder analysis system so that it can start analysing the next file.


getStreamStatus

public int getStreamStatus()
Status of the intput stream

Returns:
stream status

setStreamStatus

public void setStreamStatus(int streamStatus)

areSampleSettingsOk

public boolean areSampleSettingsOk(int numInputsRequested,
                                   float sampleRateRequested)

showSampleSettingsDialog

public void showSampleSettingsDialog(AcquisitionDialog acquisitionDialog)

getStatusBarComponent

public java.awt.Component getStatusBarComponent()

supportsChannelLists

public boolean supportsChannelLists()

getInputChannelMap

public int getInputChannelMap(AcquisitionParameters acquisitionParameters)
Returns:
a bitmap of output channels. this should ALWAYS be a bitmap of channels 0 to n-1 even if different hardware channels are used since hardware channels are no longer passed through PAMGUARD.

getDeviceName

public abstract java.lang.String getDeviceName()
Gets a name for the acquisition device (may just be a number but need to generalise).

Returns: