File: decodedtext.h

package info (click to toggle)
js8call 2.5.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,720 kB
  • sloc: cpp: 562,651; sh: 898; python: 132; ansic: 102; makefile: 4
file content (89 lines) | stat: -rw-r--r-- 2,703 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
// -*- Mode: C++ -*-
/*
 * Class to handle the formatted string as returned from the decoder
 *
 * VK3ACF August 2013
 */

#ifndef DECODEDTEXT_H
#define DECODEDTEXT_H

#include "JS8.h"
#include <QString>
#include <QStringList>

class DecodedText {
  public:
    // Constructors

    explicit DecodedText(JS8::Event::Decoded const &);
    explicit DecodedText(QString const &frame, int bits, int submode);

    // Inline accessors

    int bits() const { return bits_; }
    QString compoundCall() const { return compound_; }
    QStringList directedMessage() const { return directed_; }
    float dt() const { return dt_; }
    QString extra() const { return extra_; }
    QString frame() const { return frame_; }
    quint8 frameType() const { return frameType_; }
    int frequencyOffset() const { return frequencyOffset_; }
    bool isAlt() const { return isAlt_; }
    bool isCompound() const { return !compound_.isEmpty(); }
    bool isDirectedMessage() const { return directed_.length() > 2; }
    bool isHeartbeat() const { return isHeartbeat_; }
    bool isLowConfidence() const { return isLowConfidence_; }
    QString message() const { return message_; }
    int snr() const { return snr_; }
    int submode() const { return submode_; }
    // You can use decode_time() from commons.h to split up this integer:
    int time() const { return time_; }

    // Accessors

    QStringList messageWords() const;
    QString string() const;

  private:
    // Unpacking strategies, attempted in order until one of them
    // works or all of them have failed.

    bool tryUnpackFastData(QString const &);
    bool tryUnpackData(QString const &);
    bool tryUnpackHeartbeat(QString const &);
    bool tryUnpackCompound(QString const &);
    bool tryUnpackDirected(QString const &);

    static constexpr std::array unpackStrategies = {
        &DecodedText::tryUnpackFastData, &DecodedText::tryUnpackData,
        &DecodedText::tryUnpackHeartbeat, &DecodedText::tryUnpackCompound,
        &DecodedText::tryUnpackDirected};

    // Core constructor; delegated to by the public constructors.

    DecodedText(QString const &frame, int bits, int submode,
                bool isLowConfidence,
                int time, // As generated by code_time() in commons.h.
                int frequencyOffset, float snr, float dt);

    // Data members ** ORDER DEPENDENCY **

    quint8 frameType_;
    QString frame_;
    bool isAlt_;
    bool isHeartbeat_;
    bool isLowConfidence_;
    QString compound_;
    QStringList directed_;
    QString extra_;
    QString message_;
    int bits_;
    int submode_;
    int time_;
    int frequencyOffset_;
    int snr_;
    float dt_;
};

#endif // DECODEDTEXT_H