clickDetector
Class RainbowFile

java.lang.Object
  extended by clickDetector.RainbowFile
All Implemented Interfaces:
ClickFileStorage

public class RainbowFile
extends java.lang.Object
implements ClickFileStorage

Author:
Doug Gillespie

Creates a file in the RainbowClick file format. Required Rainbowclick structures are subclasses of RainbowFile. The class is also responsible for holding the file handle, etc.

Not all RainbowClick structures are implemented since may of them contain no useful data. Parameter settings will be added to other Pam storage as that developes.


Field Summary
private  WindowsBuffer clickBuffer
           
private  ClickDetector clickDetector
           
(package private) static byte CURRENT_FILE_FORMAT
           
private  WindowsFile file
           
private  java.lang.String fileName
           
private  long fileSamples
           
private  long fileStartTime
           
static int HEADER_CLICK
           
static int HEADER_GPSDATA
           
static int HEADER_NOISE
           
static int HEADER_SECTION
           
static int HEADER_SEISMIC
           
(package private) static int MAX_PATH
           
(package private) static int NC_ANALPARMS
           
(package private) static int NC_ANALTYPE
           
(package private) static int NC_AUTOADJUST
           
(package private) static int NC_DATABASESTUFF
           
(package private) static int NC_DATHEADER
           
(package private) static int NC_DIGITALFILTER
           
(package private) static int NC_DIGITALFILTERDISPLAY
           
(package private) static int NC_DIGITALPREFILTER
           
(package private) static int NC_DISPARMS
           
(package private) static int NC_EVERYTHING
           
(package private) static int NC_FILEOPTIONS
           
(package private) static int NC_FILTPARMS
           
(package private) static int NC_NARROWREJECT
           
(package private) static int NC_ONLINEID
           
(package private) static int NC_OPTIONS
           
(package private) static int NC_OUTPUTPARS
           
(package private) static int NC_RAWFILTPARMS
           
(package private) static int NC_RUNPARDATA
           
(package private) static int NC_SCSETTINGS
           
(package private) static int NC_SECTIONSTUFF
           
(package private) static int NC_SECTIONTIME
           
(package private) static int NC_STORAGEOPTIONS
           
(package private) static int NC_TRACKOPTIONS
           
(package private) static int NC_WAVFILEINFO
           
private  int nClicksInFile
          Used mainly offline to get how many clicks there are in the file.
private  java.util.Calendar rainbowCalendar
           
private  java.io.File rainbowFile
           
private  long sampleOffset
           
private  float sampleRate
           
private  java.util.ArrayList<RainbowFileSectionData> sectionDataList
           
private  long structureEndPoint
           
 
Constructor Summary
RainbowFile(ClickDetector clickDetector)
           
 
Method Summary
 boolean checkStorage()
           
static boolean checkStorage(java.lang.String dirName)
           
 void closeClickStorage()
           
protected  void finalize()
           
(package private)  java.lang.String getDateFileName()
          Create a default data file name
 long getFileEndTime()
           
 long getFileStartTime()
           
(package private)  int getInputDevice()
           
 int getNClicksInFile()
           
 ClickDetection getNextClick()
          Get the next clicks from the file.
 int getNumSections()
           
 java.io.File getRainbowFile()
          Get the current File object
private  long getRainbowStructureSize(int structId)
           
 float getSampleRate()
           
private  java.io.File getSourceWavFile()
           
private  java.lang.String getSourceWavFileName()
           
 java.lang.String getStorageName()
           
(package private)  java.lang.String getWavFileName(java.io.File wavFile)
           
 boolean gotoSectionData(int iSection)
           
 boolean gotoSectionHead(int iSection)
           
 boolean moveToClicks()
           
 boolean openClickStorage(java.io.File oldFile)
          Open an old rainbowclick file to reload data for viewing or for batch conversion into binary files.
 boolean openClickStorage(long sampleOffset)
          Open a new rainbowFile for storage.
(package private)  boolean readAnalParms(ClickParameters clickParameters)
           
(package private)  boolean readAnalType(ClickParameters clickParameters)
           
private  boolean readClickHeader(ClickDetection click)
           
 boolean readClickStructure(int structId, ClickParameters clickParameters)
           
 boolean readClickStructures(ClickParameters clickParameters)
           
 boolean readClickStructures(ClickParameters clickParameters, boolean fromStart)
          Read click head structures from a rainbowclick file.
(package private)  int readFileHeader()
           
(package private)  boolean readFiltParms(ClickParameters clickParameters)
           
 boolean readSCSettings(ClickParameters clickParameters)
           
(package private)  boolean readSectionTime()
           
(package private)  long readSystemTime()
           
private  boolean readWavData(ClickDetection click)
           
private  boolean readWavFileInfo()
           
 boolean reWriteClick(ClickDetection click)
           
private  boolean skipClickStructure(int structId)
           
private  boolean skipWavData(ClickDetection click)
           
private  void useSectionParams(RainbowFileSectionData rainbowFileSectionData)
           
(package private)  boolean writeAnalParms(ClickParameters clickParameters)
           
(package private)  boolean writeAnalType(ClickParameters clickParameters)
           
 boolean writeClick(ClickDetection click)
           
 boolean writeClickHeader(ClickDetection click)
           
private  boolean writeClickHeader(WriteWinFile winFile, ClickDetection click)
           
 boolean writeClickStructure(int structId, ClickParameters clickParameters)
           
 boolean writeClickStructures(ClickParameters clickParameters)
           
(package private)  boolean writeFileHeader(int nClicks)
           
(package private)  boolean writeFiltParms(ClickParameters clickParameters)
           
 boolean writeSCSettings(ClickParameters clickParameters)
           
(package private)  boolean writeSectionTime(long timeMS, int duration, short whyStopped)
           
(package private)  boolean writeSystemTime(long timeMS)
           
private  boolean writeWavFileInfo()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CURRENT_FILE_FORMAT

static final byte CURRENT_FILE_FORMAT
See Also:
Constant Field Values

MAX_PATH

static final int MAX_PATH
See Also:
Constant Field Values

NC_SCSETTINGS

static final int NC_SCSETTINGS
See Also:
Constant Field Values

NC_ANALPARMS

static final int NC_ANALPARMS
See Also:
Constant Field Values

NC_FILTPARMS

static final int NC_FILTPARMS
See Also:
Constant Field Values

NC_RAWFILTPARMS

static final int NC_RAWFILTPARMS
See Also:
Constant Field Values

NC_DATHEADER

static final int NC_DATHEADER
See Also:
Constant Field Values

NC_ANALTYPE

static final int NC_ANALTYPE
See Also:
Constant Field Values

NC_SECTIONTIME

static final int NC_SECTIONTIME
See Also:
Constant Field Values

NC_RUNPARDATA

static final int NC_RUNPARDATA
See Also:
Constant Field Values

NC_DISPARMS

static final int NC_DISPARMS
See Also:
Constant Field Values

NC_OPTIONS

static final int NC_OPTIONS
See Also:
Constant Field Values

NC_OUTPUTPARS

static final int NC_OUTPUTPARS
See Also:
Constant Field Values

NC_TRACKOPTIONS

static final int NC_TRACKOPTIONS
See Also:
Constant Field Values

NC_DATABASESTUFF

static final int NC_DATABASESTUFF
See Also:
Constant Field Values

NC_FILEOPTIONS

static final int NC_FILEOPTIONS
See Also:
Constant Field Values

NC_WAVFILEINFO

static final int NC_WAVFILEINFO
See Also:
Constant Field Values

NC_DIGITALFILTER

static final int NC_DIGITALFILTER
See Also:
Constant Field Values

NC_DIGITALFILTERDISPLAY

static final int NC_DIGITALFILTERDISPLAY
See Also:
Constant Field Values

NC_AUTOADJUST

static final int NC_AUTOADJUST
See Also:
Constant Field Values

NC_ONLINEID

static final int NC_ONLINEID
See Also:
Constant Field Values

NC_NARROWREJECT

static final int NC_NARROWREJECT
See Also:
Constant Field Values

NC_STORAGEOPTIONS

static final int NC_STORAGEOPTIONS
See Also:
Constant Field Values

NC_DIGITALPREFILTER

static final int NC_DIGITALPREFILTER
See Also:
Constant Field Values

NC_EVERYTHING

static final int NC_EVERYTHING
See Also:
Constant Field Values

NC_SECTIONSTUFF

static final int NC_SECTIONSTUFF
See Also:
Constant Field Values

HEADER_CLICK

public static final int HEADER_CLICK
See Also:
Constant Field Values

HEADER_SECTION

public static final int HEADER_SECTION
See Also:
Constant Field Values

HEADER_GPSDATA

public static final int HEADER_GPSDATA
See Also:
Constant Field Values

HEADER_NOISE

public static final int HEADER_NOISE
See Also:
Constant Field Values

HEADER_SEISMIC

public static final int HEADER_SEISMIC
See Also:
Constant Field Values

clickDetector

private ClickDetector clickDetector

fileName

private java.lang.String fileName

rainbowFile

private java.io.File rainbowFile

file

private volatile WindowsFile file

clickBuffer

private WindowsBuffer clickBuffer

sampleOffset

private long sampleOffset

fileStartTime

private long fileStartTime

fileSamples

private long fileSamples

structureEndPoint

private long structureEndPoint

sampleRate

private float sampleRate

rainbowCalendar

private java.util.Calendar rainbowCalendar

sectionDataList

private java.util.ArrayList<RainbowFileSectionData> sectionDataList

nClicksInFile

private int nClicksInFile
Used mainly offline to get how many clicks there are in the file.

Constructor Detail

RainbowFile

public RainbowFile(ClickDetector clickDetector)
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

openClickStorage

public boolean openClickStorage(long sampleOffset)
Open a new rainbowFile for storage.

Specified by:
openClickStorage in interface ClickFileStorage

openClickStorage

public boolean openClickStorage(java.io.File oldFile)
Open an old rainbowclick file to reload data for viewing or for batch conversion into binary files.


gotoSectionHead

public boolean gotoSectionHead(int iSection)

useSectionParams

private void useSectionParams(RainbowFileSectionData rainbowFileSectionData)

gotoSectionData

public boolean gotoSectionData(int iSection)

getDateFileName

java.lang.String getDateFileName()
Create a default data file name

Returns:
name

getWavFileName

java.lang.String getWavFileName(java.io.File wavFile)

closeClickStorage

public void closeClickStorage()
Specified by:
closeClickStorage in interface ClickFileStorage

getNumSections

public int getNumSections()
Returns:
the number of sections in an old style RC file.

writeClickStructures

public boolean writeClickStructures(ClickParameters clickParameters)
Specified by:
writeClickStructures in interface ClickFileStorage

readClickStructures

public boolean readClickStructures(ClickParameters clickParameters)

readClickStructures

public boolean readClickStructures(ClickParameters clickParameters,
                                   boolean fromStart)
Read click head structures from a rainbowclick file.

Parameters:
clickParameters -
Returns:
true if read ok, false otherwise

moveToClicks

public boolean moveToClicks()

getNextClick

public ClickDetection getNextClick()
Get the next clicks from the file. Assume that the file pointer is in the right place, etc.

Returns:
next click, or null if EOF.

writeClickStructure

public boolean writeClickStructure(int structId,
                                   ClickParameters clickParameters)

readClickStructure

public boolean readClickStructure(int structId,
                                  ClickParameters clickParameters)

skipClickStructure

private boolean skipClickStructure(int structId)

getRainbowStructureSize

private long getRainbowStructureSize(int structId)

writeSCSettings

public boolean writeSCSettings(ClickParameters clickParameters)

readSCSettings

public boolean readSCSettings(ClickParameters clickParameters)

writeClickHeader

public boolean writeClickHeader(ClickDetection click)
Specified by:
writeClickHeader in interface ClickFileStorage

reWriteClick

public boolean reWriteClick(ClickDetection click)

writeClick

public boolean writeClick(ClickDetection click)
Specified by:
writeClick in interface ClickFileStorage

writeClickHeader

private boolean writeClickHeader(WriteWinFile winFile,
                                 ClickDetection click)

readClickHeader

private boolean readClickHeader(ClickDetection click)

readWavData

private boolean readWavData(ClickDetection click)

skipWavData

private boolean skipWavData(ClickDetection click)

writeFileHeader

boolean writeFileHeader(int nClicks)

readFileHeader

int readFileHeader()

writeAnalParms

boolean writeAnalParms(ClickParameters clickParameters)

readAnalParms

boolean readAnalParms(ClickParameters clickParameters)

writeAnalType

boolean writeAnalType(ClickParameters clickParameters)

readAnalType

boolean readAnalType(ClickParameters clickParameters)

getInputDevice

int getInputDevice()

writeFiltParms

boolean writeFiltParms(ClickParameters clickParameters)

readFiltParms

boolean readFiltParms(ClickParameters clickParameters)

writeSectionTime

boolean writeSectionTime(long timeMS,
                         int duration,
                         short whyStopped)

readSectionTime

boolean readSectionTime()

writeSystemTime

boolean writeSystemTime(long timeMS)

readSystemTime

long readSystemTime()

writeWavFileInfo

private boolean writeWavFileInfo()

readWavFileInfo

private boolean readWavFileInfo()

getSourceWavFileName

private java.lang.String getSourceWavFileName()

getSourceWavFile

private java.io.File getSourceWavFile()

getStorageName

public java.lang.String getStorageName()
Specified by:
getStorageName in interface ClickFileStorage

checkStorage

public boolean checkStorage()
Specified by:
checkStorage in interface ClickFileStorage

checkStorage

public static boolean checkStorage(java.lang.String dirName)

getFileStartTime

public long getFileStartTime()
Returns:
the file start time in standard Java milliseconds

getFileEndTime

public long getFileEndTime()
Returns:
the file end time in standard Java milliseconds

getSampleRate

public float getSampleRate()
Returns:
the files sample rate in Hz

getRainbowFile

public java.io.File getRainbowFile()
Get the current File object

Returns:
File object.

getNClicksInFile

public int getNClicksInFile()
Returns:
the nClicksInFile