Class ClipProcess
- All Implemented Interfaces:
 PamObserver,ProcessAnnotator,SpectrogramMarkObserver
separate subscriber processes for each triggering data block, but these all send clip requests back into the main observer of the actual raw data - so that all clips are made from the same central thread.
Let the request queue trigger off the main clock signal.
- Author:
 - Doug Gillespie
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassclassData needed for a clip request. - 
Field Summary
Fields inherited from class PamguardMVC.PamProcess
outputDataBlocks, parentDataBlock, processName, sampleRateFields inherited from interface Spectrogram.SpectrogramMarkObserver
MOUSE_DOWN, MOUSE_DRAG, MOUSE_UP - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionbooleancanMark()findClipFile(ClipDataUnit clipDataUnit) Find the wav file to go with a particular clipbooleanflushDataBlockBuffers(long maxWait) Work through all the output datablocks and wait for their internal buffers to flush through.Name of the mark.longvoidmasterClockUpdate(long timeMilliseconds, long sampleNumber) voidnewData(PamObservable o, PamDataUnit arg) voidpamStart()Called for each process to tell it to start (may not be necessary for processes which are listening for data anyway).voidplayClip(ClipDataUnit clipDataUnit) voidCalled for each process before any of them receive the PamStart commandvoidprocessNewBuoyData(BuoyStatusDataUnit buoyStatusDataUnit, PamDataUnit pamDataUnit) booleanspectrogramNotification(SpectrogramDisplay display, MouseEvent mouseEvent, int downUp, int channel, long startMilliseconds, long duration, double f1, double f2, TDGraphFX tdDisplay) Override this to process data from the marked spectrogram.voidCalled at end of setup of after settings dialog to subscribe data blocks.Methods inherited from class Spectrogram.SpectrogramMarkProcess
getMarkObserverName, pamStopMethods inherited from class PamguardMVC.PamProcess
absMillisecondsToSamples, absSamplesToMilliseconds, addData, addMultiPlexDataBlock, addOutputDataBlock, changedThreading, clearOldData, createAnnotations, destroyProcess, dumpBufferStatus, getAncestorDataBlock, getAnnotation, getChainPosition, getCompatibleDataUnits, getCpuPercent, getFrequencyRange, getLastSourceNotificationObject, getLastSourceNotificationType, getMuiltiplexDataBlock, getNumAnnotations, getNumMuiltiplexDataBlocks, getNumOutputDataBlocks, getObserverName, getObserverObject, getOfflineData, getOfflineData, getOutputDataBlock, getOutputDataBlocks, getPamControlledUnit, getParentDataBlock, getParentDataBlocks, getParentProcess, getProcessCheck, getProcessName, getRawSourceDataBlock, getRawSourceDataBlock, getSampleRate, getSourceDataBlock, getSourceProcess, hasOutputDatablock, isCanMultiThread, isExternalProcess, isMultiplex, makePamProcess, noteNewSettings, notifyModelChanged, prepareProcessOK, receiveSourceNotification, relMillisecondsToSamples, relSamplesToMilliseconds, removeAllDataBlocks, removeAllMultiPlexDataBlocks, removeMultiPlexDataBlock, removeObservable, removeOutputDatablock, resetDataBlocks, saveViewerData, setCanMultiThread, setExternalProcess, setMultiplex, setParentDataBlock, setParentDataBlock, setProcessCheck, setProcessName, setSampleRate, setupProcess, toString, updateData 
- 
Constructor Details
- 
ClipProcess
 
 - 
 - 
Method Details
- 
newData
- Overrides:
 newDatain classPamProcess
 - 
masterClockUpdate
public void masterClockUpdate(long timeMilliseconds, long sampleNumber) - Specified by:
 masterClockUpdatein interfacePamObserver- Overrides:
 masterClockUpdatein classPamProcess
 - 
prepareProcess
public void prepareProcess()Description copied from class:PamProcessCalled for each process before any of them receive the PamStart command- Overrides:
 prepareProcessin classPamProcess
 - 
pamStart
public void pamStart()Description copied from class:PamProcessCalled for each process to tell it to start (may not be necessary for processes which are listening for data anyway).- Overrides:
 pamStartin classSpectrogramMarkProcess
 - 
findClipFile
Find the wav file to go with a particular clip- Parameters:
 clipDataUnit- data unit to find the file for.- Returns:
 - file, or null if not found.
 
 - 
flushDataBlockBuffers
public boolean flushDataBlockBuffers(long maxWait) Description copied from class:PamProcessWork 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.
- Overrides:
 flushDataBlockBuffersin classPamProcess- Parameters:
 maxWait- maxWait time in milliseconds.- Returns:
 - true if successful, or false if there was a timeout.
 
 - 
getRequiredDataHistory
- Specified by:
 getRequiredDataHistoryin interfacePamObserver- Overrides:
 getRequiredDataHistoryin classPamProcess- Parameters:
 arg- optional argument from PamObservable- Returns:
 - time in milliseconds required by data held in PamObservable
 
 - 
spectrogramNotification
public boolean spectrogramNotification(SpectrogramDisplay display, MouseEvent mouseEvent, int downUp, int channel, long startMilliseconds, long duration, double f1, double f2, TDGraphFX tdDisplay) Description copied from class:SpectrogramMarkProcessOverride this to process data from the marked spectrogram.The spectrogram will have already ensured that Raw waveform data and FFT data that made the SpectrogramDisplay are still in memory and the data blocks can be accessed using
PamRawDataBlock rawDataBlock = (PamRawDataBlock) display.getSourceRawDataBlock();
and
PamDataBlock fftDataBlock = display.getSourceFFTDataBlock();
To obtain raw data, first convert the startMilliseconds and duration to sample numbers using
long startSample = absMillisecondsToSamples(startMilliseconds);
and
int numSamples = (int) relMillisecondsToSamples(duration);
then make a bitmap of the channels you wnat -
int channelMap;
channelMap = PamUtils.SetBit(0, channel, 1); // just the channel that had the mark
channelMap = rawDataBlock.getChannelMap(); // all channels in the raw data block
Then get teh samples from the raw data block ...
double[][] rawData = rawDataBlock.getSamples(startSample, numSamples, channelMap);
To get the FFT data, use PamDataUnit fftDataUnit;
int fftDataUnitIndex = fftDataBlock.getIndexOfFirstUnitAfter(startMilliseconds);
if (fftDataUnitIndex >= 0) while (fftDataUnitIndex invalid input: '<' fftDataBlock.getUnitsCount()) {
fftDataUnit = fftDataBlock.getDataUnit(fftDataUnitIndex, PamDataBlock.REFERENCE_CURRENT);
if (fftDataUnit.timeMilliseconds + fftDataUnit.duration > startMilliseconds + duration) {
break;
}
// process that unit in any way you want, then get the next unit
fftDataUnitIndex ++;
}
Remember that the data units will contain one channel of fft data each and multiple channels may be interleaved.
- Specified by:
 spectrogramNotificationin interfaceSpectrogramMarkObserver- Overrides:
 spectrogramNotificationin classSpectrogramMarkProcess- Parameters:
 display- spectrogram displaydownUp- 0 = mouse down, 1 = mouse up, 2 = drag + button number in upper 16 bits.channel- channel or sequence number, depending on the sourcestartMilliseconds- start time in milliseconds.duration- duration in milliseconds.f1- min frequency in Hzf2- max frequency in Hz- Returns:
 - true if the user has popped up a menu or done something that should stop the sending display from carrying out any further actions on this mouse action (put in place to prevent the spectrogram menu popping up when editing marks in viewer mode).
 
 - 
canMark
public boolean canMark()- Returns:
 - whether or not it's possible to use this marker. Generally false when in viewer mode, but maynot always be.
 
 - 
subscribeDataBlocks
public void subscribeDataBlocks()Called at end of setup of after settings dialog to subscribe data blocks. - 
getClipControl
- Returns:
 - the clipControl
 
 - 
getClipDataBlock
- Returns:
 - the clipDataBlock
 
 - 
getClipSpectrogramMarkDataBlock
- Returns:
 - the clipSpectrogramMarkDataBlock
 
 - 
processNewBuoyData
- Overrides:
 processNewBuoyDatain classPamProcess
 - 
getMarkName
Description copied from interface:SpectrogramMarkObserverName of the mark. Observers may have several mark types and might want to change the name to indicate what action will be taken when a mark is made- Returns:
 
 - 
playClip
 - 
getManualAnnotaionHandler
- Returns:
 - the manualAnnotaionHandler
 
 
 -