File: decodedtext.h

package info (click to toggle)
jtdx 2.2.159%2Bimproved-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 75,336 kB
  • sloc: cpp: 38,503; f90: 31,141; python: 27,061; ansic: 11,772; sh: 409; fortran: 353; makefile: 232
file content (103 lines) | stat: -rw-r--r-- 3,311 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// -*- Mode: C++ -*-
/*
 * Class to handle the formatted string as returned from the fortran decoder
 *
 * VK3ACF August 2013
 */


#ifndef DECODEDTEXT_H
#define DECODEDTEXT_H

#include <QObject>
#include <QString>
#include <QRegularExpression>
#include <QHash>


/*
012345678901234567890123456789012345678901234
^    ^    ^   ^    ^ ^                     ^
2343 -11  0.8 1259 # YV6BFE F6GUU R-08
2343 -19  0.3  718 # VE6WQ SQ2NIJ -14
2343  -7  0.3  815 # KK4DSD W7VP -16
2343 -13  0.1 3627 @ CT1FBK IK5YZT R+02
1021 -20  0.3 1598 # CQ PU2NRT GG66        *
1051 -18  0.3 1355 # UA3DJY LU1DA -23      *
1306 -26  0.7 1747 # CQ HS6OKJ OK25        *
1619 -29  2.5  702 # CQ ZS6BK KG43         *   real string_
"
0605  Tx      1259 # CQ VK3ACF QF22
*/

class DecodedText : public QObject
{
Q_OBJECT;
public:
    explicit DecodedText (QString const& message, QObject *parent = nullptr);

    QString string();
    QString message() { return message_; };
    int indexOf(QString s) { return string_.indexOf(s); };
    int indexOf(QString s, int i) { return string_.indexOf(s,i); };
    QString mid(int f, int t) { return string_.mid(f,t); };
    QString left(int i) { return string_.left(i); };

    void clear() { string_.clear(); };

    QString CQersCall(QString& grid,QString& tyyp);

    bool isJT65();
    bool isJT9();
    bool isTX();
    bool isHint();
    bool isStandardMessage () const {return is_standard_;}

    bool isWrong();
    bool isNonStd1();
    bool isNonStd2();
    bool isEnd();
    bool isFin();
    bool isDebug();
    bool isDXped();
    int frequencyOffset();  // hertz offset from the tuned dial or rx frequency, aka audio frequency
    int snr();
    float dt();

    // find and extract any report. Returns true if this is a standard message
  bool report(QString const& myBaseCall, QString const& dxBaseCall, /*mod*/QString& report,QString& type);

    // get the first text word, usually the call
    QString call();

    // get the second word, most likely the de call and the third word, most likely grid
    void deCallAndGrid(/*out*/QString& call, QString& grid);

    unsigned timeInSeconds() const;

    // returns a string of the SNR field with a leading + or - followed by two digits
    QString report();

private:
     enum Columns { column_time    = 0,
                    column_snr     = 5,
                    column_dt      = 9,
                    column_freq    = 14,
                    column_mode    = 19,
                    column_qsoText = 21};
    QString string_;
    QRegularExpression _cqLongerRe = QRegularExpression(" CQ ([A-Z]{1,4}|[0-9]{3,3}) ");
    QRegularExpression _gridRe = QRegularExpression("^(?![Rr]{2}73)[A-Ra-r]{2,2}[0-9]{2,2}$");
    QRegularExpression _repRe = QRegularExpression("[<>]");
//    QRegularExpression _callRe = QRegularExpression("(([A-Z]{1,2})|([A-Z][0-9]))[0-9][A-Z]{1,3}");
//    QRegularExpression _callRe = QRegularExpression("([BFGIKMNRTW]|[A-Z0-9]{2})[0-9][A-Z0-9]{0,3}[A-Z]");
    QRegularExpression _callRe = QRegularExpression("[2-9]{0,1}[A-Z]{1,2}[0-9]{1,4}[A-Z]{0,6}");
    int padding_;
    QString message_;
    bool is_standard_;
    QHash<QString, QString> debug_translation_;
};



#endif // DECODEDTEXT_H