/*************************************************************************** * 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 namespace Gempa { namespace CAPS { template class UncompressedMSEED : public Encoder { MSEEDEncoderPacket get_packet() { return _format->getPacket(_clk.getTime(-_bp), _clk.correction(), _timingQuality); } void queuePacket(MSEEDEncoderPacket &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*)value); ++_sampleCount; ++_bp; } virtual int type() const { return _format->packType; } private: MSEEDFormat *_format; MSEEDEncoderPacket _current_packet; int _bp; }; } } #endif // __STEIM1_H__