summaryrefslogtreecommitdiffstats
path: root/clients/tde/src
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-09 18:42:52 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-09 18:42:52 -0500
commit83ded525e622feb0318c93d64012882e649568f6 (patch)
treece2b13b9b54af601adf71c0b91a331cb0d5ce743 /clients/tde/src
parentfc455268a511d91113f59c04b50fa08b7c37b554 (diff)
downloadulab-83ded525e622feb0318c93d64012882e649568f6.tar.gz
ulab-83ded525e622feb0318c93d64012882e649568f6.zip
Move part connection and disconnection code into tqtrla library
Diffstat (limited to 'clients/tde/src')
-rw-r--r--clients/tde/src/app/views/instrumentview.cpp3
-rw-r--r--clients/tde/src/part/fpgaprogram/part.cpp170
-rw-r--r--clients/tde/src/part/fpgaprogram/part.h12
-rw-r--r--clients/tde/src/part/fpgaview/part.cpp161
-rw-r--r--clients/tde/src/part/fpgaview/part.h12
5 files changed, 43 insertions, 315 deletions
diff --git a/clients/tde/src/app/views/instrumentview.cpp b/clients/tde/src/app/views/instrumentview.cpp
index 191444d..b2fd5db 100644
--- a/clients/tde/src/app/views/instrumentview.cpp
+++ b/clients/tde/src/app/views/instrumentview.cpp
@@ -75,10 +75,7 @@ bool InstrumentView::queryExit() {
return true;
}
-printf("[RAJA DEBUG 700.0] In InstrumentView::queryExit\n\r"); fflush(stdout);
m_instrumentPart->closeURL();
-printf("[RAJA DEBUG 700.1] In InstrumentView::queryExit\n\r"); fflush(stdout);
-
return true;
}
diff --git a/clients/tde/src/part/fpgaprogram/part.cpp b/clients/tde/src/part/fpgaprogram/part.cpp
index f70ab49..6723952 100644
--- a/clients/tde/src/part/fpgaprogram/part.cpp
+++ b/clients/tde/src/part/fpgaprogram/part.cpp
@@ -54,12 +54,7 @@
#include "floatspinbox.h"
#include "layout.h"
-// RAJA UNCOMMENT ME
-//#define SERVER_TIMEOUT_MS 10000
-// RAJA DEBUG ONLY
-#define SERVER_TIMEOUT_MS 100000
#define NETWORK_COMM_TIMEOUT_MS 2500
-#define FPGA_DATA_PROCESSING_TIMEOUT_MS 2500
namespace RemoteLab {
@@ -68,9 +63,11 @@ typedef KParts::GenericFactory<RemoteLab::FPGAProgramPart> Factory;
K_EXPORT_COMPONENT_FACTORY(libremotelab_fpgaprogrammer, RemoteLab::Factory)
FPGAProgramPart::FPGAProgramPart(TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQStringList&)
- : RemoteInstrumentPart( parent, name ), m_socket(0), m_base(0), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL),
- m_commHandlerState(0), m_connectionActiveAndValid(false), m_tickerState(0)
+ : RemoteInstrumentPart( parent, name ), m_base(NULL), m_commHandlerState(0), m_connectionActiveAndValid(false), m_tickerState(0)
{
+ // Initialize important base class variables
+ m_clientLibraryName = CLIENT_LIBRARY;
+
// Initialize mutex
m_connectionMutex = new TQMutex(false);
@@ -79,8 +76,6 @@ FPGAProgramPart::FPGAProgramPart(TQWidget *parentWidget, const char *widgetName,
setWidget(new TQVBox(parentWidget, widgetName));
// Create timers
- 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);
@@ -161,153 +156,26 @@ bool FPGAProgramPart::closeURL() {
return true;
}
-void FPGAProgramPart::disconnectFromServer() {
- m_connectionTimer->stop();
+void FPGAProgramPart::disconnectFromServerCallback() {
m_updateTimeoutTimer->stop();
- if (m_socket) {
- m_socket->clearPendingData();
- m_socket->close();
- delete m_socket;
- m_socket = NULL;
- }
- processLockouts();
}
-void FPGAProgramPart::finishConnectingToServer() {
- if (!m_socket) {
- connToServerState = -1;
- connToServerConnecting = false;
- processLockouts();
- return;
- }
-
- if (connToServerConnecting) {
- switch(connToServerState) {
- case 0:
- if (!connToServerTimeoutTimer) {
- connToServerTimeoutTimer = new TQTimer;
- connToServerTimeoutTimer->start(SERVER_TIMEOUT_MS, TRUE);
- }
- if ((m_socket->state() == TQSocket::Connecting) || (m_socket->state() == TQSocket::HostLookup)) {
- if (!connToServerTimeoutTimer->isActive()) {
- connToServerState = -3;
- connToServerConnecting = false;
- disconnectFromServer();
- KMessageBox::error(0, i18n("<qt>Unable to establish connection to remote server</qt>"), i18n("Connection Failed"));
- }
- }
- else {
- if (m_socket->state() == TQSocket::Connected) {
- printf("[DEBUG] Initial connection established...\n\r"); fflush(stdout);
- m_socket->setDataTimeout(SERVER_TIMEOUT_MS);
- m_socket->setUsingKerberos(true);
- connToServerState = 1;
- }
- else {
- connToServerState = -1;
- connToServerConnecting = false;
- disconnectFromServer();
- KMessageBox::error(0, i18n("<qt>Unable to establish connection to remote server</qt>"), i18n("Connection Failed"));
- }
- }
- break;
- case 1:
- if (m_socket->kerberosStatus() == TDEKerberosClientSocket::KerberosInitializing) {
- // Do nothing
- }
- else {
- if (m_socket->kerberosStatus() != TDEKerberosClientSocket::KerberosInUse) {
- connToServerState = -1;
- connToServerConnecting = false;
- disconnectFromServer();
- KMessageBox::error(0, 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 {
- connToServerState = 2;
- }
- }
- break;
- case 2:
- // Connection established!
- // Read magic number and proto version from server
- m_socket->processPendingData();
- 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;
- case 3:
- // Read response from server
- 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;
- 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_socket->setDataTimeout(NETWORK_COMM_TIMEOUT_MS);
- m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE);
- processLockouts();
- mainEventLoop();
- return;
- }
- else {
- TQStringList errorStrings = textForServerError(response);
- connToServerState = -1;
- connToServerConnecting = false;
- disconnectFromServer();
- KMessageBox::error(0, errorStrings[0], errorStrings[1]);
- close();
- return;
- }
- }
- break;
- }
-
- m_connectionTimer->start(100, TRUE);
- }
+void FPGAProgramPart::connectionFinishedCallback() {
+ 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_socket->setDataTimeout(NETWORK_COMM_TIMEOUT_MS);
+ m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE);
+ processLockouts();
+ mainEventLoop();
+ return;
}
-int FPGAProgramPart::connectToServer(TQString server) {
- if (m_socket) {
- return -1;
- }
- if (!m_socket) {
- m_socket = new TDEKerberosClientSocket(this);
- connect(m_socket, TQT_SIGNAL(statusMessageUpdated(const TQString&)), this, TQT_SLOT(setStatusMessage(const TQString&) ));
- }
- m_socket->setServiceName("remotefpga");
- m_socket->setServerFQDN(server);
- m_socket->connectToHost(server, 4004);
-
- // Finish connecting when appropriate
- connToServerState = 0;
- connToServerConnecting = true;
- m_connectionTimer->start(100, TRUE);
-
- return 0;
+void FPGAProgramPart::connectionStatusChangedCallback() {
+ processLockouts();
}
void FPGAProgramPart::programRunButtonClicked() {
diff --git a/clients/tde/src/part/fpgaprogram/part.h b/clients/tde/src/part/fpgaprogram/part.h
index db74e62..2a0880c 100644
--- a/clients/tde/src/part/fpgaprogram/part.h
+++ b/clients/tde/src/part/fpgaprogram/part.h
@@ -59,7 +59,6 @@ namespace RemoteLab
virtual bool openFile() { return false; } // pure virtual in the base class
virtual bool closeURL();
static KAboutData *createAboutData();
- int connectToServer(TQString server);
public slots:
virtual bool openURL(const KURL &url);
@@ -70,24 +69,19 @@ namespace RemoteLab
void mainEventLoop();
void processLockouts();
void connectionClosed();
- void disconnectFromServer();
- void finishConnectingToServer();
+ void connectionFinishedCallback();
+ void disconnectFromServerCallback();
+ void connectionStatusChangedCallback();
void setTickerMessage(TQString message);
void programRunButtonClicked();
private:
- TDEKerberosClientSocket* m_socket;
FPGAProgramBase* m_base;
TQMutex* m_connectionMutex;
- TQTimer* m_connectionTimer;
TQTimer* m_pingDelayTimer;
TQTimer* m_updateTimeoutTimer;
- bool connToServerConnecting;
- int connToServerState;
- TQTimer *connToServerTimeoutTimer;
-
int m_commHandlerState;
int m_commHandlerMode;
int m_commHandlerNextState;
diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp
index 7ac5dbf..e833f98 100644
--- a/clients/tde/src/part/fpgaview/part.cpp
+++ b/clients/tde/src/part/fpgaview/part.cpp
@@ -563,12 +563,15 @@ K_EXPORT_COMPONENT_FACTORY(libremotelab_fpgaviewer, RemoteLab::Factory)
#define LED_SIZE LED_BASE_SIZE,LED_BASE_SIZE
FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQStringList&)
- : RemoteInstrumentPart( parent, name ), m_socket(0), m_base(0), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL), m_interfaceMode(BasicInterfaceMode),
+ : RemoteInstrumentPart( parent, name ), m_base(NULL), m_interfaceMode(BasicInterfaceMode),
m_commHandlerState(0), m_commHandlerMode(0), m_connectionActiveAndValid(false), m_tickerState(0), m_remoteInputModeEnabled(false), m_4bitInputValue(0), m_4bitOutputValue(0),
m_8bitInputValue(0), m_8bitOutputValue(0), m_16bitInputValue(0), m_16bitOutputValue(0), m_7segDigit3OutputValue(0xffffffff),
m_7segDigit2OutputValue(0xffffffff), m_7segDigit1OutputValue(0xffffffff), m_7segDigit0OutputValue(0xffffffff),
m_batchOutputFile(NULL), m_dataOutputFile(NULL)
{
+ // Initialize important base class variables
+ m_clientLibraryName = CLIENT_LIBRARY;
+
// Initialize mutex
m_connectionMutex = new TQMutex(false);
@@ -991,153 +994,25 @@ bool FPGAViewPart::closeURL() {
return true;
}
-void FPGAViewPart::disconnectFromServer() {
- m_connectionTimer->stop();
+void FPGAViewPart::disconnectFromServerCallback() {
m_updateTimer->stop();
- if (m_socket) {
- m_socket->clearPendingData();
- m_socket->close();
- delete m_socket;
- m_socket = NULL;
- }
- processLockouts();
}
-void FPGAViewPart::finishConnectingToServer() {
- if (!m_socket) {
- connToServerState = -1;
- connToServerConnecting = false;
- processLockouts();
- return;
- }
-
- if (connToServerConnecting) {
- switch(connToServerState) {
- case 0:
- if (!connToServerTimeoutTimer) {
- connToServerTimeoutTimer = new TQTimer;
- connToServerTimeoutTimer->start(SERVER_TIMEOUT_MS, TRUE);
- }
- if ((m_socket->state() == TQSocket::Connecting) || (m_socket->state() == TQSocket::HostLookup)) {
- if (!connToServerTimeoutTimer->isActive()) {
- connToServerState = -3;
- connToServerConnecting = false;
- disconnectFromServer();
- KMessageBox::error(0, i18n("<qt>Unable to establish connection to remote server</qt>"), i18n("Connection Failed"));
- }
- }
- else {
- if (m_socket->state() == TQSocket::Connected) {
- printf("[DEBUG] Initial connection established...\n\r"); fflush(stdout);
- m_socket->setDataTimeout(SERVER_TIMEOUT_MS);
- m_socket->setUsingKerberos(true);
- connToServerState = 1;
- }
- else {
- connToServerState = -1;
- connToServerConnecting = false;
- disconnectFromServer();
- KMessageBox::error(0, i18n("<qt>Unable to establish connection to remote server</qt>"), i18n("Connection Failed"));
- }
- }
- break;
- case 1:
- if (m_socket->kerberosStatus() == TDEKerberosClientSocket::KerberosInitializing) {
- // Do nothing
- }
- else {
- if (m_socket->kerberosStatus() != TDEKerberosClientSocket::KerberosInUse) {
- connToServerState = -1;
- connToServerConnecting = false;
- disconnectFromServer();
- KMessageBox::error(0, 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 {
- connToServerState = 2;
- }
- }
- break;
- case 2:
- // Connection established!
- // Read magic number and proto version from server
- m_socket->processPendingData();
- 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;
- case 3:
- // Read response from server
- 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;
- 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;
- m_commHandlerMode = 0;
- m_updateTimer->start(FPGA_COMM_TIMEOUT_MS, FALSE);
- processLockouts();
- updateDisplay();
- return;
- }
- else {
- TQStringList errorStrings = textForServerError(response);
- connToServerState = -1;
- connToServerConnecting = false;
- disconnectFromServer();
- KMessageBox::error(0, errorStrings[0], errorStrings[1]);
- close();
- return;
- }
- }
- break;
- }
-
- m_connectionTimer->start(100, TRUE);
- }
+void FPGAViewPart::connectionFinishedCallback() {
+ 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;
+ m_commHandlerMode = 0;
+ m_updateTimer->start(FPGA_COMM_TIMEOUT_MS, FALSE);
+ processLockouts();
+ updateDisplay();
+ return;
}
-int FPGAViewPart::connectToServer(TQString server) {
- if (m_socket) {
- return -1;
- }
- if (!m_socket) {
- m_socket = new TDEKerberosClientSocket(this);
- connect(m_socket, TQT_SIGNAL(statusMessageUpdated(const TQString&)), this, TQT_SLOT(setStatusMessage(const TQString&) ));
- }
- m_socket->setServiceName("remotefpga");
- m_socket->setServerFQDN(server);
- m_socket->connectToHost(server, 4004);
-
- // Finish connecting when appropriate
- connToServerState = 0;
- connToServerConnecting = true;
- m_connectionTimer->start(100, TRUE);
-
- return 0;
+void FPGAViewPart::connectionStatusChangedCallback() {
+ processLockouts();
}
TQPtrList<KAction> FPGAViewPart::menuActionList() {
diff --git a/clients/tde/src/part/fpgaview/part.h b/clients/tde/src/part/fpgaview/part.h
index a0b0463..572cadc 100644
--- a/clients/tde/src/part/fpgaview/part.h
+++ b/clients/tde/src/part/fpgaview/part.h
@@ -147,7 +147,6 @@ namespace RemoteLab
virtual bool openFile() { return false; } // pure virtual in the base class
virtual bool closeURL();
static KAboutData *createAboutData();
- int connectToServer(TQString server);
virtual TQPtrList<KAction> menuActionList();
public slots:
@@ -159,8 +158,9 @@ namespace RemoteLab
void updateDisplay();
void processLockouts();
void connectionClosed();
- void disconnectFromServer();
- void finishConnectingToServer();
+ void connectionFinishedCallback();
+ void disconnectFromServerCallback();
+ void connectionStatusChangedCallback();
void switchToBasicMode();
void switchToIntermediateMode();
void switchToAdvancedMode();
@@ -183,16 +183,10 @@ namespace RemoteLab
void receiveInputStatesFromRemoteFPGA();
private:
- TDEKerberosClientSocket* m_socket;
FPGAViewBase* m_base;
TQMutex* m_connectionMutex;
- TQTimer* m_connectionTimer;
TQTimer* m_updateTimer;
- bool connToServerConnecting;
- int connToServerState;
- TQTimer *connToServerTimeoutTimer;
-
TQPtrList<KAction> m_menuActionList;
KActionMenu* m_modeSubMenu;
KToggleAction* m_modeBasicEnabled;