Initial commit based on common repo commit ffeb9c9b
This commit is contained in:
84
libs/gempa/caps/mseed/uncompressed.h
Normal file
84
libs/gempa/caps/mseed/uncompressed.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 by gempa GmbH *
|
||||
* *
|
||||
* All Rights Reserved. *
|
||||
* *
|
||||
* NOTICE: All information contained herein is, and remains *
|
||||
* the property of gempa GmbH and its suppliers, if any. The intellectual *
|
||||
* and technical concepts contained herein are proprietary to gempa GmbH *
|
||||
* and its suppliers. *
|
||||
* Dissemination of this information or reproduction of this material *
|
||||
* is strictly forbidden unless prior written permission is obtained *
|
||||
* from gempa GmbH. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef CAPS_MSEED_UNCOMPRESSED_H
|
||||
#define CAPS_MSEED_UNCOMPRESSED_H
|
||||
|
||||
#include "encoder.h"
|
||||
#include "mseed.h"
|
||||
|
||||
#include <gempa/caps/endianess.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
namespace Gempa {
|
||||
namespace CAPS {
|
||||
|
||||
template<typename T> class UncompressedMSEED : public Encoder {
|
||||
MSEEDEncoderPacket<T> get_packet() {
|
||||
return _format->get_packet<T>(_clk.get_time(-_bp),
|
||||
_clk.correction(), _timingQuality);
|
||||
}
|
||||
|
||||
void queue_packet(MSEEDEncoderPacket<T> &pckt) {
|
||||
_format->updateBuffer(pckt.record, _sampleCount, 1);
|
||||
|
||||
Packet *packet = new Packet(DataRecordPtr(pckt.record), _format->networkCode, _format->stationCode,
|
||||
_format->locationCode, _format->channelCode);
|
||||
_packetQueue.push_back(PacketPtr(packet));
|
||||
pckt.reset();
|
||||
reset();
|
||||
}
|
||||
|
||||
public:
|
||||
UncompressedMSEED(MSEEDFormat *format, int freqn, int freqd)
|
||||
: Encoder(freqn, freqd),
|
||||
_format(format), _bp(0) {
|
||||
}
|
||||
virtual ~UncompressedMSEED() { if ( _format ) delete _format; }
|
||||
virtual void flush() {
|
||||
if ( _current_packet.valid() ) {
|
||||
queue_packet(_current_packet);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void push(void *value) {
|
||||
if ( !_current_packet.valid() )
|
||||
_current_packet = get_packet();
|
||||
else if ( _sampleCount * sizeof(T) >= _current_packet.datalen ) {
|
||||
flush();
|
||||
_current_packet = get_packet();
|
||||
}
|
||||
|
||||
_current_packet.data[_sampleCount] =
|
||||
Gempa::CAPS::Endianess::Converter::ToBigEndian<T>(*(T*)value);
|
||||
++_sampleCount;
|
||||
++_bp;
|
||||
}
|
||||
|
||||
virtual int type() const { return _format->packType; }
|
||||
|
||||
private:
|
||||
MSEEDFormat *_format;
|
||||
MSEEDEncoderPacket<T> _current_packet;
|
||||
int _bp;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __STEIM1_H__
|
||||
Reference in New Issue
Block a user