[seiscomp, scanloc] Install, add .gitignore
This commit is contained in:
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