|
|
|
@ -31,6 +31,7 @@
|
|
|
|
|
#include <kstatusbar.h>
|
|
|
|
|
#include <kstdaction.h>
|
|
|
|
|
#include <knuminput.h>
|
|
|
|
|
#include <kmdcodec.h>
|
|
|
|
|
#include <kurlrequester.h>
|
|
|
|
|
#include <tqfile.h> //encodeName()
|
|
|
|
|
#include <tqtimer.h> //postInit() hack
|
|
|
|
@ -57,6 +58,7 @@
|
|
|
|
|
// RAJA DEBUG ONLY
|
|
|
|
|
#define SERVER_TIMEOUT_MS 100000
|
|
|
|
|
#define FPGA_COMM_TIMEOUT_MS 500
|
|
|
|
|
#define FPGA_DATA_PROCESSING_TIMEOUT_MS 2500
|
|
|
|
|
|
|
|
|
|
FPGALed::FPGALed(TQWidget *parent, const char *name)
|
|
|
|
|
: KLed(parent, name), m_clickable(true)
|
|
|
|
@ -905,7 +907,10 @@ void FPGAViewPart::processLockouts() {
|
|
|
|
|
else {
|
|
|
|
|
m_base->dataProcessingInputFile->setEnabled(true);
|
|
|
|
|
m_base->dataProcessingOutputFile->setEnabled(true);
|
|
|
|
|
m_base->dataProcessingGenerateValidationString->setEnabled(true);
|
|
|
|
|
// FIXME
|
|
|
|
|
// Re-enable this when a good way to implement it (using Kerberos?) is found!
|
|
|
|
|
//m_base->dataProcessingGenerateValidationString->setEnabled(true);
|
|
|
|
|
m_base->dataProcessingGenerateValidationString->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((m_connectionActiveAndValid == true) && (m_commHandlerMode == 0)) {
|
|
|
|
@ -1285,11 +1290,13 @@ void FPGAViewPart::updateDisplay() {
|
|
|
|
|
m_base->batchTestProgressBar->setTotalSteps(m_batchInputValueList.count());
|
|
|
|
|
|
|
|
|
|
m_batchOutputFile = new TQFile(m_base->batchTestOutputFile->url());
|
|
|
|
|
if (m_batchOutputFile->open(IO_WriteOnly)) {
|
|
|
|
|
if (m_batchOutputFile->open(IO_ReadWrite)) {
|
|
|
|
|
m_batchCurrentValueIndex = 0;
|
|
|
|
|
m_commHandlerState = 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
delete m_batchOutputFile;
|
|
|
|
|
m_batchOutputFile = NULL;
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>Unable to open selected batch output file</qt>"), i18n("Batch Failed"));
|
|
|
|
|
m_commHandlerMode = 0;
|
|
|
|
|
m_commHandlerState = 0;
|
|
|
|
@ -1308,6 +1315,10 @@ void FPGAViewPart::updateDisplay() {
|
|
|
|
|
else if (m_commHandlerState == 1) {
|
|
|
|
|
if (m_batchCurrentValueIndex >= m_batchInputValueList.count()) {
|
|
|
|
|
// Done!
|
|
|
|
|
m_batchOutputFile->flush();
|
|
|
|
|
m_batchOutputFile->close();
|
|
|
|
|
delete m_batchOutputFile;
|
|
|
|
|
m_batchOutputFile = NULL;
|
|
|
|
|
m_commHandlerMode = 0;
|
|
|
|
|
m_commHandlerState = 0;
|
|
|
|
|
m_base->batchTestProgressBar->setProgress(0);
|
|
|
|
@ -1356,9 +1367,15 @@ void FPGAViewPart::updateDisplay() {
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (!m_updateTimer->isActive()) {
|
|
|
|
|
UPDATEDISPLAY_TIMEOUT
|
|
|
|
|
m_batchOutputFile->flush();
|
|
|
|
|
m_batchOutputFile->close();
|
|
|
|
|
delete m_batchOutputFile;
|
|
|
|
|
m_batchOutputFile = NULL;
|
|
|
|
|
m_base->batchTestProgressBar->setProgress(0);
|
|
|
|
|
m_commHandlerMode = 0;
|
|
|
|
|
m_commHandlerState = 0;
|
|
|
|
|
processLockouts();
|
|
|
|
|
UPDATEDISPLAY_TIMEOUT
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1366,7 +1383,158 @@ void FPGAViewPart::updateDisplay() {
|
|
|
|
|
else if (m_commHandlerMode == 2) {
|
|
|
|
|
// Data processing mode
|
|
|
|
|
// This detects when the incoming data file is a picture (bmp, png, etc.) and processes it accordingly
|
|
|
|
|
// RAJA FIXME
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (m_commHandlerState == 0) {
|
|
|
|
|
m_base->batchTestStatusLabel->setText(i18n("Reading input data") + "...");
|
|
|
|
|
m_batchInputValueList.clear();
|
|
|
|
|
TQFile file(m_base->batchTestInputFile->url());
|
|
|
|
|
if (file.open(IO_ReadOnly)) {
|
|
|
|
|
// Is it an image?
|
|
|
|
|
m_dataIsImage = m_dataInputImage.load(m_base->batchTestInputFile->url());
|
|
|
|
|
|
|
|
|
|
if ((file.size() <= 16384) || ((m_dataIsImage) && ((m_dataInputImage.height()*m_dataInputImage.width()) <= 16384))) {
|
|
|
|
|
m_base->dataProcessingProgressBar->setTotalSteps(0);
|
|
|
|
|
m_base->dataProcessingProgressBar->setProgress(0);
|
|
|
|
|
|
|
|
|
|
m_dataOutputFile = new TQFile(m_base->batchTestOutputFile->url());
|
|
|
|
|
if (m_dataOutputFile->open(IO_ReadWrite)) {
|
|
|
|
|
if (!m_dataIsImage) {
|
|
|
|
|
m_dataByteArray = file.readAll();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// Show image in GUI
|
|
|
|
|
TQPixmap inputImagePixmap(m_dataInputImage);
|
|
|
|
|
m_base->ImageInputLabel->setPixmap(inputImagePixmap);
|
|
|
|
|
// Populate m_dataByteArray with image data
|
|
|
|
|
int x;
|
|
|
|
|
int y;
|
|
|
|
|
int imageWidth = m_dataInputImage.width();
|
|
|
|
|
m_dataByteArray.resize(m_dataInputImage.height()*imageWidth);
|
|
|
|
|
for (y=0; y<m_dataInputImage.height(); y++) {
|
|
|
|
|
for (x=0; x<m_dataInputImage.width(); x++) {
|
|
|
|
|
m_dataByteArray[(y*imageWidth)+x] = tqGray(m_dataInputImage.pixel(x,y));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_base->dataProcessingStatusLabel->setText(i18n("Transmitting data to FPGA") + "...");
|
|
|
|
|
|
|
|
|
|
// Transmit m_dataByteArray to FPGA
|
|
|
|
|
m_socket->writeLine("M\r");
|
|
|
|
|
int len = m_dataByteArray.size();
|
|
|
|
|
if (len >= 16384) {
|
|
|
|
|
len = 16384;
|
|
|
|
|
}
|
|
|
|
|
TQByteArray dataToSend(16384*2);
|
|
|
|
|
for (i=0; i<(len*2); i++) {
|
|
|
|
|
dataToSend[(i*2)+0] = m_dataByteArray[i];
|
|
|
|
|
dataToSend[(i+2)+1] = '\r';
|
|
|
|
|
}
|
|
|
|
|
m_socket->writeBlock(dataToSend, len*2);
|
|
|
|
|
|
|
|
|
|
m_base->dataProcessingStatusLabel->setText(i18n("Waiting for data from FPGA") + "...");
|
|
|
|
|
|
|
|
|
|
m_updateTimer->start(FPGA_DATA_PROCESSING_TIMEOUT_MS, FALSE);
|
|
|
|
|
|
|
|
|
|
m_batchCurrentValueIndex = 0;
|
|
|
|
|
m_commHandlerState = 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>Unable to open selected data output file</qt>"), i18n("Data Processing Failed"));
|
|
|
|
|
m_commHandlerMode = 0;
|
|
|
|
|
m_commHandlerState = 0;
|
|
|
|
|
m_base->dataProcessingProgressBar->setTotalSteps(1);
|
|
|
|
|
m_base->dataProcessingProgressBar->setProgress(0);
|
|
|
|
|
processLockouts();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>Selected data input file exceeds the maximum allowed size of 16,384 bytes</qt>"), i18n("Data Processing Failed"));
|
|
|
|
|
m_commHandlerMode = 0;
|
|
|
|
|
m_commHandlerState = 0;
|
|
|
|
|
m_base->dataProcessingProgressBar->setTotalSteps(1);
|
|
|
|
|
m_base->dataProcessingProgressBar->setProgress(0);
|
|
|
|
|
processLockouts();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>Unable to open selected data input file</qt>"), i18n("Data Processing Failed"));
|
|
|
|
|
m_commHandlerMode = 0;
|
|
|
|
|
m_commHandlerState = 0;
|
|
|
|
|
m_base->dataProcessingProgressBar->setTotalSteps(1);
|
|
|
|
|
m_base->dataProcessingProgressBar->setProgress(0);
|
|
|
|
|
processLockouts();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (m_commHandlerState == 1) {
|
|
|
|
|
if (m_socket->bytesAvailable() >= 16384) {
|
|
|
|
|
TQByteArray recData(16384);
|
|
|
|
|
m_socket->readBlock(recData.data(), recData.size());
|
|
|
|
|
|
|
|
|
|
m_base->dataProcessingStatusLabel->setText(i18n("Writing data to file") + "...");
|
|
|
|
|
if (!m_dataIsImage) {
|
|
|
|
|
// Write data straight to file
|
|
|
|
|
m_dataOutputFile->writeBlock(recData);
|
|
|
|
|
m_base->ImageOutputLabel->setPixmap(TQPixmap());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// Write data to image, then write image to file
|
|
|
|
|
TQImage outputImage(m_dataInputImage.width(), m_dataInputImage.height(), m_dataInputImage.depth());
|
|
|
|
|
int x;
|
|
|
|
|
int y;
|
|
|
|
|
int imageWidth = outputImage.width();
|
|
|
|
|
m_dataByteArray.resize(outputImage.height()*imageWidth);
|
|
|
|
|
for (y=0; y<outputImage.height(); y++) {
|
|
|
|
|
for (x=0; x<outputImage.width(); x++) {
|
|
|
|
|
outputImage.setPixel(x, y, recData[(y*imageWidth)+x]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
TQPixmap outputImagePixmap(outputImage);
|
|
|
|
|
m_base->ImageOutputLabel->setPixmap(outputImagePixmap);
|
|
|
|
|
outputImage.save(m_dataOutputFile, "PNG");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_dataOutputFile->flush();
|
|
|
|
|
|
|
|
|
|
// Calculate signature and write metadata to verification file
|
|
|
|
|
m_dataOutputFile->reset();
|
|
|
|
|
TQByteArray writtenFile = m_dataOutputFile->readAll();
|
|
|
|
|
KMD5 writtenMD5(writtenFile);
|
|
|
|
|
|
|
|
|
|
TQFile verificationFile(m_base->batchTestOutputFile->url() + ".vrf");
|
|
|
|
|
if (verificationFile.open(IO_ReadWrite)) {
|
|
|
|
|
TQCString datastring = writtenMD5.hexDigest();
|
|
|
|
|
datastring.prepend("md5=");
|
|
|
|
|
verificationFile.writeBlock(datastring);
|
|
|
|
|
datastring = (TQString("datetime=").arg(TQDateTime::currentDateTime().toString())).ascii();
|
|
|
|
|
verificationFile.writeBlock(datastring);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_dataOutputFile->close();
|
|
|
|
|
delete m_dataOutputFile;
|
|
|
|
|
m_dataOutputFile = NULL;
|
|
|
|
|
m_base->dataProcessingProgressBar->setTotalSteps(1);
|
|
|
|
|
m_base->dataProcessingProgressBar->setProgress(0);
|
|
|
|
|
m_commHandlerMode = 0;
|
|
|
|
|
m_commHandlerState = 0;
|
|
|
|
|
processLockouts();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (!m_updateTimer->isActive()) {
|
|
|
|
|
m_dataOutputFile->flush();
|
|
|
|
|
m_dataOutputFile->close();
|
|
|
|
|
delete m_dataOutputFile;
|
|
|
|
|
m_dataOutputFile = NULL;
|
|
|
|
|
m_base->dataProcessingProgressBar->setTotalSteps(1);
|
|
|
|
|
m_base->dataProcessingProgressBar->setProgress(0);
|
|
|
|
|
m_commHandlerMode = 0;
|
|
|
|
|
m_commHandlerState = 0;
|
|
|
|
|
processLockouts();
|
|
|
|
|
UPDATEDISPLAY_TIMEOUT
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|