libdrmconf  0.12.0
A library to program DMR radios.
chirpformat.hh
1 
8 #ifndef CHIRPFORMAT_HH
9 #define CHIRPFORMAT_HH
10 
11 #include "errorstack.hh"
12 #include <QSet>
13 
14 class QTextStream;
15 class Config;
16 class QStringList;
17 class FMChannel;
18 
19 
23 {
24 protected:
27  enum class Duplex {
28  None,
29  Positive,
30  Negative,
31  Split,
32  Off
33  };
34 
36  enum class Mode {
37  FM,
38  NFM,
39  WFM,
40  AM,
41  DV,
42  DN
43  };
44 
46  enum class ToneMode {
47  None,
48  Tone,
49  TSQL,
50  TSQL_R,
51  DTCS,
52  DTCS_R,
53  Cross
54  };
55 
57  enum class Polarity {
58  Normal,
59  Reversed
60  };
61 
64  enum class CrossMode {
65  NoneTone,
66  NoneDTCS,
67  ToneNone,
68  ToneTone,
69  ToneDTCS,
70  DTCSNone,
71  DTCSTone,
72  DTCSDTCS
73  };
74 
75 protected:
77  static const QSet<QString> _mandatoryHeaders;
79  static const QSet<QString> _knownHeaders;
81  static const QHash<QString, Duplex> _duplexCodes;
83  static const QHash<QString, Mode> _modeCodes;
85  static const QHash<QString, ToneMode> _toneModeCodes;
87  static const QHash<QString, CrossMode> _crossModes;
88 };
89 
90 
93 class ChirpReader: public ChirpFormat
94 {
95 
96 public:
99  static bool read(QTextStream &stream, Config *config, const ErrorStack &err=ErrorStack());
100 
101 protected:
104  static bool readLine(QTextStream &stream, QStringList &list, const ErrorStack &err=ErrorStack());
105 
108  static bool processLine(const QStringList &header, const QStringList &line,
109  Config *config, const ErrorStack &err=ErrorStack());
110 
112  static bool processDuplex(const QString &code, Duplex &duplex, const ErrorStack &err=ErrorStack());
114  static bool processMode(const QString &code, Mode &mode, const ErrorStack &err=ErrorStack());
116  static bool processToneMode(const QString &code, ToneMode &mode, const ErrorStack &err=ErrorStack());
118  static bool processPolarity(const QString &code, Polarity &txPol, Polarity &rxPol, const ErrorStack &err=ErrorStack());
120  static bool processCrossMode(const QString &code, CrossMode &crossMode, const ErrorStack &err = ErrorStack());
121 };
122 
123 
127 {
128 public:
130  static bool write(QTextStream &stream, Config *config, const ErrorStack &err=ErrorStack());
131 
132 protected:
134  static bool writeHeader(QTextStream &stream, const ErrorStack &err = ErrorStack());
136  static bool writeChannel(QTextStream &stream, int i, FMChannel *channel, const ErrorStack &err=ErrorStack());
138  static bool encodeFrequency(QTextStream &stream, FMChannel *channel, const ErrorStack &err = ErrorStack());
140  static bool encodeSubTone(QTextStream &stream, FMChannel *channel, const ErrorStack &err = ErrorStack());
142  static bool encodeBandwidth(QTextStream &stream, FMChannel *channel, const ErrorStack &err = ErrorStack());
143 };
144 
145 
146 #endif // CHIRPFORMAT_HH
Some common constants for the CIRP reader/writer.
Definition: chirpformat.hh:23
CrossMode
Generic mode for sub tones.
Definition: chirpformat.hh:64
@ DTCSNone
TX DCS, no RX.
@ ToneDTCS
TX CTCSS, RX DCS.
@ NoneDTCS
No TX, RX DCS.
@ DTCSTone
TX DCS, RX CTCSS.
@ ToneTone
TX CTCSS, RX CTCSS.
@ NoneTone
No TX, RX CTCSS.
@ ToneNone
TX CTCSS, no RX.
@ DTCSDTCS
TX DCS, RX DCS.
static const QSet< QString > _mandatoryHeaders
Internal set of mandatory headers.
Definition: chirpformat.hh:77
static const QHash< QString, Mode > _modeCodes
Mapping of mode codes.
Definition: chirpformat.hh:83
static const QHash< QString, ToneMode > _toneModeCodes
Mapping of tone mode codes.
Definition: chirpformat.hh:85
Mode
Possible CHIRP channel modes.
Definition: chirpformat.hh:36
@ AM
AM, usually airband (not supported by qdmr yet).
@ NFM
12.5kHz FM (also NBFM).
@ DV
D-STAR (not supported by qdmr yet).
@ WFM
100kHz FM (WBFM, broadcast).
@ DN
SystemFusion (not supported by qdmr yet).
@ FM
25kHz FM (still NBFM).
static const QHash< QString, Duplex > _duplexCodes
Mapping of duplex codes.
Definition: chirpformat.hh:81
static const QHash< QString, CrossMode > _crossModes
Mapping of cross mode codes.
Definition: chirpformat.hh:87
ToneMode
Possible modes for transmitting and processing sub tones.
Definition: chirpformat.hh:46
@ DTCS
Transmission of a DCS code and also DCS squelch.
@ DTCS_R
Transmission of a DCS code and also DCS squelch.
@ TSQL_R
Inverted, CTCSS tone squelch. That is, the squelch opens if a specific CTCSS tone is not received.
@ None
No transmission of subtones.
@ TSQL
CTCSS tone squelch.
@ Cross
More complex setting (see CrossMode).
@ Tone
Transmission of a CTCSS tone.
Polarity
Polarity of DCS codes.
Definition: chirpformat.hh:57
@ Reversed
Reversed DCS encoding.
@ Normal
Normal DCS encoding.
Duplex
Possible values for the "duplex" column.
Definition: chirpformat.hh:27
@ Positive
Positive frequency offset, TX above RX frequency.
@ None
No offset at all. That is, the TX and RX frequencies are equal.
@ Split
Explicit transmit frequency.
@ Off
No transmit frequency specified. Channel is RX only.
@ Negative
Negative frequency offset, TX below RX frequency.
static const QSet< QString > _knownHeaders
Internal used set of known headers.
Definition: chirpformat.hh:79
Implements the CHIRP CSV reader.
Definition: chirpformat.hh:94
static bool read(QTextStream &stream, Config *config, const ErrorStack &err=ErrorStack())
Reads a CHIRP CSV file from the given stream and updates the given configuration.
Definition: chirpformat.cc:66
static bool processPolarity(const QString &code, Polarity &txPol, Polarity &rxPol, const ErrorStack &err=ErrorStack())
Helper function to parse a polarity column.
Definition: chirpformat.cc:351
static bool readLine(QTextStream &stream, QStringList &list, const ErrorStack &err=ErrorStack())
Internal used method to read a line from the given stream.
Definition: chirpformat.cc:118
static bool processToneMode(const QString &code, ToneMode &mode, const ErrorStack &err=ErrorStack())
Helper function to parse a tone mode column.
Definition: chirpformat.cc:341
static bool processDuplex(const QString &code, Duplex &duplex, const ErrorStack &err=ErrorStack())
Helper function to parse a duplex column.
Definition: chirpformat.cc:321
static bool processLine(const QStringList &header, const QStringList &line, Config *config, const ErrorStack &err=ErrorStack())
Line parser, the header must be read before and passed to this method.
Definition: chirpformat.cc:148
static bool processMode(const QString &code, Mode &mode, const ErrorStack &err=ErrorStack())
Helper function to parse a mode column.
Definition: chirpformat.cc:331
static bool processCrossMode(const QString &code, CrossMode &crossMode, const ErrorStack &err=ErrorStack())
Helper function to parse a cross mode column.
Definition: chirpformat.cc:380
Implements the chirp writer.
Definition: chirpformat.hh:127
static bool writeChannel(QTextStream &stream, int i, FMChannel *channel, const ErrorStack &err=ErrorStack())
Writes a channel into the given stream.
Definition: chirpformat.cc:429
static bool writeHeader(QTextStream &stream, const ErrorStack &err=ErrorStack())
Writes the header into the given stream.
Definition: chirpformat.cc:416
static bool encodeFrequency(QTextStream &stream, FMChannel *channel, const ErrorStack &err=ErrorStack())
Writes frequency related columns to the given stream.
Definition: chirpformat.cc:452
static bool encodeSubTone(QTextStream &stream, FMChannel *channel, const ErrorStack &err=ErrorStack())
Wirtes sub tone related columns to the given stream.
Definition: chirpformat.cc:470
static bool write(QTextStream &stream, Config *config, const ErrorStack &err=ErrorStack())
Writes the (FM channels) of the given codeplug as a CHIRP CSV file into the given stream.
Definition: chirpformat.cc:395
static bool encodeBandwidth(QTextStream &stream, FMChannel *channel, const ErrorStack &err=ErrorStack())
Writes the bandwidth column to the given stream.
Definition: chirpformat.cc:533
The config class, representing the codeplug configuration.
Definition: config.hh:70
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Extension to the AnalogChannel class to implement an analog FM channel.
Definition: channel.hh:210