summaryrefslogtreecommitdiffstats
path: root/clients/tde
diff options
context:
space:
mode:
Diffstat (limited to 'clients/tde')
-rw-r--r--clients/tde/src/app/remotemdi.cpp28
-rw-r--r--clients/tde/src/part/fpgaprogram/part.cpp206
-rw-r--r--clients/tde/src/part/fpgaprogram/part.h3
-rw-r--r--clients/tde/src/part/fpgaview/part.cpp31
4 files changed, 187 insertions, 81 deletions
diff --git a/clients/tde/src/app/remotemdi.cpp b/clients/tde/src/app/remotemdi.cpp
index eec5144..0ae6680 100644
--- a/clients/tde/src/app/remotemdi.cpp
+++ b/clients/tde/src/app/remotemdi.cpp
@@ -215,6 +215,8 @@ void RemoteMDI::finishConnectingToServer() {
KMessageBox::error(this, i18n("<qt>Unable to establish Kerberos protocol with remote server<p>Please verify that you currently hold a valid Kerberos ticket</qt>"), i18n("Connection Failed"));
}
else {
+ connect(m_rsvSvrSocket, SIGNAL(readyRead()), m_rsvSvrSocket, SLOT(processPendingData()));
+ m_rsvSvrSocket->processPendingData();
connToServerState = 2;
}
}
@@ -223,10 +225,18 @@ void RemoteMDI::finishConnectingToServer() {
// Connection established!
// Read magic number and proto version from server
TQDataStream* ds = new TQDataStream(m_rsvSvrSocket);
+ ds->setPrintableData(true);
+ while (!m_rsvSvrSocket->canReadFrame()) {
+ tqApp->processEvents();
+ if (!m_rsvSvrSocket) {
+ return;
+ }
+ }
TQ_UINT32 magicnum;
TQ_UINT32 protover;
*ds >> magicnum;
*ds >> protover;
+ m_rsvSvrSocket->clearFrameTail();
printf("[DEBUG] Got magic number %d and protocol version %d\n\r", magicnum, protover); fflush(stdout);
delete ds;
if ((magicnum == MAGIC_NUMBER) && (protover == PROTOCOL_VERSION)) {
@@ -285,11 +295,20 @@ void RemoteMDI::promptForStationType() {
}
TQDataStream ds(m_rsvSvrSocket);
+ ds.setPrintableData(true);
// Request list of laboratory stations
StationList slist;
ds << TQString("LIST");
+ m_rsvSvrSocket->writeEndOfFrame();
+ while (!m_rsvSvrSocket->canReadFrame()) {
+ tqApp->processEvents();
+ if (!m_rsvSvrSocket) {
+ return;
+ }
+ }
ds >> slist;
+ m_rsvSvrSocket->clearFrameTail();
printf("[RAJA DEBUG 200.2] Got list of stations, count is %d\n\r", slist.count()); fflush(stdout);
@@ -298,8 +317,17 @@ void RemoteMDI::promptForStationType() {
if (ret == KDialog::Accepted) {
TQString result;
ds << TQString("BIND");
+ m_rsvSvrSocket->writeEndOfFrame();
ds << select.m_selectedStation;
+ m_rsvSvrSocket->writeEndOfFrame();
+ while (!m_rsvSvrSocket->canReadFrame()) {
+ tqApp->processEvents();
+ if (!m_rsvSvrSocket) {
+ return;
+ }
+ }
ds >> result;
+ m_rsvSvrSocket->clearFrameTail();
printf("[RAJA DEBUG 100.0] '%s'\n\r", result.ascii()); fflush(stdout);
if (result == "OK") {
// Success!
diff --git a/clients/tde/src/part/fpgaprogram/part.cpp b/clients/tde/src/part/fpgaprogram/part.cpp
index d1a19df..f70ab49 100644
--- a/clients/tde/src/part/fpgaprogram/part.cpp
+++ b/clients/tde/src/part/fpgaprogram/part.cpp
@@ -26,6 +26,7 @@
#include <kaboutdata.h> //::createAboutData()
#include <kaction.h>
#include <klocale.h>
+#include <ktextedit.h>
#include <kmessagebox.h> //::start()
#include <kparts/genericfactory.h>
#include <kstatusbar.h>
@@ -89,6 +90,7 @@ FPGAProgramPart::FPGAProgramPart(TQWidget *parentWidget, const char *widgetName,
m_base = new FPGAProgramBase(widget());
// Initialize widgets
+ m_base->programmingLogBox->setReadOnly(true);
connect(m_base->programRunButton, SIGNAL(clicked()), this, SLOT(programRunButtonClicked()));
connect(m_base->programmingInputFile, SIGNAL(textChanged(const TQString &)), this, SLOT(processLockouts()));
@@ -229,17 +231,21 @@ void FPGAProgramPart::finishConnectingToServer() {
// Connection established!
// Read magic number and proto version from server
m_socket->processPendingData();
- if (m_socket->bytesAvailable() > 0) {
+ if (m_socket->canReadFrame()) {
TQDataStream ds(m_socket);
+ ds.setPrintableData(true);
TQ_UINT32 magicnum;
TQ_UINT32 protover;
ds >> magicnum;
ds >> protover;
+ m_socket->clearFrameTail();
printf("[DEBUG] Got magic number %d and protocol version %d\n\r", magicnum, protover); fflush(stdout);
// Request connection to backend server
ds << TQString("SERV");
+ m_socket->writeEndOfFrame();
ds << TQString(CLIENT_LIBRARY);
+ m_socket->writeEndOfFrame();
connToServerState = 3;
}
break;
@@ -248,8 +254,10 @@ void FPGAProgramPart::finishConnectingToServer() {
m_socket->processPendingData();
if (m_socket->bytesAvailable() > 0) {
TQDataStream ds(m_socket);
+ ds.setPrintableData(true);
TQString response;
ds >> response;
+ m_socket->clearFrameTail();
if (response == "OK") {
connToServerState = 4;
connToServerConnecting = false;
@@ -312,9 +320,7 @@ void FPGAProgramPart::programRunButtonClicked() {
m_tickerState = 0; \
m_commHandlerState = 0; \
m_commHandlerMode = 0; \
- while (m_socket->bytesAvailable() > 0) { \
- m_socket->readBlock(data, 64); \
- } \
+ m_socket->clearIncomingData(); \
setStatusMessage(i18n("Server ping timeout. Please verify the status of your network connection.")); \
m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE); \
m_connectionMutex->unlock(); \
@@ -323,8 +329,33 @@ void FPGAProgramPart::programRunButtonClicked() {
#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::setTickerMessage(TQString message) {
+ m_connectionActiveAndValid = true;
+ TQString tickerChar;
+ switch (m_tickerState) {
+ case 0:
+ tickerChar = "-";
+ break;
+ case 1:
+ tickerChar = "\\";
+ break;
+ case 2:
+ tickerChar = "|";
+ break;
+ case 3:
+ tickerChar = "/";
+ break;
+ }
+ setStatusMessage(message + TQString("... %1").arg(tickerChar));
+ m_tickerState++;
+ if (m_tickerState > 3) {
+ m_tickerState = 0;
+ }
+}
+
void FPGAProgramPart::mainEventLoop() {
TQDataStream ds(m_socket);
+ ds.setPrintableData(true);
if (!m_connectionMutex->tryLock()) {
TQTimer::singleShot(0, this, SLOT(mainEventLoop())); // Handle the concurrently received call immediately after current execution
@@ -332,59 +363,49 @@ void FPGAProgramPart::mainEventLoop() {
}
if (m_socket) {
- char data[64];
-
if (m_commHandlerMode == 0) {
// Normal operation
switch (m_commHandlerState) {
case 0:
// Get status of remote system
- // RAJA FIXME
-
+ // Clear buffers to synchronize frames in case of data corruption
+ m_socket->clearIncomingData();
ds << TQString("STATUS");
+ m_socket->writeEndOfFrame();
m_commHandlerState = 1;
break;
case 1:
// Get all data
- if (m_socket->bytesAvailable() > 0) {
+ if (m_socket->canReadFrame()) {
PAT_WATCHDOG_TIMER
- // RAJA FIXME
TQString status;
ds >> status;
-
-printf("[RAJA DEBUG 106.0] Status: '%s'\n\r", status.ascii()); fflush(stdout);
+ m_socket->clearFrameTail();
if (status == "") {
// Transfer probably failed
UPDATEDISPLAY_TIMEOUT
}
-
- m_connectionActiveAndValid = true;
- TQString tickerChar;
- switch (m_tickerState) {
- case 0:
- tickerChar = "-";
- break;
- case 1:
- tickerChar = "\\";
- break;
- case 2:
- tickerChar = "|";
- break;
- case 3:
- tickerChar = "/";
- break;
+ else if (status == "IDLE") {
+ // Do nothing
}
- setStatusMessage(i18n("Running") + TQString("... %1").arg(tickerChar));
- m_tickerState++;
- if (m_tickerState > 3) {
- m_tickerState = 0;
+ else if (status == "LOGMESSAGES") {
+ // Fire next event loop immediately
+ TQTimer::singleShot(0, this, SLOT(mainEventLoop()));
+ // Retrieve messages on next event loop
+ m_commHandlerState = 3;
+ m_commHandlerNextState = 2;
+ m_commHandlerNextMode = 0;
}
- m_pingDelayTimer->start(250, TRUE);
- m_commHandlerState = 2;
+ setTickerMessage(i18n("Connected"));
+
+ if (m_commHandlerState == 1) {
+ m_pingDelayTimer->start(250, TRUE);
+ m_commHandlerState = 2;
+ }
}
else {
if (!m_updateTimeoutTimer->isActive()) {
@@ -393,6 +414,7 @@ printf("[RAJA DEBUG 106.0] Status: '%s'\n\r", status.ascii()); fflush(stdout);
}
break;
case 2:
+ // Let the client and server rest for a bit to lower CPU/network overhead
if (!m_pingDelayTimer->isActive()) {
// Fire next event loop immediately
TQTimer::singleShot(0, this, SLOT(mainEventLoop()));
@@ -401,11 +423,37 @@ printf("[RAJA DEBUG 106.0] Status: '%s'\n\r", status.ascii()); fflush(stdout);
}
PAT_WATCHDOG_TIMER
break;
+ case 3:
+ // Get new log messages
+ if (m_socket->canReadFrame()) {
+ PAT_WATCHDOG_TIMER
+
+ TQString messages;
+ ds >> messages;
+ m_socket->clearFrameTail();
+
+ if (messages == "") {
+ // Transfer probably failed
+ UPDATEDISPLAY_TIMEOUT
+ }
+ else {
+ m_base->programmingLogBox->append(messages);
+
+ m_pingDelayTimer->start(250, TRUE);
+ m_commHandlerState = m_commHandlerNextState;
+ m_commHandlerMode = m_commHandlerNextMode;
+ }
+ }
+ else {
+ if (!m_updateTimeoutTimer->isActive()) {
+ UPDATEDISPLAY_TIMEOUT
+ }
+ }
+ break;
}
}
else if (m_commHandlerMode == 1) {
// Program mode!
- // RAJA FIXME
if (m_commHandlerState == 0) {
m_base->programmingStatusLabel->setText(i18n("Reading input file") + "...");
TQFile file(m_base->programmingInputFile->url());
@@ -413,15 +461,18 @@ printf("[RAJA DEBUG 106.0] Status: '%s'\n\r", status.ascii()); fflush(stdout);
m_programmingFileData = file.readAll();
file.close();
+ // Busy indicator
m_base->programmingProgressBar->setTotalSteps(0);
m_base->programmingProgressBar->setProgress(0);
// Transmit file to remote server
m_base->programmingStatusLabel->setText(i18n("Sending data to server") + "...");
ds << TQString("FILE");
+ m_socket->writeEndOfFrame();
m_programmingFileTotalSize = m_programmingFileData.size();
m_programmingFileTransferredBytes = 0;
ds << m_programmingFileTotalSize;
+ m_socket->writeEndOfFrame();
m_base->programmingProgressBar->setTotalSteps(m_programmingFileTotalSize);
m_commHandlerState = 1;
@@ -430,16 +481,17 @@ printf("[RAJA DEBUG 106.0] Status: '%s'\n\r", status.ascii()); fflush(stdout);
KMessageBox::error(0, i18n("<qt>Unable to open selected programming file</qt>"), i18n("Program Failed"));
m_commHandlerMode = 0;
m_commHandlerState = 0;
- m_base->programmingProgressBar->setTotalSteps(1);
- m_base->programmingProgressBar->setProgress(0);
+ m_base->programmingProgressBar->reset();
processLockouts();
}
+ PAT_WATCHDOG_TIMER
}
else if (m_commHandlerState == 1) {
TQ_ULONG bytesLeft = (m_programmingFileTotalSize-m_programmingFileTransferredBytes);
TQ_ULONG bytesToTransfer = bytesLeft;
- if (bytesToTransfer > 512) {
- bytesToTransfer = 512;
+ TQ_ULONG maxTransferChunk = maximumSocketDataChunkSize();
+ if (bytesToTransfer > maxTransferChunk) {
+ bytesToTransfer = maxTransferChunk;
}
m_programmingFileTransferredBytes = m_programmingFileTransferredBytes + m_socket->writeBlock(m_programmingFileData.data()+m_programmingFileTransferredBytes, bytesToTransfer);
m_base->programmingProgressBar->setProgress(m_programmingFileTransferredBytes);
@@ -447,86 +499,108 @@ printf("[RAJA DEBUG 106.0] Status: '%s'\n\r", status.ascii()); fflush(stdout);
// Initiate programming
m_base->programmingStatusLabel->setText(i18n("Programming device") + "...");
ds << TQString("PROGRAM");
+ m_socket->writeEndOfFrame();
// Request status
ds << TQString("STATUS");
+ m_socket->writeEndOfFrame();
+
+ // Busy indicator
+ m_base->programmingProgressBar->setTotalSteps(0);
+ m_base->programmingProgressBar->setProgress(0);
m_commHandlerState = 2;
}
else {
+ setTickerMessage(i18n("Transmitting data"));
// Fire next event loop immediately
TQTimer::singleShot(0, this, SLOT(mainEventLoop()));
}
+ PAT_WATCHDOG_TIMER
}
else if (m_commHandlerState == 2) {
// Get response
- if (m_socket->bytesAvailable() > 0) {
+ if (m_socket->canReadFrame()) {
PAT_WATCHDOG_TIMER
- // RAJA FIXME
TQString result;
ds >> result;
+ m_socket->clearFrameTail();
if (result == "PROGRAMMING") {
+ setTickerMessage(i18n("Programming device"));
// Request status
ds << TQString("STATUS");
+ m_socket->writeEndOfFrame();
+ }
+ else if (result == "LOGMESSAGES") {
+ // Fire next event loop immediately
+ TQTimer::singleShot(0, this, SLOT(mainEventLoop()));
+ // Retrieve messages on next event loop
+ m_commHandlerState = 3;
+ m_commHandlerMode = 0;
+ m_commHandlerNextState = 3;
+ m_commHandlerNextMode = 1;
}
else if (result == "DONE") {
- int retCode;
+ TQ_INT32 retCode;
TQString log;
ds >> retCode;
- ds >> log;
+ m_socket->clearFrameTail();
- // RAJA FIXME
- // Handle errors
- // This does not update the log as it should!
- if (retCode < 0) {
+ 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);
+ m_base->programmingProgressBar->reset();
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 (result == "") {
- // Transfer probably failed
- // Do nothing
+ else {
+ // Done!
+ m_commHandlerMode = 0;
+ m_commHandlerState = 0;
+ TQTimer::singleShot(0, this, SLOT(mainEventLoop()));
+ m_base->programmingProgressBar->reset();
+ processLockouts();
+ }
}
- else {
+ else if (result == "ERROR") {
// Error!
m_commHandlerMode = 0;
m_commHandlerState = 0;
TQTimer::singleShot(0, this, SLOT(mainEventLoop()));
- m_base->programmingProgressBar->setTotalSteps(1);
- m_base->programmingProgressBar->setProgress(0);
+ m_base->programmingProgressBar->reset();
KMessageBox::error(0, i18n("<qt>Unknown error</qt>"), i18n("Program Failed"));
processLockouts();
}
+ else {
+ // Unknown response
+ // Request status
+ ds << TQString("STATUS");
+ m_socket->writeEndOfFrame();
+ }
}
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);
+ m_base->programmingProgressBar->reset();
processLockouts();
UPDATEDISPLAY_TIMEOUT
}
}
}
+ else if (m_commHandlerState == 3) {
+ // Request status
+ ds << TQString("STATUS");
+ m_socket->writeEndOfFrame();
+ m_commHandlerState = 2;
+ PAT_WATCHDOG_TIMER
+ }
}
SET_WATCHDOG_TIMER
diff --git a/clients/tde/src/part/fpgaprogram/part.h b/clients/tde/src/part/fpgaprogram/part.h
index 05f3431..db74e62 100644
--- a/clients/tde/src/part/fpgaprogram/part.h
+++ b/clients/tde/src/part/fpgaprogram/part.h
@@ -72,6 +72,7 @@ namespace RemoteLab
void connectionClosed();
void disconnectFromServer();
void finishConnectingToServer();
+ void setTickerMessage(TQString message);
void programRunButtonClicked();
@@ -89,6 +90,8 @@ namespace RemoteLab
int m_commHandlerState;
int m_commHandlerMode;
+ int m_commHandlerNextState;
+ int m_commHandlerNextMode;
bool m_connectionActiveAndValid;
unsigned char m_tickerState;
TQByteArray m_programmingFileData;
diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp
index e4a56d4..7ac5dbf 100644
--- a/clients/tde/src/part/fpgaview/part.cpp
+++ b/clients/tde/src/part/fpgaview/part.cpp
@@ -1061,17 +1061,21 @@ void FPGAViewPart::finishConnectingToServer() {
// Connection established!
// Read magic number and proto version from server
m_socket->processPendingData();
- if (m_socket->bytesAvailable() > 0) {
+ if (m_socket->canReadFrame()) {
TQDataStream ds(m_socket);
+ ds.setPrintableData(true);
TQ_UINT32 magicnum;
TQ_UINT32 protover;
ds >> magicnum;
ds >> protover;
+ m_socket->clearFrameTail();
printf("[DEBUG] Got magic number %d and protocol version %d\n\r", magicnum, protover); fflush(stdout);
// Request connection to backend server
ds << TQString("SERV");
+ m_socket->writeEndOfFrame();
ds << TQString(CLIENT_LIBRARY);
+ m_socket->writeEndOfFrame();
connToServerState = 3;
}
break;
@@ -1080,8 +1084,10 @@ void FPGAViewPart::finishConnectingToServer() {
m_socket->processPendingData();
if (m_socket->bytesAvailable() > 0) {
TQDataStream ds(m_socket);
+ ds.setPrintableData(true);
TQString response;
ds >> response;
+ m_socket->clearFrameTail();
printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r", response.ascii()); fflush(stdout);
if (response == "OK") {
connToServerState = 4;
@@ -1332,7 +1338,7 @@ void FPGAViewPart::updateDisplay() {
KMessageBox::error(0, i18n("<qt>Unable to open selected batch output file</qt>"), i18n("Batch Failed"));
m_commHandlerMode = 0;
m_commHandlerState = 0;
- m_base->batchTestProgressBar->setProgress(0);
+ m_base->batchTestProgressBar->reset();
processLockouts();
}
}
@@ -1340,7 +1346,7 @@ void FPGAViewPart::updateDisplay() {
KMessageBox::error(0, i18n("<qt>Unable to open selected batch input file</qt>"), i18n("Batch Failed"));
m_commHandlerMode = 0;
m_commHandlerState = 0;
- m_base->batchTestProgressBar->setProgress(0);
+ m_base->batchTestProgressBar->reset();
processLockouts();
}
}
@@ -1353,7 +1359,7 @@ void FPGAViewPart::updateDisplay() {
m_batchOutputFile = NULL;
m_commHandlerMode = 0;
m_commHandlerState = 0;
- m_base->batchTestProgressBar->setProgress(0);
+ m_base->batchTestProgressBar->reset();
processLockouts();
}
else {
@@ -1403,7 +1409,7 @@ void FPGAViewPart::updateDisplay() {
m_batchOutputFile->close();
delete m_batchOutputFile;
m_batchOutputFile = NULL;
- m_base->batchTestProgressBar->setProgress(0);
+ m_base->batchTestProgressBar->reset();
m_commHandlerMode = 0;
m_commHandlerState = 0;
processLockouts();
@@ -1476,8 +1482,7 @@ void FPGAViewPart::updateDisplay() {
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);
+ m_base->dataProcessingProgressBar->reset();
processLockouts();
}
}
@@ -1485,8 +1490,7 @@ void FPGAViewPart::updateDisplay() {
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);
+ m_base->dataProcessingProgressBar->reset();
processLockouts();
}
}
@@ -1494,8 +1498,7 @@ void FPGAViewPart::updateDisplay() {
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);
+ m_base->dataProcessingProgressBar->reset();
processLockouts();
}
}
@@ -1546,8 +1549,7 @@ void FPGAViewPart::updateDisplay() {
m_dataOutputFile->close();
delete m_dataOutputFile;
m_dataOutputFile = NULL;
- m_base->dataProcessingProgressBar->setTotalSteps(1);
- m_base->dataProcessingProgressBar->setProgress(0);
+ m_base->dataProcessingProgressBar->reset();
m_commHandlerMode = 0;
m_commHandlerState = 0;
processLockouts();
@@ -1558,8 +1560,7 @@ void FPGAViewPart::updateDisplay() {
m_dataOutputFile->close();
delete m_dataOutputFile;
m_dataOutputFile = NULL;
- m_base->dataProcessingProgressBar->setTotalSteps(1);
- m_base->dataProcessingProgressBar->setProgress(0);
+ m_base->dataProcessingProgressBar->reset();
m_commHandlerMode = 0;
m_commHandlerState = 0;
processLockouts();