kradio4  r778
rds_group.h
Go to the documentation of this file.
1 /***************************************************************************
2  rds.h - description
3  -------------------
4  begin : Feb 2009
5  copyright : (C) 2009 Ernst Martin Witte, Klas Kalass
6  email : emw-kradio@nocabal.de, klas@kde.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef KRADIO_V4LRADIO_RDS_GROUP_H
19 #define KRADIO_V4LRADIO_RDS_GROUP_H
20 
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24 
25 #include <kdemacros.h>
26 
27 #define RDS_BLK_A 0
28 #define RDS_BLK_B 1
29 #define RDS_BLK_C 2
30 #define RDS_BLK_D 3
31 #define RDS_BLK_C_ 4
32 #define RDS_BLK_E 5
33 #define RDS_BLK_E_ 6
34 #define RDS_BLK_RESERVED 7
35 #define RDS_BLK_MAXCOUNT 8
36 
37 #define RDS_PI_BLOCK RDS_BLK_A
38 #define RDS_PI_SHIFT 0
39 #define RDS_PI_MASK 0xFFFF
40 
41 #define RDS_GRP_BLOCK RDS_BLK_B
42 #define RDS_GRP_SHIFT 11
43 #define RDS_GRP_MASK 0xF800
44 
45 #define RDS_TP_BLOCK RDS_BLK_B
46 #define RDS_TP_SHIFT 10
47 #define RDS_TP_MASK 0x0400
48 
49 #define RDS_PTY_BLOCK RDS_BLK_B
50 #define RDS_PTY_SHIFT 5
51 #define RDS_PTY_MASK 0x03E0
52 
53 #define RDS_0A_POS_BLOCK RDS_BLK_B
54 #define RDS_0A_POS_SHIFT 0
55 #define RDS_0A_POS_MASK 0x0003
56 
57 
76 };
77 
78 class KDE_EXPORT RDSGroup
79 {
80 public:
81  RDSGroup();
82  virtual ~RDSGroup();
83 
84  virtual int addRawData(const unsigned char *rawdata, int size) = 0;
85  virtual void clear();
86  virtual bool isComplete() const = 0;
87 
88  int getPI () const { return m_pi_code; }
89  int getTP () const { return m_tp; }
90  int getPTY() const { return m_pty; }
91  int getGroupType() const { return m_group_code; }
92 
93  unsigned short getBlock(unsigned int block_nr)
94  const { return (block_nr <= RDS_BLK_D) ? m_rawdata[block_nr] : 0; }
95 
96  double statsBlockErrorRate() const;
97  double statsGroupErrorRate() const;
98 
99 protected:
100  void statsAccountGroupError(int nGroups, int nErrors);
101  void statsAccountBlockError(int nGroups, int nErrors);
102  void decode();
103 
104  unsigned short m_rawdata[RDS_BLK_MAXCOUNT];
105 
106  int m_pty;
108  bool m_tp;
110 
115 };
116 
117 
118 
119 
120 #endif
121 
bool m_tp
Definition: rds_group.h:108
int m_pty
Definition: rds_group.h:106
#define RDS_BLK_D
Definition: rds_group.h:30
unsigned short getBlock(unsigned int block_nr) const
Definition: rds_group.h:93
RDSGroupType
Definition: rds_group.h:58
int getPTY() const
Definition: rds_group.h:90
#define RDS_BLK_MAXCOUNT
Definition: rds_group.h:35
int m_stats_group_count
Definition: rds_group.h:111
int m_stats_group_errors
Definition: rds_group.h:112
int getPI() const
Definition: rds_group.h:88
int getTP() const
Definition: rds_group.h:89
int m_pi_code
Definition: rds_group.h:109
int getGroupType() const
Definition: rds_group.h:91
int m_stats_block_count
Definition: rds_group.h:113
int m_stats_block_errors
Definition: rds_group.h:114
int m_group_code
Definition: rds_group.h:107