[seiscomp, scanloc] Install, add .gitignore
This commit is contained in:
17
include/seiscomp/plugins/dataavailabilty/api.h
Normal file
17
include/seiscomp/plugins/dataavailabilty/api.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef SC_DAPLUGIN_API_H
|
||||
#define SC_DAPLUGIN_API_H
|
||||
|
||||
#if defined(WIN32) && (defined(SC_DAPLUGIN_SHARED) || defined(SC_ALL_SHARED))
|
||||
# if defined(SC_DAPLUGIN_EXPORTS)
|
||||
# define SC_DAPLUGIN_API __declspec(dllexport)
|
||||
# define SC_DAPLUGIN_TEMPLATE_EXPORT
|
||||
# else
|
||||
# define SC_DAPLUGIN_API __declspec(dllimport)
|
||||
# define SC_DAPLUGIN_TEMPLATE_EXPORT extern
|
||||
# endif
|
||||
#else
|
||||
# define SC_DAPLUGIN_API
|
||||
# define SC_DAPLUGIN_TEMPLATE_EXPORT
|
||||
#endif
|
||||
|
||||
#endif
|
265
include/seiscomp/plugins/dataavailabilty/collector.h
Normal file
265
include/seiscomp/plugins/dataavailabilty/collector.h
Normal file
@ -0,0 +1,265 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2020 by gempa GmbH *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* GNU Affero General Public License Usage *
|
||||
* This file may be used under the terms of the GNU Affero *
|
||||
* Public License version 3.0 as published by the Free Software Foundation *
|
||||
* and appearing in the file LICENSE included in the packaging of this *
|
||||
* file. Please review the following information to ensure the GNU Affero *
|
||||
* Public License version 3.0 requirements will be met: *
|
||||
* https://www.gnu.org/licenses/agpl-3.0.html. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SEISCOMP_DATAAVAILABILITY_COLLECTOR_H
|
||||
#define SEISCOMP_DATAAVAILABILITY_COLLECTOR_H
|
||||
|
||||
#include <seiscomp/plugins/dataavailability/api.h>
|
||||
|
||||
#include <seiscomp/core/exceptions.h>
|
||||
#include <seiscomp/core/interfacefactory.h>
|
||||
#include <seiscomp/core/interruptible.h>
|
||||
#include <seiscomp/core/optional.h>
|
||||
#include <seiscomp/core/timewindow.h>
|
||||
|
||||
#include <seiscomp/datamodel/dataextent.h>
|
||||
#include <seiscomp/datamodel/datasegment.h>
|
||||
#include <seiscomp/datamodel/waveformstreamid.h>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
/******************************************************************************
|
||||
scardac API Changelog
|
||||
******************************************************************************
|
||||
|
||||
1
|
||||
- Initial API
|
||||
|
||||
2
|
||||
- Add setStartTime() and setEndTime() methods
|
||||
|
||||
*/
|
||||
#define SCARDAC_API_VERSION 2
|
||||
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace DataAvailability {
|
||||
|
||||
class CollectorException : public Core::GeneralException {
|
||||
public:
|
||||
CollectorException();
|
||||
CollectorException(std::string what);
|
||||
};
|
||||
|
||||
|
||||
DEFINE_SMARTPOINTER(Collector);
|
||||
|
||||
/**
|
||||
* @brief The Collector class defines an abstract interface to read record meta
|
||||
* data of a waveform archive, e.g., data files organized in a directory
|
||||
* structure.
|
||||
*/
|
||||
class SC_DAPLUGIN_API Collector : public Core::InterruptibleObject {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Data file iterator
|
||||
// ------------------------------------------------------------------
|
||||
public:
|
||||
DEFINE_SMARTPOINTER(RecordIterator);
|
||||
|
||||
class RecordIterator : public Seiscomp::Core::InterruptibleObject {
|
||||
protected:
|
||||
RecordIterator() = default;
|
||||
|
||||
public:
|
||||
virtual ~RecordIterator() = default;
|
||||
|
||||
virtual bool valid() const = 0;
|
||||
virtual bool next() = 0;
|
||||
virtual const Core::Time& startTime() const = 0;
|
||||
virtual const Core::Time& endTime() const = 0;
|
||||
virtual double sampleRate() const = 0;
|
||||
virtual const std::string& quality() const = 0;
|
||||
|
||||
void handleInterrupt(int sig) override;
|
||||
|
||||
protected:
|
||||
bool _abortRequested{false};
|
||||
};
|
||||
|
||||
|
||||
DECLARE_SC_CLASS(Collector)
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// X'truction
|
||||
// ------------------------------------------------------------------
|
||||
protected:
|
||||
/**
|
||||
* @brief The constructor is protected because this is an
|
||||
* abstract base class.
|
||||
*/
|
||||
Collector() = default;
|
||||
|
||||
|
||||
public:
|
||||
//! D'tor
|
||||
virtual ~Collector() = default;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Collector interface
|
||||
// ------------------------------------------------------------------
|
||||
public:
|
||||
using WaveformIDs = std::map<std::string, DataModel::WaveformStreamID>;
|
||||
using DataChunks = std::vector<std::string>;
|
||||
|
||||
/**
|
||||
* @brief Set the source location of the waveform archive. This is
|
||||
* implementation specific but typically the base path of a
|
||||
* directory structure.
|
||||
* @param source The source definition.
|
||||
*/
|
||||
virtual bool setSource(const char *source);
|
||||
|
||||
/**
|
||||
* @brief Set a start time for all collection routines.
|
||||
* @param startTime Start of timewindow to restrict collection operation
|
||||
* to.
|
||||
* @since SCARDAC API 2, SeisComP ABI 16.0.0
|
||||
*/
|
||||
virtual void setStartTime(Core::Time startTime);
|
||||
|
||||
/**
|
||||
* @brief Set an end time for all collection routines.
|
||||
* @param endTime End of timewindow to restrict collection operation to.
|
||||
* @since SCARDAC API 2, SeisComP ABI 16.0.0
|
||||
*/
|
||||
virtual void setEndTime(Core::Time endTime);
|
||||
|
||||
/**
|
||||
* @brief Reset all internal buffers and states except for the source.
|
||||
*/
|
||||
virtual void reset();
|
||||
|
||||
/**
|
||||
* @brief Collect a set of waveform IDs found in the archive.
|
||||
* @param wids Result set containing the collected waveform IDs.
|
||||
* @return Status flag.
|
||||
*/
|
||||
virtual void collectWaveformIDs(WaveformIDs &wids) = 0;
|
||||
|
||||
/**
|
||||
* @brief Collect data chucks, e.g., file names, for a spefific
|
||||
* waveform ID in the specified time window. The chunks must be
|
||||
* sorted according to the sampling time in ascending order.
|
||||
* @param chunks A vector to store the chunk IDs, e.g., the file names
|
||||
* relative to the archive base path.
|
||||
* @param wid The stream ID to look up chunks for.
|
||||
*/
|
||||
virtual void collectChunks(DataChunks &chunks,
|
||||
const DataModel::WaveformStreamID &wid) = 0;
|
||||
|
||||
/**
|
||||
* @brief Return the data time window for a specific data chunk. The
|
||||
* returned time window is not expected to guarantee the
|
||||
* availability of data.
|
||||
* @param window The time window represented by the data chunk
|
||||
* @param chunk The chunk ID, e.g., the file name relative to the
|
||||
* archive base path.
|
||||
* @return Status flag.
|
||||
*/
|
||||
virtual bool chunkTimeWindow(Core::TimeWindow &window,
|
||||
const std::string &chunk) = 0;
|
||||
|
||||
/**
|
||||
* @brief Return the chunk's last modification time.
|
||||
* @param chunk The chunk ID, e.g., the file name relative to the
|
||||
* archive base path.
|
||||
* @return Chunk modification time.
|
||||
*/
|
||||
virtual Core::Time chunkMTime(const std::string &chunk);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Open a data chunk for record-based iteration.
|
||||
* @param chunk The chunk ID, e.g., the file name relative to the
|
||||
* archive base path.
|
||||
* @param wid The waveform stream ID corresponding to the chunk
|
||||
* @return The data chunk iterator or nullptr if the chunk could not be
|
||||
* opened. The ownership is transferred to the caller.
|
||||
*/
|
||||
virtual RecordIterator* begin(const std::string &chunk,
|
||||
const DataModel::WaveformStreamID &wid) = 0;
|
||||
|
||||
/**
|
||||
* @brief threadSafe Define whether or not a collector instance may
|
||||
* be used by multiple threads simultaneously. Thread-safty is only
|
||||
* required for the following methods:
|
||||
* - chunkTimeWindow
|
||||
* - chunkMTime
|
||||
* - begin
|
||||
* @return True if the collector instance can be used from multiple
|
||||
* threads.
|
||||
*/
|
||||
virtual bool threadSafe() const = 0;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Collector static interface
|
||||
// ------------------------------------------------------------------
|
||||
public:
|
||||
/**
|
||||
* @brief Create a data availability collector for the given service.
|
||||
* @param service The service name.
|
||||
* @return A pointer to the data availabiltiy collector object
|
||||
* \note
|
||||
* The returned pointer has to be deleted by the caller!
|
||||
*/
|
||||
static Collector *Create(const char *service);
|
||||
|
||||
/**
|
||||
* @brief Open a data availability collector. This will call @Create.
|
||||
* @param url A source URL of format [service://]source,
|
||||
* e.g., sds:///data/archive. Service defaults to 'sds'.
|
||||
* @return A pointer to the data availabiltiy collector object. If the
|
||||
* requested service is not supported, nullptr will be returned.
|
||||
* \note
|
||||
* The returned pointer has to be deleted by the caller!
|
||||
*/
|
||||
static Collector *Open(const char *url);
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Collector protected interface
|
||||
// ------------------------------------------------------------------
|
||||
protected:
|
||||
|
||||
void handleInterrupt(int) override;
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Protected members
|
||||
// ------------------------------------------------------------------
|
||||
protected:
|
||||
std::string _source;
|
||||
bool _abortRequested{false};
|
||||
|
||||
OPT(Core::Time) _startTime;
|
||||
OPT(Core::Time) _endTime;
|
||||
};
|
||||
|
||||
|
||||
DEFINE_INTERFACE_FACTORY(Collector);
|
||||
|
||||
|
||||
#define REGISTER_DATAAVAILABILITY_COLLECTOR_VAR(Class, Service) \
|
||||
Seiscomp::Core::Generic::InterfaceFactory<Seiscomp::DataAvailability::Collector, Class> __##Class##InterfaceFactory__(Service)
|
||||
|
||||
#define REGISTER_DATAAVAILABILITY_COLLECTOR(Class, Service) \
|
||||
static REGISTER_DATAAVAILABILITY_COLLECTOR_VAR(Class, Service)
|
||||
|
||||
|
||||
} // ns DataAvailability
|
||||
} // ns Seiscomp
|
||||
|
||||
|
||||
#endif // SEISCOMP_DATAAVAILABILITY_COLLECTOR_H
|
157
include/seiscomp/plugins/dataavailabilty/collector/sds.h
Normal file
157
include/seiscomp/plugins/dataavailabilty/collector/sds.h
Normal file
@ -0,0 +1,157 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2020 by gempa GmbH *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* GNU Affero General Public License Usage *
|
||||
* This file may be used under the terms of the GNU Affero *
|
||||
* Public License version 3.0 as published by the Free Software Foundation *
|
||||
* and appearing in the file LICENSE included in the packaging of this *
|
||||
* file. Please review the following information to ensure the GNU Affero *
|
||||
* Public License version 3.0 requirements will be met: *
|
||||
* https://www.gnu.org/licenses/agpl-3.0.html. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SEISCOMP_DATAAVAILABILITY_COLLECTOR_SDS_H
|
||||
#define SEISCOMP_DATAAVAILABILITY_COLLECTOR_SDS_H
|
||||
|
||||
#include <seiscomp/plugins/dataavailability/collector.h>
|
||||
|
||||
#include <seiscomp/core/defs.h>
|
||||
#include <seiscomp/core/record.h>
|
||||
#include <seiscomp/core/datetime.h>
|
||||
|
||||
#include <seiscomp/datamodel/dataextent.h>
|
||||
#include <seiscomp/datamodel/datasegment.h>
|
||||
#include <seiscomp/datamodel/waveformstreamid.h>
|
||||
|
||||
#include <seiscomp/io/recordinput.h>
|
||||
#include <seiscomp/io/recordstream/file.h>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace DataAvailability {
|
||||
|
||||
|
||||
DEFINE_SMARTPOINTER(SDSCollector);
|
||||
|
||||
|
||||
class SDSCollector : public Collector {
|
||||
|
||||
public:
|
||||
class RecordIterator : public Collector::RecordIterator {
|
||||
public:
|
||||
/**
|
||||
* @brief RecordIterator
|
||||
* @param file The absolute file path
|
||||
* @param wid StreamID the file is expected to contain data for
|
||||
*/
|
||||
RecordIterator(std::string file,
|
||||
const DataModel::WaveformStreamID &wid);
|
||||
|
||||
public:
|
||||
~RecordIterator() override = default;
|
||||
|
||||
bool valid() const override;
|
||||
bool next() override;
|
||||
const Core::Time& startTime() const override;
|
||||
const Core::Time& endTime() const override;
|
||||
double sampleRate() const override;
|
||||
const std::string& quality() const override;
|
||||
|
||||
protected:
|
||||
std::string _file;
|
||||
std::string _sid;
|
||||
RecordStream::File _stream;
|
||||
IO::RecordInput _input;
|
||||
|
||||
RecordPtr _rec;
|
||||
Core::Time _endTime;
|
||||
std::string _quality;
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
SDSCollector() = default;
|
||||
~SDSCollector() override = default;
|
||||
|
||||
bool setSource(const char *source) override;
|
||||
void setStartTime(Core::Time startTime) override;
|
||||
void setEndTime(Core::Time endTime) override;
|
||||
|
||||
void reset() override;
|
||||
void collectWaveformIDs(WaveformIDs &wids) override;
|
||||
void collectChunks(DataChunks &chunks,
|
||||
const DataModel::WaveformStreamID &wid) override;
|
||||
bool chunkTimeWindow(Core::TimeWindow &window,
|
||||
const std::string &chunk) override;
|
||||
Core::Time chunkMTime(const std::string &chunk) override;
|
||||
Collector::RecordIterator* begin(
|
||||
const std::string &chunk,
|
||||
const DataModel::WaveformStreamID &wid) override;
|
||||
bool threadSafe() const override;
|
||||
|
||||
protected:
|
||||
struct IDDate {
|
||||
std::string streamID;
|
||||
int year{0};
|
||||
int doy{0}; // 0 = 1st of January
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Scan an archive recursively for available WaveformIDs.
|
||||
* @param wids The collected waveform IDs.
|
||||
* @param dir Current directory path.
|
||||
* @param depth Remaining directory depth. If 0 the current directory
|
||||
* is scanned for files.
|
||||
*/
|
||||
virtual void scanDirectory(WaveformIDs &wids,
|
||||
const boost::filesystem::path &dir,
|
||||
uint16_t depth = 3);
|
||||
|
||||
/**
|
||||
* @brief Scan a directory for available WaveformIDs.
|
||||
* @param wids The collected waveform IDs.
|
||||
* @param dir The directory path in which to search files.
|
||||
*/
|
||||
virtual void scanFiles(WaveformIDs &wids,
|
||||
const boost::filesystem::path &dir);
|
||||
|
||||
/**
|
||||
* @brief Return the stream ID and date for a given file name.
|
||||
* @param filename The file name to extract the stream ID from.
|
||||
* @return An IDDate object holding the stream ID and file date or an
|
||||
* default contructed IDDate with an empty streamID.
|
||||
*/
|
||||
virtual IDDate fileStreamID(const std::string &filename);
|
||||
|
||||
/**
|
||||
* @brief Check if a specific date is covered by the startTime and
|
||||
* endTime boundaries.
|
||||
* @param year The year of the date.
|
||||
* @param doy The day of the year as days since January 1st.
|
||||
* @return true If the specified date is within the timewindow
|
||||
* boundaries (if any) else false.
|
||||
*/
|
||||
virtual bool checkTimeWindow(int year, int doy);
|
||||
|
||||
protected:
|
||||
using ArchiveYearItem = std::pair<int, boost::filesystem::path>;
|
||||
using ArchiveYears = std::vector<ArchiveYearItem>;
|
||||
|
||||
boost::filesystem::path _basePath;
|
||||
ArchiveYears _archiveYears;
|
||||
|
||||
OPT(int) _startYear;
|
||||
OPT(int) _startDOY; // 0 = 1st of January
|
||||
OPT(int) _endYear;
|
||||
OPT(int) _endDOY; // 0 = 1st of January
|
||||
};
|
||||
|
||||
} // ns DataAvailability
|
||||
} // ns Seiscomp
|
||||
|
||||
#endif // SEISCOMP_DATAAVAILABILITY_COLLECTOR_SDS_H
|
17
include/seiscomp/plugins/events/api.h
Normal file
17
include/seiscomp/plugins/events/api.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef SC_EVPLUGIN_API_H
|
||||
#define SC_EVPLUGIN_API_H
|
||||
|
||||
#if defined(WIN32) && (defined(SC_EVPLUGIN_SHARED) || defined(SC_ALL_SHARED))
|
||||
# if defined(SC_EVPLUGIN_EXPORTS)
|
||||
# define SC_EVPLUGIN_API __declspec(dllexport)
|
||||
# define SC_EVPLUGIN_TEMPLATE_EXPORT
|
||||
# else
|
||||
# define SC_EVPLUGIN_API __declspec(dllimport)
|
||||
# define SC_EVPLUGIN_TEMPLATE_EXPORT extern
|
||||
# endif
|
||||
#else
|
||||
# define SC_EVPLUGIN_API
|
||||
# define SC_EVPLUGIN_TEMPLATE_EXPORT
|
||||
#endif
|
||||
|
||||
#endif
|
99
include/seiscomp/plugins/events/eventprocessor.h
Normal file
99
include/seiscomp/plugins/events/eventprocessor.h
Normal file
@ -0,0 +1,99 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) GFZ Potsdam *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* GNU Affero General Public License Usage *
|
||||
* This file may be used under the terms of the GNU Affero *
|
||||
* Public License version 3.0 as published by the Free Software Foundation *
|
||||
* and appearing in the file LICENSE included in the packaging of this *
|
||||
* file. Please review the following information to ensure the GNU Affero *
|
||||
* Public License version 3.0 requirements will be met: *
|
||||
* https://www.gnu.org/licenses/agpl-3.0.html. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SEISCOMP_APPLICATIONS_EVENTPROCESSOR_H__
|
||||
#define SEISCOMP_APPLICATIONS_EVENTPROCESSOR_H__
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include <seiscomp/core/baseobject.h>
|
||||
#include <seiscomp/core/interfacefactory.h>
|
||||
#include <seiscomp/config/config.h>
|
||||
#include <seiscomp/plugins/events/api.h>
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
scevent API Changelog
|
||||
******************************************************************************
|
||||
2
|
||||
- Added list of event journal entries to process()
|
||||
|
||||
<undefined>
|
||||
- Initial API
|
||||
*/
|
||||
#define SCEVENT_EVENTPROCESSOR_API_VERSION 2
|
||||
|
||||
|
||||
namespace Seiscomp {
|
||||
|
||||
|
||||
namespace DataModel {
|
||||
|
||||
class Event;
|
||||
DEFINE_SMARTPOINTER(JournalEntry);
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace Client {
|
||||
|
||||
|
||||
DEFINE_SMARTPOINTER(EventProcessor);
|
||||
|
||||
|
||||
class SC_EVPLUGIN_API EventProcessor : public Seiscomp::Core::BaseObject {
|
||||
// ----------------------------------------------------------------------
|
||||
// Public types
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
typedef std::list<DataModel::JournalEntryPtr> Journal;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// X'truction
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
EventProcessor();
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Virtual public interface
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
//! Setup all configuration parameters
|
||||
virtual bool setup(const Config::Config &config) = 0;
|
||||
|
||||
//! Processes an event. The preferred object (Origin, Magnitude,
|
||||
//! FocalMechanism) are guaranteed to be found with *::Find(id)
|
||||
//! methods.
|
||||
//! This method should return true if the event objects needs
|
||||
//! an update.
|
||||
virtual bool process(DataModel::Event *event,
|
||||
const Journal &journals) = 0;
|
||||
};
|
||||
|
||||
|
||||
DEFINE_INTERFACE_FACTORY(EventProcessor);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define REGISTER_EVENTPROCESSOR(Class, Service) \
|
||||
Seiscomp::Core::Generic::InterfaceFactory<Seiscomp::Client::EventProcessor, Class> __##Class##InterfaceFactory__(Service)
|
||||
|
||||
|
||||
#endif
|
77
include/seiscomp/plugins/events/scoreprocessor.h
Normal file
77
include/seiscomp/plugins/events/scoreprocessor.h
Normal file
@ -0,0 +1,77 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) GFZ Potsdam *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* GNU Affero General Public License Usage *
|
||||
* This file may be used under the terms of the GNU Affero *
|
||||
* Public License version 3.0 as published by the Free Software Foundation *
|
||||
* and appearing in the file LICENSE included in the packaging of this *
|
||||
* file. Please review the following information to ensure the GNU Affero *
|
||||
* Public License version 3.0 requirements will be met: *
|
||||
* https://www.gnu.org/licenses/agpl-3.0.html. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SEISCOMP_APPLICATIONS_SCOREPROCESSOR_H__
|
||||
#define SEISCOMP_APPLICATIONS_SCOREPROCESSOR_H__
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <seiscomp/core/baseobject.h>
|
||||
#include <seiscomp/core/interfacefactory.h>
|
||||
#include <seiscomp/config/config.h>
|
||||
#include <seiscomp/plugins/events/api.h>
|
||||
|
||||
|
||||
namespace Seiscomp {
|
||||
|
||||
|
||||
namespace DataModel {
|
||||
|
||||
class Origin;
|
||||
class FocalMechanism;
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace Client {
|
||||
|
||||
|
||||
DEFINE_SMARTPOINTER(ScoreProcessor);
|
||||
|
||||
|
||||
class SC_EVPLUGIN_API ScoreProcessor : public Seiscomp::Core::BaseObject {
|
||||
// ----------------------------------------------------------------------
|
||||
// X'struction
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
ScoreProcessor();
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Virtual public interface
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
//! Setup all configuration parameters
|
||||
virtual bool setup(const Config::Config &config) = 0;
|
||||
|
||||
//! Evaluates an origin.
|
||||
//! This method should return a score value. The higher the score
|
||||
//! the higher the origins priority in the process of selecting the
|
||||
//! preferred origin.
|
||||
virtual double evaluate(DataModel::Origin *origin) = 0;
|
||||
virtual double evaluate(DataModel::FocalMechanism *fm) = 0;
|
||||
};
|
||||
|
||||
|
||||
DEFINE_INTERFACE_FACTORY(ScoreProcessor);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define REGISTER_ORIGINSCOREPROCESSOR(Class, Service) \
|
||||
Seiscomp::Core::Generic::InterfaceFactory<Seiscomp::Client::ScoreProcessor, Class> __##Class##InterfaceFactory__(Service)
|
||||
|
||||
|
||||
#endif
|
17
include/seiscomp/plugins/monitor/api.h
Normal file
17
include/seiscomp/plugins/monitor/api.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef SC_MPLUGIN_API_H
|
||||
#define SC_MPLUGIN_API_H
|
||||
|
||||
#if defined(WIN32) && (defined(SC_MPLUGIN_SHARED) || defined(SC_ALL_SHARED))
|
||||
# if defined(SC_MPLUGIN_EXPORTS)
|
||||
# define SC_MPLUGIN_API __declspec(dllexport)
|
||||
# define SC_MPLUGIN_TEMPLATE_EXPORT
|
||||
# else
|
||||
# define SC_MPLUGIN_API __declspec(dllimport)
|
||||
# define SC_MPLUGIN_TEMPLATE_EXPORT extern
|
||||
# endif
|
||||
#else
|
||||
# define SC_MPLUGIN_API
|
||||
# define SC_MPLUGIN_TEMPLATE_EXPORT
|
||||
#endif
|
||||
|
||||
#endif
|
75
include/seiscomp/plugins/monitor/monitoroutplugininterface.h
Normal file
75
include/seiscomp/plugins/monitor/monitoroutplugininterface.h
Normal file
@ -0,0 +1,75 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) GFZ Potsdam *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* GNU Affero General Public License Usage *
|
||||
* This file may be used under the terms of the GNU Affero *
|
||||
* Public License version 3.0 as published by the Free Software Foundation *
|
||||
* and appearing in the file LICENSE included in the packaging of this *
|
||||
* file. Please review the following information to ensure the GNU Affero *
|
||||
* Public License version 3.0 requirements will be met: *
|
||||
* https://www.gnu.org/licenses/agpl-3.0.html. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SEISCOMP_APPLICATIONS_MONITOROUTPLUGININTERFACE_H__
|
||||
#define SEISCOMP_APPLICATIONS_MONITOROUTPLUGININTERFACE_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <seiscomp/core/baseobject.h>
|
||||
#include <seiscomp/core/interfacefactory.h>
|
||||
#include <seiscomp/config/config.h>
|
||||
#include <seiscomp/plugins/monitor/api.h>
|
||||
#include <seiscomp/plugins/monitor/types.h>
|
||||
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace Applications {
|
||||
|
||||
|
||||
DEFINE_SMARTPOINTER(MonitorOutPluginInterface);
|
||||
|
||||
|
||||
class SC_MPLUGIN_API MonitorOutPluginInterface : public Seiscomp::Core::BaseObject {
|
||||
DECLARE_SC_CLASS(MonitorOutPluginInterface);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// X'struction
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
MonitorOutPluginInterface(const std::string& name);
|
||||
virtual ~MonitorOutPluginInterface() {}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Public interface
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
virtual bool initOut(const Config::Config &cfg) = 0;
|
||||
virtual bool deinitOut() = 0;
|
||||
virtual bool print(const ClientTable& table) = 0;
|
||||
virtual bool refreshOut() = 0;
|
||||
virtual bool clearOut() = 0;
|
||||
|
||||
const std::string& name() const;
|
||||
|
||||
static MonitorOutPluginInterface* Create(const std::string& service);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Private data members
|
||||
// ---------------------------------------------------------------------
|
||||
private:
|
||||
std::string _name;
|
||||
|
||||
};
|
||||
|
||||
|
||||
DEFINE_INTERFACE_FACTORY(MonitorOutPluginInterface);
|
||||
|
||||
#define REGISTER_MONITOR_OUT_PLUGIN_INTERFACE(Class, Service) \
|
||||
Seiscomp::Core::Generic::InterfaceFactory<Seiscomp::Applications::MonitorOutPluginInterface, Class> __##Class##InterfaceFactory__(Service)
|
||||
|
||||
} // namespace Applications
|
||||
} // namespace Seiscomp
|
||||
|
||||
#endif
|
116
include/seiscomp/plugins/monitor/monitorplugininterface.h
Normal file
116
include/seiscomp/plugins/monitor/monitorplugininterface.h
Normal file
@ -0,0 +1,116 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) GFZ Potsdam *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* GNU Affero General Public License Usage *
|
||||
* This file may be used under the terms of the GNU Affero *
|
||||
* Public License version 3.0 as published by the Free Software Foundation *
|
||||
* and appearing in the file LICENSE included in the packaging of this *
|
||||
* file. Please review the following information to ensure the GNU Affero *
|
||||
* Public License version 3.0 requirements will be met: *
|
||||
* https://www.gnu.org/licenses/agpl-3.0.html. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SEISCOMP_APPLICATIONS_MONITORPLUGININTERFACE_H__
|
||||
#define SEISCOMP_APPLICATIONS_MONITORPLUGININTERFACE_H__
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <seiscomp/core/baseobject.h>
|
||||
#include <seiscomp/core/interfacefactory.h>
|
||||
#include <seiscomp/config/config.h>
|
||||
#include <seiscomp/plugins/monitor/api.h>
|
||||
#include <seiscomp/plugins/monitor/types.h>
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace Applications {
|
||||
|
||||
|
||||
SC_MPLUGIN_API bool findName(ClientInfoData clientData, std::string name);
|
||||
|
||||
|
||||
DEFINE_SMARTPOINTER(MonitorPluginInterface);
|
||||
|
||||
class MFilterParser;
|
||||
class MFilterInterface;
|
||||
|
||||
|
||||
class SC_MPLUGIN_API MonitorPluginInterface : public Seiscomp::Core::BaseObject {
|
||||
DECLARE_SC_CLASS(MonitorPluginInterface);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// X'struction
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
MonitorPluginInterface(const std::string& name);
|
||||
virtual ~MonitorPluginInterface();
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Public interface
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
static MonitorPluginInterface *Create(const std::string &service);
|
||||
|
||||
virtual bool init(const Config::Config &cfg);
|
||||
|
||||
virtual void process(const ClientTable &clientTable) = 0;
|
||||
|
||||
bool initFilter(const Config::Config &cfg);
|
||||
bool operational() const;
|
||||
bool isFilteringEnabled() const;
|
||||
void setOperational(bool val);
|
||||
|
||||
const std::string &filterString() const;
|
||||
const ClientTable *filter(const ClientTable& clientTable);
|
||||
const ClientTable *filterMean(const ClientTable& clientTable);
|
||||
void setFilterMeanInterval(double interval);
|
||||
|
||||
const ClientTable *match() const;
|
||||
|
||||
const std::string &name() const;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Private interface
|
||||
// ----------------------------------------------------------------------
|
||||
private:
|
||||
template <Client::Status::ETag tag>
|
||||
void sumData(ClientInfoData &lhs, const ClientInfoData &rhs);
|
||||
|
||||
template <Client::Status::ETag tag>
|
||||
void calculateMean(ClientInfoData &lhs, size_t count);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Private members
|
||||
// ----------------------------------------------------------------------
|
||||
private:
|
||||
Core::TimeSpan _filterMeanInterval;
|
||||
Core::Time _filterMeanTimeMark;
|
||||
ClientTable _filterMeanClientTable;
|
||||
std::map<std::string, size_t> _filterMeanMessageCount;
|
||||
|
||||
ClientTable _match;
|
||||
std::string _name;
|
||||
bool _operational;
|
||||
bool _isFilteringEnabled;
|
||||
std::string _filterStr;
|
||||
MFilterParser *_mFilterParser;
|
||||
MFilterInterface *_filter;
|
||||
|
||||
};
|
||||
|
||||
|
||||
DEFINE_INTERFACE_FACTORY(MonitorPluginInterface);
|
||||
|
||||
|
||||
#define REGISTER_MONITOR_PLUGIN_INTERFACE(Class, Service) \
|
||||
Seiscomp::Core::Generic::InterfaceFactory<Seiscomp::Applications::MonitorPluginInterface, Class> __##Class##InterfaceFactory__(Service)
|
||||
|
||||
|
||||
} // namespace Applications
|
||||
} // namespace Seiscomp
|
||||
|
||||
#endif
|
73
include/seiscomp/plugins/monitor/types.h
Normal file
73
include/seiscomp/plugins/monitor/types.h
Normal file
@ -0,0 +1,73 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) GFZ Potsdam *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* GNU Affero General Public License Usage *
|
||||
* This file may be used under the terms of the GNU Affero *
|
||||
* Public License version 3.0 as published by the Free Software Foundation *
|
||||
* and appearing in the file LICENSE included in the packaging of this *
|
||||
* file. Please review the following information to ensure the GNU Affero *
|
||||
* Public License version 3.0 requirements will be met: *
|
||||
* https://www.gnu.org/licenses/agpl-3.0.html. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SEISCOMP_APPLICATIONS_TYPES_H__
|
||||
#define SEISCOMP_APPLICATIONS_TYPES_H__
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
#include <seiscomp/messaging/status.h>
|
||||
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace Applications {
|
||||
|
||||
typedef std::map<Client::Status::Tag, std::string> ClientInfoData;
|
||||
|
||||
struct ClientTableEntry {
|
||||
ClientTableEntry(const ClientInfoData &data)
|
||||
: info(data), processed(false), printed(false) {}
|
||||
|
||||
ClientTableEntry(const Client::Status &status)
|
||||
: processed(false), printed(false) {
|
||||
*this = status;
|
||||
}
|
||||
|
||||
ClientTableEntry &operator=(const ClientInfoData &data) {
|
||||
if ( info != data ) {
|
||||
info = data;
|
||||
processed = false;
|
||||
printed = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
ClientTableEntry &operator=(const Client::Status &status) {
|
||||
ClientInfoData data;
|
||||
for ( int i = 0; i < Client::Status::ETagQuantity; ++i ) {
|
||||
Client::Status::Tag tag;
|
||||
if ( !status.values[i].empty() ) {
|
||||
tag.fromInt(i);
|
||||
data[tag] = status.values[i];
|
||||
}
|
||||
}
|
||||
|
||||
return *this = data;
|
||||
}
|
||||
|
||||
operator ClientInfoData &() { return info; }
|
||||
operator const ClientInfoData &() const { return info; }
|
||||
|
||||
ClientInfoData info; //! The client information
|
||||
bool processed; //! Has this entry already been seen by a plugin?
|
||||
bool printed; //! Has this entry already been seen by an output
|
||||
//! plugin?
|
||||
};
|
||||
|
||||
typedef std::list<ClientTableEntry> ClientTable;
|
||||
|
||||
} // namespace Applications
|
||||
} // namespace Seiscomp
|
||||
|
||||
#endif
|
17
include/seiscomp/plugins/qc/api.h
Normal file
17
include/seiscomp/plugins/qc/api.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef SC_QCPLUGIN_API_H
|
||||
#define SC_QCPLUGIN_API_H
|
||||
|
||||
#if defined(WIN32) && (defined(SC_QCPLUGIN_SHARED) || defined(SC_ALL_SHARED))
|
||||
# if defined(SC_QCPLUGIN_EXPORTS)
|
||||
# define SC_QCPLUGIN_API __declspec(dllexport)
|
||||
# define SC_QCPLUGIN_TEMPLATE_EXPORT
|
||||
# else
|
||||
# define SC_QCPLUGIN_API __declspec(dllimport)
|
||||
# define SC_QCPLUGIN_TEMPLATE_EXPORT extern
|
||||
# endif
|
||||
#else
|
||||
# define SC_QCPLUGIN_API
|
||||
# define SC_QCPLUGIN_TEMPLATE_EXPORT
|
||||
#endif
|
||||
|
||||
#endif
|
75
include/seiscomp/plugins/qc/qcbuffer.h
Normal file
75
include/seiscomp/plugins/qc/qcbuffer.h
Normal file
@ -0,0 +1,75 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) GFZ Potsdam *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* GNU Affero General Public License Usage *
|
||||
* This file may be used under the terms of the GNU Affero *
|
||||
* Public License version 3.0 as published by the Free Software Foundation *
|
||||
* and appearing in the file LICENSE included in the packaging of this *
|
||||
* file. Please review the following information to ensure the GNU Affero *
|
||||
* Public License version 3.0 requirements will be met: *
|
||||
* https://www.gnu.org/licenses/agpl-3.0.html. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SEISCOMP_QC_QCBUFFER_H__
|
||||
#define SEISCOMP_QC_QCBUFFER_H__
|
||||
|
||||
|
||||
#include <seiscomp/qc/qcprocessor.h>
|
||||
#include <seiscomp/plugins/qc/api.h>
|
||||
|
||||
using namespace Seiscomp::Processing;
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace Applications {
|
||||
namespace Qc {
|
||||
|
||||
typedef std::list<QcParameterCPtr> BufferBase;
|
||||
|
||||
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
DEFINE_SMARTPOINTER(QcBuffer);
|
||||
|
||||
class SC_QCPLUGIN_API QcBuffer : public Core::BaseObject, public BufferBase {
|
||||
public:
|
||||
QcBuffer();
|
||||
QcBuffer(double maxBufferSize);
|
||||
|
||||
mutable Core::Time lastEvalTime;
|
||||
|
||||
void push_back(const QcParameter *qcp);
|
||||
|
||||
/*
|
||||
const QcParameter* qcParameter(const Core::Time &time) const;
|
||||
const QcBuffer* qcParameter(const Core::Time &startTime, const Core::Time &endTime) const;
|
||||
*/
|
||||
QcBuffer *qcParameter(const Core::TimeSpan &lastNSeconds) const;
|
||||
|
||||
void info() const;
|
||||
void dump() const;
|
||||
bool recentlyUsed() const;
|
||||
void setRecentlyUsed(bool status);
|
||||
|
||||
const Core::Time& startTime() const;
|
||||
const Core::Time& endTime() const;
|
||||
Core::TimeSpan length() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
private:
|
||||
double _maxBufferSize;
|
||||
bool _recentlyUsed;
|
||||
|
||||
|
||||
};
|
||||
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
120
include/seiscomp/plugins/qc/qcconfig.h
Normal file
120
include/seiscomp/plugins/qc/qcconfig.h
Normal file
@ -0,0 +1,120 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) GFZ Potsdam *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* GNU Affero General Public License Usage *
|
||||
* This file may be used under the terms of the GNU Affero *
|
||||
* Public License version 3.0 as published by the Free Software Foundation *
|
||||
* and appearing in the file LICENSE included in the packaging of this *
|
||||
* file. Please review the following information to ensure the GNU Affero *
|
||||
* Public License version 3.0 requirements will be met: *
|
||||
* https://www.gnu.org/licenses/agpl-3.0.html. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SEISCOMP_QC_QCCONFIG_H__
|
||||
#define SEISCOMP_QC_QCCONFIG_H__
|
||||
|
||||
#include <seiscomp/core/exceptions.h>
|
||||
#include <seiscomp/core/baseobject.h>
|
||||
#include <seiscomp/plugins/qc/api.h>
|
||||
#include <seiscomp/plugins/qc/qcplugin.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace Applications {
|
||||
namespace Qc {
|
||||
|
||||
|
||||
class SC_QCPLUGIN_API QcConfigException: public Core::GeneralException {
|
||||
public:
|
||||
QcConfigException(): Core::GeneralException("Qc config exception") {}
|
||||
QcConfigException(const std::string &what): Core::GeneralException(what) {}
|
||||
};
|
||||
|
||||
|
||||
DEFINE_SMARTPOINTER(QcConfig);
|
||||
class SC_QCPLUGIN_API QcConfig : public Core::BaseObject {
|
||||
DECLARE_SC_CLASS(QcConfig);
|
||||
|
||||
public:
|
||||
//! default Constructor
|
||||
QcConfig();
|
||||
|
||||
//! initializing Constructor
|
||||
QcConfig(QcApp *app, const std::string &pluginName="default");
|
||||
|
||||
//! destructor
|
||||
virtual ~QcConfig();
|
||||
|
||||
//! Read plugin specific configuration from config files. If not found,
|
||||
//! use plugin.defaults. If not found, use compiled-in default.
|
||||
std::string readConfig(const std::string& pluginName,
|
||||
const std::string& keyWord,
|
||||
const std::string& defaultValue) const;
|
||||
|
||||
//! Returns true if configured in realtime only mode; false otherwise
|
||||
bool realtimeOnly() const;
|
||||
|
||||
//! Returns the over all buffer length
|
||||
int buffer() const;
|
||||
|
||||
//! Returns the archive interval time span
|
||||
int archiveInterval() const;
|
||||
|
||||
//! Returns the configured archive buffer length
|
||||
//! if it is <= buffer length; buffer length otherwise
|
||||
int archiveBuffer() const;
|
||||
|
||||
//! Returns the report interval time span
|
||||
int reportInterval() const;
|
||||
|
||||
//! Returns the configured report buffer length
|
||||
//! if it is <= buffer length; buffer length otherwise
|
||||
int reportBuffer() const;
|
||||
|
||||
//! Returns the configured timeout for realtime only processors
|
||||
//! throws exception in case of archive mode
|
||||
int reportTimeout() const;
|
||||
|
||||
//! Returns the alert interval time span if in realtime processing mode
|
||||
//! throws exception in case of archive mode
|
||||
int alertInterval() const;
|
||||
|
||||
//! Returns the configured report buffer length
|
||||
//! if it is <= buffer length; buffer length otherwise in realtime mode
|
||||
//! throws exception in case of archive mode
|
||||
int alertBuffer() const;
|
||||
|
||||
//! Returns the thresholds triggering alarm in realtime mode
|
||||
//! throws exception in case of archive mode
|
||||
std::vector<int> alertThresholds() const;
|
||||
|
||||
//! Returns true if configured in realtime only mode; false otherwise
|
||||
static bool RealtimeOnly(const QcApp *app, const std::string &pluginName);
|
||||
|
||||
private:
|
||||
QcApp* _app;
|
||||
bool _realtime;
|
||||
int _buffer;
|
||||
int _archiveInterval;
|
||||
int _archiveBuffer;
|
||||
int _reportInterval;
|
||||
int _reportBuffer;
|
||||
int _reportTimeout;
|
||||
int _alertInterval;
|
||||
int _alertBuffer;
|
||||
std::vector<int> _alertThresholds;
|
||||
|
||||
void setQcConfig(const std::string &pluginName);
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
131
include/seiscomp/plugins/qc/qcmessenger.h
Normal file
131
include/seiscomp/plugins/qc/qcmessenger.h
Normal file
@ -0,0 +1,131 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) GFZ Potsdam *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* GNU Affero General Public License Usage *
|
||||
* This file may be used under the terms of the GNU Affero *
|
||||
* Public License version 3.0 as published by the Free Software Foundation *
|
||||
* and appearing in the file LICENSE included in the packaging of this *
|
||||
* file. Please review the following information to ensure the GNU Affero *
|
||||
* Public License version 3.0 requirements will be met: *
|
||||
* https://www.gnu.org/licenses/agpl-3.0.html. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SEISCOMP_QCMESSENGER_H__
|
||||
#define SEISCOMP_QCMESSENGER_H__
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include <seiscomp/core/exceptions.h>
|
||||
#include <seiscomp/core/message.h>
|
||||
#include <seiscomp/utils/timer.h>
|
||||
#include <seiscomp/plugins/qc/api.h>
|
||||
#include <seiscomp/messaging/connection.h>
|
||||
#include <seiscomp/datamodel/object.h>
|
||||
#include <seiscomp/datamodel/waveformquality.h>
|
||||
#include <seiscomp/datamodel/notifier.h>
|
||||
#include <seiscomp/core/datamessage.h>
|
||||
#include <seiscomp/plugins/qc/qcplugin.h>
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace Applications {
|
||||
namespace Qc {
|
||||
|
||||
using namespace std;
|
||||
using namespace Seiscomp;
|
||||
using namespace Seiscomp::Core;
|
||||
using namespace Seiscomp::Client;
|
||||
using namespace Seiscomp::DataModel;
|
||||
|
||||
|
||||
class SC_QCPLUGIN_API ConfigException: public GeneralException {
|
||||
public:
|
||||
ConfigException(): GeneralException("config exception") {}
|
||||
ConfigException(const string& what): GeneralException(what) {}
|
||||
};
|
||||
|
||||
class SC_QCPLUGIN_API ConnectionException: public GeneralException {
|
||||
public:
|
||||
ConnectionException(): GeneralException("connection exception") {}
|
||||
ConnectionException(const string& what): GeneralException(what) {}
|
||||
};
|
||||
|
||||
class SC_QCPLUGIN_API DatabaseException: public GeneralException {
|
||||
public:
|
||||
DatabaseException(): GeneralException("database exception") {}
|
||||
DatabaseException(const string& what): GeneralException(what) {}
|
||||
};
|
||||
|
||||
|
||||
struct SC_QCPLUGIN_API QcIndex {
|
||||
QcIndex() {}
|
||||
QcIndex(const std::string &k, const Core::Time &s) : key(k), startTime(s) {}
|
||||
|
||||
std::string key;
|
||||
Core::Time startTime;
|
||||
};
|
||||
|
||||
|
||||
class SC_QCPLUGIN_API QcIndexMap {
|
||||
public:
|
||||
QcIndexMap() {}
|
||||
|
||||
bool find(const QcIndex &idx) const {
|
||||
std::map<std::string, Core::Time>::const_iterator it;
|
||||
it = _indexMap.find(idx.key);
|
||||
return it != _indexMap.end() && it->second == idx.startTime;
|
||||
}
|
||||
|
||||
void insert(const QcIndex &idx) {
|
||||
_indexMap[idx.key] = idx.startTime;
|
||||
}
|
||||
|
||||
size_t size() const {
|
||||
return _indexMap.size();
|
||||
}
|
||||
|
||||
private:
|
||||
std::map<std::string, Core::Time> _indexMap;
|
||||
};
|
||||
|
||||
|
||||
DEFINE_SMARTPOINTER(QcMessenger);
|
||||
|
||||
class SC_QCPLUGIN_API QcMessenger : public Core::BaseObject {
|
||||
public:
|
||||
//! Initializing Constructor
|
||||
QcMessenger(QcApp* app);
|
||||
|
||||
//! Attach object to message and schedule sending
|
||||
//! (if notifier is true send as notifier message; as data message otherwise)
|
||||
bool attachObject(DataModel::Object* obj, bool notifier, Operation operation=OP_UNDEFINED);
|
||||
|
||||
//! Scheduler for sending messages (called periodically by application)
|
||||
void scheduler();
|
||||
|
||||
//! Send Qc Message
|
||||
bool sendMessage(Message* msg);
|
||||
|
||||
void flushMessages();
|
||||
|
||||
private:
|
||||
QcIndexMap _qcIndex;
|
||||
NotifierMessagePtr _notifierMsg;
|
||||
DataMessagePtr _dataMsg;
|
||||
QcApp* _app;
|
||||
Core::TimeSpan _sendInterval;
|
||||
int _maxSize;
|
||||
Util::StopWatch _timer;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
147
include/seiscomp/plugins/qc/qcplugin.h
Normal file
147
include/seiscomp/plugins/qc/qcplugin.h
Normal file
@ -0,0 +1,147 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) GFZ Potsdam *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* GNU Affero General Public License Usage *
|
||||
* This file may be used under the terms of the GNU Affero *
|
||||
* Public License version 3.0 as published by the Free Software Foundation *
|
||||
* and appearing in the file LICENSE included in the packaging of this *
|
||||
* file. Please review the following information to ensure the GNU Affero *
|
||||
* Public License version 3.0 requirements will be met: *
|
||||
* https://www.gnu.org/licenses/agpl-3.0.html. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SEISCOMP_QC_QCPLUGIN_H__
|
||||
#define SEISCOMP_QC_QCPLUGIN_H__
|
||||
|
||||
#include <seiscomp/processing/application.h>
|
||||
#include <seiscomp/qc/qcprocessor.h>
|
||||
#include <seiscomp/core/interfacefactory.h>
|
||||
#include <seiscomp/core/plugin.h>
|
||||
#include <seiscomp/utils/timer.h>
|
||||
#include <seiscomp/plugins/qc/api.h>
|
||||
#include <seiscomp/datamodel/waveformquality.h>
|
||||
|
||||
#include <queue>
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
|
||||
namespace bsig = boost::signals2;
|
||||
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace Applications {
|
||||
namespace Qc {
|
||||
|
||||
|
||||
class QcMessenger;
|
||||
class QcConfig;
|
||||
class QcBuffer;
|
||||
|
||||
DEFINE_SMARTPOINTER(QcBuffer);
|
||||
|
||||
SC_QCPLUGIN_API DataModel::WaveformStreamID getWaveformID(const std::string &streamID);
|
||||
|
||||
class SC_QCPLUGIN_API QcApp : public Processing::Application {
|
||||
public:
|
||||
QcApp(int argc, char **argv) : Processing::Application(argc, argv) {}
|
||||
|
||||
virtual bool exitRequested() const { return false; }
|
||||
virtual const QcConfig* qcConfig() const { return NULL; }
|
||||
virtual QcMessenger* qcMessenger() const { return NULL; }
|
||||
|
||||
typedef bsig::signal<void()> TimerSignal;
|
||||
virtual void addTimeout(const TimerSignal::slot_type& onTimeout) const {}
|
||||
virtual bool archiveMode() const { return false; }
|
||||
virtual std::string creatorID() const = 0;
|
||||
|
||||
TimerSignal doneSignal;
|
||||
};
|
||||
|
||||
|
||||
DEFINE_SMARTPOINTER(QcPlugin);
|
||||
|
||||
class QcPlugin : public Processing::QcProcessorObserver {
|
||||
DECLARE_SC_CLASS(QcPlugin)
|
||||
|
||||
public:
|
||||
|
||||
QcPlugin();
|
||||
virtual ~QcPlugin();
|
||||
|
||||
public:
|
||||
//! Initialize all needed ressources
|
||||
virtual bool init(QcApp* app, QcConfig *cfg, std::string streamID);
|
||||
|
||||
//! Called from the corresponding QcProcessor to propagate news
|
||||
virtual void update();
|
||||
|
||||
//! Returns the plugin specific name given to plugin registry
|
||||
virtual std::string registeredName() const = 0;
|
||||
|
||||
//! Returns the plugin specific parameter names
|
||||
virtual std::vector<std::string> parameterNames() const = 0;
|
||||
|
||||
//! Returns the corresponding QcProcessor object
|
||||
Processing::QcProcessor* qcProcessor();
|
||||
|
||||
//! Finish the work
|
||||
void done();
|
||||
|
||||
protected:
|
||||
void onTimeout();
|
||||
virtual void timeoutTask() = 0;
|
||||
|
||||
virtual double mean(const QcBuffer* qcb) const;
|
||||
virtual double stdDev(const QcBuffer* qcb, double mean) const;
|
||||
|
||||
virtual void generateNullReport() const;
|
||||
virtual void generateReport(const QcBuffer* reportBuffer) const;
|
||||
virtual void generateAlert(const QcBuffer* staBuffer, const QcBuffer* ltaBuffer) const;
|
||||
|
||||
//! collect objects to be send to qcMessenger
|
||||
void pushObject(DataModel::Object* obj) const;
|
||||
|
||||
//! pass the collected objects to qcMessenger
|
||||
//! false = data messages; true = notifier messages
|
||||
void sendObjects(bool notifier = false);
|
||||
|
||||
void sendMessages(const Core::Time &rectime);
|
||||
|
||||
mutable std::queue<DataModel::ObjectPtr> _objects;
|
||||
std::string _name;
|
||||
std::vector<std::string> _parameterNames;
|
||||
std::string _streamID;
|
||||
QcApp* _app;
|
||||
QcMessenger* _qcMessenger;
|
||||
const QcConfig* _qcConfig;
|
||||
mutable QcBufferPtr _qcBuffer;
|
||||
Processing::QcProcessorPtr _qcProcessor;
|
||||
|
||||
private:
|
||||
mutable Core::Time _lastArchiveTime;
|
||||
mutable Core::Time _lastReportTime;
|
||||
mutable Core::Time _lastAlertTime;
|
||||
mutable bool _firstRecord;
|
||||
mutable Util::StopWatch _timer;
|
||||
};
|
||||
|
||||
|
||||
typedef std::vector<QcPluginPtr> QcPlugins;
|
||||
|
||||
DEFINE_INTERFACE_FACTORY(QcPlugin);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define REGISTER_QCPLUGIN(Class, Service) \
|
||||
Seiscomp::Core::Generic::InterfaceFactory<Seiscomp::Applications::Qc::QcPlugin, Class> __##Class##InterfaceFactory__(Service)
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user