summaryrefslogtreecommitdiffstats
path: root/clients/tde/src/part/fpgaview
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/part/fpgaview
parentfc455268a511d91113f59c04b50fa08b7c37b554 (diff)
downloadulab-83ded525e622feb0318c93d64012882e649568f6.tar.gz
ulab-83ded525e622feb0318c93d64012882e649568f6.zip
Move part connection and disconnection code into tqtrla library
Diffstat (limited to 'clients/tde/src/part/fpgaview')
-rw-r--r--clients/tde/src/part/fpgaview/part.cpp161
-rw-r--r--clients/tde/src/part/fpgaview/part.h12
2 files changed, 21 insertions, 152 deletions
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;