summaryrefslogtreecommitdiffstats
path: root/clients/tde/src/app/remotemdi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clients/tde/src/app/remotemdi.cpp')
-rw-r--r--clients/tde/src/app/remotemdi.cpp67
1 files changed, 37 insertions, 30 deletions
diff --git a/clients/tde/src/app/remotemdi.cpp b/clients/tde/src/app/remotemdi.cpp
index ae06857..1df78df 100644
--- a/clients/tde/src/app/remotemdi.cpp
+++ b/clients/tde/src/app/remotemdi.cpp
@@ -29,7 +29,7 @@ using namespace std;
#include "views/instrumentview.h"
RemoteMDI::RemoteMDI()
- : KMdiMainFrm(0, "RemoteMDI", KMdi::ChildframeMode), m_children(NULL), m_rsvSvrSocket(NULL)
+ : KMdiMainFrm(0, "RemoteMDI", KMdi::ChildframeMode), m_children(0), m_rsvSvrSocket(NULL)
{
setXMLFile("remotelabui.rc");
@@ -42,9 +42,9 @@ RemoteMDI::RemoteMDI()
KStdAction::quit(TQT_TQOBJECT(this), TQT_SLOT(close()), ac);
KStdAction::configureToolbars(TQT_TQOBJECT(this), TQT_SLOT(configToolbars()), ac);
KStdAction::keyBindings(TQT_TQOBJECT(this), TQT_SLOT(configKeys()), ac);
- connect_action = new KAction(i18n("Connect to Server"), "connect_creating", NULL, TQT_TQOBJECT(this), TQT_SLOT(connectToServer()), ac, "connect_server");
- disconnect_action = new KAction(i18n("Disconnect from Server"), "connect_no", NULL, TQT_TQOBJECT(this), TQT_SLOT(disconnectFromServer()), ac, "disconnect_server");
- inst_sa_menu = new KAction(i18n("Launch Spectrum Analyzer"), "remote", NULL, TQT_TQOBJECT(this), TQT_SLOT(startSpectrumAnalyzer()), ac, "spectrum_analyzer");
+ connect_action = new KAction(i18n("Connect to Server"), "connect_creating", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(connectToServer()), ac, "connect_server");
+ disconnect_action = new KAction(i18n("Disconnect from Server"), "connect_no", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(disconnectFromServer()), ac, "disconnect_server");
+ inst_sa_menu = new KAction(i18n("Launch Spectrum Analyzer"), "remote", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(startSpectrumAnalyzer()), ac, "spectrum_analyzer");
// Add Window menu
if ( !isFakingSDIApplication() ) {
@@ -85,21 +85,24 @@ RemoteMDI::~RemoteMDI()
while (m_rsvSvrSocket->state() == TQSocket::Closing) {
tqApp->processEvents();
}
- delete m_rsvSvrSocket;
}
}
void RemoteMDI::connectToServer() {
if (m_rsvSvrSocket) {
- return;
+ if (m_rsvSvrSocket->state() != TQSocket::Idle) {
+ return;
+ }
}
connect_action->setEnabled(false);
disconnect_action->setEnabled(false);
// Connect to the central reservation/control server
- m_rsvSvrSocket = new TDEKerberosClientSocket(this);
- connect(m_rsvSvrSocket, SIGNAL(connectionClosed()), this, SLOT(connectionClosedHandler()));
+ if (!m_rsvSvrSocket) {
+ m_rsvSvrSocket = new TDEKerberosClientSocket(this);
+ connect(m_rsvSvrSocket, SIGNAL(connectionClosed()), this, SLOT(connectionClosedHandler()));
+ }
m_rsvSvrSocket->setServiceName("remotefpga");
if (m_serverHost != "") {
m_rsvSvrSocket->setServerFQDN(m_serverHost);
@@ -116,18 +119,16 @@ void RemoteMDI::connectToServer() {
else {
// Connection established!
// Read magic number and proto version from server
- TQDataStream ds(m_rsvSvrSocket);
+ TQDataStream* ds = new TQDataStream(m_rsvSvrSocket);
TQ_UINT32 magicnum;
TQ_UINT32 protover;
- ds >> magicnum;
- ds >> protover;
- printf("[RAJA DEBUG 200.0] Got magic %d and proto %d\n\r", magicnum, protover); fflush(stdout);
+ *ds >> magicnum;
+ *ds >> protover;
+ 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)) {
disconnect_action->setEnabled(true);
-
- // Read the next line from the server
- TQString str = m_rsvSvrSocket->readLine();
- printf("[RAJA DEBUG 200.1] Got %s\n\r", str.ascii()); fflush(stdout);
+ promptForStationType();
}
else {
disconnectFromServer();
@@ -148,6 +149,24 @@ void RemoteMDI::connectToServer() {
processLockouts();
}
+void RemoteMDI::promptForStationType() {
+ if (!m_rsvSvrSocket) {
+ return;
+ }
+ if (m_rsvSvrSocket->state() != TQSocket::Connected) {
+ return;
+ }
+
+ TQDataStream ds(m_rsvSvrSocket);
+
+ // Request list of laboratory stations
+ StationList slist;
+ ds << TQString("LIST");
+ ds >> slist;
+
+ printf("[RAJA DEBUG 200.2] Got list of stations, count is %d\n\r", slist.count()); fflush(stdout);
+}
+
void RemoteMDI::disconnectFromServer() {
connect_action->setEnabled(false);
disconnect_action->setEnabled(false);
@@ -157,8 +176,6 @@ void RemoteMDI::disconnectFromServer() {
while (m_rsvSvrSocket->state() == TQSocket::Closing) {
tqApp->processEvents();
}
- delete m_rsvSvrSocket;
- m_rsvSvrSocket = 0;
}
connect_action->setEnabled(true);
@@ -239,20 +256,10 @@ void RemoteMDI::openNewWindow(KMdiChildView *view)
void RemoteMDI::childWindowCloseRequest(KMdiChildView *pWnd) {
RemoteLab::InstrumentView* iview = dynamic_cast<RemoteLab::InstrumentView*>(pWnd);
if (iview) {
+ // Give the child a chance to finish what it was doing and exit cleanly (i.e. without crashing!)
iview->closeConnections();
iview->hide();
- // Give the child a chance to finish what it was doing
- // FIXME HACK
- // There is no nice way to shut down the instrument parts it seems...
- // Debug why they crash when this delay is set to zero!
- m_closelist.append(pWnd);
- TQTimer::singleShot(100, this, SLOT(processCloseList()));
- }
-}
-
-void RemoteMDI::processCloseList() {
- if (m_closelist.begin() != m_closelist.end()) {
- KMdiMainFrm::childWindowCloseRequest(*m_closelist.begin());
+ KMdiMainFrm::childWindowCloseRequest(pWnd);
}
}