clickDetector
Class ClickDetector

java.lang.Object
  extended by PamguardMVC.PamProcess
      extended by clickDetector.ClickDetector
All Implemented Interfaces:
Annotator, PamObserver

public class ClickDetector
extends PamProcess

Main click detector process.

Observes a raw data block, filters and thresholds the data to create Click objects

Author:
Doug Gillespie
See Also:
ClickDetection

Nested Class Summary
(package private)  class ClickDetector.ChannelGroupDetector
           
(package private) static class ClickDetector.ClickStatus
           
(package private)  class ClickDetector.NewClickMonitor
          To improve performance, raw data is sent to each ChannelGroupDetector into a different thread.
 
Field Summary
(package private)  AcquisitionProcess acquisitionProcess
           
private  long allSamplesProcessed
           
private  long blockDuration
           
private  long blockStartSample
           
private  double[][] channelData
           
private  ClickDetector.ChannelGroupDetector[] channelGroupDetectors
           
private  int channelsReceived
           
private  ClickBinaryDataSource clickBinaryDataSource
           
private  ClickControl clickControl
           
private  long clickCount
           
private  ClickFileStorage clickStorage
           
(package private)  int correlationLength
           
protected  Correlations correlations
           
private  PamRawDataBlock doubleFilteredData
           
protected  FastFFT fastFFT
           
private  long fileStartSample
           
private  IirfFilter[] firstFilter
           
private  double[] freqLims
           
private  int[] globalChannelIndex
           
private  int[] globalChannelList
           
private  Hilbert hilbert
           
private  boolean lockDownfile
          Flag to stop the click detector running in the other thread from attempting to write to the file while it's either closed or it's in the process of writing it's header control structures when the pam stops.
private  boolean multiThread
           
private  int nChan
           
private  int nChannelGroups
           
private  ClickDetector.NewClickMonitor newClickMonitor
           
private  NoiseDataBlock noiseDataBlock
           
private  OfflineEventDataBlock offlineEventDataBlock
           
private  ClickDataBlock outputClickData
           
private  boolean pauseDetection
          flag to stop the detector trying to do anything if the parametrs are in the process of being recreated which is probably going on in a different thread.
private  ClickParameters previousParameters
           
private  PamRawDataBlock rawDataSource
           
private  long requiredKeptSamples
           
private  long samplesPerStore
           
private  long secondCounter
           
private  IirfFilter[] secondFilter
           
private  long startTimeMillis
           
private  ClickDetector THIS
           
protected  PamDataBlock<ClickDetection> trackedClicks
           
private  PamDataBlock<TriggerLevelDataUnit> triggerDataBlock
           
private  ClickTriggerFunctionDataBlock triggerFunctionDataBlock
           
private  TriggerHistogram[] triggerHistogram
           
 
Fields inherited from class PamguardMVC.PamProcess
outputDataBlocks, processName, sampleRate
 
Constructor Summary
ClickDetector(ClickControl clickControl)
           
 
Method Summary
 void closeOutputFile()
           
private  boolean completeClick(ClickDetection newClick)
          Once a click is detected, does everything else to it such as calculate bearing, check species, send to click train detector, etc.
 void createFilters()
           
 ClickDetector.ChannelGroupDetector findChannelGroupDetector(int channelBitmap)
           
 ClickBinaryDataSource getClickBinaryDataSource()
           
 ClickControl getClickControl()
           
 long getClickCount()
           
 ClickDataBlock getClickDataBlock()
           
 PamRawDataBlock[] getFilteredDataBlocks()
           
 Hilbert getHilbert()
           
 OfflineEventDataBlock getOfflineEventDataBlock()
           
 PamDataBlock<ClickDetection> getOutputClickData()
           
 long getRequiredDataHistory(PamObservable o, java.lang.Object arg)
           
 long getSamplesProcessed()
           
 long getStartTimeMillis()
           
 PamDataBlock<ClickDetection> getTrackedClicks()
           
 PamDataBlock<TriggerLevelDataUnit> getTriggerDataBlock()
           
 ClickTriggerFunctionDataBlock getTriggerFunctionDataBlock()
           
 void newData(PamObservable obs, PamDataUnit newData)
           
 void newParameters()
           
 void notifyArrayChanged()
           
 boolean openOutputFile(boolean doHeader)
           
 void pamStart()
          Called for each process to tell it to start (may not be necessary for processes which are listening for data anyway.
 void pamStop()
          Stops the process.
 void prepareProcess()
          Called for each process before any of them receive the PamStart command
private  void preProcessData()
           
 boolean reWriteClick(ClickDetection click, boolean waveformToo)
           
 void secondTimer(long sampleNumber)
           
 void setSampleRate(float sampleRate, boolean notify)
          New sample rate
 void setupProcess()
          called for every process once the systemmodel has been created.
private  void sortOutDataBlocks()
           
 boolean wantClick(ClickDetection click, ClickIdInformation idInfo)
          Return true if the click should be processed and stored.
private  boolean wantMultiThread()
          Quick way of making a local decision on multithreading
 
Methods inherited from class PamguardMVC.PamProcess
absMillisecondsToSamples, absSamplesToMilliseconds, addOutputDataBlock, changedThreading, clearOldData, createAnnotations, destroyProcess, fillXMLElement, fillXMLParameters, getAncestorDataBlock, getAnnotation, getBackendProcess, getChainPosition, getCpuPercent, getNumAnnotations, getNumOutputDataBlocks, getObserverName, getObserverObject, getOfflineData, getOutputDataBlock, getPamControlledUnit, getParentDataBlock, getParentProcess, getProcessName, getRawSourceDataBlock, getSampleRate, getSourceDataBlock, getSourceProcess, isCanMultiThread, makePamProcess, masterClockUpdate, noteNewSettings, notifyModelChanged, relMillisecondsToSamples, relSamplesToMilliseconds, removeObservable, removeOutputDatablock, saveViewerData, setBackendProcess, setCanMultiThread, setParentDataBlock, setParentDataBlock, setProcessName, toString, update, updateData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

THIS

private ClickDetector THIS

nChannelGroups

private int nChannelGroups

multiThread

private boolean multiThread

channelGroupDetectors

private ClickDetector.ChannelGroupDetector[] channelGroupDetectors

globalChannelList

private int[] globalChannelList

globalChannelIndex

private int[] globalChannelIndex

startTimeMillis

private long startTimeMillis

clickControl

private ClickControl clickControl

channelsReceived

private int channelsReceived

channelData

private double[][] channelData

nChan

private int nChan

hilbert

private Hilbert hilbert

outputClickData

private ClickDataBlock outputClickData

offlineEventDataBlock

private OfflineEventDataBlock offlineEventDataBlock

noiseDataBlock

private NoiseDataBlock noiseDataBlock

blockStartSample

private long blockStartSample

blockDuration

private long blockDuration

allSamplesProcessed

private long allSamplesProcessed

rawDataSource

private PamRawDataBlock rawDataSource

triggerDataBlock

private PamDataBlock<TriggerLevelDataUnit> triggerDataBlock

doubleFilteredData

private PamRawDataBlock doubleFilteredData

trackedClicks

protected PamDataBlock<ClickDetection> trackedClicks

triggerFunctionDataBlock

private ClickTriggerFunctionDataBlock triggerFunctionDataBlock

firstFilter

private IirfFilter[] firstFilter

secondFilter

private IirfFilter[] secondFilter

secondCounter

private long secondCounter

triggerHistogram

private TriggerHistogram[] triggerHistogram

clickStorage

private ClickFileStorage clickStorage

samplesPerStore

private long samplesPerStore

fileStartSample

private long fileStartSample

clickCount

private long clickCount

freqLims

private double[] freqLims

requiredKeptSamples

private long requiredKeptSamples

fastFFT

protected FastFFT fastFFT

correlations

protected Correlations correlations

newClickMonitor

private ClickDetector.NewClickMonitor newClickMonitor

acquisitionProcess

AcquisitionProcess acquisitionProcess

correlationLength

int correlationLength

clickBinaryDataSource

private ClickBinaryDataSource clickBinaryDataSource

previousParameters

private ClickParameters previousParameters

pauseDetection

private volatile boolean pauseDetection
flag to stop the detector trying to do anything if the parametrs are in the process of being recreated which is probably going on in a different thread.


lockDownfile

private volatile boolean lockDownfile
Flag to stop the click detector running in the other thread from attempting to write to the file while it's either closed or it's in the process of writing it's header control structures when the pam stops.

Constructor Detail

ClickDetector

public ClickDetector(ClickControl clickControl)
Method Detail

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
notify - Notify other PamObservers and PamObservables in the chain.

wantMultiThread

private boolean wantMultiThread()
Quick way of making a local decision on multithreading

Returns:
true if want multithreading on click detector

setupProcess

public void setupProcess()
Description copied from class: PamProcess
called for every process once the systemmodel has been created. this is a good time to check out and find input data blocks and similar tasks.

Overrides:
setupProcess in class PamProcess

createFilters

public void createFilters()

newParameters

public void newParameters()

getClickDataBlock

public ClickDataBlock getClickDataBlock()
Returns:
The main output click data block.

getOfflineEventDataBlock

public OfflineEventDataBlock getOfflineEventDataBlock()
Returns:
the offlineEventDataBlock

getRequiredDataHistory

public long getRequiredDataHistory(PamObservable o,
                                   java.lang.Object arg)
Specified by:
getRequiredDataHistory in interface PamObserver
Overrides:
getRequiredDataHistory in class PamProcess
Parameters:
o - PamObservable class requiring the data
arg - optional argument from PamObservable
Returns:
time in milliseconds requried by data held in PamObservable

secondTimer

public void secondTimer(long sampleNumber)

newData

public void newData(PamObservable obs,
                    PamDataUnit newData)
Overrides:
newData in class PamProcess

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

pamStart

public void pamStart()
Description copied from class: PamProcess
Called for each process to tell it to start (may not be necessary for processes which are listening for data anyway.

Specified by:
pamStart in class PamProcess

preProcessData

private void preProcessData()

sortOutDataBlocks

private void sortOutDataBlocks()

openOutputFile

public boolean openOutputFile(boolean doHeader)

closeOutputFile

public void closeOutputFile()

pamStop

public void pamStop()
Description copied from class: PamProcess
Stops the process.

Specified by:
pamStop in class PamProcess

getStartTimeMillis

public long getStartTimeMillis()

reWriteClick

public boolean reWriteClick(ClickDetection click,
                            boolean waveformToo)

getClickControl

public ClickControl getClickControl()

getSamplesProcessed

public long getSamplesProcessed()

getClickCount

public long getClickCount()

getTriggerDataBlock

public PamDataBlock<TriggerLevelDataUnit> getTriggerDataBlock()

getOutputClickData

public PamDataBlock<ClickDetection> getOutputClickData()

completeClick

private boolean completeClick(ClickDetection newClick)
Once a click is detected, does everything else to it such as calculate bearing, check species, send to click train detector, etc.

Returns:
true if the tasks complete successfully and the click is to be kept. false otherwise.

wantClick

public boolean wantClick(ClickDetection click,
                         ClickIdInformation idInfo)
Return true if the click should be processed and stored.

If there is no online classification, we want everything If there is classification, but we've not told it to discard, etc

Parameters:
click -
idInfo -
Returns:

getFilteredDataBlocks

public PamRawDataBlock[] getFilteredDataBlocks()

getTriggerFunctionDataBlock

public ClickTriggerFunctionDataBlock getTriggerFunctionDataBlock()

getTrackedClicks

public PamDataBlock<ClickDetection> getTrackedClicks()

getHilbert

public Hilbert getHilbert()

notifyArrayChanged

public void notifyArrayChanged()

findChannelGroupDetector

public ClickDetector.ChannelGroupDetector findChannelGroupDetector(int channelBitmap)

getClickBinaryDataSource

public ClickBinaryDataSource getClickBinaryDataSource()
Returns:
the clickBinaryDataSource