BDS Public
BdsApi 4.0.1
This is the Blacknest BDS API.
Loading...
Searching...
No Matches

This class defines the interface for generic data file access that all of the BDS data converters share. More...

#include <BdsDataFile.h>

Inheritance diagram for Bds::DataFile:
Bds::DataFileAd22 Bds::DataFileAscii Bds::DataFileBdrs Bds::DataFileBds Bds::DataFileBknas Bds::DataFileCd Bds::DataFileCss Bds::DataFileGcf Bds::DataFileIdc Bds::DataFileIms Bds::DataFileLac Bds::DataFileLog Bds::DataFileResponse Bds::DataFileSac Bds::DataFileSeed Bds::DataFileStationXml Bds::DataFileTapeDigitiser Bds::DataFileWra Bds::DataFileWraAgso

Public Types

enum  DataOrder { DataOrderUnknown , DataOrderAll , DataOrderSample , DataOrderChannel }
 
enum  Features { FeatureNone = 0x00 , FeatureCanWrite = 0x01 , FeatureCanRead = 0x02 }
 
enum  WriteOptionsList { WriteOptionNone = 0x00 , WriteOptionSensorData = 0x01 , WriteOptionNoMetadata = 0x02 }
 
enum  ReadOptionsList {
  ReadOptionNone = 0x00 , ReadOptionValidate = 0x01 , ReadOptionFileNameProcess = 0x02 , ReadOptionFixCorruptions = 0x04 ,
  ReadOptionReorder = 0x08 , ReadOptionDeleteDuplicates = 0x10 , ReadOptionInfoExtra = 0x20 , ReadOptionIgnoreSamplerate = 0x40 ,
  ReadOptionPrintBlocks = 0x80 , ReadOptionFixSampleRate = 0x100
}
 

Public Member Functions

 DataFile ()
 
virtual ~DataFile ()
 
virtual void init ()
 Initialise.
 
virtual BError open (BString fileName, BString mode)
 Open the file for read or write.
 
virtual BError close ()
 Close the file.
 
virtual BError setFormat (BString format)
 Set the sub-format.
 
virtual BString getFileName ()
 Return the file name.
 
virtual DataOrder getDataOrder ()
 Get the expected order of writing data, by sample or by channel.
 
virtual int getFeatures ()
 Get bitmask of supported features.
 
virtual BString getFixesInfo ()
 Get readable list of fixes that can be applied to faulty data files.
 
void getNotices (BStringList &notices)
 Get a list of any notices.
 
virtual BError setInfo (const DataInfo &dataInfo, const ChannelInfos &channelInfos, WriteOptionsList options=WriteOptionNone)
 Set information on data for write.
 
virtual BError start (BUInt channel, BUInt segment)
 Start writing next segment of data.
 
virtual BError writeData (const DataBlock &data)
 Write a block of data.
 
virtual BError end ()
 End write segment.
 
virtual BError flush ()
 Flush data to disk.
 
virtual BError fileNameProcess ()
 Parse the file name for a date/time.
 
virtual BError getFormat (BString &format)
 Get sub-format.
 
virtual BError getInfo (DataInfo &dataInfo, DataFileOptions options, BList< DataError > &errors)
 Get info on data.
 
virtual BError seekBlock (BUInt32 channel, BUInt segment, BTimeStamp time, BUInt32 &blockNumber, BUInt64 &sampleNumber, DataBlock &data)
 Find requested block on given channel given a time.
 
virtual BError readData (BUInt32 channel, BUInt segment, BUInt32 blockNumber, DataBlock &dataBlock)
 Read a block.
 
virtual BError getMetaData (ChannelInfos &channelInfos, BUInt32 options, BList< DataError > &errors)
 Return all known MetaData in the file.
 
void dataErrorFixup (const DataInfo &dataInfo, BList< DataError > &errors)
 Fixup data errors, mainly start/end times to be within data.
 
BInt64 timeCompare (BTimeStamp t1, BTimeStamp t2, BUInt diff)
 Compare timestamps with a margin.
 
int duplicateCheck (const DataBlock &data1, const DataBlock &data2, BUInt channel=0)
 Check if blocks are duplicates.
 
BUInt64 getFilePosition ()
 

Static Public Member Functions

static DataFormats getFormats ()
 Get list of supported formats.
 

Protected Attributes

BString ofileName
 
BString omode
 
BTimeStamp ofileNameTime
 
BFile ofile
 
BString oformat
 
BStringList onotices
 

Detailed Description

This class defines the interface for generic data file access that all of the BDS data converters share.

Member Enumeration Documentation

◆ DataOrder

Enumerator
DataOrderUnknown 
DataOrderAll 
DataOrderSample 
DataOrderChannel 

◆ Features

Enumerator
FeatureNone 
FeatureCanWrite 
FeatureCanRead 

◆ WriteOptionsList

Enumerator
WriteOptionNone 
WriteOptionSensorData 
WriteOptionNoMetadata 

◆ ReadOptionsList

Enumerator
ReadOptionNone 
ReadOptionValidate 
ReadOptionFileNameProcess 
ReadOptionFixCorruptions 
ReadOptionReorder 
ReadOptionDeleteDuplicates 
ReadOptionInfoExtra 
ReadOptionIgnoreSamplerate 
ReadOptionPrintBlocks 
ReadOptionFixSampleRate 

Constructor & Destructor Documentation

◆ DataFile()

Bds::DataFile::DataFile ( )

◆ ~DataFile()

Bds::DataFile::~DataFile ( )
virtual

Member Function Documentation

◆ init()

void Bds::DataFile::init ( )
virtual

Initialise.

◆ open()

BError Bds::DataFile::open ( BString  fileName,
BString  mode 
)
virtual

Open the file for read or write.

Parameters
fileNameThe filename to open. Can be a full path or relative path to the current working directory
modeThe open mode. Can be "r" or "w".

Opens a file of the gievn file format

Reimplemented in Bds::DataFileAscii, Bds::DataFileBds, Bds::DataFileBknas, Bds::DataFileIms, Bds::DataFileLog, and Bds::DataFileTapeDigitiser.

◆ close()

BError Bds::DataFile::close ( )
virtual

Close the file.

Reimplemented in Bds::DataFileBds, Bds::DataFileIms, and Bds::DataFileSeed.

◆ setFormat()

BError Bds::DataFile::setFormat ( BString  format)
virtual

Set the sub-format.

Parameters
formatThe data files format

When a data converter support multiple sub-format, this chooses the one to use.

Reimplemented in Bds::DataFileAscii, Bds::DataFileBds, Bds::DataFileLog, Bds::DataFileWra, and Bds::DataFileSeed.

◆ getFileName()

BString Bds::DataFile::getFileName ( )
virtual

Return the file name.

◆ getDataOrder()

◆ getFeatures()

BError Bds::DataFile::getFeatures ( )
virtual

Get bitmask of supported features.

Returns a bit mask of the data converters featurs from the set FeatureCanWrite = 0x01 and FeatureCanRead = 0x02

Reimplemented in Bds::DataFileAd22, Bds::DataFileAscii, Bds::DataFileBdrs, Bds::DataFileCd, Bds::DataFileCss, Bds::DataFileGcf, Bds::DataFileIdc, Bds::DataFileIms, Bds::DataFileLac, Bds::DataFileLog, Bds::DataFileResponse, Bds::DataFileSac, Bds::DataFileStationXml, Bds::DataFileWra, Bds::DataFileWraAgso, and Bds::DataFileSeed.

◆ getFixesInfo()

BError Bds::DataFile::getFixesInfo ( )
virtual

Get readable list of fixes that can be applied to faulty data files.

returns a human readable string describing the fixes to currupted files this data converter can implement when the ReadOptionFixCorruptions option is used

Reimplemented in Bds::DataFileAd22, Bds::DataFileBdrs, Bds::DataFileCd, Bds::DataFileGcf, Bds::DataFileLac, Bds::DataFileWra, and Bds::DataFileSeed.

◆ getNotices()

void Bds::DataFile::getNotices ( BStringList notices)

Get a list of any notices.

◆ setInfo()

BError Bds::DataFile::setInfo ( const DataInfo dataInfo,
const ChannelInfos channelInfos,
WriteOptionsList  options = WriteOptionNone 
)
virtual

Set information on data for write.

Parameters
dataInfoInfo on the Sensor data channels to be written
channelInfosThe metadata for the data channels
optionsA bitmask of options including: WriteOptionSensorData, WriteOptionNoMetadata WriteOptionSensorData: Writes Sensor data to the file WriteOptionNoMetadata: Disable the writing of Metadata

This function provides the information to create and write to a data file of this given format.

Reimplemented in Bds::DataFileIdc, Bds::DataFileResponse, Bds::DataFileStationXml, Bds::DataFileIms, Bds::DataFileSac, Bds::DataFileAscii, Bds::DataFileBds, Bds::DataFileBknas, Bds::DataFileLog, and Bds::DataFileSeed.

◆ start()

BError Bds::DataFile::start ( BUInt  channel,
BUInt  segment 
)
virtual

Start writing next segment of data.

Parameters
channelThe Channel number, 0 for all channels if multiple channel
segmentThe data segment number

This starts writing a contiguous time segment of data to the file. It might write a section header etc depending of the file format

Reimplemented in Bds::DataFileAscii, Bds::DataFileIms, Bds::DataFileLog, and Bds::DataFileSeed.

◆ writeData()

BError Bds::DataFile::writeData ( const DataBlock data)
virtual

Write a block of data.

Parameters
dataA block of data

This writes a block of data to the file

Reimplemented in Bds::DataFileAscii, Bds::DataFileBds, Bds::DataFileBknas, Bds::DataFileIms, Bds::DataFileLog, and Bds::DataFileSeed.

◆ end()

BError Bds::DataFile::end ( )
virtual

End write segment.

This defines the end of a data segment.

Reimplemented in Bds::DataFileAscii, Bds::DataFileIms, Bds::DataFileLog, and Bds::DataFileSeed.

◆ flush()

BError Bds::DataFile::flush ( )
virtual

Flush data to disk.

Makes sure all of the files contents is flushed from RAM to the disk.

Reimplemented in Bds::DataFileBds.

◆ fileNameProcess()

BError Bds::DataFile::fileNameProcess ( )
virtual

Parse the file name for a date/time.

◆ getFormat()

BError Bds::DataFile::getFormat ( BString format)
virtual

Get sub-format.

Parameters
formatThe returned format

Returns the name of the sub-format in use

◆ getInfo()

BError Bds::DataFile::getInfo ( DataInfo dataInfo,
DataFileOptions  options,
BList< DataError > &  errors 
)
virtual

Get info on data.

Parameters
dataInfoInfo on the Sensor data channels to be written
optionsA bitmask of options including: ReadOptionValidate = 0x01, ReadOptionFileNameProcess = 0x02, ReadOptionFixCorruptions = 0x04, ReadOptionReorder = 0x08, ReadOptionDeleteDuplicates = 0x10, ReadOptionInfoExtra = 0x20, ReadOptionIgnoreSamplerate = 0x40, ReadOptionPrintBlocks = 0x80, ReadOptionFixSampleRate = 0x100
errorsReturns a list of errors and/or warnings ReadOptionValidate: performs data file validation ReadOptionFileNameProcess: Validate the filename for particular file formats ReadOptionFixCorruptions: Fix know file curruptions ReadOptionReorder: Re-order blocks into time order ReadOptionDeleteDuplicates: Delete duplicate blocks where they are completely duplicate in startTime and data. ReadOptionInfoExtra: Read the extra string Metadata information specific to the format ReadOptionIgnoreSamplerate: Ignore samplerate differences ReadOptionPrintBlocks: debug option to print information on the blocks to stdout ReadOptionFixSampleRate: Fors specific formats fixe curruptions in the samplerate gieven

This function scans the file and returns detailed Metadata from the blocks in the file.

Reimplemented in Bds::DataFileAd22, Bds::DataFileBdrs, Bds::DataFileBds, Bds::DataFileCd, Bds::DataFileCss, Bds::DataFileGcf, Bds::DataFileLac, Bds::DataFileLog, Bds::DataFileTapeDigitiser, Bds::DataFileWra, Bds::DataFileWraAgso, and Bds::DataFileSeed.

◆ seekBlock()

BError Bds::DataFile::seekBlock ( BUInt32  channel,
BUInt  segment,
BTimeStamp  time,
BUInt32 blockNumber,
BUInt64 sampleNumber,
DataBlock data 
)
virtual

Find requested block on given channel given a time.

Parameters
channelThe channel number. 0 for all channels.
segmentThe segment number. 0 for all segments
timeThe time of a sample to search for
blockNumberThe returned block number
sampleNumberThe sample number inside the block (based on sampleRate)
dataThe matched DataBlock

This seeks for the a DataBlock in the file that contains a sample for the time provided. If channel is other than 0 then it seeks for a DataBlock for the given channel. If the data is sample multiplexed a Channel number of 0 can be given which will return the location of a dataBlock containing all of the Channels. If Segment is 0 then the block number returned is referenced to the start of the set of files. If a particular segment number is given then the seek and the returned block number is within that segment.

Reimplemented in Bds::DataFileBds.

◆ readData()

BError Bds::DataFile::readData ( BUInt32  channel,
BUInt  segment,
BUInt32  blockNumber,
DataBlock dataBlock 
)
virtual

Read a block.

Parameters
channelThe channel number. 0 Means all channels
segmentThe segment number. 0 Means all segments
blockNumberThe block number. This starts from 0.
dataBlockThe returned DataBlock

This function is used to read a data block from the file.

Reimplemented in Bds::DataFileAd22, Bds::DataFileBdrs, Bds::DataFileCd, Bds::DataFileCss, Bds::DataFileGcf, Bds::DataFileLac, Bds::DataFileLog, Bds::DataFileTapeDigitiser, Bds::DataFileWra, Bds::DataFileWraAgso, Bds::DataFileSeed, and Bds::DataFileBds.

◆ getMetaData()

BError Bds::DataFile::getMetaData ( ChannelInfos channelInfos,
BUInt32  options,
BList< DataError > &  errors 
)
virtual

Return all known MetaData in the file.

Parameters
channelInfosThe Metadata in the file is returned in this
optionsThis operators similarly to the getInfo options although some features are not relevent
errorsReturns a list of errors and/or warnings

This function is similar to getInfo except that it returns the list of Channel metadata in the file if any. Only certain formats can provide this.

Reimplemented in Bds::DataFileIdc, Bds::DataFileIms, Bds::DataFileResponse, Bds::DataFileSac, Bds::DataFileStationXml, and Bds::DataFileSeed.

◆ dataErrorFixup()

void Bds::DataFile::dataErrorFixup ( const DataInfo dataInfo,
BList< DataError > &  errors 
)

Fixup data errors, mainly start/end times to be within data.

◆ timeCompare()

BInt64 Bds::DataFile::timeCompare ( BTimeStamp  t1,
BTimeStamp  t2,
BUInt  diff 
)

Compare timestamps with a margin.

◆ duplicateCheck()

int Bds::DataFile::duplicateCheck ( const DataBlock data1,
const DataBlock data2,
BUInt  channel = 0 
)

Check if blocks are duplicates.

◆ getFilePosition()

BUInt64 Bds::DataFile::getFilePosition ( )

◆ getFormats()

DataFormats Bds::DataFile::getFormats ( )
static

Get list of supported formats.

Member Data Documentation

◆ ofileName

BString Bds::DataFile::ofileName
protected

◆ omode

BString Bds::DataFile::omode
protected

◆ ofileNameTime

BTimeStamp Bds::DataFile::ofileNameTime
protected

◆ ofile

BFile Bds::DataFile::ofile
protected

◆ oformat

BString Bds::DataFile::oformat
protected

◆ onotices

BStringList Bds::DataFile::onotices
protected

The documentation for this class was generated from the following files: