diff options
Diffstat (limited to 'widgets/mainwindow.h')
| -rw-r--r-- | widgets/mainwindow.h | 214 |
1 files changed, 136 insertions, 78 deletions
diff --git a/widgets/mainwindow.h b/widgets/mainwindow.h index fdc0d444..52d7fdc0 100644 --- a/widgets/mainwindow.h +++ b/widgets/mainwindow.h @@ -49,6 +49,7 @@ class QHBoxLayout; #include "Audio/TxRequest.hpp" #include "Audio/WavLoadCoordinator.hpp" #include "commons.h" +#include "lib/qra/q65/q65_limits.h" #include "FastDecode.hpp" #include "ReferenceSpectrum.hpp" #include "Radio.hpp" @@ -57,6 +58,9 @@ class QHBoxLayout; #include "models/FrequencyList.hpp" #include "Configuration.hpp" #include "JttyN1mmOutput.hpp" +#include "JttyReceiveAudio.hpp" +#include "JttyMmttyHandoff.hpp" +#include "JttyTxLifecycle.hpp" #include "WSPR/WSPRBandHopping.hpp" #include "Transceiver/Transceiver.hpp" #include "DisplayManual.hpp" @@ -75,7 +79,8 @@ class QHBoxLayout; #include "AutoRespondScoring.hpp" #include "AutoRespondPeriod.hpp" #include "HoundTransmissionPolicy.hpp" -#include "JttyDraftAcceptanceTracker.hpp" +#include "JttyLiveEntry.hpp" +#include "JttyTransmitQueue.hpp" #include "QsoProgress.hpp" #include "DecodeOperatingContext.hpp" #include "DecoderOutputFramer.hpp" @@ -184,7 +189,8 @@ public: QueueFull, BackendRejected, Aborted, - NotAvailable + NotAvailable, + BackendTimedOut }; Q_ENUM(JttyTxRejectReason) @@ -193,7 +199,7 @@ public: static QRegularExpression const non_r_db_regexp; explicit MainWindow(QDir const& temp_directory, bool multiple, MultiSettings *, - QSharedMemory *shdmem, unsigned downSampleFactor, + DecoderIpc::Session& decoderSession, unsigned downSampleFactor, QSplashScreen *, QProcessEnvironment const&, bool automated_test, QString base_style_sheet, std::unique_ptr<AudioInputSource> audio_input_source = {}, @@ -208,7 +214,7 @@ public: #endif bool decoderBusy () const - {return m_fastDecodePending || DecodeOwner::None != m_decodeOwner || m_ft8MtdDecodeCoordinator.hasPending ();} + {return m_fastDecodePending || DecodeOwner::None != m_decodeOwner || m_ft8MtdDecodeCoordinator.hasPending () || jttyReviewBusy();} void set_mode_from_command_line(const QString& mode, bool lock_mode = false); bool decoderBackendRunning () const; bool diskDataActive () const {return m_diskData;} @@ -230,18 +236,27 @@ public: static constexpr int liveAudioTestDecodeLowFrequency () {return 200;} static constexpr int liveAudioTestDecodeHighFrequency () {return 3000;} bool configureLiveAudioTestDecodeRange (); + bool startWavDecodeTest (QString const& path); bool prepareLiveAudioTestFt8InputCompletion (); QString completeLiveAudioTestFt8Input (qint64 frames); bool configureLiveAudioTestHandoff (); quint64 liveAudioTestPublishedDecoderGeneration () const { return m_automated_test && DecodeOwner::Jt9 == m_decodeOwner - && m_activeJt9Decode.generation == m_nextDecoderGeneration + && m_decoderSession.accepts (m_activeJt9Decode.generation) ? m_activeJt9Decode.generation : 0; } quint64 liveAudioTestDecodeCycleGeneration () const {return m_decodeCycleGeneration;} quint64 liveAudioTestReceiveEpoch () const {return m_receiveConsumer.epoch ();} bool liveAudioTestReceivingAudio () const {return m_receivingAudio;} + QString checkLiveAudioTestJttyFrequencyChanges(); + bool startLiveAudioTestJttyWav(QString const& path); + QString checkLiveAudioTestJttyMailboxOverflow(); + QString checkLiveAudioTestJttyDrain(); + bool liveAudioTestJttyStreamActive () const + { + return m_jttyTxStream && m_jttyTxStream->isActive (); + } LiveAudioTestFt8TransmitRequest startLiveAudioTestFt8Transmit ( qint64 targetPeriodStartMs); #endif @@ -306,7 +321,7 @@ public: void msgAvgDecode2(); void fastPick(int x0, int x1, int y); void skedFreq(double sf); - void jttyDecodeAgainAt(float secondsAgo); + void jttyDecodeAgainAtSample(quint64 reception, qint64 sample); private: enum class DecodeOwner @@ -330,6 +345,7 @@ private: Terminating, Killing, ReplacementStarting, + Failed, Closing }; @@ -344,15 +360,13 @@ private: { qint32 generation {0}; DecodeOperatingContext context; - bool copiedSamples {false}; bool obsolete {false}; Ft8MtdDecodeCoordinator::Stage ft8Stage {Ft8MtdDecodeCoordinator::Stage::None}; qint64 ft8Period {-1}; }; static constexpr int MaxActiveStationRows = 50; - // Keep this matched with MAX_CALLERS in the Q65 q3list Fortran helpers. - static constexpr int MaxQ65PileupCallers = 50; + static constexpr int MaxQ65PileupCallers = Q65_CALLER_CAPACITY; void change_layout (std::size_t) override; void keyPressEvent (QKeyEvent *) override; @@ -619,6 +633,7 @@ private slots: void on_cbMenus_toggled(bool b); void on_cbAutoSeq_toggled(bool b); void on_cbIncludeTime_toggled(bool b); + void on_cbLowerCase_toggled(bool); void networkError (QString const&); void on_ClrAvgButton_clicked(); void on_actionWSPR_triggered(); @@ -645,6 +660,7 @@ private slots: void on_sbTR_FST4W_valueChanged (int); void on_sbFtol_valueChanged (int); void on_sbFtol_2_valueChanged (int); + void on_comboBoxJttyStyle_currentIndexChanged (int index); void on_cbFast9_clicked(bool b); void on_sbCQTxFreq_valueChanged(int n); void on_cbCQTx_toggled(bool b); @@ -683,7 +699,6 @@ private slots: void on_rbEchoCW_toggled(bool b); void on_leEchoMessage_textChanged(); void on_pbSendMessage_clicked(); - void on_Tx_Message_returnPressed(); void on_pbF1_clicked(); void on_pbF2_clicked(); @@ -759,6 +774,10 @@ private: Q_SIGNAL void sendMessage (TxEvidence::TxRequest, SoundOutput *) const; Q_SIGNAL void startJttyStream (TxEvidence::TxRequest, SoundOutput *); Q_SIGNAL void endJttyStream () const; + Q_SIGNAL void clearJttyStream (TxAudioQueueEpoch epoch) const; + Q_SIGNAL void enqueueJttyStream (QByteArray const& samples, + TxAudioQueueEpoch epoch, + qint64 enqueueId) const; Q_SIGNAL void outAttenuationChanged (qreal) const; Q_SIGNAL void toggleShorthand () const; Q_SIGNAL void reset_audio_input_stream (bool report_dropped_frames) const; @@ -772,7 +791,9 @@ private: void recordTxSourceCommit (TxEvidence::TxStartSnapshot const& snapshot); void recordRawTxPlayout (TxEvidence::TxRawPlayoutSnapshot const& snapshot); void noteTxStopReason (TxEvidence::TxStopReason reason); + void requestTxStop (TxEvidence::TxStopReason reason); void noteTxModeChange (QString const& mode); + void updateModeControlLock (); int txStopTailMs (bool tciAudio) const; void stopTxEvidence (int tailMs); void captureJttyTxEvidenceTotals (qint64 servedSamples, qint64 totalSamples, @@ -796,7 +817,22 @@ private: void abortSuperFoxTxStart(); void displayFoxTxMsgs(); void jtty_tx(QString message); - void submitJttyDraft(QString message); + void commitJttyLiveEntry(); + void startJttyLiveStream(); + void autoAdvanceJttyLiveEntry(); + void idleFlushJttyLiveEntry(); + bool commitJttyLiveEntryPlan(bool forceFlush, int holdbackWords, bool isFinal); + void sendJttyFillerPadding(); + void clearJttyLiveEntry(); + void insertJttyLiveEntryText(QString const& text); + void insertJttyChatOpener(); + void insertJttyChatSignoff(); + void applyJttyLiveEntryFormatting(); + void guardJttyLiveEntryLock(); + void updateJttyLiveEntryFrameLabel(); + double jttyRequestSentFraction(qint64 requestId) const; + int jttyRequestFramesDone(qint64 requestId) const; + int countJttyTransmitFrames(QString const& preparedMessage) const; #ifdef WIN32 void handleMmttyTxString(QString message); void handleMmttyStartTx(); @@ -808,45 +844,68 @@ private: void handleMmttyJttySessionDrained(qint64 sessionId); void completeMmttyJttyOutput(bool drained = false); void startPendingMmttyJttyTx(); + void beginMmttyHandoff(); + void resumeMmttyHandoff(); + void handleMmttyHandoffTimeout(); + void finalizeMmttyExternalAbort(); + bool mmttyNeedsHandoff() const; QString jttyRejectReasonText(JttyTxRejectReason reason) const; #endif - void execute_jtty_tx(qint64 requestId, QString message); + void execute_jtty_tx(qint64 requestId, QString message, bool isFinal = true); void execute_jtty_tones(qint64 requestId, QString const& message, - int const itone[], int nsym); - void advanceJttyTxQueueEpoch(); + int const itone[], int nsym, int frequency = -1); + void enqueueJttySegments(qint64 requestId, QVector<Jtty::TransmitSegment> segments); + void enqueueJttyToneSegment(qint64 requestId, QString const& message, + int const tones[], int toneCount); + void feedJttyTransmitQueue(); + void updateJttyTransmitDisplay(qint64 servedSamples); + void updateJttySendButton(); + void onJttyBackendProgress(TxAudioQueueProgress progress); qint64 jttyTxCommittedSamples() const; void completeJttyTxEnqueue(qint64 requestId, QString const& message, TxAudioQueueProgress progress, bool newSession, bool useTciAudio); - void recordAcceptedJttyTextRequest(qint64 requestId, qint64 endSample); - QVector<qint64> takeCompletedJttyTextRequests(TxAudioQueueEpoch epoch, - qint64 totalAtDrain); - void clearAcceptedJttyTextRequests(TxAudioQueueEpoch epoch); void handleJttyContestSerial(QString const& message); void abort_jtty_tx(); void interruptJttyTx(); - void rejectPendingJttyTciMessages(JttyTxRejectReason reason); + void rejectPendingJttyMessages(JttyTxRejectReason reason); void sync_tci_tx_volume (bool force = false); void onJttyBackendDrained(TxAudioQueueDrainState drain); + void finishJttyDrain(JttyTxLifecycle::Drain const& drain); void onJttyBackendEnqueueAccepted(qint64 enqueueId, qint64 sampleCount, TxAudioQueueProgress progress); - void onJttyBackendEnqueueFailed(TxAudioQueueEpoch epoch, qint64 enqueueId); + void onJttyBackendEnqueueFailed(TxAudioQueueEpoch epoch, qint64 enqueueId, + TxAudioQueueEnqueueFailure failure); + void handleJttyEnqueueTimeout(); void handleJttyTxWatchdog(); - void resetJttyTxState(); void startJttyTxWatchdog(int durationMs); - void jtty_save_wav(); bool jtty_key_struck(QKeyEvent * e); bool sendJttyFunctionKey(int index); - // istart0/istop (sample indices into dec_data.d2) bound the Fortran scan - // to a window instead of the whole buffer; -1/-1 (the default) means - // unwindowed, matching the original behavior exactly. Returns true when - // this call delivers a completed message admitted to the QSO history. - bool jtty_decode(int k, int istart0 = -1, int istop = -1); - void renderJttyAllFreqLines(); - void renderJttyQsoLines(); + struct JttyReceiveState; + std::shared_ptr<JttyReceiveState> m_jttyReceive; + void initializeJttyReceive(); + void consumeJttyAudio(JttyReceiveMailboxPtr mailbox); + void pumpJttyReceive(); + void refreshJttyReceiveLines(); + void cancelJttyReview(); + void finishJttyReception(); + void restartJttyReception(); + void startJttyReview(quint64 reception, qint64 sample, bool picked); + void decodeJttyDisk(int k); + void finishJttyDisk(); + void updateJttyReceivePolicy(bool continuous); + void updateJttyReceiveContext(); + void updateJttySavePolicy(); + void beginJttyDisk(); + bool jttyReviewBusy() const; + bool jttyDrainInProgress() const; + bool jttyDiskActive() const; + void closeAfterJttyDrain(); + bool m_discardJttyWavLoad = false; + void drainJttyReceive(); void jtty_again(); - void flushJttyDecodeLines(); QString jtty_msg_expand(QString msg); + int jttySnrForSelectedWord(QString const& word, bool leftPane) const; QString specOpLabel() const; void initializeFFT(int nsps); void initializeFFT(int nsps, int fftSize); @@ -917,6 +976,7 @@ private: QScopedPointer<CabrilloLogWindow> m_contestLogWindow; QScopedPointer<ColorHighlighting> m_colorHighlighting; Transceiver::TransceiverState m_rigState; + QPointer<MessageBox> m_swrWarning; Frequency m_lastDialFreq; QString m_lastBand; QString m_lastCallsign; @@ -1006,6 +1066,8 @@ private: qint32 m_idleMinutes; qint32 m_nSubMode; qint32 m_nclearave; + bool m_jt65ClearAveragesPending {true}; + bool m_q65ClearAveragesPending {true}; qint32 m_minSync; qint32 m_dBm; qint32 m_nWSPRdecodes; @@ -1048,7 +1110,7 @@ private: qint32 m_position; qint64 m_decoderDiagSequence=0; qint64 m_decoderDiagActiveSequence=0; - qint32 m_nextDecoderGeneration=0; + DecoderIpc::InputState m_decoderInput; qint32 m_decoderDiagStartIhsym=0; qint32 m_decoderDiagStartHsymStop=0; qint32 m_decoderDiagStartNzhsym=0; @@ -1074,7 +1136,6 @@ private: bool m_decoderDiagHardHangLogged=false; bool m_decoderDiagAbnormalClear=false; bool m_decoderCompletedSinceStart=false; - bool m_jt9PayloadValid=false; bool m_closing=false; bool m_txFirst; bool m_tx1_enabled_preference {true}; @@ -1194,6 +1255,7 @@ private: QLabel last_tx_label; QLabel auto_tx_label; QLabel band_hopping_label; + QLabel swr_label; QLabel ndecodes_label; QProgressBar progressBar; QLabel watchdog_label; @@ -1247,6 +1309,7 @@ private: QTimer splashTimer; QTimer p1Timer; QTimer m_jttyTxWatchdog; + QTimer m_jttyEnqueueWatchdog; QTimer m_refSpecTimer; AutoRespondSelectionLatch m_autoRespondSelectionLatch; AutoRespondScores m_autoRespondScores; @@ -1257,6 +1320,8 @@ private: QString m_baseCall; QString m_hisCall; QString m_hisGrid; + int m_jttyHisCallSnr = -10; // SNR of the decode selected as DX call, for %R; cleared when the DX call changes + int m_jttyMessageStyle = 0; // Jtty::MessageStyle: 0=Contest, 1=Ft8 (see JttyMessages.hpp) QString m_appDir; QString m_cqStr; QString m_palette; @@ -1378,7 +1443,7 @@ private: QDateTime m_dateTimeBestSP; QDateTime m_dateTimeSeqStart; //Nominal start time of Rx sequence about to be decoded - QSharedMemory *mem_jt9; + DecoderIpc::Session& m_decoderSession; QString m_QSOText; unsigned m_downSampleFactor; QThread::Priority m_audioThreadPriority; @@ -1401,11 +1466,9 @@ private: qint64 m_liveAudioTestFt8StartSessionId {-1}; qint64 m_liveAudioTestFt8StartGeneration {-1}; #endif - bool m_jttyTxActive; - bool m_jttyTxUsesTciAudio; - TxAudioQueueEpoch m_jttyTxQueueEpoch; - TxAudioQueueProgress m_jttyTxQueueProgress; - struct PendingJttyTciMessage + JttyTxLifecycle m_jttyTxLifecycle; + JttyTxLifecycle::StopContext m_delayedJttyStopContext; + struct PendingJttyMessage { TxAudioQueueEpoch epoch; qint64 enqueueId; @@ -1414,48 +1477,38 @@ private: QString message; bool newSession; }; - QVector<PendingJttyTciMessage> m_pendingJttyTciMessages; - struct AcceptedJttyTxRequest - { - TxAudioQueueEpoch epoch; - qint64 requestId; - qint64 endSample; - }; - QVector<AcceptedJttyTxRequest> m_acceptedJttyTxRequests; - JttyDraftAcceptanceTracker m_jttyDraftAcceptanceTracker; + QVector<PendingJttyMessage> m_pendingJttyMessages; + Jtty::TransmitQueue m_jttyTransmitQueue; + TxAudioQueueProgress m_jttyQueueProgress; + bool m_feedingJttyTransmitQueue {false}; + qint64 m_jttyDisplayedEndSample {0}; + QString m_jttyQueueNotice; + bool m_jttyLiveEntryArmed {false}; + bool m_guardingJttyLiveEntryLock {false}; + int m_jttyLiveEntryCommitted {0}; // Tx_Message chars already sent/queued; locked against edits. + QString m_jttyLiveEntryLockedText; // cached committed prefix, to detect edits that touch it + struct PendingLiveEntryCommit { qint64 requestId; int start, end; int totalFrames {0}; }; + // Committed spans not yet confirmed fully transmitted; drives progressive sent/queued coloring and reject-triggered unlocking. + QVector<PendingLiveEntryCommit> m_jttyLiveEntryPending; + // Frames from commits that have fully drained since the box was last cleared; the frame-count label adds this to still-pending progress. + int m_jttyLiveEntryFramesSent {0}; + // Fires a batch flush of whatever's safely committable after a short typing pause, so auto-advance doesn't wait indefinitely for kJttyAutoAdvanceBatchWords to pile up on a short message. + QTimer m_jttyAutoAdvanceIdleTimer; qint64 m_jttyTxRequestId; - qint64 m_jttyTciEnqueueId; - struct JttyQsoLine - { - qint64 messageId {0}; - float frequency {0.f}; - QString text; - float sequenceStart {0.f}; - QDateTime messageStartUtc; - }; - QVector<JttyQsoLine> m_jttyQsoLines; - QTextBlock m_jttyQsoGroupStart; - QTextBlock m_jttyQsoGroupEnd; - int m_jttyQsoGroupEndPosition {-1}; - bool m_jttyQsoRenderedLowerCase {false}; - bool m_jttyQsoRenderedIncludeTime {false}; - struct JttyDecodeLine - { - qint64 messageId {0}; - float frequency {0.f}; - QString text; - float sequenceStart {0.f}; - QDateTime messageStartUtc; - bool complete {false}; - bool written {false}; - DecodeOperatingContext context; - }; - QVector<JttyDecodeLine> m_jttyAllFreqLines; - int m_jttyLastAllFreqsK = -1; // detects a restarted decode (new WAV, or "decode again") - qint32 m_jttyLastSavedWavK0 = -1; // m_k0 at last JTTY WAV save; skips saving unchanged audio again - QTextBlock m_jttyAllFreqsGroupStart; // start of decodedTextBrowser's currently-growing group + qint64 m_jttyEnqueueId; #ifdef WIN32 Jtty::N1mmOutput m_mmttyJttyOutput; + struct PendingMmttyJttyMessage + { + qint64 requestId; + QString message; + QVector<int> tones; + bool literal {false}; + }; + QVector<PendingMmttyJttyMessage> m_pendingMmttyJttyMessages; + Jtty::MmttyHandoff m_mmttyHandoff; + QTimer m_mmttyHandoffWatchdog; + bool m_preserveMmttyOutputDuringStop {false}; #endif bool m_block_pwr_tooltip; bool m_PwrBandSetOK; @@ -1488,6 +1541,9 @@ private: quint32 hold_rx, quint32 release_rx, quint32 expiries, quint32 invalid); void startTxAudioAfterPttDelay (); + void updateRigMeters (Transceiver::TransceiverState const&); + bool stopForHighSWR (Transceiver::TransceiverState const&); + void showHighSWRWarning (unsigned swr); void updateStatusBar(); void updateMainWindowAccessibility(); void registerMainWindowFocusControls(); @@ -1664,10 +1720,11 @@ private: DecodePublishResult publishPendingFt8Decode (); void decode (Ft8MtdDecodeCoordinator::Stage stage, qint64 ft8Period = -1); qint64 currentFt8DecodePeriod () const; + void beginDecoderInput (); bool usesFt8MtdFinal () const; int configuredFt8MtdEarlyStageCount () const; std::unique_ptr<Ft8MtdDecodeCoordinator::PendingMtdDecode> - capturePendingFt8MtdDecode (qint64 period) const; + capturePendingFt8MtdDecode (qint64 period); void cancelPendingFt8Decode (QString const& reason); void reportFt8BackpressureDecision ( Ft8MtdDecodeCoordinator::Decision const& decision, qint64 period); @@ -1683,6 +1740,7 @@ private: bool activeDecodeOperatingContextMatchesCurrent() const; bool initializeDecoderSharedMemory(); void startDecoderProcess(); + void failDecoderStartup(QString const& reason); bool beginDecode( DecodeOwner owner, decoder_params_t const * diagnosticParams = nullptr, DecodeOperatingContext const * diagnosticContext = nullptr); |
