All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Static Public Member Functions
GeopsyCore::MiniSeedVolume Class Reference

Brief description of class still missing. More...

#include <MiniSeedVolume.h>

Inheritance diagram for GeopsyCore::MiniSeedVolume:
QVector

List of all members.

Public Member Functions

bool read (QString name)
 ~MiniSeedVolume ()

Static Public Member Functions

static void errorLog (QString fileName, QString title, int errorCode)
static void errorMessage (QString fileName, QString title, int errorCode)
static bool isValid (QString fileName)

Detailed Description

Brief description of class still missing.

Represents a Mini Seed volume. This class is used only while reading a new file.


Constructor & Destructor Documentation

References TRACE.

{
  TRACE;
  qDeleteAll(*this);
}

Member Function Documentation

void GeopsyCore::MiniSeedVolume::errorLog ( QString  fileName,
QString  title,
int  errorCode 
) [static]

References QGpCoreTools::endl(), and TRACE.

Referenced by GeopsyCore::MiniSeedReader::nextRecord().

{
  TRACE;
  QString msg=errorString(errorCode);
  if( !msg.isEmpty()) {
    App::stream() << title << ":" << msg.arg(fileName) << endl;
  }
}
void GeopsyCore::MiniSeedVolume::errorMessage ( QString  fileName,
QString  title,
int  errorCode 
) [static]

References MSG_ID, and TRACE.

Referenced by read().

{
  TRACE;
  QString msg=errorString(errorCode);
  if( !msg.isEmpty()) {
    Message::warning(MSG_ID, title, msg.arg(fileName), Message::cancel(), true);
  }
}
bool GeopsyCore::MiniSeedVolume::isValid ( QString  fileName) [static]

References TRACE.

Referenced by GeopsyCore::SignalFileFormat::fromContent().

{
  TRACE;
  LibMSeed::MSRecord *msr=0;
  int msErr=ms_readmsr (&msr, fileName.toAscii().data(), -1, NULL, NULL, 1, 0, 0);
  ms_readmsr (&msr, NULL, -1, NULL, NULL, 1, 0, 0);
  return msErr==MS_NOERROR;
}
bool GeopsyCore::MiniSeedVolume::read ( QString  name)

Parse a Mini seed volume and fill its internal list of MiniSeedTrace pointers

References GeopsyCore::MiniSeedTrace::addRecord(), errorMessage(), MSG_ID, GeopsyCore::MiniSeedTrace::split(), QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  LibMSeed::MSRecord * msr=0;
  int msErr=0;
  off_t currentPos=0;
  /* Read next seed record with
      int reclen=-1            Use automatic record length (usually read from Blockette 1000)
      off_t *fpos=currentPos   Store all position of records in file
      int *last =NULL            Don't care about last record, just wait for MS_ENDOFFILE
      flag skipnotdata=1       Skip all invalid data chunks
      flag dataflag=0          Do not unpack values
      flag verbose=0           Be not verbose
  */
  // TODO: look for another way with UNICODE support for file names, tried with utf-8, but it does not work either.
  if(QString(name.toAscii())!=name) {
    Message::warning(MSG_ID, tr("Loading Miniseed"),
                     tr("File path contains non-ASCII characters. This is a current limitation of IRIS MiniSeed library. "
                        "Move your file to a directory path with ASCII characters only.\n%1").arg(name), Message::cancel(), true);
    return false;
  }
  while(( msErr=ms_readmsr (&msr, name.toAscii().data(), -1, &currentPos, NULL, 1, 0, 0))==MS_NOERROR) {
    MiniSeedTrace * sig=findTrace(msr);
    if(!sig) {
      sig=new MiniSeedTrace(msr);
      append(sig);
    }
    sig->addRecord(msr, currentPos);
  }
  ms_readmsr (&msr, NULL, 0, NULL, NULL, 0, 0, 0);
  if(msErr!= MS_ENDOFFILE) {
    errorMessage(name, tr("Loading Miniseed"), msErr);
    return false;
  }
  // Check continuity of traces and split non-continuous traces
  for(int i=0; i<count(); i++) {
    MiniSeedTrace * sig=at(i);
    while(true) {
      sig=sig->split();
      if(sig) {
        i++;
        insert(i, sig);
      } else {
        break;
      }
    }
  }
  return true;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines