Package Acquisition

Class AcquisitionProcess

java.lang.Object
PamguardMVC.PamProcess
Acquisition.AcquisitionProcess
All Implemented Interfaces:
PamObserver, ProcessAnnotator
Direct Known Subclasses:
STAcquisitionProcess

public class AcquisitionProcess extends PamProcess
Data acquisition process for all types of input device. This arranges the output data block and starts and stops the device in the detected DaqSystem. Each DaqSystem should operate a different thread to read the device / file and add its data to the volatile Vector newDataUnits. AcquisitonProcess will poll newDataUnits on a timer and when new data is found, put that data into PamDataUnits and PamRawDataBlocks to be sent out for processing.

Author:
Doug Gillespie
See Also:
  • Field Details

  • Method Details

    • setupDataBlock

      public void setupDataBlock()
      called when acquisition parameters change.
    • pamStart

      public void pamStart()
      Interval between daq checks in milliseconds
      Specified by:
      pamStart in class PamProcess
    • pamStop

      public void pamStop()
      Description copied from class: PamProcess
      Stops the process.
      Specified by:
      pamStop in class PamProcess
    • pamStop

      public void pamStop(String reason)
    • recordPPSOffset

      public void recordPPSOffset(long timeNow, long edgeSample, long gpsUTC, Long serverTime)
    • acquisitionStopped

      public void acquisitionStopped()
    • sendSourceNotification

      public void sendSourceNotification(int type, Object object)
      Let all observers of the raw data know that the daq status has changed. Right now, this is intended to let everyone know that the Daq has started or stopped, so that the various threads can clean themselves up.
      Parameters:
      type - the type of change (see global fields at the top of this class)
      object - (null for now, but added in case we need to pass something later)
    • prepareProcessOK

      public boolean prepareProcessOK()
      Description copied from class: PamProcess
      New version of prepareProcess which get's called from PAMController prior to PAMGuard starting up. If a single process returns false from this function, startup will be aborted.

      For backwards compatibility (to save the need to modify every process) there is a default function which simply calls the older prepareProcess() function, then return true, but processes which might fail can override this and return false instead if they so wish.

      Initial motivation for this function was to stop millions of empty files being created when the watchdog is running but the DAQ can't start.

      Overrides:
      prepareProcessOK in class PamProcess
      Returns:
      true if it's looking highly likely that the process is going to start OK.
    • prepareProcess

      public void prepareProcess()
      Description copied from class: PamProcess
      Called for each process before any of them receive the PamStart command
      Overrides:
      prepareProcess in class PamProcess
    • setSampleRate

      public void setSampleRate(float sampleRate, boolean notify)
      Description copied from interface: PamObserver
      New sample rate
      Specified by:
      setSampleRate in interface PamObserver
      Overrides:
      setSampleRate in class PamProcess
      Parameters:
      notify - Notify other PamObservers and PamObservables in the chain.
    • setNumChannels

      public void setNumChannels(int numChannels)
    • setNumChannels

      public void setNumChannels(int numChannels, int[] channelList)
      Set up channels when using a channel list - note that hardware channels are no longer passed through the system so software channels are now used throughout.
      Parameters:
      numChannels -
      channelList -
    • streamClosed

      public void streamClosed()
    • streamEnded

      public void streamEnded()
    • streamOpen

      public void streamOpen()
    • streamPaused

      public void streamPaused()
    • getBufferSeconds

      public double getBufferSeconds()
    • getMaxBufferSeconds

      public double getMaxBufferSeconds()
      Returns:
      the maximum number of seconds of data which can be buffered. This used to be fixed at 3, but now that individual raw data blocks contain >> 1s of data for low frequency DAQ, this can be exceeded in a single data unit, which causes continual resets.
    • needRestart

      public boolean needRestart()
    • newData

      public void newData(PamObservable o, PamDataUnit arg)
      Overrides:
      newData in class PamProcess
    • getNewDataQueue

      public AudioDataQueue getNewDataQueue()
    • getRunningSystem

      public DaqSystem getRunningSystem()
    • rawAmplitude2dB

      public double rawAmplitude2dB(double rawAmplitude, int channel, boolean fast)
      Convert a raw amplitude to dB re 1 micropascal based on calibration information held in the AcquisitionController
      Parameters:
      rawAmplitude - raw amplitude (should be -1 invalid input: '<' rawAmplitude invalid input: '<' 1)
      Returns:
      amplitude in dB re 1 uPa.
    • getPeak2PeakVoltage

      public double getPeak2PeakVoltage(int swChannel)
      Some devices may be setting this per channel.
      Parameters:
      swChannel - software channel number
      Returns:
      peak to peak voltage range.
    • prepareFastAmplitudeCalculation

      public double prepareFastAmplitudeCalculation(int channel)
      Prepares for fast amplitude calculations
      Parameters:
      channel - number i.e. 0 - 31, NOT a bitmap.
    • rawAmplitude2dB

      public double[] rawAmplitude2dB(double[] rawAmplitude, int channel)
      Convert a raw amplitude to dB re 1 micropascal based on calibration information held in the AcquisitionController for an array of double data
      Parameters:
      rawAmplitude - raw amplitude (should be -1 invalid input: '<' rawAmplitude invalid input: '<' 1)
      channel - channel number (MUST be a channel 0 - 31, not a sequence number)
      Returns:
      amplitude in dB re 1 uPa.
    • fftAmplitude2dB

      public double fftAmplitude2dB(double fftAmplitude, int channel, float sampleRate, int fftLength, boolean isSquared, boolean fast)
      Convert the amplitude of fft data into a spectrum level measurement in dB re 1 micropacal / sqrt(Hz).
      Parameters:
      fftAmplitude - magnitude of the fft data (not the magnitude squared !)
      channel - channel number (MUST be a channel, and not a sequence number)
      sampleRate - sample rate - this needs to be sent, since this function is often called from decimated data, in which case the sample rate will be different.
      fftLength - length of the FFT (needed for Parsevals correction)
      isSquared - is magnitude squared (in which case sqrt will be taken).
      fast - use fast calculation (after call to prepareFastAmplitudeCalculation(...).
      Returns:
      spectrum level amplitude.
    • fftAmplitude2dB

      public double[] fftAmplitude2dB(double[] fftAmplitude, int channel, float sampleRate, int fftLength, boolean isSquared)
      Convert the amplitude of fft data into a spectrum level measurement in dB re 1 micropacal / sqrt(Hz) for an array of double values.
      Parameters:
      fftAmplitude - magnitude of the fft data (not the magnitude squared !)
      channel - the channel number (MUST be a channel, and not a sequence number)
      fftLength - lengthof the fft (needed for Parsevals correction)
      Returns:
      spectrum level amplitude.
    • fftBandAmplitude2dB

      public double fftBandAmplitude2dB(double fftAmplitude, int channel, int fftLength, boolean isSquared, boolean fast)
      Convert the amplitude of fft data into a level measurement in dB re 1 micropacal / sqrt(Hz).

      Note that this function differs from fftAmplitude2dB in that this one used the FFT length to correct for Parsevals theorum and integratin over the length of the FFT, but it does NOT convert the result to a spectrum level measurement.

      Parameters:
      fftAmplitude - magnitude of the fft data (not the magnitude squared !)
      fftLength - lengthof the fft (needed for Parsevals correction)
      Returns:
      level amplitude in dB
    • dbMicropascalToSignal

      public double dbMicropascalToSignal(int channel, double dBMuPascal)
      Converts dB in micropascal to ADC counts on a 0 - 1 scale.
      Parameters:
      channel - channel number, i.e. channel index 0 - 31 NOT a bitmap.
      dBMuPascal - db in micropascal
      Returns:
      ADC counts on a 0-1 scale.
    • getAcquisitionControl

      public AcquisitionControl getAcquisitionControl()
      Returns:
      Returns the acquisitionControl.
    • getRawDataBlock

      public PamRawDataBlock getRawDataBlock()
      Returns:
      the rawDataBlock
    • getOfflineData

      public int getOfflineData(OfflineDataLoadInfo offlineLoadDataInfo)
      Overrides:
      getOfflineData in class PamProcess
    • getTotalSamples

      public long getTotalSamples(int iChannel)
      Get the total number of samples acquired by a particular channel.
      Parameters:
      iChannel -
      Returns:
      number of samples.
    • getStallCheckSeconds

      public long getStallCheckSeconds()
    • isStalled

      public boolean isStalled()
      Returns:
      if the acquisition system seems to have stopped acquiring data.
    • getDaqStatusDataBlock

      public PamDataBlock<DaqStatusDataUnit> getDaqStatusDataBlock()
      Get the DAQ status data block. Contains data unit with info on sample numbers etc.
      Returns:
      the daqStatusDataBlock
    • getStoreInfo

      public InputStoreInfo getStoreInfo(boolean detail)
    • setAnalysisStartTime

      public boolean setAnalysisStartTime(long startTime)