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.3 KiB
C++
95 lines
2.3 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 nibble_word;
|
|
u_int32_t sample_word[15];
|
|
};
|
|
|
|
//*****************************************************************************
|
|
// Steim2Encoder
|
|
//*****************************************************************************
|
|
|
|
template<typename T>
|
|
class Steim2Encoder : public Encoder {
|
|
public:
|
|
Steim2Encoder(MSEEDFormat *format, int freqn, int freqd)
|
|
: Encoder(freqn, freqd), format(format), frame_count(0),
|
|
bp(0), fp(0), spw(4), last_sample(0), nibble_word(0) {
|
|
}
|
|
virtual ~Steim2Encoder();
|
|
virtual void flush();
|
|
|
|
virtual void push(void *value);
|
|
virtual int type() const { return DE_STEIM2; }
|
|
|
|
private:
|
|
void update_spw(int bp);
|
|
void store(int32_t value);
|
|
void init_packet();
|
|
void finish_packet();
|
|
void update_packet();
|
|
|
|
MSEEDEncoderPacket<Steim2Frame> get_packet() {
|
|
return format->get_packet<Steim2Frame>(_clk.get_time(bp),
|
|
_clk.correction(), _timingQuality);
|
|
}
|
|
|
|
void queue_packet(MSEEDEncoderPacket<Steim2Frame> &pckt);
|
|
|
|
int number_of_frames(const MSEEDEncoderPacket<Steim2Frame> &packet) {
|
|
return (packet.datalen >> 6);
|
|
}
|
|
|
|
private:
|
|
MSEEDFormat *format;
|
|
int frame_count;
|
|
int bp;
|
|
int fp;
|
|
int32_t last_s;
|
|
int spw;
|
|
int32_t last_sample;
|
|
int32_t buf[8];
|
|
u_int32_t nibble_word;
|
|
MSEEDEncoderPacket<Steim2Frame> current_packet;
|
|
};
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
#include "steim2.ipp"
|
|
|
|
#endif // __STEIM2_H__
|
|
|