summaryrefslogtreecommitdiff
path: root/Ft8TxLoopbackTestController.hpp
blob: de80ac263a1aaef852f67ccd16305c043156feb9 (plain)
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
// -*- Mode: C++ -*-
#ifndef FT8_TX_LOOPBACK_TEST_CONTROLLER_HPP__
#define FT8_TX_LOOPBACK_TEST_CONTROLLER_HPP__

#include <QObject>
#include <QString>
#include <QTimer>

class FixtureSoundOutput;
class MainWindow;

class Ft8TxLoopbackTestController final
  : public QObject
{
  Q_OBJECT

public:
  Ft8TxLoopbackTestController (MainWindow * window,
                               FixtureSoundOutput * output,
                               QString capturePath,
                               QObject * parent = nullptr);

  void begin ();
  bool succeeded () const {return m_succeeded;}

private:
  void prepareWhenReady ();
  void startWhenScheduled ();
  void handleStartDecision (qint64 sessionId, qint64 generation,
                            qint64 targetPeriodStartMs, bool accepted,
                            qint64 actualStartMs);
  void maybeFinish ();
  bool validateCapture (QString * error) const;
  void fail (QString const& reason);
  void checkForUnexpectedModal ();

  MainWindow * m_window;
  FixtureSoundOutput * m_output;
  QString m_capturePath;
  QTimer m_timeout;
  QTimer m_prepareTimer;
  QTimer m_startTimer;
  QTimer m_modalTimer;
  qint64 m_targetPeriodStartMs {0};
  qint64 m_startSessionId {-1};
  qint64 m_startGeneration {-1};
  qint64 m_startCallbackMs {-1};
  qint64 m_startDecidedMs {-1};
  qint64 m_firstNonSilentFrame {-1};
  qint64 m_capturedFrames {0};
  int m_captureStartCount {0};
  int m_captureStopCount {0};
  int m_startAttemptCount {0};
  bool m_prepared {false};
  bool m_autoDisabledDuringTransmit {false};
  bool m_finished {false};
  bool m_succeeded {false};
};

#endif