Package Acquisition
Class AcquisitionProcess
java.lang.Object
PamguardMVC.PamProcess
Acquisition.AcquisitionProcess
- All Implemented Interfaces:
PamObserver
,ProcessAnnotator
- Direct Known Subclasses:
STAcquisitionProcess
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
double
dbMicropascalToSignal
(int channel, double dBMuPascal) Converts dB in micropascal to ADC counts on a 0 - 1 scale.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.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).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).double
Get the DAQ status data block.double
int
getOfflineData
(OfflineDataLoadInfo offlineLoadDataInfo) double
getPeak2PeakVoltage
(int swChannel) Some devices may be setting this per channel.long
getStoreInfo
(boolean detail) long
getTotalSamples
(int iChannel) Get the total number of samples acquired by a particular channel.boolean
boolean
void
newData
(PamObservable o, PamDataUnit arg) void
pamStart()
Interval between daq checks in millisecondsvoid
pamStop()
Stops the process.void
double
prepareFastAmplitudeCalculation
(int channel) Prepares for fast amplitude calculationsvoid
Called for each process before any of them receive the PamStart commandboolean
New version of prepareProcess which get's called from PAMController prior to PAMGuard starting up.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 datadouble
rawAmplitude2dB
(double rawAmplitude, int channel, boolean fast) Convert a raw amplitude to dB re 1 micropascal based on calibration information held in the AcquisitionControllervoid
recordPPSOffset
(long timeNow, long edgeSample, long gpsUTC, Long serverTime) void
sendSourceNotification
(int type, Object object) Let all observers of the raw data know that the daq status has changed.boolean
setAnalysisStartTime
(long startTime) void
setNumChannels
(int numChannels) 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.void
setSampleRate
(float sampleRate, boolean notify) New sample ratevoid
called when acquisition parameters change.void
void
void
void
Methods inherited from class PamguardMVC.PamProcess
absMillisecondsToSamples, absSamplesToMilliseconds, addData, addMultiPlexDataBlock, addOutputDataBlock, changedThreading, clearOldData, createAnnotations, destroyProcess, dumpBufferStatus, flushDataBlockBuffers, getAncestorDataBlock, getAnnotation, getChainPosition, getCompatibleDataUnits, getCpuPercent, getFrequencyRange, getLastSourceNotificationObject, getLastSourceNotificationType, getMuiltiplexDataBlock, getNumAnnotations, getNumMuiltiplexDataBlocks, getNumOutputDataBlocks, getObserverName, getObserverObject, getOfflineData, getOutputDataBlock, getOutputDataBlocks, getPamControlledUnit, getParentDataBlock, getParentDataBlocks, getParentProcess, getProcessCheck, getProcessName, getRawSourceDataBlock, getRawSourceDataBlock, getRequiredDataHistory, getSampleRate, getSourceDataBlock, getSourceProcess, hasOutputDatablock, isCanMultiThread, isExternalProcess, isMultiplex, makePamProcess, masterClockUpdate, noteNewSettings, notifyModelChanged, processNewBuoyData, receiveSourceNotification, relMillisecondsToSamples, relSamplesToMilliseconds, removeAllDataBlocks, removeAllMultiPlexDataBlocks, removeMultiPlexDataBlock, removeObservable, removeOutputDatablock, resetDataBlocks, saveViewerData, setCanMultiThread, setExternalProcess, setMultiplex, setParentDataBlock, setParentDataBlock, setProcessCheck, setProcessName, setupProcess, toString, updateData
-
Field Details
-
LASTDATA
public static final int LASTDATA- See Also:
-
FIRSTDATA
public static final int FIRSTDATA- See Also:
-
-
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 classPamProcess
-
pamStop
public void pamStop()Description copied from class:PamProcess
Stops the process.- Specified by:
pamStop
in classPamProcess
-
pamStop
-
recordPPSOffset
-
acquisitionStopped
public void acquisitionStopped() -
sendSourceNotification
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 classPamProcess
- 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 classPamProcess
-
setSampleRate
public void setSampleRate(float sampleRate, boolean notify) Description copied from interface:PamObserver
New sample rate- Specified by:
setSampleRate
in interfacePamObserver
- Overrides:
setSampleRate
in classPamProcess
- 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
- Overrides:
newData
in classPamProcess
-
getNewDataQueue
-
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
- Returns:
- Returns the acquisitionControl.
-
getRawDataBlock
- Returns:
- the rawDataBlock
-
getOfflineData
- Overrides:
getOfflineData
in classPamProcess
-
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
Get the DAQ status data block. Contains data unit with info on sample numbers etc.- Returns:
- the daqStatusDataBlock
-
getStoreInfo
-
setAnalysisStartTime
public boolean setAnalysisStartTime(long startTime)
-