Classes | Public Slots | Public Member Functions
TitanProcess Class Reference

Brief description of class still missing. More...

#include <TitanProcess.h>

List of all members.

Classes

struct  File

Public Slots

void fileCreated (const QString &path)

Public Member Functions

void setInitialWatchDelay (int secs)
void setSignalDuration (double d)
bool setSourcePath (const QString &path)
void setStationName (const QString &name)
void setTimeReference (const QDateTime &t)
 TitanProcess (QObject *parent=0)
 ~TitanProcess ()

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

TitanProcess::TitanProcess ( QObject *  parent = 0)

Description of constructor still missing

References fileCreated(), GeopsyCore::AsciiSignalFormat::insertRule(), GeopsyCore::AsciiSignalFormatRule::setData(), GeopsyCore::AsciiSignalFormat::setHeaderPattern(), GeopsyCore::AsciiSignalFormat::setHeaderType(), GeopsyCore::AsciiSignalFormatRule::setPattern(), GeopsyCore::AsciiSignalFormat::setTimeFormat(), and TRACE.

    : QObject(parent), _workDir("/tmp")
{
  TRACE;
  connect(&_fsWatcher, SIGNAL(fileCreated(const QString &)), this, SLOT(fileCreated(const QString&)));
  _workDir.mkdir("kephren");
  _workDir.cd("kephren");
  _fltFilter.append("*.flt");
  _binFilter.append("*.BIN");
  _binInfoFilter.append("*.BIN");
  _binInfoFilter.append("*.info");
  _timeReference.setDate(QDate::currentDate());
  _timeReference.setTime(QTime(0,0,0));
  _signalDuration=300.0;
  _sendLedTimer.setInterval(60000);
  connect(&_sendLedTimer, SIGNAL(timeout()), this, SLOT(setSendLedStatus()));

  // Defines rules for parsing a Titan ascii format
  _titanAsciiFormat.setHeaderType(AsciiSignalFormat::EndHeaderPattern);
  _titanAsciiFormat.setHeaderPattern("^[#]{10,} *$");
  _titanAsciiFormat.setTimeFormat("yyyy.MM.dd-hh:mm:ss");
  // Channel mapping to component: TODO add a configuration file with channel names
  // Components are ignored here, they will be recognized by channel names (including Z, N or E)
  //_titanAsciiFormat.addComponentMap("0", Signal::Vertical);
  //_titanAsciiFormat.addComponentMap("1", Signal::North);
  //_titanAsciiFormat.addComponentMap("2", Signal::East);
  AsciiSignalFormatRule rule;
  rule.setData(MetaDataFactory::Name);
  rule.setPattern("\n([a-zA-Z0-9_]+) *station *\n");
  _titanAsciiFormat.insertRule(0, rule);
  // Use Comment to store channel number
  _channels.insert(0, "C1Z");
  _channels.insert(1, "C1N");
  _channels.insert(2, "C1E");
  _channels.insert(3, "C2Z");
  _channels.insert(4, "C2N");
  _channels.insert(5, "C2E");
  rule.setData(Comments::staticId());
  rule.setPattern("\n([0-9]+) *channel *\n");
  _titanAsciiFormat.insertRule(0, rule);
  rule.setData(MetaDataFactory::SamplingFrequency);
  rule.setPattern("\n([0-9\\.]+) *sample *rate *\n");
  _titanAsciiFormat.insertRule(0, rule);
  rule.setData(MetaDataFactory::TimeReference);
  rule.setPattern("\n([0-9]{4}\\.[0-9]{2}\\.[0-9]{2}.[0-9]{2}:[0-9]{2}:[0-9]{2}).* start *time *\n");
  _titanAsciiFormat.insertRule(0, rule);
  rule.setData(MetaDataFactory::T0);
  rule.setPattern("[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+) *start *time *\n");
  _titanAsciiFormat.insertRule(0, rule);
  // Do not read VoltPerCount to stay in count and avoid rescaling when sending data.
  //rule.setData(Signal::DataIndex(Signal::VoltPerCount));
  //rule.setPattern("\n[0-9\\.]+ *conversion *factor *[(] *nV */ *digit *[)] *\n");
  //rule.setFactor(1e-9);
  //_titanAsciiFormat.addRule(rule);
}

Description of destructor still missing

References TRACE.

{
  TRACE;
  // Cleans everything in work directory
  QStringList tmpFiles=_workDir.entryList(QDir::Files | QDir::NoDotAndDotDot);
  foreach(QString f, tmpFiles) {
    _workDir.remove(f);
  }
  // ... and removes it
  _workDir.cdUp();
  _workDir.rmdir("kephren");
}

Member Function Documentation

void TitanProcess::fileCreated ( const QString &  path) [slot]

References GeopsyCore::GeopsyCoreEngine::clear(), QGpCoreTools::endl(), GeopsyCore::geopsyCore, QGpCoreTools::tr(), and TRACE.

Referenced by TitanProcess().

{
  TRACE;
  QFileInfo fi(path);
  File f;
  f.time.setTime(QTime::fromString(fi.fileName(), "hh.mm.ss"));
  f.time.setDate(QDate::fromString(fi.dir().dirName(), "yyyy.MM.dd"));
  f.path=path;
  _files.append(f);
  App::stream() << tr("new data from %1").arg(f.time.toString("yyyy-MM-dd hh:mm:ss")) << endl;
  if(!extractTime(path)) {
    return;
  }
  if(loadTitan()) {
    send();
    // Clean all geopsy database
    geopsyCore->clear();
  }
}
void TitanProcess::setInitialWatchDelay ( int  secs) [inline]
void TitanProcess::setSignalDuration ( double  d) [inline]
{_signalDuration=d;}
bool TitanProcess::setSourcePath ( const QString &  path)

References QGpCoreTools::endl(), KephrenFtpWatcher::setPath(), QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  ASSERT(!_stationName.isEmpty());
  QDir d(path);
  if(!d.exists(_stationName)) {
    App::stream() << tr("error: source path %1/%2 does not exist").arg(path).arg(_stationName) << endl;
    return false;
  }
  d.cd(_stationName);
  QFileInfo fi(d.absolutePath());
  if(!fi.isReadable()) {
    App::stream() << tr("error: not enough permissions to read source path %1").arg(fi.filePath()) << endl;
    return false;
  }
  _fsWatcher.setPath(fi.filePath());
  App::stream() << tr("source path: %1").arg(fi.filePath()) << endl;
  return true;
}
void TitanProcess::setStationName ( const QString &  name) [inline]
{_stationName=name;}
void TitanProcess::setTimeReference ( const QDateTime &  t) [inline]
{_timeReference=t;}

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