Compared with b5b045a:
- Model CH0 and CH1 as independent channel sessions sharing one device connection.
- Keep one outstanding frame per channel and tighten read/release ownership validation.
- Unify facade and PCIES2MM diagnostic details in a per-channel ChannelErrorState.
- Treat polling timeouts and stop wakeups as expected control flow instead of persistent faults.
- Report detailed errors only when an API operation actually fails.
- Remove obsolete preview timing/error diagnostics and the redundant debug error API.
- Refresh the public and internal API references, architecture diagrams, and learning guides.
105 lines
2.9 KiB
C++
105 lines
2.9 KiB
C++
#pragma once
|
|
|
|
#include <gvfg_capture.h>
|
|
#include <gvfg_preview.h>
|
|
|
|
#include <QFile>
|
|
#include <QString>
|
|
#include <QWidget>
|
|
|
|
#include <array>
|
|
#include <atomic>
|
|
#include <cstdint>
|
|
#include <mutex>
|
|
#include <thread>
|
|
|
|
class QCloseEvent;
|
|
class PreviewWindow;
|
|
class QTimer;
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
namespace Ui
|
|
{
|
|
class MainWindow;
|
|
}
|
|
QT_END_NAMESPACE
|
|
|
|
class MainWindow final : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit MainWindow(QWidget *parent = nullptr);
|
|
~MainWindow() override;
|
|
|
|
protected:
|
|
void closeEvent(QCloseEvent *event) override;
|
|
|
|
private:
|
|
void refreshDevices();
|
|
void showPreviewWindow();
|
|
void showFullscreenPreviewWindow();
|
|
bool openDevice();
|
|
bool applyOutputFormat();
|
|
void closeDevice();
|
|
void startCapture();
|
|
void stopCapture();
|
|
bool applyPreview();
|
|
void updatePreviewSourceSize(const gvfg_signal_status_t &signal);
|
|
void updatePreviewSourceSize();
|
|
void processPendingEvents();
|
|
void updateSignalStatus(bool queryHardware = true);
|
|
void updateUiState();
|
|
void showError(const QString &apiName, gvfg_status_t status);
|
|
void openLogFile();
|
|
bool openLogFilePart();
|
|
void rotateLogFileIfNeeded();
|
|
void writeLogFileLine(const QString &line);
|
|
#if GVFG_INTERNAL_DIAGNOSTICS
|
|
void writeDiagnosticSnapshot(const QString &statusText);
|
|
#endif
|
|
void appendLog(const QString &message);
|
|
void captureReadLoop();
|
|
void joinCaptureThread();
|
|
|
|
static constexpr qint64 kMaxLogFileBytes = 20ll * 1024ll * 1024ll;
|
|
|
|
Ui::MainWindow *ui_ = nullptr;
|
|
PreviewWindow *previewWindow_ = nullptr;
|
|
std::array<gvfg_device_info_t, GVFG_MAX_DEVICES> devices_{};
|
|
int deviceCount_ = 0;
|
|
gvfg_handle handle_ = nullptr;
|
|
int selectedChannel_ = GVFG_CHANNEL_0;
|
|
gvfg_preview_handle previewHandle_ = nullptr;
|
|
std::atomic<bool> captureRunning_{false};
|
|
std::atomic<bool> captureStop_{false};
|
|
std::atomic<bool> frameAvailable_{false};
|
|
std::thread captureThread_;
|
|
std::atomic<double> getFrameAverageMs_{0.0};
|
|
std::atomic<double> getFrameMaximumMs_{0.0};
|
|
std::atomic<double> getFrameWindowMaximumMs_{0.0};
|
|
std::atomic<uint64_t> getFrameSamples_{0};
|
|
uint64_t previewFailureCount_ = 0;
|
|
std::atomic<double> previewCallAverageMs_{0.0};
|
|
std::atomic<double> previewCallMaximumMs_{0.0};
|
|
std::atomic<double> previewCallWindowMaximumMs_{0.0};
|
|
std::atomic<uint64_t> previewCallSamples_{0};
|
|
QTimer *runtimeStatusTimer_ = nullptr;
|
|
gvfg_signal_status_t cachedSignalStatus_{};
|
|
bool haveCachedSignalStatus_ = false;
|
|
QString lastSignalStatusText_;
|
|
QString lastLoggedInputStatus_;
|
|
#if GVFG_INTERNAL_DIAGNOSTICS
|
|
uint64_t lastDebugDmaErrors_ = 0;
|
|
bool haveDebugBaseline_ = false;
|
|
#endif
|
|
QFile logFile_;
|
|
std::mutex logFileMutex_;
|
|
QString logDirPath_;
|
|
QString logFilePath_;
|
|
QString logSessionStamp_;
|
|
int logPartIndex_ = 1;
|
|
};
|
|
|
|
QWidget *createMainWindow();
|