public abstract class PamProcess extends java.lang.Object implements PamObserver, ProcessAnnotator
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 and Description |
---|
PamProcess(PamControlledUnit pamControlledUnit,
PamDataBlock parentDataBlock) |
PamProcess(PamControlledUnit pamControlledUnit,
PamDataBlock parentDataBlock,
java.lang.String processName) |
Modifier and Type | Method and Description |
---|---|
long |
absMillisecondsToSamples(long millis)
Convert a time in milli seconds to a number of samples.
|
long |
absSamplesToMilliseconds(long samples)
Convert am ADC sample number to a millisecond time.
|
void |
addOutputDataBlock(PamDataBlock outputDataBlock)
Adds an additional PamDataBlock to the process
|
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.
|
void |
clearOldData()
Clears all data from all output data blocks of this process.
|
void |
createAnnotations(boolean notifyDownstream) |
void |
destroyProcess()
Called from the PamControlled unit when a PamControlled unit is removed from
the model.
|
void |
fillXMLElement(org.w3c.dom.Document doc,
org.w3c.dom.Element processData,
int procId)
Fill in XML data for a specific process.
|
boolean |
flushDataBlockBuffers(long maxWait)
Work through all the output datablocks and wait for their
internal buffers to flush through.
|
PamDataBlock |
getAncestorDataBlock(java.lang.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.
|
ProcessAnnotation |
getAnnotation(PamDataBlock pamDataBlock,
int annotation)
Get an Annotation
|
int |
getChainPosition() |
double |
getCpuPercent() |
int |
getNumAnnotations(PamDataBlock pamDataBlock) |
int |
getNumOutputDataBlocks() |
java.lang.String |
getObserverName() |
PamObserver |
getObserverObject() |
int |
getOfflineData(PamDataBlock dataBlock,
PamObserver endUser,
long startMillis,
long endMillis,
RequestCancellationObject cancellationObject)
Request offline data.
|
PamDataBlock |
getOutputDataBlock(int block)
Each process may produce multiple data blocks.
|
java.util.ArrayList<PamDataBlock> |
getOutputDataBlocks()
Get the full list of output datablocks - used in logger forms so they
can all be mapped easily once created.
|
PamControlledUnit |
getPamControlledUnit() |
PamDataBlock |
getParentDataBlock() |
PamProcess |
getParentProcess() |
java.lang.String |
getProcessName() |
PamRawDataBlock |
getRawSourceDataBlock(float sampleRate)
Find the absolute source of raw audio data
if one exists
|
long |
getRequiredDataHistory(PamObservable o,
java.lang.Object arg) |
float |
getSampleRate() |
PamDataBlock<PamDataUnit> |
getSourceDataBlock()
find the absolute source of data, if one exists.
|
PamProcess |
getSourceProcess() |
boolean |
isCanMultiThread() |
void |
makePamProcess(PamControlledUnit pamControlledUnit,
PamDataBlock parentDataBlock,
java.lang.String processName) |
void |
masterClockUpdate(long timeMilliseconds,
long sampleNumber) |
void |
newData(PamObservable o,
PamDataUnit arg) |
void |
noteNewSettings() |
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 |
prepareProcess()
Called for each process before any of them receive the PamStart command
|
void |
processNewBuoyData(BuoyStatusDataUnit dataUnit,
PamDataUnit dataUnit2) |
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 milliseconds
|
void |
removeAllDataBlocks()
Remove all data blocks from a process.
|
void |
removeObservable(PamObservable observable)
Called when a PamDataBlock observed by this PamProcess is
removed.
|
void |
removeOutputDatablock(PamDataBlock outputDataBlock) |
void |
resetDataBlocks()
reset datablocks.
|
void |
saveViewerData()
Save data (to binary files and to database)
in viewer mode.
|
void |
setCanMultiThread(boolean canMultiThread) |
void |
setParentDataBlock(PamDataBlock newParentDataBlock)
Set a parent data block with the default options of rethreading
if set
|
void |
setParentDataBlock(PamDataBlock newParentDataBlock,
boolean reThread)
Set a parent data block for the process with the option to rethread
the data exchange process.
|
void |
setProcessName(java.lang.String processName) |
void |
setSampleRate(float sampleRate,
boolean notify)
New sample rate
|
void |
setupProcess()
called for every process once the systemmodel has been created.
|
java.lang.String |
toString() |
void |
update(PamObservable o,
PamDataUnit arg)
Informs the PamObserver that new data have been added to the Observable
class
|
void |
updateData(PamObservable o,
PamDataUnit arg) |
public PamProcess(PamControlledUnit pamControlledUnit, PamDataBlock parentDataBlock)
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)public PamProcess(PamControlledUnit pamControlledUnit, PamDataBlock parentDataBlock, java.lang.String processName)
public PamObserver getObserverObject()
getObserverObject
in interface PamObserver
public void destroyProcess()
public void removeAllDataBlocks()
public void makePamProcess(PamControlledUnit pamControlledUnit, PamDataBlock parentDataBlock, java.lang.String processName)
public PamDataBlock getParentDataBlock()
public PamProcess getParentProcess()
public PamDataBlock getAncestorDataBlock(java.lang.Class unitDataType)
unitDataType
- class type of data in the sought after
data block (e.g. RawDataUnit.classPamDataBlock
public void setParentDataBlock(PamDataBlock newParentDataBlock)
newParentDataBlock
- source data block.public void setParentDataBlock(PamDataBlock newParentDataBlock, boolean reThread)
newParentDataBlock
- source data blockreThread
- rethread if multithreading is enabled.public final void createAnnotations(boolean notifyDownstream)
public void changedThreading()
public void setProcessName(java.lang.String processName)
processName
- Sets the name of the processpublic java.lang.String getProcessName()
public java.lang.String getObserverName()
getObserverName
in interface PamObserver
public void setSampleRate(float sampleRate, boolean notify)
PamObserver
setSampleRate
in interface PamObserver
notify
- Notify other PamObservers and PamObservables in the chain.public void masterClockUpdate(long timeMilliseconds, long sampleNumber)
masterClockUpdate
in interface PamObserver
public long relSamplesToMilliseconds(long samples)
samples
- Number of ADC samplespublic long absSamplesToMilliseconds(long samples)
samples
- sample number (from start of run)public long absMillisecondsToSamples(long millis)
millis
- Current time in milliseconds
(UTC millseconds from the epoch - the standard Java way)relMillisecondsToSamples(double)
public long relMillisecondsToSamples(double millis)
millis
- number of millisecondsabsMillisecondsToSamples(long)
public void noteNewSettings()
noteNewSettings
in interface PamObserver
public float getSampleRate()
public PamProcess getSourceProcess()
public PamDataBlock<PamDataUnit> getSourceDataBlock()
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.
public PamRawDataBlock getRawSourceDataBlock(float sampleRate)
public int getChainPosition()
public PamDataBlock getOutputDataBlock(int block)
block
- Index of the required blockpublic int getNumOutputDataBlocks()
public void addOutputDataBlock(PamDataBlock outputDataBlock)
outputDataBlock
- Reference to a PamDataBlockpublic void removeOutputDatablock(PamDataBlock outputDataBlock)
public java.lang.String toString()
toString
in class java.lang.Object
public void clearOldData()
public void resetDataBlocks()
public void prepareProcess()
public long getRequiredDataHistory(PamObservable o, java.lang.Object arg)
getRequiredDataHistory
in interface PamObserver
o
- PamObservable class requiring the dataarg
- optional argument from PamObservablepublic final void update(PamObservable o, PamDataUnit arg)
PamObserver
update
in interface PamObserver
o
- Reference to the Observable (a PamDataBlock)arg
- Reference to the new PamDataUnitpublic void newData(PamObservable o, PamDataUnit arg)
public void updateData(PamObservable o, PamDataUnit arg)
public void setupProcess()
public double getCpuPercent()
public abstract void pamStart()
public abstract void pamStop()
public void removeObservable(PamObservable observable)
removeObservable
in interface PamObserver
public PamControlledUnit getPamControlledUnit()
public ProcessAnnotation getAnnotation(PamDataBlock pamDataBlock, int annotation)
ProcessAnnotator
getAnnotation
in interface ProcessAnnotator
pamDataBlock
- Annotated datablockannotation
- annotation numberpublic int getNumAnnotations(PamDataBlock pamDataBlock)
getNumAnnotations
in interface ProcessAnnotator
pamDataBlock
- Annotated datablockpublic void notifyModelChanged(int changeType)
public void setCanMultiThread(boolean canMultiThread)
canMultiThread
- the canMultiThread to setpublic boolean isCanMultiThread()
public void saveViewerData()
This gets called automatically on system exit and can also be called from the file menu.
public int getOfflineData(PamDataBlock dataBlock, PamObserver endUser, long startMillis, long endMillis, RequestCancellationObject cancellationObject)
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.
dataBlock
- data block making the request.endUser
- observer which made the original data request.startMillis
- start time in millisecondsendMillis
- end time in milliseconds.cancellationObject
- public final void fillXMLElement(org.w3c.dom.Document doc, org.w3c.dom.Element processData, int procId)
filling is split into two parts. First this Finalised function fills in basic data about the process, it then calls fillXMLParameters which will add more module specific information.
doc
- xml documentprocessData
- xml element to add datatopublic boolean flushDataBlockBuffers(long maxWait)
This is used when stopping PAMGUARD to ensure that all data complete processing before anything else happens.
maxWait
- maxWait time in milliseconds.public void processNewBuoyData(BuoyStatusDataUnit dataUnit, PamDataUnit dataUnit2)
public java.util.ArrayList<PamDataBlock> getOutputDataBlocks()