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.

95 lines
2.6 KiB
C

/*****************************************************************************
* steim2.h
*
* Steim2 encoder
*
* (c) 2000 Andres Heinloo, GFZ Potsdam
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any later
* version. For more information, see http://www.gnu.org/
*
* ================
* Change log
* ===============
*
* 01.01.2013 Adapted code to CAPS client library requirements (gempa GmbH)
*****************************************************************************/
#ifndef CAPS_MSEED_STEIM2_H
#define CAPS_MSEED_STEIM2_H
#include "encoder.h"
#include "mseed.h"
namespace Gempa {
namespace CAPS {
//*****************************************************************************
// Steim2Frame
//*****************************************************************************
struct Steim2Frame {
u_int32_t nibbleWord;
u_int32_t sampleWord[15];
};
//*****************************************************************************
// Steim2Encoder
//*****************************************************************************
template<typename T>
class Steim2Encoder : public Encoder {
public:
Steim2Encoder(MSEEDFormat *format, int freqn, int freqd)
: Encoder(freqn, freqd), _format(format), _frameCount(0)
, _bp(0), _fp(0), _spw(4), _lastSample(0), _nibbleWord(0) {
}
virtual ~Steim2Encoder();
virtual void flush();
virtual void push(void *value);
virtual int type() const { return DE_STEIM2; }
private:
void updateSpw(int bp);
void store(int32_t value);
void initPacket();
void updatePacket();
void finishPacket();
MSEEDEncoderPacket<Steim2Frame> getPacket() {
return _format->getPacket<Steim2Frame>(_clk.getTime(_bp),
_clk.correction(), _timingQuality);
}
void queuePacket(MSEEDEncoderPacket<Steim2Frame> &pckt);
int numberOfFrames(const MSEEDEncoderPacket<Steim2Frame> &packet) const {
return (packet.datalen >> 6);
}
private:
MSEEDFormat *_format;
int _frameCount;
int _bp;
int _fp;
int32_t _last_s;
int _spw;
int32_t _lastSample;
int32_t _buf[8];
u_int32_t _nibbleWord;
MSEEDEncoderPacket<Steim2Frame> _currentPacket;
};
}
}
#include "steim2.ipp"
#endif // __STEIM2_H__