casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
VLATapeInput Class Reference

This class reads VLA archive records from a Tape. More...

#include <VLATapeInput.h>

Inheritance diagram for VLATapeInput:
VLAArchiveInput

Public Member Functions

 VLATapeInput (const casacore::Path &device, casacore::uInt whichFile=0)
 Create an object that reads its data from the specified file on the specified tape device. More...
 
 VLATapeInput (const casacore::Path &device, const casacore::Block< casacore::uInt > &whichFiles)
 Create an object that reads its data from the specified files on the specified tape device. More...
 
 ~VLATapeInput ()
 The destructor closes the tape device. More...
 
virtual casacore::Bool read ()
 Reads the next logical record from specified tape. More...
 
- Public Member Functions inherited from VLAArchiveInput
virtual ~VLAArchiveInput ()
 The destructor is virtual to ensure that the destructor in a derived class is actually used. More...
 
casacore::ByteSourcelogicalRecord ()
 This returns a reconstructed VLA logical record from the input stream. More...
 
const casacore::ByteSourcelogicalRecord () const
 
casacore::Bool hasData () const
 Returns if true if the current record contains data. More...
 

Private Member Functions

 VLATapeInput ()
 
 VLATapeInput (const VLATapeInput &other)
 
VLATapeInputoperator= (const VLATapeInput &other)
 
casacore::Bool findFirstRecord (casacore::Short &m)
 
casacore::Bool nextFile ()
 
casacore::Bool nextRecord ()
 
casacore::Bool fillBuffer (casacore::uInt &bytesToRead)
 

Private Attributes

casacore::TapeIO itsTape
 
casacore::Block< casacore::uIntitsFiles
 
casacore::Int itsCurFile
 
casacore::Block< casacore::uCharitsBuffer
 

Static Private Attributes

static const casacore::uInt ReadSize
 

Additional Inherited Members

- Protected Member Functions inherited from VLAArchiveInput
 VLAArchiveInput ()
 
- Protected Attributes inherited from VLAArchiveInput
casacore::MemoryIO itsMemIO
 
casacore::ByteSinkSource itsRecord
 
- Static Protected Attributes inherited from VLAArchiveInput
static const casacore::uInt BlockSize
 
static const casacore::uInt HeaderSize
 
static const casacore::uInt MaxBlocksPerPhysicalRecord
 

Detailed Description

This class reads VLA archive records from a Tape.

Prerequisite

  1. The IO Module

Etymology

This class is designed to reads VLA archive records from a Tape

Synopsis

This class is designed to read VLA archive data. The data may be read from a disk, tape drive or any other data source supported by the IO module. A call to the operator++() function assembles the next reconstructed VLA archive data record from the input. A reference to this data can be obtained using the logicalRecord function.

Refer to the "VLA Archive casacore::Data casacore::Format", VLA Computer Memorandum 186 by G.C. Hunt, K.P. Sowinski, and T.J. Bottomly; June 1993. (This is also available as AIPS++ note 159)

The VLA archive records are always a multiple of 2048 bytes. The record sizes were designed for use with magnetic tapes, so there is a maximum physical record size of 13*2048=26624 bytes.

The low level class (blockio), that actually does the I/O, allows for a record (hereinafter chunk) size and for a input block size of a multiple of the chunk size. The low level read operation tests for the number of bytes actually read from the device.

The helper classes VlaDiskInput, VlaTapeInput, and VlaStdInput are designed to deal with the low level input from the devices in an analogous fashion to the ones used for casacore::FITS input.

Since a read may be issued for an arbitrary number of bytes from a disk, the chunk multiple is arbitrary and may be used to tune the speed of operation. There is an obvious trade-off between the block size created in the blockio class and the number of read operations.

The story is quite different for tape input. A read request for at least the maximum physical record size must be made to avoid loss of data. Since a single tape record will be read with a single read operation, there is no point is having it any larger. The chunk multiple must be exactly 13 so that the block size is 26624.

The reconstitution algorithm is as follows:

  1. Read a 2048 chunk from the input.

The first two 16-bit integers should contain the values 1 and n, where n is the number of "physical records" in the current "logical record." (If the first value is not 1, then the chunk is rejected and a new one read until the first 16-bit value is 1.) These two values are not part of the reconstituted "logical record."

  1. The next 32-bit integer contains the length of the "logical record" in 16-bit words. The buffer is resized so that it can contain the whole reconstituted "logical record."
  2. The remainder of the chunk is copied to the buffer.
  3. Successive chunks are read from the input.

The chunks are copied into the buffer until the "logical record" is complete. For "logical records" longer than 26620 byte, this is not the whole story. Each "physical record" contains maximum of 13 chunks. When the first "physical record" of 13 chunks has been read, the next chunk will be the first of the next "physical record." The first two 16-bit integers will now be 2 and n, to indicate that this is the second "physical record" of the sequence. These 4 bytes are decoded and the rest of this chunk is copied to the buffer. And so on...

An end-of-file condition on the input will cause record processing to be declared complete.

Example

To open and read a VLA archive data file VLAArchiveInput *in; casacore::Block <casacore::Char> *buff; casacore::String fileName = " "; casacore::String fileType = "tape";

if (fileType == casacore::String("tape")) { in = new VLAArchiveInput(fileName.chars(), VLAArchiveInput::Tape); } else { in = new VLAArchiveInput(fileName.chars(), VLAArchiveInput::Disk); }

casacore::uInt record = 0; for (buff=&(in->next()); in->atEnd()==false; buff=&(in->next()), record++) { cout << "casacore::Record" << record << endl; process record pointed to by buff }

Motivation

To Do

  1. Bulletproofing - check for realistic buffer size (<1e6)
  2. Bulletproofing - check newn and newm on each read
  3. What happens after a single end-of-file on a tape drive?
  4. Add record skipping
  5. Should it work with stdin? This is in place but not debugged.

Definition at line 166 of file VLATapeInput.h.

Constructor & Destructor Documentation

VLATapeInput::VLATapeInput ( const casacore::Path device,
casacore::uInt  whichFile = 0 
)

Create an object that reads its data from the specified file on the specified tape device.

The whichFile argument indicates which tape to read from the tape with zero meaning "read the next file". The first file containing data (ie ignoring the tape header file) is file 1. An exception is thrown if there is any problem opening (readonly) the tape device or if the tape cannot be positioned to the start of the specified file.

VLATapeInput::VLATapeInput ( const casacore::Path device,
const casacore::Block< casacore::uInt > &  whichFiles 
)

Create an object that reads its data from the specified files on the specified tape device.

The tape is rewound and only the specified file is read. The first file containing data (ie ignoring the tape header file) is file 1 and zero means "read the next file". An exception is thrown if there is any problem opening (readonly) the tape device or if the tape cannot be positioned to the start of the first specified file. The file numbers should be in increasing order as only one pass through the tape is made.

VLATapeInput::~VLATapeInput ( )

The destructor closes the tape device.

VLATapeInput::VLATapeInput ( )
private
VLATapeInput::VLATapeInput ( const VLATapeInput other)
private

Member Function Documentation

casacore::Bool VLATapeInput::fillBuffer ( casacore::uInt bytesToRead)
private
casacore::Bool VLATapeInput::findFirstRecord ( casacore::Short m)
private
casacore::Bool VLATapeInput::nextFile ( )
private
casacore::Bool VLATapeInput::nextRecord ( )
private
VLATapeInput& VLATapeInput::operator= ( const VLATapeInput other)
private
virtual casacore::Bool VLATapeInput::read ( )
virtual

Reads the next logical record from specified tape.

Returns false if there was a problem assembling the next record ie., it returns the value of the hasData() member function.

Implements VLAArchiveInput.

Member Data Documentation

casacore::Block<casacore::uChar> VLATapeInput::itsBuffer
private

Definition at line 247 of file VLATapeInput.h.

casacore::Int VLATapeInput::itsCurFile
private

Definition at line 242 of file VLATapeInput.h.

casacore::Block<casacore::uInt> VLATapeInput::itsFiles
private

Definition at line 237 of file VLATapeInput.h.

casacore::TapeIO VLATapeInput::itsTape
private

Definition at line 234 of file VLATapeInput.h.

const casacore::uInt VLATapeInput::ReadSize
staticprivate

Definition at line 200 of file VLATapeInput.h.


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