In file frwriter/FrWriter.hh:

class FrWriter

DMT frame writer API.

Inheritance:


Public Methods

FrWriter (void)
Default (Null) constructor
FrWriter (const char* Name, int Run)
Construct and connect to destination file
~FrWriter (void)
Destructor
void setDebug (int debug=0)
Set the debug flag.
void addChannel (const char* Name, TSeries** TSptr=0)
Add a channel to the request list.
void rmChannel (const char* Name)
Remove a channel from the request list.
int open (const char* File, bool toc=false)
Open a file.
int open (FrameCPP::OFrameStream* writer)
Open a file specified by a framewriter.
void close (void)
Close the current data file.
void erase (void)
Erase the current data frame.
int writeFrame (void)
Fill the requested TSeries.
int buildFrame (const Time& Start=Time(0), const Interval& dT=0.0)
Create a data frame from the data.
void addFrequencySeries (const char* Name, const FSeries& fs)
Add a processed data frequency series to the frame.
void addHistory (const std::string& Name, const Time& t, const std::string& cmt)
Add a History record.
void addProcData (const std::string& Name, const std::string& comment, int type, int subtype, const Time& Start, const Time& End, double fShift, double fPhase, double fRange, double bw, FrVectRef& vect)
Add a processed data structure.
void addProcSeries (const char* Name, const TSeries& TS)
Add a pre-processed data structure to the frame.
void addRawSeries (const char* Name, const TSeries& TS)
Add an ADC data structure.
void addSimEvent (const char* Name, const char* Comment, const char* Inputs, const Time& GPSMax, Interval before, Interval after, float Amp, const std::vector< std::pair<std::string, float> >& v)
Add a simulated data structure.
void addSimSeries (const char* Name, const TSeries& TS)
Add a simulated data structure.
void addSeries (const char* Name, const TSeries& TS)
Add an ADC data structure.
void addSpectrum (const char* Name, const FSpectrum& sp)
Add a spectrum to the frame.
void addStatic (FrStatDataRef& s)
Add a static data structure to the output frame.
void addStatic (const std::string& Name, unsigned long version, const Time& GpsStart, const Time& GpsEnd, void* det, const FSeries& fs)
Write a static frequency series.
void addStatic (const std::string& Name, unsigned long version, const Time& GpsStart, const Time& GpsEnd, void* det, const TSeries& ts)
Write a static time series.
void* addStdDetector (const std::string& iName)
Add a FrameCPP Detector record.
void addWriterHistory (void)
Add a FrameCPP History record.
int getDebug (void) const
Get the debug flag.
const char* getFile (void) const
Get the input file name.
const FrameCPP::FrameH* getFrame (void) const
Get a pointer to the current frame header.
std::string getFrameID (void) const
Copy a Frame ID into the specified string.
Time getTime (void) const
Get the Start time.
bool is_open (void) const
Test open status.
std::ostream& list (std::ostream& out) const
List requested channels.
void setCompress (FrVectRef::compression_mode cmode)
Set the compression mode for data vectors
void setName (const std::string& name)
Set run Number and reset the frame count
void setRunID (int run)
Set run Number and reset the frame count
void copyDetectors (const FrameCPP::FrameH& f)
Copy detector information.
void copyHistory (const FrameCPP::FrameH& f)
Copy history information.
void copyAuxData (const FrameCPP::FrameH& f)
Copy auxillary data.
void addRawAdc (const FrameCPP::FrameH& f, const char* Name)
Copy adc data.
void addRawAdc (const FrameCPP::FrAdcData& adc)
Copy adc data.

Documentation

FrWriter methods are used to create frames from TSeries objects and other data. THe FrWriter API is used as follows. A frame writer is created and then opened with the open() method. Any TSeries that are to be written to all output frames are introoduced to the frame writer with the addChannel() function. For each frame to be written user must build the frame with buildFrame(), add any additional TSeries data with addSeries() or other data using the FrameCPP API and the frame pointer from getFrame() and write it out with writeFrame(). After all frames have been written, the frame writer is closed with close() and/or deleted.

A sample code segment is shown below.

     TSeries ts(Now(), Interval(1./16384.), 16384, Sine(1000.0));
     FrWriter fw("TestFrame", -1);
     fw.buildFrame(ts.getStartTime(), Interval(1.0));
     fw.addRawSeries("Sine_1kHz", ts);
     fw.addHistory("FrWriterExample", Now(), "FrWriter usage example");
     fw.addWriterHistory();
     fw.open("TestFrame.gwf", true);
     fw.writeFrame();
     fw.close();
     

The above code creates a frame in file "TestFrame.F" with a frame ID of "TestFrame" and a run number of -1. A single time raw data channel named "Sine_1kHz" with a 1kHz sine wave is written to the frame. History records are written describing the program used (specified explicitly with addHistory()) and the FrWriter version (specified by addWriterHistory()). The negative run number specified in the constructor indicates that the frame contains Monte Carlo geenrated data.

FrWriter(void)
Default (Null) constructor

FrWriter(const char* Name, int Run)
Construct and connect to destination file. Any frame name may be used. The run number should follow the frame standard run number convention.
Parameters:
Name - Frame name.
Current - run number.

~FrWriter(void)
Destructor

void setDebug(int debug=0)
If the debug flag is set, explanatory messages will be printed when an error is encountered.

void addChannel(const char* Name, TSeries** TSptr=0)
The specified channel is added to the list of channels to be processed by buildFrame. A channel may be included in the list only once. Subsequent calls to addChannel will replace the original request. TSptr specifies the location of a pointer to the data. Note that the data are not copied until buildFrame is called. Core must be taken that the specified pointer (TSptr) must therefore still exists and points to valid data at the time buildFrame is called. The data are written with the same type as the TSeries.
Parameters:
Name - Name of channel to collect data from.
TSptr - Address of TSeries pointer.

void rmChannel(const char* Name)
The named channel is removed from the request list.

int open(const char* File, bool toc=false)
The file is opened for output. If a file is already open, it will be closed, and a new file will be opened.
Parameters:
File - name of output file.
tco - If true, write a table of contents.

int open(FrameCPP::OFrameStream* writer)
The specified framewriter is used for output. If a file is already open the current frame writer is closed and deleted.

void close(void)
The current data file is closed and the frame writer is deleted.

void erase(void)
The current frame is deleted without being written.

int writeFrame(void)
Data from TSeries specified by addChannel() are copied to the output frame.

int buildFrame(const Time& Start=Time(0), const Interval& dT=0.0)
A frame is constructed and data from all TSeries specified with addChannel are copied into the frame.
Returns:
Zero if valid frame read in, otherwise -1.
Parameters:
Start - Frame start time.
dT - Frame length.

void addFrequencySeries(const char* Name, const FSeries& fs)
Add a processed data frequency series to the frame.
Parameters:
Name - Name of ProcData to be added.
FS - FSeries containing pre-processed data.

void addHistory(const std::string& Name, const Time& t, const std::string& cmt)
Add a history record as defined by the arguments.
Parameters:
Name - Name of History record.
t - Time of post processing.
cmt - Additional comments.

void addProcData(const std::string& Name, const std::string& comment, int type, int subtype, const Time& Start, const Time& End, double fShift, double fPhase, double fRange, double bw, FrVectRef& vect)
Add a processed data structure.
Parameters:
Name - Name of ProcData to be added.
comment - FrProcData comment.
type - FrProcData type code
subtype - FrProcData subtype code
Start - Start time.
End - End time.
fShift - Heterodyne frequency
fPhase - Heterodyne phase
fRange - Frequency range
bw - Bandwidth
FrVectRef - Vector reference.

void addProcSeries(const char* Name, const TSeries& TS)
Add a pre-processed data series to the frame from a TSeries.
Parameters:
Name - Name of ProcData to be added.
TS - Time series containing pre-processed data.

void addRawSeries(const char* Name, const TSeries& TS)
Add a raw data channel to the frame from a TSeries.
Parameters:
Name - Name of ADC to be added.
TS - Time series containing Adc data.

void addSimEvent(const char* Name, const char* Comment, const char* Inputs, const Time& GPSMax, Interval before, Interval after, float Amp, const std::vector< std::pair<std::string, float> >& v)
Add a simulated data channel to the frame from a TSeries.
Parameters:
Name - Name of Simulated channel to be added.
Comment - Description of event
Inputs - Description of input data
GPSMax - GPS time of event maximum
before - Interval before maximum
after - Interval after maximum
Amp - Event amplitude
v - Other parameter values.

void addSimSeries(const char* Name, const TSeries& TS)
Add a simulated data channel to the frame from a TSeries.
Parameters:
Name - Name of Simulated channel to be added.
TS - Time series containing simulated data.

void addSeries(const char* Name, const TSeries& TS)
Add a raw data channel to the frame from a TSeries. This is equivalent to addRawSeries, but kept for backward compatibility.
Parameters:
Name - Name of ADC to be added.
TS - Time series containing Adc data.

void addSpectrum(const char* Name, const FSpectrum& sp)
Add a spectrum from a FSpectrum object to the frame in a FrProcData object.
Parameters:
Name - Name of ProcData to be added.
sp - FSpectrum containing pre-processed data.

void addStatic(FrStatDataRef& s)
Add a static data structure to the output frame.
Parameters:
s - Static data reference.

void addStatic(const std::string& Name, unsigned long version, const Time& GpsStart, const Time& GpsEnd, void* det, const FSeries& fs)
Write an FSeries as an FrStatData structure.
Parameters:
Name - Name of FrStatData to be added.
version - Static data version.
GpsStart - Start of data validity.
GpsEnd - End of data validity.
det - Pointer to FrDetector for this FSeries.
fs - FSeries containing pre-processed data.

void addStatic(const std::string& Name, unsigned long version, const Time& GpsStart, const Time& GpsEnd, void* det, const TSeries& ts)
Write a TSeries as an FrStatData structure.
Parameters:
Name - Name of FrStatData to be added.
version - Static data version.
GpsStart - Start of data validity.
GpsEnd - End of data validity.
det - Pointer to FrDetector for this TSeries.
ts - TSeries containing pre-processed data.

void* addStdDetector(const std::string& iName)
Add a detector record with the standard parameters for the instrument specified by the prefix.
Returns:
Pointer to the inserted FrDetector object.
Parameters:
iName - Ifo prefix. Only the first two characters are used.

void addWriterHistory(void)
Add a history record with the current version of FrameCPP.

int getDebug(void) const
Returns the level of debug information that was requested.
Returns:
Debug print level.

const char* getFile(void) const
Returns a pointer to a string containing the current input file name. If no file is open, a pointer to the next file name is returned.

const FrameCPP::FrameH* getFrame(void) const
Returns a pointer to the current frame header.

std::string getFrameID(void) const
An identifier of the form <ifo-id>-<GPS-time>.F is generated for the current Frame and copied to the specified string.
Returns:
string containing the current frame identifier.

Time getTime(void) const
Returns the time at which data collection is to start.

bool is_open(void) const
Test whether the FrWriter is open. The FrWriter is considered to be open if an open OFrameStream is pointed to by mWriter.
Returns:
true if the FrWriter is open.

std::ostream& list(std::ostream& out) const
A formatted list of requested channels, their decimation factors, and latest time copied is printed to the specified output stream.
Returns:
Output strem reference.
Parameters:
out - Reference to the output stream to which the list will be written.

void setCompress(FrVectRef::compression_mode cmode)
Set the compression mode for data vectors

void setName(const std::string& name)
Set run Number and reset the frame count

void setRunID(int run)
Set run Number and reset the frame count

void copyDetectors(const FrameCPP::FrameH& f)
Copy the detector information (both processed and simulation) from an existing frame.
Parameters:
f - Frame containing detector information to be copied.

void copyHistory(const FrameCPP::FrameH& f)
Copy the history information from an existing frame.
Parameters:
f - Frame containing history information to be copied.

void copyAuxData(const FrameCPP::FrameH& f)
Copy the auxillary data from an existing frame.
Parameters:
f - Frame containing auxillary data to be copied.

void addRawAdc(const FrameCPP::FrameH& f, const char* Name)
Copy the adc data from an existing frame.
Parameters:
f - Frame containing adc data to be copied.
Name - Name of adc to be copied.

void addRawAdc(const FrameCPP::FrAdcData& adc)
Copy the adc data from an existing frame.
Parameters:
f - Frame containing auxillary data to be copied.


This class has no child classes.
Author:
John G Zweizig
Version:
1.3; Last modified April 27, 2006

alphabetic index hierarchy of classes


Please send questions and comments to zweizig_j@ligo.caltech.edu


generated by doc++