libdrmconf 0.14.0
A library to program DMR radios.
Loading...
Searching...
No Matches
chirpformat.hh
1
8#ifndef CHIRPFORMAT_HH
9#define CHIRPFORMAT_HH
10
11#include "errorstack.hh"
12#include <QSet>
13
14class QTextStream;
15class Config;
16class FMChannel;
17
22{
23protected:
26 enum class Duplex {
27 None,
28 Positive,
29 Negative,
30 Split,
32 };
33
35 enum class Mode {
36 FM,
37 NFM,
38 WFM,
39 AM,
41 DN
42 };
43
45 enum class ToneMode {
46 None,
47 Tone,
48 TSQL,
49 TSQL_R,
51 DTCS_R,
52 Cross
53 };
54
56 enum class Polarity {
57 Normal,
59 };
60
63 enum class CrossMode {
64 NoneTone,
65 NoneDTCS,
66 ToneNone,
67 ToneTone,
68 ToneDTCS,
69 DTCSNone,
70 DTCSTone,
72 };
73
74protected:
76 static const QSet<QString> _mandatoryHeaders;
78 static const QSet<QString> _knownHeaders;
80 static const QHash<QString, Duplex> _duplexCodes;
82 static const QHash<QString, Mode> _modeCodes;
84 static const QHash<QString, ToneMode> _toneModeCodes;
86 static const QHash<QString, CrossMode> _crossModes;
87};
88
89
93{
94
95public:
98 static bool read(QTextStream &stream, Config *config, const ErrorStack &err=ErrorStack());
99
100protected:
103 static bool readLine(QTextStream &stream, QStringList &list, const ErrorStack &err=ErrorStack());
104
107 static bool processLine(const QStringList &header, const QStringList &line,
108 Config *config, const ErrorStack &err=ErrorStack());
109
111 static bool processDuplex(const QString &code, Duplex &duplex, const ErrorStack &err=ErrorStack());
113 static bool processMode(const QString &code, Mode &mode, const ErrorStack &err=ErrorStack());
115 static bool processToneMode(const QString &code, ToneMode &mode, const ErrorStack &err=ErrorStack());
117 static bool processPolarity(const QString &code, Polarity &txPol, Polarity &rxPol, const ErrorStack &err=ErrorStack());
119 static bool processCrossMode(const QString &code, CrossMode &crossMode, const ErrorStack &err = ErrorStack());
120};
121
122
126{
127public:
129 static bool write(QTextStream &stream, Config *config, const ErrorStack &err=ErrorStack());
130
131protected:
133 static bool writeHeader(QTextStream &stream, const ErrorStack &err = ErrorStack());
135 static bool writeChannel(QTextStream &stream, int i, FMChannel *channel, const ErrorStack &err=ErrorStack());
137 static bool encodeFrequency(QTextStream &stream, FMChannel *channel, const ErrorStack &err = ErrorStack());
139 static bool encodeSubTone(QTextStream &stream, FMChannel *channel, const ErrorStack &err = ErrorStack());
141 static bool encodeBandwidth(QTextStream &stream, FMChannel *channel, const ErrorStack &err = ErrorStack());
142};
143
144
145#endif // CHIRPFORMAT_HH
Some common constants for the CIRP reader/writer.
Definition chirpformat.hh:22
CrossMode
Generic mode for sub tones.
Definition chirpformat.hh:63
@ 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:14
static const QHash< QString, Mode > _modeCodes
Mapping of mode codes.
Definition chirpformat.hh:31
static const QHash< QString, ToneMode > _toneModeCodes
Mapping of tone mode codes.
Definition chirpformat.hh:40
Mode
Possible CHIRP channel modes.
Definition chirpformat.hh:35
@ 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:24
static const QHash< QString, CrossMode > _crossModes
Mapping of cross mode codes.
Definition chirpformat.hh:50
ToneMode
Possible modes for transmitting and processing sub tones.
Definition chirpformat.hh:45
@ 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.
@ TSQL
CTCSS tone squelch.
@ Cross
More complex setting (see CrossMode).
@ Tone
Transmission of a CTCSS tone.
Polarity
Polarity of DCS codes.
Definition chirpformat.hh:56
@ Reversed
Reversed DCS encoding.
@ Normal
Normal DCS encoding.
Duplex
Possible values for the "duplex" column.
Definition chirpformat.hh:26
@ 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:18
Implements the CHIRP CSV reader.
Definition chirpformat.hh:93
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:355
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:345
static bool processDuplex(const QString &code, Duplex &duplex, const ErrorStack &err=ErrorStack())
Helper function to parse a duplex column.
Definition chirpformat.cc:325
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:335
static bool processCrossMode(const QString &code, CrossMode &crossMode, const ErrorStack &err=ErrorStack())
Helper function to parse a cross mode column.
Definition chirpformat.cc:384
Implements the chirp writer.
Definition chirpformat.hh:126
static bool writeChannel(QTextStream &stream, int i, FMChannel *channel, const ErrorStack &err=ErrorStack())
Writes a channel into the given stream.
Definition chirpformat.cc:433
static bool writeHeader(QTextStream &stream, const ErrorStack &err=ErrorStack())
Writes the header into the given stream.
Definition chirpformat.cc:420
static bool encodeFrequency(QTextStream &stream, FMChannel *channel, const ErrorStack &err=ErrorStack())
Writes frequency related columns to the given stream.
Definition chirpformat.cc:456
static bool encodeSubTone(QTextStream &stream, FMChannel *channel, const ErrorStack &err=ErrorStack())
Writes sub tone related columns to the given stream.
Definition chirpformat.cc:474
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:399
static bool encodeBandwidth(QTextStream &stream, FMChannel *channel, const ErrorStack &err=ErrorStack())
Writes the bandwidth column to the given stream.
Definition chirpformat.cc:544
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:43
Extension to the AnalogChannel class to implement an analog FM channel.
Definition channel.hh:249