From a457eafea55706f0f9f2f9be0083a9913df4bb19 Mon Sep 17 00:00:00 2001 From: simoninns Date: Tue, 26 Dec 2017 16:20:21 +0100 Subject: [PATCH] Added ability to abort PIC captures. Reduced buffer sizes to minimize frame overrun --- .../QtUsb/qusbbulktransfer.cpp | 8 ++-- .../DomesdayDuplicator/mainwindow.cpp | 48 ++++++++++++++++--- .../DomesdayDuplicator/mainwindow.h | 2 + 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/Linux-Application/DomesdayDuplicator/QtUsb/qusbbulktransfer.cpp b/Linux-Application/DomesdayDuplicator/QtUsb/qusbbulktransfer.cpp index aed4f90..0404183 100644 --- a/Linux-Application/DomesdayDuplicator/QtUsb/qusbbulktransfer.cpp +++ b/Linux-Application/DomesdayDuplicator/QtUsb/qusbbulktransfer.cpp @@ -99,19 +99,19 @@ bool transferRunning; // (16 * 16384) = 256Kbytes // // Size of transfer queue = -// (256Kbytes) * 16 = 4Mbytes +// (128Kbytes) * 16 = 2Mbytes // // Size of each disk buffer = -// 4MBytes * 32 = 128Mbytes +// 2MBytes * 16 = 32Mbytes // // Total size of disk buffers = -// 128Mbytes * 4 = 512Mbytes +// 32Mbytes * 4 = 128Mbytes // #define REQUEST_SIZE 16 #define PACKET_SIZE 16384 #define QUEUE_DEPTH 16 +#define QUEUE_BUFFERS_PER_DISK_BUFFER 16 #define NUMBER_OF_DISK_BUFFERS 4 -#define QUEUE_BUFFERS_PER_DISK_BUFFER 32 // FPGA test mode status flag static bool testModeFlag; diff --git a/Linux-Application/DomesdayDuplicator/mainwindow.cpp b/Linux-Application/DomesdayDuplicator/mainwindow.cpp index ff5b5ad..a8b4c5a 100644 --- a/Linux-Application/DomesdayDuplicator/mainwindow.cpp +++ b/Linux-Application/DomesdayDuplicator/mainwindow.cpp @@ -122,11 +122,13 @@ MainWindow::MainWindow(QWidget *parent) : clvPicNextState = clvPicCurrentState; cavPicCaptureActive = false; + cavPicCaptureAbort = false; cavPicPollTimer = new QTimer(this); connect(cavPicPollTimer, SIGNAL(timeout()), this, SLOT(cavPicPoll())); cavPicPollTimer->start(50); // Update 20 times a second clvPicCaptureActive = false; + clvPicCaptureAbort = false; clvPicPollTimer = new QTimer(this); connect(clvPicPollTimer, SIGNAL(timeout()), this, SLOT(clvPicPoll())); clvPicPollTimer->start(50); // Update 20 times a second @@ -742,6 +744,12 @@ void MainWindow::cavPicPoll(void) qDebug() << "MainWindow::cavPicPoll(): Player command error flagged - aborting"; cavPicNextState = cavState_error; } + + // Check for abort capture flag + if (cavPicCaptureAbort) { + qDebug() << "MainWindow::cavPicPoll(): Abort capture flag is set - stopping capture"; + cavPicNextState = cavState_stopCapture; + } break; case cavState_stopCapture: @@ -756,6 +764,7 @@ void MainWindow::cavPicPoll(void) // Unlock the physical player controls playerControl->command(lvdpControl::PlayerCommands::command_keyLockOff, 0); lvdpPlayerControl->unlockAllPlayerControls(); + ui->cavCapturePushButton->setText("Capture"); cavPicNextState = cavState_idle; cavPicCaptureActive = false; @@ -770,6 +779,7 @@ void MainWindow::cavPicPoll(void) // Unlock the physical player controls playerControl->command(lvdpControl::PlayerCommands::command_keyLockOff, 0); lvdpPlayerControl->unlockAllPlayerControls(); + ui->cavCapturePushButton->setText("Capture"); cavPicNextState = cavState_idle; cavPicCaptureActive = false; @@ -975,6 +985,12 @@ void MainWindow::clvPicPoll(void) qDebug() << "MainWindow::clvPicPoll(): Player command error flagged - aborting"; clvPicNextState = clvState_error; } + + // Check for abort capture flag + if (clvPicCaptureAbort) { + qDebug() << "MainWindow::clvPicPoll(): Abort capture flag is set - stopping capture"; + clvPicNextState = clvState_stopCapture; + } break; case clvState_stopCapture: @@ -989,6 +1005,7 @@ void MainWindow::clvPicPoll(void) // Unlock the physical player controls playerControl->command(lvdpControl::PlayerCommands::command_keyLockOff, 0); lvdpPlayerControl->unlockAllPlayerControls(); + ui->clvCapturePushButton->setText("Capture"); clvPicNextState = clvState_idle; clvPicCaptureActive = false; @@ -1003,6 +1020,7 @@ void MainWindow::clvPicPoll(void) // Unlock the physical player controls playerControl->command(lvdpControl::PlayerCommands::command_keyLockOff, 0); lvdpPlayerControl->unlockAllPlayerControls(); + ui->clvCapturePushButton->setText("Capture"); clvPicNextState = clvState_idle; clvPicCaptureActive = false; @@ -1016,10 +1034,19 @@ void MainWindow::on_cavCapturePushButton_clicked() // Ensure any command errors are cleared playerControl->isLastCommandError(); - // Start the CAV PIC capture + // Make sure the CLV PIC capture is not running if (!clvPicCaptureActive) { - qDebug() << "MainWindow::on_cavCapturePushButton_clicked(): Starting CAV PIC capture"; - cavPicCaptureActive = true; + if (!cavPicCaptureActive) { + // CAV capture not running... start it + qDebug() << "MainWindow::on_cavCapturePushButton_clicked(): Starting CAV PIC capture"; + cavPicCaptureAbort = false; + cavPicCaptureActive = true; + ui->cavCapturePushButton->setText("Abort"); + } else { + // CAV capture is running... abort + qDebug() << "MainWindow::on_cavCapturePushButton_clicked(): Aborting CAV PIC capture"; + cavPicCaptureAbort = true; + } } else { qDebug() << "MainWindow::on_cavCapturePushButton_clicked(): Error - CLV PIC capture in progress"; } @@ -1031,10 +1058,19 @@ void MainWindow::on_clvCapturePushButton_clicked() // Ensure any command errors are cleared playerControl->isLastCommandError(); - // Start the CLV PIC capture + // Make sure the CAV PIC capture is not running if (!cavPicCaptureActive) { - qDebug() << "MainWindow::on_clvCapturePushButton_clicked(): Starting CLV PIC capture"; - clvPicCaptureActive = true; + if (!clvPicCaptureActive) { + // CAV capture not running... start it + qDebug() << "MainWindow::on_clvCapturePushButton_clicked(): Starting CLV PIC capture"; + clvPicCaptureAbort = false; + clvPicCaptureActive = true; + ui->clvCapturePushButton->setText("Abort"); + } else { + // CAV capture is running... abort + qDebug() << "MainWindow::on_clvCapturePushButton_clicked(): Aborting CLV PIC capture"; + clvPicCaptureAbort = true; + } } else { qDebug() << "MainWindow::on_clvCapturePushButton_clicked(): Error - CAV PIC capture in progress"; } diff --git a/Linux-Application/DomesdayDuplicator/mainwindow.h b/Linux-Application/DomesdayDuplicator/mainwindow.h index 9f16220..d040fed 100644 --- a/Linux-Application/DomesdayDuplicator/mainwindow.h +++ b/Linux-Application/DomesdayDuplicator/mainwindow.h @@ -127,6 +127,7 @@ private slots: CavPicStates cavPicCurrentState; CavPicStates cavPicNextState; bool cavPicCaptureActive; + bool cavPicCaptureAbort; QTimer* cavPicPollTimer; // CLV PIC capture state-machine @@ -150,6 +151,7 @@ private slots: ClvPicStates clvPicCurrentState; ClvPicStates clvPicNextState; bool clvPicCaptureActive; + bool clvPicCaptureAbort; QTimer* clvPicPollTimer; };