nidaqdev
Class NIDAQProcess

java.lang.Object
  extended by Acquisition.DaqSystem
      extended by nidaqdev.NIDAQProcess
All Implemented Interfaces:
PamSettings

public class NIDAQProcess
extends DaqSystem
implements PamSettings


Nested Class Summary
(package private)  class NIDAQProcess.AllowMultiBoard
           
(package private)  class NIDAQProcess.NICaptureThread
          New capture thread for JNI operation
(package private)  class NIDAQProcess.NITransferThread
           
(package private)  class NIDAQProcess.SelectBoard
           
 
Field Summary
private  AcquisitionDialog acquisitionDialog
           
private  javax.swing.JCheckBox allowMultiBoard
           
private  javax.swing.JComboBox audioDevices
           
private  long[] channelSampleCount
           
private  int daqChannels
           
private  AcquisitionControl daqControl
           
private  javax.swing.JPanel daqDialog
           
private  int dataUnitSamples
           
private  javax.swing.JComboBox inputType
           
private  java.util.List<RawDataUnit> newDataUnits
           
private  NIChannelListPanel niChannelListPanel
           
private  Nidaq nidaq
           
private  java.util.ArrayList<NIDeviceInfo> niDevices
           
private  NIDaqParams niParameters
           
private  int rawBufferSize
           
private  javax.swing.JLabel warningText
           
 
Fields inherited from class Acquisition.DaqSystem
PARAMETER_FIXED, PARAMETER_UNKNOWN, STREAM_CLOSED, STREAM_ENDED, STREAM_OPEN, STREAM_PAUSED, STREAM_RUNNING
 
Constructor Summary
NIDAQProcess(AcquisitionControl daqControl)
           
 
Method Summary
 boolean canPlayBack(float sampleRate)
           
private  void checkDevice()
           
private  javax.swing.JPanel createDaqDialogPanel()
           
 void daqHasEnded()
          Called after DAQ has stopped - for whatever reason.
 boolean dialogGetParams()
          Called by AcquisitionDialog.GetParams so that parameters can be extracted from the dialog component.
 void dialogSetParams()
          Called by AcquisitionDialog.SetParams so that the dialog componenet can update it's fields
 void enableMasterDevice()
           
private  void enableMultiBoardOps()
           
 void fullBuffer(int iChan, double[] data)
          Get's called back from the C side.
 int getChannels()
           
 ChannelListPanel getDaqSpecificChannelListPanel(AcquisitionDialog acquisitionDialog)
          GEt a channel list panel (invented for NI cards which have many more options)
 javax.swing.JPanel 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.
 int getDataUnitSamples()
           
 NIDeviceInfo getDeviceInfo(int iDevice)
           
protected  int[] getDeviceList()
           
 java.lang.String getDeviceName()
          Gets a name for the acquisition device (may just be a number but need to generalise).
protected  int[] getHWChannelList()
           
protected  int getMasterDevice()
           
 int getMaxChannels()
           
 int getMaxSampleRate()
           
 java.util.ArrayList<NIDeviceInfo> getNiDevices()
           
 NIDaqParams getNiParameters()
           
 double getPeak2PeakVoltage(int swChannel)
           
 int getSampleRate()
           
 java.io.Serializable getSettingsReference()
           
 long getSettingsVersion()
           
 java.lang.String getSystemName()
           
 java.lang.String getSystemType()
           
 java.lang.String getUnitName()
           
 java.lang.String getUnitType()
           
protected  boolean isEnabledMultiBoardOps()
           
 boolean isRealTime()
           
 boolean prepareSystem(AcquisitionControl daqControl)
          Prepare the DaqSystem.
protected  double readSampleRate()
          Pass through for easy access from channellistpanel
 boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings)
           
protected  void setDeviceList(int[] deviceList)
           
protected  void setHWChannelList(int[] hwChannelsList)
           
 void setMasterDevice(int iDevice)
           
protected  void setVP2P(double vp2p)
           
 boolean startSystem(AcquisitionControl daqControl)
          Start the DaqSystem.
 void stopSystem(AcquisitionControl daqControl)
          Stop the DaqSystem.
 boolean supportsChannelLists()
           
 void useSettings()
           
private  boolean warnMultiBoardOps()
          If it's true that multi board is enabled, issue a warning and possibly return false in which case the checkbox will be unchecked again.
 
Methods inherited from class Acquisition.DaqSystem
areSampleSettingsOk, getInputChannelMap, getPlaybackSystem, getStatusBarComponent, getStreamStatus, setSelected, setStreamStatus, showSampleSettingsDialog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

daqDialog

private javax.swing.JPanel daqDialog

audioDevices

private javax.swing.JComboBox audioDevices

inputType

private javax.swing.JComboBox inputType

warningText

private javax.swing.JLabel warningText

allowMultiBoard

private javax.swing.JCheckBox allowMultiBoard

niParameters

private NIDaqParams niParameters

daqControl

private AcquisitionControl daqControl

acquisitionDialog

private AcquisitionDialog acquisitionDialog

rawBufferSize

private int rawBufferSize

daqChannels

private int daqChannels

nidaq

private Nidaq nidaq

channelSampleCount

private long[] channelSampleCount

newDataUnits

private java.util.List<RawDataUnit> newDataUnits

niDevices

private java.util.ArrayList<NIDeviceInfo> niDevices

niChannelListPanel

private NIChannelListPanel niChannelListPanel

dataUnitSamples

private int dataUnitSamples
Constructor Detail

NIDAQProcess

public NIDAQProcess(AcquisitionControl daqControl)
Method Detail

prepareSystem

public boolean prepareSystem(AcquisitionControl daqControl)
Description copied from class: DaqSystem
Prepare the DaqSystem.

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

Specified by:
prepareSystem in class DaqSystem
Parameters:
daqControl - AcquisitionControl unit.
Returns:
true if OK, false otherwise.

getDataUnitSamples

public int getDataUnitSamples()
Specified by:
getDataUnitSamples in class DaqSystem
Returns:
the number of samples expected in each data unit.

startSystem

public boolean startSystem(AcquisitionControl daqControl)
Description copied from class: DaqSystem
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)

Specified by:
startSystem in class DaqSystem
Parameters:
daqControl - AcquisitionControl unit.
Returns:
true if OK, false otherwise

stopSystem

public void stopSystem(AcquisitionControl daqControl)
Description copied from class: DaqSystem
Stop the DaqSystem.

Specified by:
stopSystem in class DaqSystem

getDaqSpecificChannelListPanel

public ChannelListPanel getDaqSpecificChannelListPanel(AcquisitionDialog acquisitionDialog)
Description copied from class: DaqSystem
GEt a channel list panel (invented for NI cards which have many more options)

Overrides:
getDaqSpecificChannelListPanel in class DaqSystem
Parameters:
acquisitionDialog - reference to main acquisition dialog
Returns:
ChannelListPanel component.

getDaqSpecificDialogComponent

public javax.swing.JPanel getDaqSpecificDialogComponent(AcquisitionDialog acquisitionDialog)
Description copied from class: DaqSystem
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.

Specified by:
getDaqSpecificDialogComponent in class DaqSystem
Parameters:
acquisitionDialog - the AcquisitionDialog this component will be added to
Returns:
dialog component specific to this DAQ device

setVP2P

protected void setVP2P(double vp2p)

createDaqDialogPanel

private javax.swing.JPanel createDaqDialogPanel()

getNiParameters

public NIDaqParams getNiParameters()

dialogSetParams

public void dialogSetParams()
Description copied from class: DaqSystem
Called by AcquisitionDialog.SetParams so that the dialog componenet can update it's fields

Specified by:
dialogSetParams in class DaqSystem

getMasterDevice

protected int getMasterDevice()

getDeviceInfo

public NIDeviceInfo getDeviceInfo(int iDevice)

dialogGetParams

public boolean dialogGetParams()
Description copied from class: DaqSystem
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.

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

getSystemType

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

Calling functions should be able to handle 'null'


getSystemName

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

getMaxChannels

public int getMaxChannels()
Specified by:
getMaxChannels in class DaqSystem
Returns:
the maximum number of channels supporrted by the selected device, or PARAMETER_UNKNOWN

getMaxSampleRate

public int getMaxSampleRate()
Specified by:
getMaxSampleRate in class DaqSystem
Returns:
the maximum sample rate supporrted by the selected device, or PARAMETER_UNKNOWN

readSampleRate

protected double readSampleRate()
Pass through for easy access from channellistpanel

Returns:

isRealTime

public boolean isRealTime()
Specified by:
isRealTime in class DaqSystem
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 boolean canPlayBack(float sampleRate)
Specified by:
canPlayBack in class DaqSystem
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 ?

getChannels

public int getChannels()

isEnabledMultiBoardOps

protected boolean isEnabledMultiBoardOps()

enableMultiBoardOps

private void enableMultiBoardOps()

getSampleRate

public int getSampleRate()

getPeak2PeakVoltage

public double getPeak2PeakVoltage(int swChannel)
Specified by:
getPeak2PeakVoltage in class DaqSystem
Returns:
peak to peak voltage for the device or PARAMETER_UNKNOWN

getSettingsReference

public java.io.Serializable getSettingsReference()
Specified by:
getSettingsReference in interface PamSettings
Returns:
The serialisable object that will be stored

getSettingsVersion

public long getSettingsVersion()
Specified by:
getSettingsVersion in interface PamSettings
Returns:
An integer version number for the settings

getUnitName

public java.lang.String getUnitName()
Specified by:
getUnitName in interface PamSettings
Returns:
A Name specific to this instance of the particular class, e.g. Sperm whale detector, Beaked whale detector, etc.

getUnitType

public java.lang.String getUnitType()
Specified by:
getUnitType in interface PamSettings
Returns:
A Name specific to the type, e.g. Glick detector

restoreSettings

public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings)
Specified by:
restoreSettings in interface PamSettings
Returns:
true if successful The object performs final checks (if needed) and then casts the settings data pamcontrolledunitSettings.settings into the correct type and uses as required

useSettings

public void useSettings()

checkDevice

private void checkDevice()

enableMasterDevice

public void enableMasterDevice()

setMasterDevice

public void setMasterDevice(int iDevice)

warnMultiBoardOps

private boolean warnMultiBoardOps()
If it's true that multi board is enabled, issue a warning and possibly return false in which case the checkbox will be unchecked again.

Returns:

fullBuffer

public void fullBuffer(int iChan,
                       double[] data)
Get's called back from the C side. The data are still in a shared buffer at this point, so copy it out into a new array.

We also need to swap threads at this point, so add the new data to a list that some other process will be emptying on a timer.

Parameters:
iChan - channel number
data - data array.

daqHasEnded

public void daqHasEnded()
Description copied from class: DaqSystem
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.

Specified by:
daqHasEnded in class DaqSystem

setDeviceList

protected void setDeviceList(int[] deviceList)

getDeviceList

protected int[] getDeviceList()

setHWChannelList

protected void setHWChannelList(int[] hwChannelsList)

getHWChannelList

protected int[] getHWChannelList()

supportsChannelLists

public boolean supportsChannelLists()
Overrides:
supportsChannelLists in class DaqSystem

getNiDevices

public java.util.ArrayList<NIDeviceInfo> getNiDevices()

getDeviceName

public java.lang.String getDeviceName()
Description copied from class: DaqSystem
Gets a name for the acquisition device (may just be a number but need to generalise).

Specified by:
getDeviceName in class DaqSystem
Returns: