Commit 2e442fb2 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

Steim 2 code

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 2116
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 66110d61
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: mseedread.cc,v 1.19 2006-05-09 17:04:02 tforb Exp $
* $Id: mseedread.cc,v 1.20 2006-05-10 11:48:15 tforb Exp $
* \author Thomas Forbriger
* \date 15/07/2004
*
......@@ -41,7 +41,7 @@
#define TF_MSEEDREAD_CC_VERSION \
"TF_MSEEDREAD_CC V1.3"
#define TF_MSEEDREAD_CC_CVSID \
"$Id: mseedread.cc,v 1.19 2006-05-09 17:04:02 tforb Exp $"
"$Id: mseedread.cc,v 1.20 2006-05-10 11:48:15 tforb Exp $"
#include <string>
#include <string.h>
......@@ -300,7 +300,7 @@ namespace datread {
DATREAD_abort("ERROR (reading MiniSEED record): "
"compression format not supported");
}
SEED::SteimReader& rframe(*pframe);
SEED::SteimFrame& rframe(*pframe);
if (waitingforxn) {
DATREAD_assert((rframe.ctrl()==SEED::SteimFrame::Fspecial),
"ERROR (reading MiniSEED record): "
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: seedstructdump.cc,v 1.13 2006-05-09 17:09:14 tforb Exp $
* $Id: seedstructdump.cc,v 1.14 2006-05-10 11:48:15 tforb Exp $
* \author Thomas Forbriger
* \date 15/03/2006
*
......@@ -35,7 +35,7 @@
#define TF_SEEDSTRUCTDUMP_CC_VERSION \
"TF_SEEDSTRUCTDUMP_CC V1.0 "
#define TF_SEEDSTRUCTDUMP_CC_CVSID \
"$Id: seedstructdump.cc,v 1.13 2006-05-09 17:09:14 tforb Exp $"
"$Id: seedstructdump.cc,v 1.14 2006-05-10 11:48:15 tforb Exp $"
#include<string>
#include<iomanip>
......@@ -441,7 +441,7 @@ namespace datread {
break;
case Steim1Frame::Fdnib1:
case Steim1Frame::Fdnib2:
Steim2Word word(f.ctrl(i), w.fw);
Steim2Word word(Steim2Word::ESteim2Control(f.ctrl(i)), w.fw);
for (int j=0; j<word.nval(); ++j)
{
os << " #";
......@@ -464,7 +464,7 @@ namespace datread {
/*----------------------------------------------------------------------*/
void dump(SteimFrame f, std::ostream& os)
void dump(SteimFrame& f, std::ostream& os)
{
os << "Steim Frame:" << std::endl;
os << " control word: 0x";
......@@ -489,7 +489,8 @@ namespace datread {
f.reset();
while (f.valid())
{
os << " " << f.value() << std::endl;
os << " (" << f.iword() << "," << f.idiff() << ") "
<< f.diff() << std::endl;
f.next();
}
} // void dump(SteimFrame f, std::ostream& os)
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: seedstructdump.h,v 1.7 2006-05-09 17:09:14 tforb Exp $
* $Id: seedstructdump.h,v 1.8 2006-05-10 11:48:15 tforb Exp $
* \author Thomas Forbriger
* \date 15/03/2006
*
......@@ -40,7 +40,7 @@
#define TF_SEEDSTRUCTDUMP_H_VERSION \
"TF_SEEDSTRUCTDUMP_H V1.1"
#define TF_SEEDSTRUCTDUMP_H_CVSID \
"$Id: seedstructdump.h,v 1.7 2006-05-09 17:09:14 tforb Exp $"
"$Id: seedstructdump.h,v 1.8 2006-05-10 11:48:15 tforb Exp $"
#include<iostream>
#include<datreadxx/seedstructs.h>
......@@ -66,7 +66,7 @@ namespace datread {
void dump_ioflags(const unsigned char& s, std::ostream& os);
void dump(const EEncodingFormat& e, std::ostream& os);
void dump(const EByteOrder& e, std::ostream& os);
void dump(SteimFrame f, std::ostream& os);
void dump(SteimFrame& f, std::ostream& os);
void dump(Steim1Frame f, std::ostream& os);
void dump(Steim2Frame f, std::ostream& os);
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: seedstructs.cc,v 1.6 2006-05-09 16:36:38 tforb Exp $
* $Id: seedstructs.cc,v 1.7 2006-05-10 11:48:15 tforb Exp $
* \author Thomas Forbriger
* \date 10/03/2006
*
......@@ -38,7 +38,7 @@
#define TF_SEEDSTRUCTS_CC_VERSION \
"TF_SEEDSTRUCTS_CC V1.1 "
#define TF_SEEDSTRUCTS_CC_CVSID \
"$Id: seedstructs.cc,v 1.6 2006-05-09 16:36:38 tforb Exp $"
"$Id: seedstructs.cc,v 1.7 2006-05-10 11:48:15 tforb Exp $"
#include<datreadxx/seedstructs.h>
#include<datreadxx/error.h>
......@@ -97,13 +97,13 @@ namespace datread {
SteimFrame::ESteimControl SteimFrame::ctrl(const int& i) const
{
unsigned int code = ((control >> ((nwords-i-1)*2)) & 0x03);
unsigned int code = ((this->control() >> ((nwords-i-1)*2)) & 0x03);
return(ESteimControl(code));
} // SteimFrame::ESteimControl SteimFrame::ctrl(const int& i) const
/*======================================================================*/
virtual void Steim1Frame::swap()
void Steim1Frame::swap()
{
Steim1Word w;
SWAPIT(this->Mdata.control);
......@@ -134,7 +134,7 @@ namespace datread {
/*======================================================================*/
virtual void Steim2Frame::swap()
void Steim2Frame::swap()
{
Steim1Word w;
SWAPIT(this->Mdata.control);
......@@ -212,17 +212,17 @@ namespace datread {
int retval=0;
Steim1Word w;
w.fw=this->word();
if (Mvalid)
if (this->valid())
{
switch(this->ctrl()) {
case SteimFrame::Fspecial:
retval=w.fw;
break;
case SteimFrame::Fbyte:
retval=int(w.byte[Minumber]);
retval=int(w.byte[this->idiff()]);
break;
case SteimFrame::Fhw:
retval=w.hw[Minumber];
retval=w.hw[this->idiff()];
break;
case SteimFrame::Ffw:
retval=w.fw;
......@@ -242,7 +242,7 @@ namespace datread {
void Steim2Frame::setn()
{
Steim2Word w(this->ctrl(), this->word());
Steim2Word w(Steim2Word::ESteim2Control(this->ctrl()), this->word());
Mn=w.nval();
} // void Steim2Frame::setn()
......@@ -250,8 +250,8 @@ namespace datread {
int Steim2Frame::diff() const
{
Steim2Word w(this->ctrl(), this->word());
int retval=w.value(Midiff);
Steim2Word w(Steim2Word::ESteim2Control(this->ctrl()), this->word());
int retval=w.value(this->idiff());
return(retval);
} // int Steim2Frame::diff()
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: seedstructs.h,v 1.14 2006-05-09 17:04:03 tforb Exp $
* $Id: seedstructs.h,v 1.15 2006-05-10 11:48:16 tforb Exp $
* \author Thomas Forbriger
* \date 16/07/2004
*
......@@ -43,7 +43,7 @@
#define TF_SEEDSTRUCTS_H_VERSION \
"TF_SEEDSTRUCTS_H V1.2"
#define TF_SEEDSTRUCTS_H_CVSID \
"$Id: seedstructs.h,v 1.14 2006-05-09 17:04:03 tforb Exp $"
"$Id: seedstructs.h,v 1.15 2006-05-10 11:48:16 tforb Exp $"
namespace datread {
......@@ -443,10 +443,12 @@ namespace datread {
*/
class SteimFrame {
public:
// --- constants section ---
//! numer of words to process
static const int nwords=15;
//! size of frame in bytes
static const int blocksize=16*sizeof(int);
// --- type definition section ---
//! possible control codes
enum ESteimControl {
Fspecial=0, //!< contains non-data information, like headers
......@@ -466,9 +468,11 @@ namespace datread {
//! data buffer
int word[nwords];
}; // struct FrameData
// --- member function section ---
//! virtual base class need virtual destructor
virtual ~SteimFrame() { }
//! return control word
int control() const { return(Mdata.control); }
unsigned int control() const { return(Mdata.control); }
//! return control code for word \c i
ESteimControl ctrl(const int& i) const;
//! return data word \c i
......@@ -482,36 +486,33 @@ namespace datread {
if (swap) { this->swap(); }
}
//! return current difference value
virtual int diff() const;
virtual int diff() const =0;
//! we are still inside the frame
bool valid() const { return(Mvalid); }
//! return control code for current word
SteimFrame::ESteimControl ctrl() const
{ return(Mdata.ctrl(this->iword())); }
{ return(this->ctrl(this->iword())); }
//! step to next difference value
void next();
//! step to first difference value
void reset();
protected:
//! swapping must be performed differently for Steim1 and Steim2
virtual void swap();
//! read data to buffer
Steim1Frame(const char* p, const bool& swap=false):
Mdata(p), Mn(0), Miword(0), Midiff(0), Mvalid(true)
{
if (swap) { this->swap(); }
reset();
}
//! return current word index
int iword() const { return(Miword); }
//! return current difference index
int idiff() const { return(Midiff); }
protected:
//! swapping must be performed differently for Steim1 and Steim2
virtual void swap() =0;
//! set Mn for current word (compression type specific)
virtual void setn() =0;
//! read data to buffer
SteimFrame(const char* p):
Mdata(p), Mn(0), Miword(0), Midiff(0), Mvalid(true) { }
// --- data section ---
//! frame data (swapped)
FrameData Mdata;
//! number of differences in this word
int Mn;
//! set Mn for current word (compression type specific)
virtual void setn();
private:
//! current word in frame
int Miword;
......@@ -530,9 +531,14 @@ namespace datread {
typedef SteimFrame Tbase;
virtual ~Steim1Frame() { }
Steim1Frame(const char* p, const bool& swap=false):
Tbase(p, swap) { }
Tbase(p)
{
if (swap) { this->swap(); }
this->reset();
}
virtual void swap();
virtual void setn();
virtual int diff() const;
}; // class Steim1Frame
/*----------------------------------------------------------------------*/
......@@ -544,9 +550,14 @@ namespace datread {
typedef SteimFrame Tbase;
virtual ~Steim2Frame() { }
Steim2Frame(const char* p, const bool& swap=false):
Tbase(p, swap) { }
Tbase(p)
{
if (swap) { this->swap(); }
this->reset();
}
virtual void swap();
virtual void setn();
virtual int diff() const;
}; // class Steim2Frame
} // namespace SEED
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment