summaryrefslogtreecommitdiffstats
path: root/clients/tde
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-06 20:57:03 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-06 20:57:03 -0500
commit1b8ef84fb9f47b82d0da6fa6e1b9fe439bc6b05c (patch)
treed4af736afcc3a2cf0ca3904cd0ac8c78fab64c66 /clients/tde
parent8cc7778d9f0d659318f50c78abb5b31db82399ca (diff)
downloadulab-1b8ef84fb9f47b82d0da6fa6e1b9fe439bc6b05c.tar.gz
ulab-1b8ef84fb9f47b82d0da6fa6e1b9fe439bc6b05c.zip
Fix a variety of issues
Diffstat (limited to 'clients/tde')
-rw-r--r--clients/tde/src/part/fpgaprogram/part.cpp137
-rw-r--r--clients/tde/src/part/fpgaprogram/part.h5
-rw-r--r--clients/tde/src/part/fpgaview/part.cpp6
3 files changed, 121 insertions, 27 deletions
diff --git a/clients/tde/src/part/fpgaprogram/part.cpp b/clients/tde/src/part/fpgaprogram/part.cpp
index 0464c8b..d1a19df 100644
--- a/clients/tde/src/part/fpgaprogram/part.cpp
+++ b/clients/tde/src/part/fpgaprogram/part.cpp
@@ -57,7 +57,7 @@
//#define SERVER_TIMEOUT_MS 10000
// RAJA DEBUG ONLY
#define SERVER_TIMEOUT_MS 100000
-#define FPGA_COMM_TIMEOUT_MS 500
+#define NETWORK_COMM_TIMEOUT_MS 2500
#define FPGA_DATA_PROCESSING_TIMEOUT_MS 2500
namespace RemoteLab {
@@ -78,15 +78,19 @@ FPGAProgramPart::FPGAProgramPart(TQWidget *parentWidget, const char *widgetName,
setWidget(new TQVBox(parentWidget, widgetName));
// Create timers
- m_updateTimer = new TQTimer(this);
m_connectionTimer = new TQTimer(this);
connect(m_connectionTimer, SIGNAL(timeout()), this, SLOT(finishConnectingToServer()));
+ m_updateTimeoutTimer = new TQTimer(this);
+ connect(m_updateTimeoutTimer, SIGNAL(timeout()), this, SLOT(mainEventLoop()));
+ m_pingDelayTimer = new TQTimer(this);
+ connect(m_pingDelayTimer, SIGNAL(timeout()), this, SLOT(mainEventLoop()));
// Create widgets
m_base = new FPGAProgramBase(widget());
// Initialize widgets
connect(m_base->programRunButton, SIGNAL(clicked()), this, SLOT(programRunButtonClicked()));
+ connect(m_base->programmingInputFile, SIGNAL(textChanged(const TQString &)), this, SLOT(processLockouts()));
TQTimer::singleShot(0, this, TQT_SLOT(postInit()));
}
@@ -139,7 +143,7 @@ void FPGAProgramPart::connectionClosed() {
}
void FPGAProgramPart::postInit() {
- connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(mainEventLoop()));
+ //
}
bool FPGAProgramPart::openURL(const KURL &url) {
@@ -157,7 +161,7 @@ bool FPGAProgramPart::closeURL() {
void FPGAProgramPart::disconnectFromServer() {
m_connectionTimer->stop();
- m_updateTimer->stop();
+ m_updateTimeoutTimer->stop();
if (m_socket) {
m_socket->clearPendingData();
m_socket->close();
@@ -246,16 +250,17 @@ void FPGAProgramPart::finishConnectingToServer() {
TQDataStream ds(m_socket);
TQString response;
ds >> response;
-printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r", response.ascii()); fflush(stdout);
if (response == "OK") {
connToServerState = 4;
connToServerConnecting = false;
connect(m_socket, SIGNAL(readyRead()), m_socket, SLOT(processPendingData()));
+ m_socket->processPendingData();
connect(m_socket, SIGNAL(newDataReceived()), this, SLOT(mainEventLoop()));
m_tickerState = 0;
m_commHandlerState = 0;
m_commHandlerMode = 0;
- m_updateTimer->start(FPGA_COMM_TIMEOUT_MS, FALSE);
+ m_socket->setDataTimeout(NETWORK_COMM_TIMEOUT_MS);
+ m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE);
processLockouts();
mainEventLoop();
return;
@@ -311,13 +316,21 @@ void FPGAProgramPart::programRunButtonClicked() {
m_socket->readBlock(data, 64); \
} \
setStatusMessage(i18n("Server ping timeout. Please verify the status of your network connection.")); \
- m_updateTimer->start(FPGA_COMM_TIMEOUT_MS, FALSE); \
+ m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE); \
+ m_connectionMutex->unlock(); \
return;
+#define SET_WATCHDOG_TIMER if (!m_updateTimeoutTimer->isActive()) m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE);
+#define PAT_WATCHDOG_TIMER m_updateTimeoutTimer->stop(); m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE);
+
void FPGAProgramPart::mainEventLoop() {
- m_updateTimer->stop();
TQDataStream ds(m_socket);
+ if (!m_connectionMutex->tryLock()) {
+ TQTimer::singleShot(0, this, SLOT(mainEventLoop())); // Handle the concurrently received call immediately after current execution
+ return;
+ }
+
if (m_socket) {
char data[64];
@@ -329,16 +342,24 @@ void FPGAProgramPart::mainEventLoop() {
// RAJA FIXME
ds << TQString("STATUS");
- m_updateTimer->start(FPGA_COMM_TIMEOUT_MS, FALSE);
m_commHandlerState = 1;
break;
case 1:
// Get all data
if (m_socket->bytesAvailable() > 0) {
+ PAT_WATCHDOG_TIMER
+
// RAJA FIXME
- TQStringList statusDetails;
- ds >> statusDetails;
+ TQString status;
+ ds >> status;
+
+printf("[RAJA DEBUG 106.0] Status: '%s'\n\r", status.ascii()); fflush(stdout);
+
+ if (status == "") {
+ // Transfer probably failed
+ UPDATEDISPLAY_TIMEOUT
+ }
m_connectionActiveAndValid = true;
TQString tickerChar;
@@ -361,16 +382,24 @@ void FPGAProgramPart::mainEventLoop() {
if (m_tickerState > 3) {
m_tickerState = 0;
}
- m_updateTimer->start(FPGA_COMM_TIMEOUT_MS, FALSE);
- m_commHandlerState = 0;
+ m_pingDelayTimer->start(250, TRUE);
+ m_commHandlerState = 2;
}
else {
- if (!m_updateTimer->isActive()) {
+ if (!m_updateTimeoutTimer->isActive()) {
UPDATEDISPLAY_TIMEOUT
}
}
-
+ break;
+ case 2:
+ if (!m_pingDelayTimer->isActive()) {
+ // Fire next event loop immediately
+ TQTimer::singleShot(0, this, SLOT(mainEventLoop()));
+ // Execute query on next event loop
+ m_commHandlerState = 0;
+ }
+ PAT_WATCHDOG_TIMER
break;
}
}
@@ -386,15 +415,14 @@ void FPGAProgramPart::mainEventLoop() {
m_base->programmingProgressBar->setTotalSteps(0);
m_base->programmingProgressBar->setProgress(0);
- m_base->programmingStatusLabel->setText(i18n("Sending data to server") + "...");
+ // Transmit file to remote server
+ m_base->programmingStatusLabel->setText(i18n("Sending data to server") + "...");
ds << TQString("FILE");
- // RAJA FIXME
- // Transmit file to remote server...
- ds << m_programmingFileData;
-
- m_base->programmingStatusLabel->setText(i18n("Programming device") + "...");
- ds << TQString("PROGRAM");
+ m_programmingFileTotalSize = m_programmingFileData.size();
+ m_programmingFileTransferredBytes = 0;
+ ds << m_programmingFileTotalSize;
+ m_base->programmingProgressBar->setTotalSteps(m_programmingFileTotalSize);
m_commHandlerState = 1;
}
@@ -408,14 +436,40 @@ void FPGAProgramPart::mainEventLoop() {
}
}
else if (m_commHandlerState == 1) {
+ TQ_ULONG bytesLeft = (m_programmingFileTotalSize-m_programmingFileTransferredBytes);
+ TQ_ULONG bytesToTransfer = bytesLeft;
+ if (bytesToTransfer > 512) {
+ bytesToTransfer = 512;
+ }
+ m_programmingFileTransferredBytes = m_programmingFileTransferredBytes + m_socket->writeBlock(m_programmingFileData.data()+m_programmingFileTransferredBytes, bytesToTransfer);
+ m_base->programmingProgressBar->setProgress(m_programmingFileTransferredBytes);
+ if (m_programmingFileTransferredBytes >= m_programmingFileTotalSize) {
+ // Initiate programming
+ m_base->programmingStatusLabel->setText(i18n("Programming device") + "...");
+ ds << TQString("PROGRAM");
+
+ // Request status
+ ds << TQString("STATUS");
+
+ m_commHandlerState = 2;
+ }
+ else {
+ // Fire next event loop immediately
+ TQTimer::singleShot(0, this, SLOT(mainEventLoop()));
+ }
+ }
+ else if (m_commHandlerState == 2) {
// Get response
if (m_socket->bytesAvailable() > 0) {
+ PAT_WATCHDOG_TIMER
+
// RAJA FIXME
TQString result;
ds >> result;
if (result == "PROGRAMMING") {
- // RAJA FIXME
+ // Request status
+ ds << TQString("STATUS");
}
else if (result == "DONE") {
int retCode;
@@ -426,32 +480,63 @@ void FPGAProgramPart::mainEventLoop() {
// RAJA FIXME
// Handle errors
+ // This does not update the log as it should!
+ if (retCode < 0) {
+ // Error!
+ m_commHandlerMode = 0;
+ m_commHandlerState = 0;
+ TQTimer::singleShot(0, this, SLOT(mainEventLoop()));
+ m_base->programmingProgressBar->setTotalSteps(1);
+ m_base->programmingProgressBar->setProgress(0);
+ KMessageBox::error(0, i18n("<qt>Programming process failure<p>Please see log for details</qt>"), i18n("Program Failed"));
+ processLockouts();
+ }
// Done!
m_commHandlerMode = 0;
m_commHandlerState = 0;
+ TQTimer::singleShot(0, this, SLOT(mainEventLoop()));
m_base->programmingProgressBar->setTotalSteps(1);
m_base->programmingProgressBar->setProgress(0);
processLockouts();
}
- }
- else {
- if (!m_updateTimer->isActive()) {
+ else if (result == "") {
+ // Transfer probably failed
+ // Do nothing
+ }
+ else {
+ // Error!
+ m_commHandlerMode = 0;
+ m_commHandlerState = 0;
+ TQTimer::singleShot(0, this, SLOT(mainEventLoop()));
m_base->programmingProgressBar->setTotalSteps(1);
m_base->programmingProgressBar->setProgress(0);
+ KMessageBox::error(0, i18n("<qt>Unknown error</qt>"), i18n("Program Failed"));
+ processLockouts();
+ }
+ }
+ else {
+ if (!m_updateTimeoutTimer->isActive()) {
m_commHandlerMode = 0;
m_commHandlerState = 0;
+ TQTimer::singleShot(0, this, SLOT(mainEventLoop()));
+ m_base->programmingProgressBar->setTotalSteps(1);
+ m_base->programmingProgressBar->setProgress(0);
processLockouts();
UPDATEDISPLAY_TIMEOUT
}
}
}
}
+
+ SET_WATCHDOG_TIMER
}
else {
m_commHandlerState = 0;
m_commHandlerMode = 0;
}
+
+ m_connectionMutex->unlock();
}
KAboutData* FPGAProgramPart::createAboutData() {
diff --git a/clients/tde/src/part/fpgaprogram/part.h b/clients/tde/src/part/fpgaprogram/part.h
index 5becdde..05f3431 100644
--- a/clients/tde/src/part/fpgaprogram/part.h
+++ b/clients/tde/src/part/fpgaprogram/part.h
@@ -80,7 +80,8 @@ namespace RemoteLab
FPGAProgramBase* m_base;
TQMutex* m_connectionMutex;
TQTimer* m_connectionTimer;
- TQTimer* m_updateTimer;
+ TQTimer* m_pingDelayTimer;
+ TQTimer* m_updateTimeoutTimer;
bool connToServerConnecting;
int connToServerState;
@@ -91,6 +92,8 @@ namespace RemoteLab
bool m_connectionActiveAndValid;
unsigned char m_tickerState;
TQByteArray m_programmingFileData;
+ TQ_ULONG m_programmingFileTotalSize;
+ TQ_ULONG m_programmingFileTransferredBytes;
};
}
diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp
index 01c23b4..e4a56d4 100644
--- a/clients/tde/src/part/fpgaview/part.cpp
+++ b/clients/tde/src/part/fpgaview/part.cpp
@@ -704,6 +704,11 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj
connect(m_base->batchTestRunButton, SIGNAL(clicked()), this, SLOT(batchTestRunButtonClicked()));
connect(m_base->dataProcessingRunButton, SIGNAL(clicked()), this, SLOT(dataProcessingRunButtonClicked()));
+ connect(m_base->batchTestInputFile, SIGNAL(textChanged(const TQString &)), this, SLOT(processLockouts()));
+ connect(m_base->batchTestOutputFile, SIGNAL(textChanged(const TQString &)), this, SLOT(processLockouts()));
+ connect(m_base->dataProcessingInputFile, SIGNAL(textChanged(const TQString &)), this, SLOT(processLockouts()));
+ connect(m_base->dataProcessingOutputFile, SIGNAL(textChanged(const TQString &)), this, SLOT(processLockouts()));
+
processAllGraphicsUpdates();
TQTimer::singleShot(0, this, TQT_SLOT(postInit()));
@@ -1082,6 +1087,7 @@ printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r", response.ascii()); ffl
connToServerState = 4;
connToServerConnecting = false;
connect(m_socket, SIGNAL(readyRead()), m_socket, SLOT(processPendingData()));
+ m_socket->processPendingData();
connect(m_socket, SIGNAL(newDataReceived()), this, SLOT(updateDisplay()));
m_tickerState = 0;
m_commHandlerState = 0;