You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.4 KiB
C

/***************************************************************************
* Copyright (C) 2015 by gempa GmbH *
* *
* All Rights Reserved. *
* *
* NOTICE: All information contained herein is, and remains *
* the property of gempa GmbH and its suppliers, if any. The intellectual *
* and technical concepts contained herein are proprietary to gempa GmbH *
* and its suppliers. *
* Dissemination of this information or reproduction of this material *
* is strictly forbidden unless prior written permission is obtained *
* from gempa GmbH. *
***************************************************************************/
#ifndef GEMPA_CAPS_PLUGINAPPLICATION_H
#define GEMPA_CAPS_PLUGINAPPLICATION_H
#include <gempa/caps/api.h>
#include <gempa/caps/plugin.h>
#include <seiscomp3/client/streamapplication.h>
#include <seiscomp3/logging/filerotator.h>
#include <seiscomp3/utils/timer.h>
namespace Gempa {
namespace CAPS {
class SC_GEMPA_CAPS_API PluginApplication : public Seiscomp::Client::StreamApplication {
public:
PluginApplication(int argc, char **argv,
const std::string &desc = "");
protected:
/**
* @brief Adds common plugin commandline options.
*/
virtual void createCommandLineDescription();
virtual void done();
virtual void exit(int returnCode);
virtual void handleRecord(Seiscomp::Record *record) {}
virtual void handleTimeout();
/**
* @brief Initialization method.
*/
virtual bool init();
/**
* @brief Reads common plugin configuration options.
*/
virtual bool initConfiguration();
/**
* @brief Validates command line parameters.
*/
virtual bool validateParameters();
protected:
struct Statistics {
uint32_t records;
uint32_t samples;
Time startTime;
Time endTime;
uint32_t gaps;
uint32_t files;
Statistics() : records(0), samples(0), gaps(0), files(0) {}
};
enum MseedEncoding {Uncompressed, Steim1, Steim2};
bool fromString(MseedEncoding &enc, std::string str);
protected:
class FileRotator : public Seiscomp::Logging::FileRotatorOutput {
public:
std::ofstream& stream() { return _stream; }
};
protected:
Plugin _plugin;
std::string _host;
ushort _port;
std::string _strAddr;
size_t _bufferSize;
size_t _backfillingBufferSize;
bool _mseed;
std::string _journalFile;
int _flushInterval;
int _ackTimeout;
int _lastAckTimeout;
int _sendTimeout;
int _maxFutureEndTime;
Statistics _stats;
bool _mseedEnabled;
MseedEncoding _mseedEncoding;
uint _mseedRecordLength;
std::string _strMseedEncoding;
std::string _strPacketType;
Seiscomp::Util::Timer _timer;
FileRotator _statusFile;
bool _logStatus;
uint _statusFlushInterval;
};
}
}
#endif