summaryrefslogtreecommitdiffstats
path: root/src/EtiReader.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-01-06 11:35:35 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-01-06 11:35:35 +0100
commit3633bcc99aedda5d9ea36c143fa339139c763d3e (patch)
tree6c296bee8cfb6aabb292fe6fc040708c7e4d2e7a /src/EtiReader.h
parent67c82c97dfcfc68d4bd71f5773d21c34c8733c83 (diff)
downloaddabmod-3633bcc99aedda5d9ea36c143fa339139c763d3e.tar.gz
dabmod-3633bcc99aedda5d9ea36c143fa339139c763d3e.tar.bz2
dabmod-3633bcc99aedda5d9ea36c143fa339139c763d3e.zip
Replace EDI-to-ETI converter with a dedicated EDI source
Diffstat (limited to 'src/EtiReader.h')
-rw-r--r--src/EtiReader.h116
1 files changed, 107 insertions, 9 deletions
diff --git a/src/EtiReader.h b/src/EtiReader.h
index cfc03af..04d627d 100644
--- a/src/EtiReader.h
+++ b/src/EtiReader.h
@@ -36,6 +36,8 @@
#include "FicSource.h"
#include "SubchannelSource.h"
#include "TimestampDecoder.h"
+#include "lib/edi/ETIDecoder.hpp"
+#include "lib/UdpSocket.h"
#include <vector>
#include <memory>
@@ -43,26 +45,42 @@
#include <sys/types.h>
-class EtiReader
+class EtiSource
+{
+public:
+ virtual unsigned getMode() = 0;
+ virtual unsigned getFp() = 0;
+
+ virtual bool sourceContainsTimestamp() = 0;
+ virtual void calculateTimestamp(struct frame_timestamp& ts) = 0;
+
+ virtual std::shared_ptr<FicSource>& getFic(void);
+ virtual const std::vector<std::shared_ptr<SubchannelSource> > getSubchannels() const = 0;
+
+protected:
+ std::shared_ptr<FicSource> myFicSource;
+};
+
+class EtiReader : public EtiSource
{
public:
EtiReader(
double& tist_offset_s,
unsigned tist_delay_stages);
- std::shared_ptr<FicSource>& getFic();
- unsigned getMode();
- unsigned getFp();
- const std::vector<std::shared_ptr<SubchannelSource> >& getSubchannels();
+ virtual unsigned getMode();
+ virtual unsigned getFp();
int process(const Buffer* dataIn);
- void calculateTimestamp(struct frame_timestamp& ts)
+ virtual void calculateTimestamp(struct frame_timestamp& ts)
{
myTimestampDecoder.calculateTimestamp(ts);
}
/* Returns true if we have valid time stamps in the ETI*/
- bool sourceContainsTimestamp();
+ virtual bool sourceContainsTimestamp();
+
+ virtual const std::vector<std::shared_ptr<SubchannelSource> > getSubchannels() const;
private:
/* Transform the ETI TIST to a PPS offset in units of 1/16384000 s */
@@ -78,13 +96,93 @@ private:
eti_EOH eti_eoh;
eti_EOF eti_eof;
eti_TIST eti_tist;
- std::shared_ptr<FicSource> myFicSource;
- std::vector<std::shared_ptr<SubchannelSource> > mySources;
TimestampDecoder myTimestampDecoder;
size_t myCurrentFrame;
bool eti_fc_valid;
+
+ std::vector<std::shared_ptr<SubchannelSource> > mySources;
+};
+
+class EdiReader : public EtiSource, public EdiDecoder::DataCollector
+{
+public:
+ virtual unsigned getMode();
+ virtual unsigned getFp();
+ virtual bool sourceContainsTimestamp() { return false; }
+ virtual void calculateTimestamp(struct frame_timestamp& ts)
+ { /* TODO */ }
+ virtual const std::vector<std::shared_ptr<SubchannelSource> > getSubchannels() const;
+
+ virtual bool isFrameReady(void);
+ virtual void clearFrame(void);
+
+ // Tell the ETIWriter what EDI protocol we receive in *ptr.
+ // This is not part of the ETI data, but is used as check
+ virtual void update_protocol(
+ const std::string& proto,
+ uint16_t major,
+ uint16_t minor);
+
+ // Update the data for the frame characterisation
+ virtual void update_fc_data(const EdiDecoder::eti_fc_data& fc_data);
+
+ virtual void update_fic(const std::vector<uint8_t>& fic);
+
+ virtual void update_err(uint8_t err);
+
+ // In addition to TSTA in ETI, EDI also transports more time
+ // stamp information.
+ virtual void update_edi_time(
+ uint32_t utco,
+ uint32_t seconds);
+
+ virtual void update_mnsc(uint16_t mnsc);
+
+ virtual void update_rfu(uint16_t rfu);
+
+ virtual void add_subchannel(const EdiDecoder::eti_stc_data& stc);
+
+ // Tell the ETIWriter that the AFPacket is complete
+ virtual void assemble(void);
+private:
+ bool m_proto_valid = false;
+ bool m_frameReady = false;
+
+ uint8_t m_err;
+
+ bool m_fc_valid = false;
+ EdiDecoder::eti_fc_data m_fc;
+
+ std::vector<uint8_t> m_fic;
+
+ bool m_time_valid = false;
+ uint32_t m_utco;
+ uint32_t m_seconds;
+
+ uint16_t m_mnsc = 0xffff;
+
+ // 16 bits: RFU field in EOH
+ uint16_t m_rfu = 0xffff;
+
+ std::map<uint8_t, std::shared_ptr<SubchannelSource> > m_sources;
};
+class EdiUdpInput {
+ public:
+ EdiUdpInput(EdiDecoder::ETIDecoder& decoder);
+ int Open(const std::string& uri);
+
+ bool isEnabled(void) const { return m_enabled; }
+
+ void rxPacket(void);
+
+ private:
+ bool m_enabled;
+ int m_port;
+
+ UdpSocket m_sock;
+ EdiDecoder::ETIDecoder& m_decoder;
+};