|
|
|
/*****************************************************************************
|
|
|
|
* steim1.h
|
|
|
|
*
|
|
|
|
* Steim1 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_STEIM1_H
|
|
|
|
#define CAPS_MSEED_STEIM1_H
|
|
|
|
|
|
|
|
#include "encoder.h"
|
|
|
|
#include "mseed.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Gempa {
|
|
|
|
namespace CAPS {
|
|
|
|
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// Steim1Frame
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
struct Steim1Frame {
|
|
|
|
u_int32_t nibbleWord;
|
|
|
|
u_int32_t sampleWord[15];
|
|
|
|
};
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// Steim1Encoder
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
class Steim1Encoder: public Encoder {
|
|
|
|
public:
|
|
|
|
Steim1Encoder(MSEEDFormat *format, int freqn, int freqd)
|
|
|
|
: Encoder(freqn, freqd), _format(format), _frameCount(0)
|
|
|
|
, _bp(0), _fp(0), _spw(4), _lastSample(0), _nibbleWord(0) {}
|
|
|
|
virtual ~Steim1Encoder();
|
|
|
|
|
|
|
|
virtual void flush();
|
|
|
|
virtual void push(void *value);
|
|
|
|
virtual int type() const { return DE_STEIM1; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
void updateSpw(int bp);
|
|
|
|
void store(int32_t value);
|
|
|
|
void initPacket();
|
|
|
|
void updatePacket();
|
|
|
|
void finishPacket();
|
|
|
|
|
|
|
|
MSEEDEncoderPacket<Steim1Frame> getPacket() {
|
|
|
|
return _format->getPacket<Steim1Frame>(_clk.getTime(_bp),
|
|
|
|
_clk.correction(), _timingQuality);
|
|
|
|
}
|
|
|
|
|
|
|
|
void queuePacket(MSEEDEncoderPacket<Steim1Frame> &pckt);
|
|
|
|
|
|
|
|
int numberOfFrames(const MSEEDEncoderPacket<Steim1Frame> &packet) {
|
|
|
|
return (packet.datalen >> 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
MSEEDFormat *_format;
|
|
|
|
int _frameCount;
|
|
|
|
int _bp;
|
|
|
|
int _fp;
|
|
|
|
int _spw;
|
|
|
|
int32_t _lastSample;
|
|
|
|
int32_t _buf[5];
|
|
|
|
u_int32_t _nibbleWord;
|
|
|
|
MSEEDEncoderPacket<Steim1Frame> _currentPacket;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "steim1.ipp"
|
|
|
|
|
|
|
|
#endif // __STEIM1_H__
|