libdrmconf 0.12.1
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 QStringList;
17class FMChannel;
23{
24protected:
27 enum class Duplex {
28 None,
29 Positive,
30 Negative,
32 Off
33 };
34
36 enum class Mode {
37 FM,
38 NFM,
39 WFM,
41 DV,
42 DN
43 };
44
46 enum class ToneMode {
47 None,
48 Tone,
49 TSQL,
51 DTCS,
52 DTCS_R,
53 Cross
54 };
55
57 enum class Polarity {
58 Normal,
60 };
61
64 enum class CrossMode {
65 NoneTone,
66 NoneDTCS,
67 ToneNone,
68 ToneTone,
69 ToneDTCS,
70 DTCSNone,
71 DTCSTone,
73 };
74
75protected:
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
94{
95
96public:
99 static bool read(QTextStream &stream, Config *config, const ErrorStack &err=ErrorStack());
100
101protected:
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{
128public:
130 static bool write(QTextStream &stream, Config *config, const ErrorStack &err=ErrorStack());
131
132protected:
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: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: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: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: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.
@ 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:18
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:354
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:344
static bool processDuplex(const QString &code, Duplex &duplex, const ErrorStack &err=ErrorStack())
Helper function to parse a duplex column.
Definition chirpformat.cc:324
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:334
static bool processCrossMode(const QString &code, CrossMode &crossMode, const ErrorStack &err=ErrorStack())
Helper function to parse a cross mode column.
Definition chirpformat.cc:383
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:432
static bool writeHeader(QTextStream &stream, const ErrorStack &err=ErrorStack())
Writes the header into the given stream.
Definition chirpformat.cc:419
static bool encodeFrequency(QTextStream &stream, FMChannel *channel, const ErrorStack &err=ErrorStack())
Writes frequency related columns to the given stream.
Definition chirpformat.cc:455
static bool encodeSubTone(QTextStream &stream, FMChannel *channel, const ErrorStack &err=ErrorStack())
Wirtes sub tone related columns to the given stream.
Definition chirpformat.cc:473
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:398
static bool encodeBandwidth(QTextStream &stream, FMChannel *channel, const ErrorStack &err=ErrorStack())
Writes the bandwidth column to the given stream.
Definition chirpformat.cc:543
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