|
|
|
@ -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 (result == "") {
|
|
|
|
|
// Transfer probably failed
|
|
|
|
|
// Do nothing
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (!m_updateTimer->isActive()) {
|
|
|
|
|
// 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() {
|
|
|
|
|