Moved the progress bar and status information to a new screen. Looks

much better now. Also added better status information for when we are
first making communication with the programmer.
This commit is contained in:
Doug Brown 2012-05-13 09:42:16 -07:00
parent 348d6121f4
commit 4d38eb6d3e
5 changed files with 102 additions and 8 deletions

View File

@ -102,13 +102,16 @@ void MainWindow::on_selectReadFileButton_clicked()
void MainWindow::on_readFromSIMMButton_clicked()
{
resetAndShowStatusPage();
p->ReadSIMMToFile(ui->chosenReadFile->text());
qDebug() << "Reading from SIMM...";
}
void MainWindow::on_writeToSIMMButton_clicked()
{
resetAndShowStatusPage();
p->WriteFileToSIMM(ui->chosenWriteFile->text());
qDebug() << "Writing to SIMM...";
}
void MainWindow::on_chosenWriteFile_textEdited(const QString &newText)
@ -130,22 +133,30 @@ void MainWindow::programmerWriteStatusChanged(WriteStatus newStatus)
{
switch (newStatus)
{
case WriteErasing:
ui->statusLabel->setText("Erasing SIMM...");
break;
case WriteComplete:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::information(this, "Write complete", "The write operation finished.");
break;
case WriteError:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Write error", "An error occurred writing to the SIMM.");
break;
case WriteCancelled:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Write cancelled", "The write operation was cancelled.");
break;
case WriteEraseComplete:
// No message needed for this
ui->statusLabel->setText("Writing SIMM...");
break;
case WriteEraseFailed:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Write error", "An error occurred erasing the SIMM.");
break;
case WriteTimedOut:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Write timed out", "The write operation timed out.");
break;
}
@ -165,6 +176,7 @@ void MainWindow::programmerWriteCompletionLengthChanged(uint32_t len)
void MainWindow::on_electricalTestButton_clicked()
{
resetAndShowStatusPage();
electricalTestString = "";
p->RunElectricalTest();
}
@ -174,18 +186,23 @@ void MainWindow::programmerElectricalTestStatusChanged(ElectricalTestStatus newS
switch (newStatus)
{
case ElectricalTestStarted:
ui->statusLabel->setText("Running electrical test...");
qDebug() << "Electrical test started";
break;
case ElectricalTestPassed:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::information(this, "Test passed", "The electrical test passed successfully.");
break;
case ElectricalTestFailed:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Test failed", "The electrical test failed:\n\n" + electricalTestString);
break;
case ElectricalTestTimedOut:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Test timed out", "The electrical test operation timed out.");
break;
case ElectricalTestCouldntStart:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Communication error", "Unable to communicate with programmer board.");
break;
}
@ -208,16 +225,23 @@ void MainWindow::programmerReadStatusChanged(ReadStatus newStatus)
{
switch (newStatus)
{
case ReadStarting:
ui->statusLabel->setText("Reading SIMM contents...");
break;
case ReadComplete:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::information(this, "Read complete", "The read operation finished.");
break;
case ReadError:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Read error", "An error occurred reading from the SIMM.");
break;
case ReadCancelled:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Read cancelled", "The read operation was cancelled.");
break;
case ReadTimedOut:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Read timed out", "The read operation timed out.");
break;
}
@ -237,8 +261,12 @@ void MainWindow::programmerIdentifyStatusChanged(IdentificationStatus newStatus)
{
switch (newStatus)
{
case IdentificationStarting:
ui->statusLabel->setText("Identifying chips...");
break;
case IdentificationComplete:
{
ui->pages->setCurrentWidget(ui->controlPage);
QString identifyString = "The chips identified themselves as:";
for (int x = 0; x < 4; x++)
{
@ -254,9 +282,11 @@ void MainWindow::programmerIdentifyStatusChanged(IdentificationStatus newStatus)
break;
}
case IdentificationError:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Identification error", "An error occurred identifying the chips on the SIMM.");
break;
case IdentificationTimedOut:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Identification timed out", "The identification operation timed out.");
break;
}
@ -266,16 +296,23 @@ void MainWindow::programmerFirmwareFlashStatusChanged(FirmwareFlashStatus newSta
{
switch (newStatus)
{
case FirmwareFlashStarting:
ui->statusLabel->setText("Flashing new firmware...");
break;
case FirmwareFlashComplete:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::information(this, "Firmware update complete", "The firmware update operation finished.");
break;
case FirmwareFlashError:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Firmware update error", "An error occurred writing firmware to the device.");
break;
case FirmwareFlashCancelled:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Firmware update cancelled", "The firmware update was cancelled.");
break;
case FirmwareFlashTimedOut:
ui->pages->setCurrentWidget(ui->controlPage);
QMessageBox::warning(this, "Firmware update timed out", "The firmware update operation timed out.");
break;
}
@ -320,6 +357,7 @@ void MainWindow::on_actionUpdate_firmware_triggered()
QString filename = QFileDialog::getOpenFileName(this, "Select a firmware image:");
if (!filename.isNull())
{
resetAndShowStatusPage();
p->FlashFirmware(filename);
qDebug() << "Updating firmware...";
}
@ -327,10 +365,11 @@ void MainWindow::on_actionUpdate_firmware_triggered()
void MainWindow::on_identifyButton_clicked()
{
resetAndShowStatusPage();
p->IdentifySIMMChips();
}
void MainWindow::portDiscovered(const QextPortInfo & info)
void MainWindow::portDiscovered(const QextPortInfo &info)
{
qDebug() << info.portName << "discovered";
@ -351,7 +390,7 @@ void MainWindow::portDiscovered(const QextPortInfo & info)
}
}
void MainWindow::portRemoved(const QextPortInfo & info)
void MainWindow::portRemoved(const QextPortInfo &info)
{
qDebug() << info.portName << "removed";
@ -363,3 +402,10 @@ void MainWindow::portRemoved(const QextPortInfo & info)
}
}
}
void MainWindow::resetAndShowStatusPage()
{
ui->progressBar->setValue(0);
ui->statusLabel->setText("Communicating with programmer...");
ui->pages->setCurrentWidget(ui->statusPage);
}

View File

@ -52,14 +52,16 @@ private slots:
void on_identifyButton_clicked();
void portDiscovered(const QextPortInfo & info);
void portRemoved(const QextPortInfo & info);
void portDiscovered(const QextPortInfo &info);
void portRemoved(const QextPortInfo &info);
private:
Ui::MainWindow *ui;
bool writeFileValid;
bool readFileValid;
QString electricalTestString;
void resetAndShowStatusPage();
};
#endif // MAINWINDOW_H

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>557</width>
<height>403</height>
<height>405</height>
</rect>
</property>
<property name="windowTitle">
@ -22,7 +22,10 @@
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<widget class="QStackedWidget" name="pages">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="controlPage">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
@ -213,11 +216,24 @@
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="statusPage">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="statusLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Status label:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
@ -243,7 +259,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2"/>
</widget>
</item>
</layout>

View File

@ -373,6 +373,7 @@ void Programmer::handleChar(uint8_t c)
// READ SIMM STATE HANDLERS
case ReadSIMMWaitingStartReply:
emit readStatusChanged(ReadStarting);
curState = ReadSIMMWaitingData;
readChunkLenRemaining = READ_CHUNK_SIZE;
break;
@ -436,6 +437,7 @@ void Programmer::handleChar(uint8_t c)
// Ensure we're in the programmer?
// Then do the command correctly
qDebug() << "We're in the bootloader, so sending an \"enter programmer\" request.";
emit startStatusChanged(ProgrammerInitializing);
sendByte(EnterProgrammer);
serialPort->close();
{
@ -449,14 +451,27 @@ void Programmer::handleChar(uint8_t c)
serialPort->open(QextSerialPort::ReadWrite);
curState = nextState;
sendByte(nextSendByte);
// Special case: Send out notification we are starting an erase command.
// I don't have any hooks into the process between now and the erase reply.
if (nextSendByte == EraseChips)
{
emit writeStatusChanged(WriteErasing);
}
break;
case BootloaderStateInProgrammer:
// Good to go...
// So change to the next state and send out the next command
// to begin whatever sequence of events we expected.
qDebug() << "Already in programmer. Good! Do the command now...";
emit startStatusChanged(ProgrammerInitialized);
curState = nextState;
sendByte(nextSendByte);
// Special case: Send out notification we are starting an erase command.
// I don't have any hooks into the process between now and the erase reply.
if (nextSendByte == EraseChips)
{
emit writeStatusChanged(WriteErasing);
}
break;
// TODO: Otherwise, raise an error?
}
@ -487,6 +502,7 @@ void Programmer::handleChar(uint8_t c)
// Ensure we're in the bootloader?
// Then do the command correctly
qDebug() << "We're in the programmer, so sending an \"enter bootloader\" request.";
emit startStatusChanged(ProgrammerInitializing);
sendByte(EnterBootloader);
serialPort->close();
{
@ -506,6 +522,7 @@ void Programmer::handleChar(uint8_t c)
// So change to the next state and send out the next command
// to begin whatever sequence of events we expected.
qDebug() << "Already in bootloader. Good! Do the command now...";
emit startStatusChanged(ProgrammerInitialized);
curState = nextState;
sendByte(nextSendByte);
break;
@ -518,6 +535,7 @@ void Programmer::handleChar(uint8_t c)
if (c == CommandReplyOK)
{
// Good to go, now waiting for identification data
emit identificationStatusChanged(IdentificationStarting);
curState = IdentificationWaitingData;
identificationCounter = 0;
}
@ -559,6 +577,7 @@ void Programmer::handleChar(uint8_t c)
case BootloaderEraseProgramAwaitingStartOKReply:
if (c == CommandReplyOK)
{
emit firmwareFlashStatusChanged(FirmwareFlashStarting);
sendByte(ComputerBootloaderWriteMore);
curState = BootloaderEraseProgramWaitingWriteMoreReply;
}

View File

@ -5,8 +5,15 @@
#include <QFile>
#include <qextserialport.h>
typedef enum StartStatus
{
ProgrammerInitializing,
ProgrammerInitialized
} StartStatus;
typedef enum ReadStatus
{
ReadStarting,
ReadComplete,
ReadError,
ReadCancelled,
@ -15,6 +22,7 @@ typedef enum ReadStatus
typedef enum WriteStatus
{
WriteErasing,
WriteComplete,
WriteError,
WriteCancelled,
@ -34,6 +42,7 @@ typedef enum ElectricalTestStatus
typedef enum IdentificationStatus
{
IdentificationStarting,
IdentificationComplete,
IdentificationError,
IdentificationTimedOut
@ -41,6 +50,7 @@ typedef enum IdentificationStatus
typedef enum FirmwareFlashStatus
{
FirmwareFlashStarting,
FirmwareFlashComplete,
FirmwareFlashError,
FirmwareFlashCancelled,
@ -72,6 +82,8 @@ public:
void GetChipIdentity(int chipIndex, uint8_t *manufacturer, uint8_t *device);
void FlashFirmware(QString filename);
signals:
void startStatusChanged(StartStatus status);
void readStatusChanged(ReadStatus status);
void readTotalLengthChanged(uint32_t total);
void readCompletionLengthChanged(uint32_t total);