Class PamProcess
- All Implemented Interfaces:
PamObserver
,ProcessAnnotator
- Direct Known Subclasses:
AcquireNmeaData
,AcquisitionProcess
,AirgunProcess
,AlarmProcess
,AmpProcess
,AngleListener
,AngleProcess
,ArrayAccelProcess
,ArraySensorProcess
,AzigramProcess
,BackupProcess
,BeamFormerBaseProcess
,BeamformProcess
,BinaryClickProcess
,BinaryStoreProcess
,CepstrumProcess
,ClickAlarmManager
,ClickDetector
,ClickTrainDetector
,ClickTrainProcess
,CPODProcess
,DbHtProcess
,DBProcess
,DecimatorProcess
,DecimatorProcessW
,DepthProcess
,DetectionGroupProcess
,DifarProcess
,EnvelopeProcess
,FilterProcess
,FormsProcess
,Group3DProcess
,HydrophoneProcess
,IMUListener
,IMUProcess
,IshDetFnProcess
,IshLocProcess
,IshPeakProcess
,KernelSmoothingProcess
,LikelihoodFFTProcess
,LinearAverageSpectraProcess
,ListeningProcess
,LtsaProcess
,MapProcess
,MarkGroupProcess
,MarkProcess
,NetworkSendProcess
,NoiseBandProcess
,NoiseProcess
,NormalizerProcess
,OfflineFileProcess
,OfflineProcessingProcess
,OneBandProcess
,OneBandPulseProcess
,PamBlockProcess
,PamFFTProcess
,PamInstantProcess
,PatchPanelProcess
,PeakDetector
,ProcessAISData
,ProcessHeadingData
,ProcessIshmaelData
,ProcessNmeaData
,QAMonitorProcess
,RavenProcess
,RecorderProcess
,RoccaProcess
,RoccaWhistleSelect
,RockBlockProcess2
,RWEProcess
,SegmenterProcess
,SonobuoyManager
,SpectralEtiProcess
,SpectrogramMarkProcess
,SpectrogramMedianFilter
,SpectrogramNoiseProcess
,TargetMotionProcess
,ThresholdDetectorProcess
,TowedArray3DProcess
,TrackedClickLocaliser
,TrackedGroupProcess
,UserDisplayProcess
,UserInputProcess
,VetoProcess
,VRProcess
,WhistleClassifierProcess
,WhistleDetector
,WhistleEventDetector
,WhistleLinker
,WhistleToneConnectProcess
- Author:
- Doug Gillespie
PamProcess is an abstract class used as a supertype for the creation of processes which either convert one type of PamData into a new type or add existing information to already existing data
All PamProcesses are Listeners and implement the Observer Class from java.util
The first PamProcess to be created will often be something which generates raw data (either by reading an input device or by reading chunks of data from a file).
Each PamProcess will require a source of data, which apart from the top level processes which acquire data, will be a PamDataBlock. The PamProcess will generally subscribe to the PamDataBlock so that it is notified of any changes (i.e. new data) being added to that block.
The PamController ...
-
Constructor Summary
ConstructorDescriptionPamProcess
(PamControlledUnit pamControlledUnit, PamDataBlock parentDataBlock) PamProcess
(PamControlledUnit pamControlledUnit, PamDataBlock parentDataBlock, String processName) -
Method Summary
Modifier and TypeMethodDescriptionlong
absMillisecondsToSamples
(long millis) Convert a time in milliseconds to a number of samples.long
absSamplesToMilliseconds
(long samples) Convert am ADC sample number to a millisecond time.final void
addData
(PamObservable o, PamDataUnit arg) Informs the PamObserver that new data have been added to the Observable classvoid
addMultiPlexDataBlock
(PamDataBlock pamDataBlock) Adds the process as an observer to the data block.void
addOutputDataBlock
(PamDataBlock outputDataBlock) Adds an additional PamDataBlock to the processvoid
Function that gets called in every process (or all processes that are listed in PamControlledUnits) and re-sets up the data source using the correct threading model.void
Clears all data from all output data blocks of this process.final void
createAnnotations
(boolean notifyDownstream) void
Called from the PamControlled unit when a PamControlled unit is removed from the model.void
dumpBufferStatus
(String message, boolean sayEmpties) Say the status of any buffers, particularly in output buffers of data blocks, but can add bespoke info for other internal buffers for some processes.boolean
flushDataBlockBuffers
(long maxWait) Work through all the output datablocks and wait for their internal buffers to flush through.getAncestorDataBlock
(Class unitDataType) Useful function to go back through the chain of data blocks and data units upstream of this process and look for a data block which has a particular data type.getAnnotation
(PamDataBlock pamDataBlock, int annotation) Get an Annotationint
ArrayList<Class<? extends PamDataUnit>>
A list of data block class types which are compatible as parent data blocks for the PamProcess.double
double[]
Get the range of frequencies over which the data in this process are likely to be present.int
getMuiltiplexDataBlock
(int block) Get a multiplex data block.int
getNumAnnotations
(PamDataBlock pamDataBlock) int
Get the number of multiplex datablocks.int
int
getOfflineData
(OfflineDataLoadInfo offlineLoadInfo) int
getOfflineData
(PamDataBlock dataBlock, PamObserver endUser, long startMillis, long endMillis, int loadKeepLayers) Request offline data.getOutputDataBlock
(int block) Each process may produce multiple data blocks.Get the full list of output datablocks - used in logger forms so they can all be mapped easily once created.Get a list of the parent datablock and any multiplex datablocks.Get a process check object.Find the absolute source of raw audio data if one existsgetRawSourceDataBlock
(float sampleRate) Deprecated.long
float
find the absolute source of data, if one exists.boolean
hasOutputDatablock
(PamDataBlock outputDataBlock) Test to see if an output datablock exists.boolean
boolean
Check whether the process can accept parent data blocks from other PamControlledUnitsboolean
Get whether multiplex data blocks are allowed.void
makePamProcess
(PamControlledUnit pamControlledUnit, PamDataBlock parentDataBlock, String processName) void
masterClockUpdate
(long timeMilliseconds, long sampleNumber) void
newData
(PamObservable o, PamDataUnit arg) void
void
notifyModelChanged
(int changeType) abstract void
pamStart()
Called for each process to tell it to start (may not be necessary for processes which are listening for data anyway).abstract void
pamStop()
Stops the process.void
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.void
processNewBuoyData
(BuoyStatusDataUnit dataUnit, PamDataUnit dataUnit2) void
receiveSourceNotification
(int type, Object object) Receive a notification from the data source - typically a change in DAQ status.long
relMillisecondsToSamples
(double millis) Convert a number of milliseconds to a number of samples.long
relSamplesToMilliseconds
(long samples) Convert a number of samples into a number of millisecondsvoid
Remove all data blocks from a process.void
removeAllMultiPlexDataBlocks
(ArrayList<PamDataBlock> pamDataBlocks) Remove a list of multiplex data blocks.void
removeMultiPlexDataBlock
(PamDataBlock pamDataBlock) Remove the process from a data block and remove datablock from list of multiplex datablocks.void
removeObservable
(PamObservable observable) Called when a PamDataBlock observed by this PamProcess is removed.void
removeOutputDatablock
(PamDataBlock outputDataBlock) void
reset datablocks.void
Save data (to binary files and to database) in viewer mode.void
setCanMultiThread
(boolean canMultiThread) void
setExternalProcess
(boolean isExternalProcess) Set whether the process can accept parent data blocks from other PamControlledUnitsvoid
setMultiplex
(boolean isMultiplex) Set whether multiplex data blocks are allowed.void
setParentDataBlock
(PamDataBlock newParentDataBlock) Set a parent data block with the default options of rethreading if setvoid
setParentDataBlock
(PamDataBlock newParentDataBlock, boolean reThread) Set a parent data block for the process with the option to rethread the data exchange process.void
setProcessCheck
(ProcessCheck processCheck) Set a process check object.void
setProcessName
(String processName) void
setSampleRate
(float sampleRate, boolean notify) New sample ratevoid
called for every process once the systemmodel has been created.toString()
void
updateData
(PamObservable o, PamDataUnit arg) Informs the PamObserver that existing data have been updated
-
Constructor Details
-
PamProcess
- Parameters:
pamControlledUnit
- Reference to the PamControlledUnit containing this process (PamProcesses can only exist within PamControlledUnits, but a PamControlledUnit can contain multiple PamProcesses)parentDataBlock
- Source data block for this process (can be null for raw data input devices)
-
PamProcess
public PamProcess(PamControlledUnit pamControlledUnit, PamDataBlock parentDataBlock, String processName)
-
-
Method Details
-
getObserverObject
- Specified by:
getObserverObject
in interfacePamObserver
- Returns:
- the actual observer. In most cases concrete classes will just return 'this' in response. The exception is the Threaded observer, which will return the single thread observer.
-
destroyProcess
public void destroyProcess()Called from the PamControlled unit when a PamControlled unit is removed from the model. Offers an opportunity to disconnect individual processed from the rest of the model. May be necessary to override to clean up some processes. -
removeAllDataBlocks
public void removeAllDataBlocks()Remove all data blocks from a process. -
makePamProcess
public void makePamProcess(PamControlledUnit pamControlledUnit, PamDataBlock parentDataBlock, String processName) -
getParentDataBlock
- Returns:
- Returns the parentDataBlock.
-
getParentDataBlocks
Get a list of the parent datablock and any multiplex datablocks.- Returns:
- a list where the first element is the parent datablock and other elements are multiplex data blocks.
-
getParentProcess
-
getAncestorDataBlock
Useful function to go back through the chain of data blocks and data units upstream of this process and look for a data block which has a particular data type. For instance, you may want the raw audio data upstream of FFT data. This may not be the data input to the FFT source, since you may be looking at some secondary FFT data source (smoothed, or noise suppressed spectrogram data for instance).- Parameters:
unitDataType
- class type of data in the sought after data block (e.g. RawDataUnit.class- Returns:
- reference to data block or null if none found
- See Also:
-
setParentDataBlock
Set a parent data block with the default options of rethreading if set- Parameters:
newParentDataBlock
- source data block.
-
setParentDataBlock
Set a parent data block for the process with the option to rethread the data exchange process. This is overridden to false if the main PAMGUARD option to rethread is off.- Parameters:
newParentDataBlock
- source data blockreThread
- rethread if multithreading is enabled.
-
createAnnotations
public final void createAnnotations(boolean notifyDownstream) -
changedThreading
public void changedThreading()Function that gets called in every process (or all processes that are listed in PamControlledUnits) and re-sets up the data source using the correct threading model. All this actually involves is resubscribing to the same data since everything else is handled in setParentDataBlock; -
setProcessName
- Parameters:
processName
- Sets the name of the process
-
getProcessName
- Returns:
- Name of the PamProcess
-
getObserverName
- Specified by:
getObserverName
in interfacePamObserver
-
setSampleRate
public void setSampleRate(float sampleRate, boolean notify) Description copied from interface:PamObserver
New sample rate- Specified by:
setSampleRate
in interfacePamObserver
- Parameters:
notify
- Notify other PamObservers and PamObservables in the chain.
-
masterClockUpdate
public void masterClockUpdate(long timeMilliseconds, long sampleNumber) - Specified by:
masterClockUpdate
in interfacePamObserver
-
relSamplesToMilliseconds
public long relSamplesToMilliseconds(long samples) Convert a number of samples into a number of milliseconds- Parameters:
samples
- Number of ADC samples- Returns:
- equivalent number of milliseconds
-
absSamplesToMilliseconds
public long absSamplesToMilliseconds(long samples) Convert am ADC sample number to a millisecond time. This function was re-written on 11/11/08 to deal with problems of sound card clocks not running at same speed as PC clock, so milliseconds from PC clock and milliseconds based on samples would drift apart. This new system bases the calculation on the times of the most recently received data unit.- Parameters:
samples
- sample number (from start of run)- Returns:
- Millisecond time (UTC milliseconds from the epoch - the standard Java way)
-
absMillisecondsToSamples
public long absMillisecondsToSamples(long millis) Convert a time in milliseconds to a number of samples.- Parameters:
millis
- Current time in milliseconds (UTC millseconds from the epoch - the standard Java way)- Returns:
- ADC Samples since the run start.
- See Also:
-
relMillisecondsToSamples
public long relMillisecondsToSamples(double millis) Convert a number of milliseconds to a number of samples.- Parameters:
millis
- number of milliseconds- Returns:
- number of ADC samples corresponding to millis milliseconds.
- See Also:
-
noteNewSettings
public void noteNewSettings()- Specified by:
noteNewSettings
in interfacePamObserver
-
getSampleRate
public float getSampleRate()- Returns:
- The sample rate in the process
-
getFrequencyRange
public double[] getFrequencyRange()Get the range of frequencies over which the data in this process are likely to be present. Note that this is pretty crude and may not reflect the true range, for example, the click detector will return the limits of it's trigger filter, and there are plenty of sounds outside of that range which may have most of their energy well outside of the trigger range of the detector.- Returns:
- Nominal frequency range for data in this block.
-
getSourceProcess
- Returns:
- The original data source process, i.e. the one reading the soundcard or the file, the one that doesn't have a parentDataBlock
-
getSourceDataBlock
find the absolute source of data, if one exists. i.e. the data output of a process that has no data input.If this is called from within acquisition, it will return null
It there is no raw data source, i.e. if the type is not PamRawDataBlock, then return null.
- Returns:
- a PamRawDataBlock or null
-
getProcessCheck
Get a process check object. This indicates the current status of a process.- Returns:
- the process check object.
-
setProcessCheck
Set a process check object. This indicates the current status of a process. -
getRawSourceDataBlock
Find the absolute source of raw audio data if one exists- Returns:
- a PamRawDataBlock or null
-
getRawSourceDataBlock
Deprecated.Find the absolute source of raw audio data if one exists- Returns:
- a PamRawDataBlock or null
-
getChainPosition
public int getChainPosition() -
getOutputDataBlock
Each process may produce multiple data blocks. This returns the reference to a specific block- Parameters:
block
- Index of the required block- Returns:
- PamDataBlock
-
getNumOutputDataBlocks
public int getNumOutputDataBlocks()- Returns:
- Total number of PamDataBlocks created by this process
-
addOutputDataBlock
Adds an additional PamDataBlock to the process- Parameters:
outputDataBlock
- Reference to a PamDataBlock
-
removeOutputDatablock
-
hasOutputDatablock
Test to see if an output datablock exists.- Parameters:
outputDataBlock
- Output datablock- Returns:
- true if the output datablock exists.
-
toString
-
clearOldData
public void clearOldData()Clears all data from all output data blocks of this process.
This gets called from the main controller at the start of operations. Can be overridden in some classes which don't want to delete existing data or they can set the clearAtStart flag in any data block. -
resetDataBlocks
public void resetDataBlocks()reset datablocks. Mostly concerned with setting timing counts in row data which may need a bit of an extra kick when handling networked data. -
prepareProcessOK
public boolean prepareProcessOK()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.
- Returns:
- true if it's looking highly likely that the process is going to start OK.
-
prepareProcess
public void prepareProcess()Called for each process before any of them receive the PamStart command -
getRequiredDataHistory
- Specified by:
getRequiredDataHistory
in interfacePamObserver
- Parameters:
arg
- optional argument from PamObservable- Returns:
- time in milliseconds required by data held in PamObservable
-
addData
Description copied from interface:PamObserver
Informs the PamObserver that new data have been added to the Observable class- Specified by:
addData
in interfacePamObserver
-
newData
-
updateData
Description copied from interface:PamObserver
Informs the PamObserver that existing data have been updated- Specified by:
updateData
in interfacePamObserver
-
setupProcess
public void setupProcess()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. -
getCpuPercent
public double getCpuPercent() -
pamStart
public abstract void pamStart()Called for each process to tell it to start (may not be necessary for processes which are listening for data anyway). -
pamStop
public abstract void pamStop()Stops the process. -
removeObservable
Called when a PamDataBlock observed by this PamProcess is removed.- Specified by:
removeObservable
in interfacePamObserver
-
getPamControlledUnit
-
getAnnotation
Description copied from interface:ProcessAnnotator
Get an Annotation- Specified by:
getAnnotation
in interfaceProcessAnnotator
- Parameters:
pamDataBlock
- Annotated datablockannotation
- annotation number- Returns:
- Annotation
-
getNumAnnotations
- Specified by:
getNumAnnotations
in interfaceProcessAnnotator
- Parameters:
pamDataBlock
- Annotated datablock- Returns:
- the number of annotations
-
notifyModelChanged
public void notifyModelChanged(int changeType) -
setCanMultiThread
public void setCanMultiThread(boolean canMultiThread) - Parameters:
canMultiThread
- the canMultiThread to set
-
isCanMultiThread
public boolean isCanMultiThread()- Returns:
- the canMultiThread
-
saveViewerData
public void saveViewerData()Save data (to binary files and to database) in viewer mode.This gets called automatically on system exit and can also be called from the file menu.
-
getOfflineData
public int getOfflineData(PamDataBlock dataBlock, PamObserver endUser, long startMillis, long endMillis, int loadKeepLayers) Request offline data.This will be called from a PamDatablock in offline viewer mode from requestOfflineData(PamObserver observer, long startMillis, long endMillis).
this is used to request data from upstream processes, e.g. o get raw data to turn into FFT data units to go to the spectrogram display (possible going via decimators and any other processes before spitting out the right data.
- Parameters:
dataBlock
- data block making the request.endUser
- observer which made the original data request.startMillis
- start time in millisecondsendMillis
- end time in milliseconds.loadKeepLayers
-cancellationObject
-- Returns:
- true if request can be satisfied (or partially satisfied).
-
getOfflineData
-
flushDataBlockBuffers
public boolean flushDataBlockBuffers(long maxWait) Work through all the output datablocks and wait for their internal buffers to flush through.This is used when stopping PAMGUARD to ensure that all data complete processing before anything else happens.
- Parameters:
maxWait
- maxWait time in milliseconds.- Returns:
- true if successful, or false if there was a timeout.
-
processNewBuoyData
-
getOutputDataBlocks
Get the full list of output datablocks - used in logger forms so they can all be mapped easily once created.- Returns:
- the outputDataBlocks
-
getCompatibleDataUnits
A list of data block class types which are compatible as parent data blocks for the PamProcess. This can return null, e.g. in the case of Acquisition process.- Returns:
- a list of PamDataBlock sub class types which can be used as parent data blocks for the process.
-
isMultiplex
public boolean isMultiplex()Get whether multiplex data blocks are allowed.- Returns:
- true if multiplex data blocks is enabled
-
setMultiplex
public void setMultiplex(boolean isMultiplex) Set whether multiplex data blocks are allowed.- Parameters:
true
- if multiplex data blocks is enabled
-
isExternalProcess
public boolean isExternalProcess()Check whether the process can accept parent data blocks from other PamControlledUnits- Returns:
- true to accept external data blocks from other PamControlledUnits.
-
setExternalProcess
public void setExternalProcess(boolean isExternalProcess) Set whether the process can accept parent data blocks from other PamControlledUnits -
getMuiltiplexDataBlock
Get a multiplex data block.- Parameters:
block
- - datablock index- Returns:
- a multiplex data block.
-
getNumMuiltiplexDataBlocks
public int getNumMuiltiplexDataBlocks()Get the number of multiplex datablocks.- Returns:
- the number of multiplex data blocks.
-
addMultiPlexDataBlock
Adds the process as an observer to the data block.- Parameters:
pamDataBlock
- - the datablock to add.
-
removeMultiPlexDataBlock
Remove the process from a data block and remove datablock from list of multiplex datablocks.- Parameters:
pamDataBlock
- - the data block to remove.
-
removeAllMultiPlexDataBlocks
Remove a list of multiplex data blocks.- Parameters:
pamDataBlocks
- -data blocks to remove.
-
receiveSourceNotification
Description copied from interface:PamObserver
Receive a notification from the data source - typically a change in DAQ status. See the constants listed in AcquisitionProcess for potential change types.- Specified by:
receiveSourceNotification
in interfacePamObserver
- Parameters:
type
- the type of changeobject
- generic object added here so that we can include anything in the future
-
getLastSourceNotificationType
public int getLastSourceNotificationType()- Returns:
- the lastSourceNotificationType
-
getLastSourceNotificationObject
- Returns:
- the lastSourceNotificationObject
-
dumpBufferStatus
Say the status of any buffers, particularly in output buffers of data blocks, but can add bespoke info for other internal buffers for some processes.- Parameters:
message
-sayEmpties
- include info even if a buffer is empty.
-