[seiscomp, scanloc] Install, add .gitignore

This commit is contained in:
2025-10-09 15:07:02 +02:00
commit 20f5301bb1
2848 changed files with 1315858 additions and 0 deletions

View File

@ -0,0 +1,41 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* 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. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_IO_RECORDSTREAM_ARCHIVE_H
#define SEISCOMP_IO_RECORDSTREAM_ARCHIVE_H
#include <seiscomp/io/recordstream.h>
namespace Seiscomp {
namespace RecordStream {
class SC_SYSTEM_CORE_API ArchiveException: public Seiscomp::IO::RecordStreamException {
public:
ArchiveException(): RecordStreamException("Archive exception") {}
ArchiveException(const std::string& what): RecordStreamException(what) {}
};
}
}
#endif

View File

@ -0,0 +1,147 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* 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. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_IO_RECORDSTREAM_ARCLINK_H
#define SEISCOMP_IO_RECORDSTREAM_ARCLINK_H
#include <string>
#include <set>
#include <iostream>
#include <sstream>
#include <fstream>
#include <seiscomp/core/interruptible.h>
#include <seiscomp/core/datetime.h>
#include <seiscomp/utils/timer.h>
#include <seiscomp/io/recordstream.h>
#include <seiscomp/core.h>
#include <seiscomp/io/socket.h>
#include <seiscomp/io/recordstream/streamidx.h>
namespace Seiscomp {
namespace RecordStream {
namespace Arclink {
namespace _private {
class SC_SYSTEM_CORE_API ArclinkException: public Seiscomp::IO::RecordStreamException {
public:
ArclinkException(): RecordStreamException("ArcLink exception") {}
ArclinkException(const std::string& what): RecordStreamException(what) {}
};
class SC_SYSTEM_CORE_API ArclinkCommandException: public ArclinkException {
public:
ArclinkCommandException(): ArclinkException("command not accepted") {}
ArclinkCommandException(const std::string& what): ArclinkException(what) {}
};
DEFINE_SMARTPOINTER(ArclinkConnection);
class SC_SYSTEM_CORE_API ArclinkConnection : public Seiscomp::IO::RecordStream {
DECLARE_SC_CLASS(ArclinkConnection);
public:
//! C'tor
ArclinkConnection();
//! Initializing Constructor
ArclinkConnection(std::string serverloc);
//! Destructor
virtual ~ArclinkConnection();
public:
//! The recordtype cannot be selected when using an arclink
//! connection. It will always create MiniSeed records
virtual bool setRecordType(const char*);
//! Initialize the arclink connection.
virtual bool setSource(const std::string &serverloc);
//! Supply user credentials
bool setUser(std::string name, std::string password);
//! Adds the given stream to the server connection description
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode);
//! Adds the given stream to the server connection description
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode,
const Seiscomp::Core::Time &stime,
const Seiscomp::Core::Time &etime);
//! Adds the given start time to the server connection description
virtual bool setStartTime(const Seiscomp::Core::Time &stime);
//! Adds the given end time to the server connection description
virtual bool setEndTime(const Seiscomp::Core::Time &etime);
//! Sets timeout
virtual bool setTimeout(int seconds);
//! Terminates the arclink connection.
virtual void close();
virtual Record *next();
//! Removes all stream list, time window, etc. -entries from the connection description object.
bool clear();
//! Reconnects a terminated arclink connection.
bool reconnect();
private:
Seiscomp::IO::Socket _sock;
std::string _serverloc;
std::string _user;
std::string _passwd;
std::list<StreamIdx> _ordered;
std::set<StreamIdx> _streams;
Seiscomp::Core::Time _stime;
Seiscomp::Core::Time _etime;
std::string _reqID;
bool _readingData;
bool _chunkMode;
int _remainingBytes;
std::ofstream _dump;
void handshake();
void cleanup();
};
} // namespace _private
//using _private::ArclinkException;
//using _private::ArclinkCommandException;
using _private::ArclinkConnection;
using _private::ArclinkConnectionPtr;
} // namespace Arclink
} // namespace RecordStream
} // namespace Seiscomp
#endif

View File

@ -0,0 +1,107 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* 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. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_SERVICES_RECORDSTREAM_COMBINED_H
#define SEISCOMP_SERVICES_RECORDSTREAM_COMBINED_H
#include <string>
#include <iostream>
#include <seiscomp/core/datetime.h>
#include <seiscomp/core/timewindow.h>
#include <seiscomp/io/recordstream.h>
#include <seiscomp/core.h>
namespace Seiscomp {
namespace RecordStream {
DEFINE_SMARTPOINTER(CombinedConnection);
class SC_SYSTEM_CORE_API CombinedConnection : public IO::RecordStream {
public:
//! C'tor
CombinedConnection();
//! Initializing Constructor
CombinedConnection(std::string serverloc);
//! Destructor
virtual ~CombinedConnection();
virtual bool setRecordType(const char*);
//! Initialize the combined connection.
virtual bool setSource(const std::string &serverloc);
//! Adds the given stream to the server connection description
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode);
//! Adds the given stream to the server connection description
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode,
const Seiscomp::Core::Time &startTime,
const Seiscomp::Core::Time &endTime);
//! Adds the given start time to the server connection description
virtual bool setStartTime(const Core::Time &stime);
//! Adds the given end time to the server connection description
virtual bool setEndTime(const Core::Time &etime);
//! Sets timeout
virtual bool setTimeout(int seconds);
//! Terminates the combined connection.
virtual void close();
//! Returns the data stream
virtual Record *next();
private:
void init();
private:
bool _started;
size_t _nStream;
size_t _nArchive;
size_t _nRealtime;
Core::Time _startTime;
Core::Time _endTime;
Core::Time _archiveEndTime;
Core::TimeSpan _realtimeAvailability;
std::set<StreamIdx> _tmpStreams;
IO::RecordStreamPtr _realtime;
IO::RecordStreamPtr _archive;
};
} // namespace RecordStream
} // namespace Seiscomp
#endif

View File

@ -0,0 +1,122 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* 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. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_SERVICES_RECORDSTREAM_CONCURRENT_H
#define SEISCOMP_SERVICES_RECORDSTREAM_CONCURRENT_H
#include <seiscomp/core/datetime.h>
#include <seiscomp/core/timewindow.h>
#include <seiscomp/io/recordstream.h>
#include <seiscomp/core.h>
#include <seiscomp/client/queue.h>
namespace Seiscomp {
namespace RecordStream {
class SC_SYSTEM_CORE_API Concurrent : public IO::RecordStream {
// ----------------------------------------------------------------------
// X'truction
// ----------------------------------------------------------------------
public:
//! C'tor
Concurrent();
//! Destructor
~Concurrent() override;
// ----------------------------------------------------------------------
// RecordStream Interface
// ----------------------------------------------------------------------
public:
bool setRecordType(const char*) override;
//! Adds the given stream to the server connection description
bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode) override;
//! Adds the given stream to the server connection description
bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode,
const Seiscomp::Core::Time &startTime,
const Seiscomp::Core::Time &endTime) override;
//! Adds the given start time to the server connection description
bool setStartTime(const Core::Time &stime) override;
//! Adds the given end time to the server connection description
bool setEndTime(const Core::Time &etime) override;
//! Adds the given end time window to the server connection description
bool setTimeWindow(const Core::TimeWindow &w) override;
//! Sets timeout
bool setTimeout(int seconds) override;
//! Terminates the combined connection.
void close() override;
Record *next() override;
// ----------------------------------------------------------------------
// Concurrent interface
// ----------------------------------------------------------------------
protected:
virtual int getRS(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode) = 0;
void reset();
// ----------------------------------------------------------------------
// Private methods and members
// ----------------------------------------------------------------------
private:
void acquiThread(IO::RecordStream *rs);
protected:
using RecordStreamItem = std::pair<IO::RecordStreamPtr, bool>;
bool _started{false};
std::vector<RecordStreamItem> _rsarray;
private:
int _nthreads{0};
std::list<std::thread> _threads;
Client::ThreadedQueue<Record*> _queue;
std::mutex _mtx;
};
} // namespace RecordStream
} // namespace Seiscomp
#endif

View File

@ -0,0 +1,166 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* 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. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_RECORDSTREAM_DECIMATION_H
#define SEISCOMP_RECORDSTREAM_DECIMATION_H
#include <sstream>
#include <map>
#include <seiscomp/core/genericrecord.h>
#include <seiscomp/io/recordstream.h>
#include <seiscomp/core.h>
namespace Seiscomp {
namespace RecordStream {
DEFINE_SMARTPOINTER(Decimation);
class SC_SYSTEM_CORE_API Decimation : public Seiscomp::IO::RecordStream {
// ----------------------------------------------------------------------
// Xstruction
// ----------------------------------------------------------------------
public:
Decimation();
virtual ~Decimation();
// ----------------------------------------------------------------------
// Public Interface
// ----------------------------------------------------------------------
public:
virtual bool setSource(const std::string &source);
virtual bool setRecordType(const char *type);
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode);
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode,
const Seiscomp::Core::Time &stime,
const Seiscomp::Core::Time &etime);
virtual bool setStartTime(const Seiscomp::Core::Time &stime);
virtual bool setEndTime(const Seiscomp::Core::Time &etime);
virtual bool setTimeWindow(const Seiscomp::Core::TimeWindow &w);
virtual bool setTimeout(int seconds);
virtual void close();
virtual Record *next();
// ----------------------------------------------------------------------
// Private Interface
// ----------------------------------------------------------------------
private:
void cleanup();
int checkSR(Record *rec) const;
bool push(Record *rec);
GenericRecord *convert(Record *rec);
// ----------------------------------------------------------------------
// Implementation
// ----------------------------------------------------------------------
private:
typedef std::vector<double> Coefficients;
struct ResampleStage {
ResampleStage() : nextStage(nullptr) {}
~ResampleStage() { if ( nextStage ) delete nextStage; }
double targetRate;
// Fixed source sample rate derived from the first record
// received.
double sampleRate;
double dt;
// Flag that indicates that a streams is passed through
// without resampling.
bool passThrough;
bool valid;
int N;
int N2;
size_t samplesToSkip;
Coefficients *coefficients;
// The ring buffer that holds the last samples for downsampling.
std::vector<double> buffer;
// The number of samples still missing in the buffer before
// filtering can be done
size_t missingSamples;
// The front index of the ring buffer
size_t front;
// Time of front of ring buffer
Core::Time startTime;
// End time of last record
Core::Time lastEndTime;
ResampleStage *nextStage;
void reset() {
missingSamples = buffer.size();
front = 0;
samplesToSkip = 0;
startTime = Core::Time();
lastEndTime = Core::Time();
if ( nextStage ) nextStage->reset();
}
};
typedef std::map<int, Coefficients*> CoefficientMap;
typedef std::map<std::string, ResampleStage*> StreamMap;
void init(ResampleStage *stage, Record *rec);
bool initCoefficients(ResampleStage *stage);
GenericRecord *resample(ResampleStage *stage, Record *rec);
IO::RecordStreamPtr _source;
double _targetRate;
double _fp;
double _fs;
int _maxN;
int _coeffScale;
StreamMap _streams;
CoefficientMap _coefficients;
GenericRecord *_nextRecord;
};
}
}
#endif

View File

@ -0,0 +1,133 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* 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. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_IO_RECORDSTREAM_WS_H
#define SEISCOMP_IO_RECORDSTREAM_WS_H
#include <string>
#include <set>
#include <iostream>
#include <sstream>
#include <seiscomp/core.h>
#include <seiscomp/core/interruptible.h>
#include <seiscomp/core/datetime.h>
#include <seiscomp/utils/timer.h>
#include <seiscomp/io/recordstream.h>
#include <seiscomp/io/socket.h>
#include <seiscomp/io/recordstream/streamidx.h>
namespace Seiscomp {
namespace RecordStream {
class SC_SYSTEM_CORE_API FDSNWSConnectionBase : public IO::RecordStream {
protected:
//! C'tor
FDSNWSConnectionBase(const char *protocol, IO::Socket *socket, int defaultPort);
public:
//! The recordtype cannot be selected when using an arclink
//! connection. It will always create MiniSeed records
virtual bool setRecordType(const char *type);
//! Initialize the arclink connection.
virtual bool setSource(const std::string &source);
//! Supply user credentials
//! Adds the given stream to the server connection description
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode);
//! Adds the given stream to the server connection description
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode,
const Core::Time &startTime,
const Core::Time &endTime);
//! Adds the given start time to the server connection description
virtual bool setStartTime(const Core::Time &startTime);
//! Adds the given end time to the server connection description
virtual bool setEndTime(const Core::Time &endTime);
//! Sets timeout
virtual bool setTimeout(int seconds);
//! Terminates the arclink connection.
virtual void close();
virtual Record *next();
//! Reconnects a terminated arclink connection.
bool reconnect();
//! Removes all stream list, time window, etc. -entries from the connection description object.
bool clear();
private:
const char *getProxy() const;
void openConnection(const std::string &);
//! Blocking read from socket
std::string readBinary(int size);
void handshake();
private:
const char *_protocol;
IO::SocketPtr _socket;
std::string _host;
std::string _url;
int _defaultPort;
std::set<StreamIdx> _streams;
Core::Time _stime;
Core::Time _etime;
std::string _reqID;
bool _readingData;
bool _chunkMode;
int _remainingBytes;
std::string _error;
};
class SC_SYSTEM_CORE_API FDSNWSConnection : public FDSNWSConnectionBase {
public:
FDSNWSConnection();
};
class SC_SYSTEM_CORE_API FDSNWSSSLConnection : public FDSNWSConnectionBase {
public:
FDSNWSSSLConnection();
};
}
}
#endif

View File

@ -0,0 +1,137 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* 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. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_SERVICES_RECORDSTREAM_RECORDFILE_H
#define SEISCOMP_SERVICES_RECORDSTREAM_RECORDFILE_H
#include <string>
#include <iostream>
#include <fstream>
#include <map>
#include <seiscomp/io/recordstream.h>
#include <seiscomp/core.h>
namespace Seiscomp {
namespace RecordStream {
DEFINE_SMARTPOINTER(File);
class SC_SYSTEM_CORE_API File : public Seiscomp::IO::RecordStream {
public:
enum SeekDir {
Begin = std::ios_base::beg,
Current = std::ios_base::cur,
End = std::ios_base::end
};
// ----------------------------------------------------------------------
// X'truction
// ----------------------------------------------------------------------
public:
File() = default;
File(std::string name);
File(const File &f);
~File() override;
// ----------------------------------------------------------------------
// Operators
// ----------------------------------------------------------------------
public:
File &operator=(const File &f);
// ----------------------------------------------------------------------
// Public RecordStream interface
// ----------------------------------------------------------------------
public:
bool setSource(const std::string &filename) override;
bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode) override;
bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode,
const Seiscomp::Core::Time &startTime,
const Seiscomp::Core::Time &endTime) override;
bool setStartTime(const Seiscomp::Core::Time &startTime) override;
bool setEndTime(const Seiscomp::Core::Time &endTime) override;
void close() override;
bool setRecordType(const char *type) override;
Record *next() override;
// ----------------------------------------------------------------------
// Public file specific interface
// ----------------------------------------------------------------------
public:
std::string name() const;
size_t tell();
File &seek(size_t pos);
File &seek(int off, SeekDir dir);
// ----------------------------------------------------------------------
// Implementation
// ----------------------------------------------------------------------
private:
struct TimeWindowFilter {
TimeWindowFilter() {}
TimeWindowFilter(const Core::Time &stime, const Core::Time &etime)
: start(stime), end(etime) {}
Core::Time start;
Core::Time end;
};
using FilterMap = std::map<std::string, TimeWindowFilter>;
using ReFilterList = std::vector<std::pair<std::string,TimeWindowFilter> >;
const TimeWindowFilter* findTimeWindowFilter(Record *rec);
RecordFactory *_factory{nullptr};
std::string _name;
bool _closeRequested;
std::fstream _fstream;
std::istream *_current{&_fstream};
FilterMap _filter;
ReFilterList _reFilter;
Core::Time _startTime;
Core::Time _endTime;
};
}
}
#endif

View File

@ -0,0 +1,154 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* 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. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_IO_RECORDSTREAM_WS_H
#define SEISCOMP_IO_RECORDSTREAM_WS_H
#include <string>
#include <set>
#include <sstream>
#include <seiscomp/core.h>
#include <seiscomp/core/datetime.h>
#include <seiscomp/io/recordstream.h>
#include <seiscomp/io/socket.h>
#include <seiscomp/io/httpsocket.h>
#include <seiscomp/io/recordstream/streamidx.h>
extern "C" {
#include "bson/bson.h"
}
namespace Seiscomp {
namespace RecordStream {
class SC_SYSTEM_CORE_API HMBQueue {
public:
//! C'tor
HMBQueue();
//! Destructor
virtual ~HMBQueue();
//! Adds the given stream
void addStream(std::string loc, std::string cha,
const Seiscomp::Core::Time &stime, const Seiscomp::Core::Time &etime);
//! Sets the sequence number
void setSequenceNumber(int64_t seq);
//! Removes all entries
void clear();
//! Returns a BSON document
bson_t* toBSON() const;
private:
Core::Time _stime;
Core::Time _etime;
int64_t _seq;
std::set<std::string> _topics;
};
template<typename SocketType>
class SC_SYSTEM_CORE_API HMBConnection : public Seiscomp::IO::RecordStream {
//DECLARE_SC_CLASS(HMBConnection<SocketType>);
public:
//! C'tor
HMBConnection();
//! Initializing Constructor
HMBConnection(std::string serverloc);
//! Destructor
virtual ~HMBConnection();
//! The recordtype cannot be selected when using an HMB
//! connection. It will always create MiniSeed records
virtual bool setRecordType(const char *type);
//! Initialize the HMB connection.
virtual bool setSource(const std::string &source);
//! Supply user credentials
//! Adds the given stream to the server connection description
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode);
//! Adds the given stream to the server connection description
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode,
const Seiscomp::Core::Time &startTime,
const Seiscomp::Core::Time &endTime);
//! Adds the given start time to the server connection description
virtual bool setStartTime(const Seiscomp::Core::Time &stime);
//! Adds the given end time to the server connection description
virtual bool setEndTime(const Seiscomp::Core::Time &etime);
//! Sets timeout
virtual bool setTimeout(int seconds);
//! Terminates the HMB connection.
virtual void close();
virtual Record *next();
//! Removes all stream list, time window, etc. -entries from the connection description object.
bool clear();
//! Reconnects a terminated HMB connection.
bool reconnect();
private:
IO::HttpSocket<SocketType> _sock;
std::string _serverHost;
std::string _serverPath;
std::string _user;
std::string _password;
std::set<Seiscomp::RecordStream::StreamIdx> _streams;
Seiscomp::Core::Time _stime;
Seiscomp::Core::Time _etime;
std::map<std::string, HMBQueue> _queues;
std::string _sid;
std::string _cid;
bool _readingData;
std::string bsonGetString(const bson_t *bson, const char *key);
int64_t bsonGetInt(const bson_t *bson, const char *key);
void bsonGetBlob(const bson_t *bson, const char *key, const void **data, int *data_len);
void initSession();
std::string receive();
};
}
}
#endif

View File

@ -0,0 +1,86 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* 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. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_SERVICES_RECORDSTREAM_MEMORY_H
#define SEISCOMP_SERVICES_RECORDSTREAM_MEMORY_H
#include <iostream>
#include <sstream>
#include <seiscomp/io/recordstream.h>
#include <seiscomp/core.h>
namespace Seiscomp {
namespace RecordStream {
DEFINE_SMARTPOINTER(Memory);
class SC_SYSTEM_CORE_API Memory: public Seiscomp::IO::RecordStream {
DECLARE_SC_CLASS(Memory);
// ----------------------------------------------------------------------
// X'truction
// ----------------------------------------------------------------------
public:
Memory();
Memory(const char *data, int size);
Memory(const Memory &mem);
virtual ~Memory();
// ----------------------------------------------------------------------
// X'truction
// ----------------------------------------------------------------------
public:
Memory &operator=(const Memory &mem);
virtual bool setSource(const std::string &);
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode);
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode,
const Seiscomp::Core::Time &startTime,
const Seiscomp::Core::Time &endTime);
virtual bool setStartTime(const Seiscomp::Core::Time &stime);
virtual bool setEndTime(const Seiscomp::Core::Time &etime);
virtual void close();
virtual bool setRecordType(const char *type);
Record *next();
private:
RecordFactory *_factory;
std::istringstream _stream;
};
}
}
#endif

View File

@ -0,0 +1,106 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* 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. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_RECORDSTREAM_RESAMPLE_H
#define SEISCOMP_RECORDSTREAM_RESAMPLE_H
#include <sstream>
#include <map>
#include <deque>
#include <seiscomp/io/recordstream.h>
#include <seiscomp/io/recordfilter/demux.h>
namespace Seiscomp {
namespace RecordStream {
DEFINE_SMARTPOINTER(Resample);
class SC_SYSTEM_CORE_API Resample : public Seiscomp::IO::RecordStream {
// ----------------------------------------------------------------------
// Xstruction
// ----------------------------------------------------------------------
public:
Resample();
virtual ~Resample();
// ----------------------------------------------------------------------
// Public Interface
// ----------------------------------------------------------------------
public:
virtual bool setSource(const std::string &source);
virtual bool setRecordType(const char *type);
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode);
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode,
const Seiscomp::Core::Time &startTime,
const Seiscomp::Core::Time &endTime);
virtual bool setStartTime(const Seiscomp::Core::Time &stime);
virtual bool setEndTime(const Seiscomp::Core::Time &etime);
virtual bool setTimeWindow(const Seiscomp::Core::TimeWindow &w);
virtual bool setTimeout(int seconds);
virtual void close();
virtual Record *next();
// ----------------------------------------------------------------------
// Private Interface
// ----------------------------------------------------------------------
private:
void push(Record *rec);
void cleanup();
// ----------------------------------------------------------------------
// Implementation
// ----------------------------------------------------------------------
private:
typedef std::deque<GenericRecord*> OutputQueue;
IO::RecordStreamPtr _source;
bool _debug;
IO::RecordDemuxFilter _demuxer;
OutputQueue _queue;
double _targetRate;
double _fp;
double _fs;
int _lanczosKernelWidth;
int _coeffScale;
};
}
}
#endif

View File

@ -0,0 +1,164 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* 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. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_IO_RECORDSTREAM_SDSARCHIVE_H
#define SEISCOMP_IO_RECORDSTREAM_SDSARCHIVE_H
#include <iostream>
#include <sstream>
#include <fstream>
#include <queue>
#include <list>
#include <set>
#include <mutex>
#include <seiscomp/core/version.h>
#include <seiscomp/io/recordstream.h>
namespace Seiscomp {
namespace RecordStream {
DEFINE_SMARTPOINTER(SDS);
class SDSArchive : public Seiscomp::IO::RecordStream {
// ----------------------------------------------------------------------
// Xstruction
// ----------------------------------------------------------------------
public:
SDSArchive();
SDSArchive(const std::string arcroot);
virtual ~SDSArchive();
// ----------------------------------------------------------------------
// Public Interface
// ----------------------------------------------------------------------
public:
virtual bool setSource(const std::string &source);
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode);
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode,
const Seiscomp::Core::Time &startTime,
const Seiscomp::Core::Time &endTime);
virtual bool setStartTime(const Seiscomp::Core::Time &stime);
virtual bool setEndTime(const Seiscomp::Core::Time &etime);
virtual bool setTimeWindow(const Seiscomp::Core::TimeWindow &tw);
virtual bool setTimeout(int seconds);
virtual void close();
virtual Seiscomp::Record *next();
// ----------------------------------------------------------------------
// Implementation
// ----------------------------------------------------------------------
private:
struct Index {
Index();
Index(const std::string& net, const std::string& sta,
const std::string& loc, const std::string& cha);
Index(const std::string& net, const std::string& sta,
const std::string& loc, const std::string& cha,
const Seiscomp::Core::Time& stime,
const Seiscomp::Core::Time& etime);
Index &operator=(const Index &other);
bool operator<(const Index &other) const;
bool operator!=(const Index &other) const;
bool operator==(const Index &other) const;
std::string net;
std::string sta;
std::string loc;
std::string cha;
mutable Seiscomp::Core::Time stime;
mutable Seiscomp::Core::Time etime;
};
typedef std::set<Index> IndexSet;
typedef std::list<Index> IndexList;
typedef std::pair<std::string,bool> File;
typedef std::queue<File> FileQueue;
std::vector<std::string> _arcroots;
Seiscomp::Core::Time _stime;
Seiscomp::Core::Time _etime;
IndexList _orderedRequests;
IndexSet _streamSet;
IndexList::iterator _curiter;
const Index *_curidx;
FileQueue _fnames;
std::set<std::string> _readFiles;
std::mutex _mutex;
bool _closeRequested;
std::ifstream _file;
int getDoy(const Seiscomp::Core::Time &time);
void resolveRequest();
bool setStart(const std::string &fname, bool bsearch);
bool resolveNet(std::string &path,
const std::string &net, const std::string &sta,
const std::string &loc, const std::string &cha,
const Seiscomp::Core::Time &requestStartTime,
int doy, int year, bool first);
bool resolveSta(std::string &path,
const std::string &net, const std::string &sta,
const std::string &loc, const std::string &cha,
const Seiscomp::Core::Time &requestStartTime,
int doy, int year, bool first);
bool resolveLoc(std::string &path,
const std::string &net, const std::string &sta,
const std::string &loc, const std::string &cha,
const Seiscomp::Core::Time &requestStartTime,
int doy, int year, bool first);
bool resolveCha(std::string &path,
const std::string &net, const std::string &sta,
const std::string &loc, const std::string &cha,
const Seiscomp::Core::Time &requestStartTime,
int doy, int year, bool first);
bool resolveFiles(const std::string &net, const std::string &sta,
const std::string &loc, const std::string &cha,
const Seiscomp::Core::Time &requestStartTime,
int doy, int year, bool first);
};
}
}
#endif

View File

@ -0,0 +1,195 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* 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. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_IO_RECORDSTREAM_SLINK_H
#define SEISCOMP_IO_RECORDSTREAM_SLINK_H
#include <string>
#include <set>
#include <iostream>
#include <sstream>
#include <signal.h>
#include <seiscomp/core/datetime.h>
#include <seiscomp/io/recordstream.h>
#include <seiscomp/core.h>
#include <seiscomp/io/socket.h>
namespace Seiscomp {
namespace RecordStream {
class SC_SYSTEM_CORE_API SeedlinkException: public Seiscomp::IO::RecordStreamException {
public:
SeedlinkException(): RecordStreamException("Seedlink exception") {}
SeedlinkException(const std::string& what): RecordStreamException(what) {}
};
class SC_SYSTEM_CORE_API SeedlinkCommandException: public SeedlinkException {
public:
SeedlinkCommandException(): SeedlinkException("command not accepted") {}
SeedlinkCommandException(const std::string& what): SeedlinkException(what) {}
};
class SC_SYSTEM_CORE_API SLStreamIdx {
public:
SLStreamIdx();
SLStreamIdx(const std::string &net, const std::string &sta,
const std::string &loc, const std::string &cha);
SLStreamIdx(const std::string &net, const std::string &sta,
const std::string &loc, const std::string &cha,
const Seiscomp::Core::Time &stime,
const Seiscomp::Core::Time &etime);
SLStreamIdx& operator=(const SLStreamIdx &other);
bool operator<(const SLStreamIdx &other) const;
bool operator==(const SLStreamIdx &other) const;
//! Returns the network code
const std::string &network() const;
//! Returns the station code
const std::string &station() const;
//! Returns the channel code
const std::string &channel() const;
//! Returns the location code
const std::string &location() const;
//! Returns the selector in <location><channel>.D notation
//! * wildcards are substituted by a corresponding number of ?
std::string selector() const;
//! Returns the start time
Core::Time startTime() const;
//! Returns the end time
Core::Time endTime() const;
//! Returns the most recent record end time
Seiscomp::Core::Time timestamp() const;
//! Sets the time stamp
void setTimestamp(Seiscomp::Core::Time &rectime) const;
private:
const std::string _net;
const std::string _sta;
const std::string _loc;
const std::string _cha;
const Core::Time _stime;
const Core::Time _etime;
mutable Core::Time _timestamp;
};
DEFINE_SMARTPOINTER(SLConnection);
class SC_SYSTEM_CORE_API SLConnection : public Seiscomp::IO::RecordStream {
DECLARE_SC_CLASS(SLConnection);
public:
//! C'tor
SLConnection();
//! Initializing Constructor
SLConnection(std::string serverloc);
//! Destructor
virtual ~SLConnection();
public:
//! The recordtype cannot be selected when using a seedlink
//! connection. It will always create MiniSeed records
virtual bool setRecordType(const char*);
//! Initialize the seedlink connection.
virtual bool setSource(const std::string &source);
//! Adds the given stream to the server connection description
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode);
//! Adds a seismic stream request to the record stream (not implemented)
virtual bool addStream(const std::string &networkCode,
const std::string &stationCode,
const std::string &locationCode,
const std::string &channelCode,
const Seiscomp::Core::Time &startTime,
const Seiscomp::Core::Time &endTime);
//! Adds the given start time to the server connection description
virtual bool setStartTime(const Seiscomp::Core::Time &startTime);
//! Adds the given end time to the server connection description
virtual bool setEndTime(const Seiscomp::Core::Time &endTime);
//! Sets timeout
virtual bool setTimeout(int seconds);
//! Disconnects and terminates (!) the seedlink connection.
virtual void close();
//! Reads the data stream
virtual Record *next();
//! Removes all stream list, time window, etc. -entries from the connection description object.
bool clear();
//! Reconnects a terminated seedlink connection.
bool reconnect();
private:
void handshake();
private:
class StreamBuffer : public std::streambuf {
public:
StreamBuffer();
std::streambuf *setbuf(char *s, std::streamsize n);
};
StreamBuffer _streambuf;
std::string _serverloc;
std::string _slrecord;
IO::Socket _sock;
std::set<SLStreamIdx> _streams;
Core::Time _stime;
Core::Time _etime;
bool _readingData;
bool _useBatch;
int _maxRetries;
int _retriesLeft;
};
}
}
#endif

View File

@ -0,0 +1,92 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* 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. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_IO_RECORDSTREAM_STREAMIDX_H
#define SEISCOMP_IO_RECORDSTREAM_STREAMIDX_H
#include <string>
#include <seiscomp/core/datetime.h>
namespace Seiscomp {
namespace RecordStream {
class SC_SYSTEM_CORE_API StreamIdx {
public:
StreamIdx();
StreamIdx(const std::string& net, const std::string& sta,
const std::string& loc, const std::string& cha);
StreamIdx(const std::string& net, const std::string& sta,
const std::string& loc, const std::string& cha,
const Seiscomp::Core::Time& stime,
const Seiscomp::Core::Time& etime);
StreamIdx& operator=(const StreamIdx &other);
bool operator<(const StreamIdx &other) const;
bool operator!=(const StreamIdx &other) const;
bool operator==(const StreamIdx &other) const;
bool operator>=(const StreamIdx &other) const;
bool operator>(const StreamIdx &other) const;
bool operator<=(const StreamIdx &other) const;
//! Returns the network code
const std::string &network() const;
//! Returns the station code
const std::string &station() const;
//! Returns the channel code
const std::string &channel() const;
//! Returns the location code
const std::string &location() const;
//! Returns the start time
Core::Time startTime() const;
//! Returns the end time
Core::Time endTime() const;
//! Returns a string: <sTime> <eTime> <network> <station> <channel> <location>
//! <*Time> in format: %Y,%m,%d,%H,%M,%S
std::string str(const Seiscomp::Core::Time& stime,
const Seiscomp::Core::Time& etime) const;
private:
const std::string _net;
const std::string _sta;
const std::string _loc;
const std::string _cha;
const Seiscomp::Core::Time _stime;
const Seiscomp::Core::Time _etime;
};
} // namespace RecordStream
} // namespace Seiscomp
#endif