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

88 lines
2.6 KiB
C

/***************************************************************************
* 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>
namespace Gempa {
namespace CAPS {
template<typename T> class UncompressedMSEED : public Encoder {
MSEEDEncoderPacket<T> get_packet() {
return _format->getPacket<T>(_clk.getTime(-_bp),
_clk.correction(), _timingQuality);
}
void queuePacket(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() ) {
queuePacket(_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__