// -*- Mode: C++ -*- #ifndef LIVE_AUDIO_TEST_CONTROLLER_HPP__ #define LIVE_AUDIO_TEST_CONTROLLER_HPP__ #include #include #include #include #include #include #include #include #include #include class FixtureAudioInput; class MainWindow; class QTextEdit; class LiveAudioTestController final : public QObject { Q_OBJECT public: enum class Mode { Ft8, Jtty }; LiveAudioTestController (MainWindow * window, FixtureAudioInput * fixture, QString expectedPath, Mode mode = Mode::Ft8, QObject * parent = nullptr); void begin (); bool succeeded () const {return m_succeeded;} private: enum class DecoderStage { None, EarlyStandard, Multithreaded }; static QSet readExpectedMessages (QString const& path, QString * error); static QStringList readExpectedJttyMessages (QString const& path, QString * error); static QString messageFromDecoderLine (QByteArray const& line); void prepareWhenReady (); void prepareFt8WhenReady (); void prepareJttyWhenReady (); void maybeFinish (); void maybeFinishFt8 (); void maybeFinishJtty (); void observeJttyDisplay (); void pollJttyDisplay (); void checkJttyReviewAndStatus (); void completeJttyTest (); void fail (QString const& reason); void checkForUnexpectedModal (); void exerciseSubmittedFt8Rollover (); MainWindow * m_window; FixtureAudioInput * m_fixture; QString m_expectedPath; Mode m_mode; QSet m_expected; QStringList m_expectedJtty; QString m_expectedJttyPrefix; QSet m_observed; QSet m_displayed; QSet m_earlyObserved; QSet m_multithreadedObserved; QSet m_earlyRaw; QSet m_multithreadedRaw; QString m_initializationError; QTimer m_timeout; QTimer m_prepareTimer; QTimer m_modalTimer; QTimer m_jttyPollTimer; QTimer m_jttyStageTimer; QTextEdit * m_jttyAllDecodes {nullptr}; QTextEdit * m_jttyQsoFrequency {nullptr}; qint64 m_emittedFrames {0}; qint64 m_captureStartMs {0}; QTextBlock m_jttyAllPrefixBlock, m_jttyQsoPrefixBlock; enum class JttyCheckStage { Live, Review, Stopped, Wav, Drain, TimedMode }; JttyCheckStage m_jttyCheckStage {JttyCheckStage::Live}; QElapsedTimer m_jttyCheckElapsed; QString m_jttyAllBeforeReview, m_jttyQsoBeforeReview; QVector m_jttyAllLiveBlocks, m_jttyQsoLiveBlocks; QString m_jttyLogPath, m_jttySaveDirectory; qint64 m_jttyInitialLogSize = 0; QByteArray m_jttyLogBeforeReview; QSet m_jttyInitialRecordings; int m_completedCycles {0}; quint64 m_submittedGeneration {0}; quint64 m_submittedCycle {0}; quint64 m_rolloverEpoch {0}; quint64 m_preRolloverEpoch {0}; int m_rolloverAcceptedEnd {0}; int m_rolloverAcceptedBlocks {0}; int m_rolloverRejectedBlocks {0}; int m_submittedCompletions {0}; std::vector m_rolloverSamples; bool m_rolloverVerified {false}; DecoderStage m_decoderStage {DecoderStage::None}; bool m_sawEarlyStandardDecode {false}; bool m_sawConfiguredMultithreadedDecode {false}; bool m_completedMultithreadedDecode {false}; bool m_fixtureFinished {false}; bool m_armed {false}; bool m_jttyAllSawPrefix {false}; bool m_jttyQsoSawPrefix {false}; QSet m_jttyAllFinals; QSet m_jttyQsoFinals; bool m_finished {false}; bool m_succeeded {false}; }; #endif