casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VLALogicalRecord.h
Go to the documentation of this file.
1 //# VLALogicalRecord.h: This class interprets a VLA logical record.
2 //# Copyright (C) 1999,2000
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef NRAO_VLALOGICALRECORD_H
29 #define NRAO_VLALOGICALRECORD_H
30 
31 #include <casa/Containers/Block.h>
33 #include <casa/aips.h>
34 #include <nrao/VLA/VLAADA.h>
36 #include <nrao/VLA/VLACDA.h>
37 #include <nrao/VLA/VLAEnum.h>
38 #include <nrao/VLA/VLARCA.h>
39 #include <nrao/VLA/VLASDA.h>
40 
41 #include <casa/namespace.h>
42 namespace casacore{
43 
44 template <class T> class Vector;
45 }
46 
47 namespace casa { //# NAMESPACE CASA - BEGIN
48 } //# NAMESPACE CASA - END
49 
50 // <summary>This class interprets a VLA logical record.</summary>
51 
52 // <reviewed reviewer="" date="" tests="" demos="">
53 
54 // <prerequisite>
55 // <ol>
56 // <li> The IO Module
57 // </ol>
58 // </prerequisite>
59 //
60 // <etymology>
61 // This class is designed to reconstitute VLA archive data records.
62 // </etymology>
63 //
64 // <synopsis>
65 
66 // This class is designed to read VLA archive data. The data may be read from
67 // a disk, tape drive or any other data source supported by the IO module. A
68 // call to the operator++() function assembles the next reconstructed VLA
69 // archive data record from the input. A reference to this data can be
70 // obtained using the logicalRecord function.
71 //
72 // Refer to the "VLA Archive casacore::Data casacore::Format", VLA Computer Memorandum 186
73 // by G.C. Hunt, K.P. Sowinski, and T.J. Bottomly; June 1993.
74 // (This is also available as AIPS++ note 159)
75 //
76 // The VLA archive records are always a multiple of 2048 bytes. The
77 // record sizes were designed for use with magnetic tapes, so there is
78 // a maximum physical record size of 13*2048=26624 bytes.
79 //
80 // The low level class (blockio), that actually does the I/O, allows
81 // for a record (hereinafter chunk) size and for a input block size of
82 // a multiple of the chunk size. The low level read operation tests
83 // for the number of bytes actually read from the device.
84 //
85 // The helper classes VlaDiskInput, VlaTapeInput, and VlaStdInput are
86 // designed to deal with the low level input from the devices in an
87 // analogous fashion to the ones used for casacore::FITS input.
88 //
89 // Since a read may be issued for an arbitrary number of bytes from a
90 // disk, the chunk multiple is arbitrary and may be used to tune the
91 // speed of operation. There is an obvious trade-off between the
92 // block size created in the blockio class and the number of read
93 // operations.
94 //
95 // The story is quite different for tape input. A read request for at
96 // least the maximum physical record size must be made to avoid loss of
97 // data. Since a single tape record will be read with a single read
98 // operation, there is no point is having it any larger. The chunk
99 // multiple must be exactly 13 so that the block size is 26624.
100 //
101 // The reconstitution algorithm is as follows:
102 //
103 // 1. Read a 2048 chunk from the input.
104 //
105 // The first two 16-bit integers should contain the values 1 and n,
106 // where n is the number of "physical records" in the current "logical
107 // record." (If the first value is not 1, then the chunk is rejected
108 // and a new one read until the first 16-bit value is 1.) These two
109 // values are not part of the reconstituted "logical record."
110 //
111 // 2. The next 32-bit integer contains the length of the "logical
112 // record" in 16-bit words. The buffer is resized so that it can
113 // contain the whole reconstituted "logical record."
114 //
115 // 3. The remainder of the chunk is copied to the buffer.
116 //
117 // 4. Successive chunks are read from the input.
118 //
119 // The chunks are copied into the buffer until the "logical record"
120 // is complete. For "logical records" longer than 26620 byte, this is
121 // not the whole story. Each "physical record" contains maximum of 13
122 // chunks. When the first "physical record" of 13 chunks has been read,
123 // the next chunk will be the first of the next "physical record." The
124 // first two 16-bit integers will now be 2 and n, to indicate that this
125 // is the second "physical record" of the sequence. These 4 bytes are
126 // decoded and the rest of this chunk is copied to the buffer. And so
127 // on...
128 //
129 // An end-of-file condition on the input will cause record processing
130 // to be declared complete.
131 // </synopsis>
132 //
133 // <example>
134 // To open and read a VLA archive data file
135 // <code>
136 // VLAArchiveInput *in;
137 // casacore::Block <casacore::Char> *buff;
138 // casacore::String fileName = " ";
139 // casacore::String fileType = "tape";
140 //
141 // if (fileType == casacore::String("tape")) {
142 // in = new VLAArchiveInput(fileName.chars(), VLAArchiveInput::Tape);
143 // } else {
144 // in = new VLAArchiveInput(fileName.chars(), VLAArchiveInput::Disk);
145 // }
146 //
147 // casacore::uInt record = 0;
148 // for (buff=&(in->next()); in->atEnd()==false; buff=&(in->next()), record++) {
149 // cout << "casacore::Record" << record << endl;
150 // // process record pointed to by buff
151 // }
152 // </code>
153 //
154 // </example>
155 //
156 // <motivation>
157 // </motivation>
158 //
159 // <todo asof="">
160 // <ol>
161 // <li> Bulletproofing - check for realistic buffer size (<1e6)
162 // <li> Bulletproofing - check newn and newm on each read
163 // <li> What happens after a single end-of-file on a tape drive?
164 // <li> Add record skipping
165 // <li> Should it work with stdin? This is in place but not debugged.
166 // </ol>
167 // </todo>
168 
170 {
171 public:
172  // Create an object that is not good for anything except that it can
173  // be assigned to (using the assigment operator).
175 
176  // Create an object that reads its data from the specified VLAArchiveInput
177  // object. The supplied pointer should be obtained from new and is "taken
178  // over". Hence the user should not delete it.
180 
181  // The copy constructor uses reference semantics
182  VLALogicalRecord(const VLALogicalRecord& other);
183 
184  // The destructor just cleans up.
186 
187  // The assignment operator uses reference semantics
189 
190  // This returns the reconstructed VLA archive record from the input
191  // stream. This casacore::ByteSource has the data stored in memory, and hence is
192  // seekable. casacore::Data read from this casacore::ByteSource will have the ModComp numeric
193  // conversions applied.
195 
196  // Reads the next logical record from the ByteSource. Returns false if there
197  // was a problem assembling the next record.
199 
200  // Returns true if this class is attached to a VLAArchiveInput object.
201  casacore::Bool isValid() const;
202 
203  // returns a reference to a class which can be used to interpret the data in
204  // the casacore::Record Control Area of the current logical record.
205  const VLARCA& RCA() const;
206 
207  // returns a reference to a class which can be used to interpret the data in
208  // the Subarray casacore::Data Area of the current logical record.
209  const VLASDA& SDA() const;
210 
211  // returns a reference to a class which can be used to interpret the data in
212  // the Correlator casacore::Data Area of the current logical record. A logical record
213  // can have have up to four correlator data areas and the argument is used to
214  // specify which one you are interested in. And exception is thrown if the
215  // input argument is greater than three.
216  const VLACDA& CDA(casacore::uInt which) const;
217 
218  // returns a reference to a class which can be used to interpret the data in
219  // the Antenna casacore::Data Area (ADA) of the current logical record. A logical
220  // record has one ADA for each antenna that contributed to the data in this
221  // record and the argument is used to specify which one you are interested
222  // in. And exception is thrown if the input argument is not less than the
223  // number of antennas in this subarray.
224  const VLAADA& ADA(casacore::uInt which) const;
225 
226  // Return the polarisations of the data in the specified CDA. This
227  // information is obtained from knowing what the correlator modes represent
228  // and checking the IF transfer switch for the specified antennas.
230  casacore::uInt ant1=0, casacore::uInt ant2=0) const;
231 
232 private:
233  //# A pointer to a class which can read VLA Archives from a variety of
234  //# sources
236 
237  //# The class which can interpret the casacore::Record Control Area portion of the
238  //# logical record.
240 
241  //# The class which can interpret the Subarray casacore::Data Area portion of the
242  //# logical record.
244 
245  //# The class which can interpret the casacore::Array casacore::Data Area portions of the
246  //# logical record.
248 
249  //# The class which can interpret the Correlator casacore::Data Area portions of the
250  //# logical record.
252 
253 };
254 #endif
VLALogicalRecord()
Create an object that is not good for anything except that it can be assigned to (using the assigment...
This class reads VLA archive records from a Tape.
A 1-D Specialization of the Array class.
casacore::Block< VLACDA > itsCDA
casacore::ByteSource & logicalRecord()
This returns the reconstructed VLA archive record from the input stream.
casacore::CountedPtr< VLAArchiveInput > itsRecordPtr
Class for read-only access to data in a given format.
Definition: ByteSource.h:91
casacore::Bool read()
Reads the next logical record from the ByteSource.
~VLALogicalRecord()
The destructor just cleans up.
VLALogicalRecord & operator=(const VLALogicalRecord &other)
The assignment operator uses reference semantics.
This class interprets a VLA logical record.
casacore::Vector< casacore::Stokes::StokesTypes > polarisations(VLAEnum::CDA cda, casacore::uInt ant1=0, casacore::uInt ant2=0) const
Return the polarisations of the data in the specified CDA.
const VLARCA & RCA() const
returns a reference to a class which can be used to interpret the data in the casacore::Record Contro...
const VLACDA & CDA(casacore::uInt which) const
returns a reference to a class which can be used to interpret the data in the Correlator casacore::Da...
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Bool isValid() const
Returns true if this class is attached to a VLAArchiveInput object.
Definition: VLACDA.h:79
Interprets the data in an antenna data area of a VLA logical record.
Definition: VLAADA.h:110
Interprets the data in an sub-array data area of a VLA logical record.
Definition: VLASDA.h:117
Definition: VLARCA.h:79
CDA
Names for the different correlator data areas&#39;s.
Definition: VLAEnum.h:84
const VLAADA & ADA(casacore::uInt which) const
returns a reference to a class which can be used to interpret the data in the Antenna casacore::Data ...
const VLASDA & SDA() const
returns a reference to a class which can be used to interpret the data in the Subarray casacore::Data...
casacore::Block< VLAADA > itsADA
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42