summaryrefslogtreecommitdiffstats
path: root/clients/tde
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-06-27 20:43:57 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-06-27 20:43:57 -0500
commit8392c611054a5bb058cd778163a7aa4ef8311c94 (patch)
tree5703e9d3ff12474fe474d37bb7c2532418c5b8aa /clients/tde
parente3bfbdc4e464d057be5095bb5bbd3240beab8ec6 (diff)
downloadulab-8392c611054a5bb058cd778163a7aa4ef8311c94.tar.gz
ulab-8392c611054a5bb058cd778163a7aa4ef8311c94.zip
Fix a number of problems
Diffstat (limited to 'clients/tde')
-rw-r--r--clients/tde/misc/remotelabui.rc32
-rw-r--r--clients/tde/src/app/remotemdi.cpp93
-rw-r--r--clients/tde/src/app/remotemdi.h5
-rw-r--r--clients/tde/src/app/views/instrumentview.cpp10
-rw-r--r--clients/tde/src/part/fpgaview/part.cpp105
-rw-r--r--clients/tde/src/part/fpgaview/part.h4
6 files changed, 185 insertions, 64 deletions
diff --git a/clients/tde/misc/remotelabui.rc b/clients/tde/misc/remotelabui.rc
index bd409b9..77b519a 100644
--- a/clients/tde/misc/remotelabui.rc
+++ b/clients/tde/misc/remotelabui.rc
@@ -6,30 +6,34 @@
<Action name="connect_server"/>
<Action name="disconnect_server"/>
</Menu>
- <Menu name="fpgaMenu">
- <text>Instrumentation</text>
- <Action name="fpga_viewer"/>
+ <Menu name="dutMenu">
+ <text>Device Under Test</text>
+ <ActionList name="dutMenu_actionlist"/>
</Menu>
<Menu name="instrumentMenu">
<text>Instrumentation</text>
- <Action name="oscilloscope"/>
- <Action name="frequency_generator"/>
- <Action name="spectrum_analyzer"/>
+ <ActionList name="instrumentMenu_actionlist"/>
+ </Menu>
+ <Menu name="serviceMenu">
+ <text>Services</text>
+ <ActionList name="serviceMenu_actionlist"/>
</Menu>
</MenuBar>
<ToolBar name="connectionToolBar" fullWidth="true" noMerge="1">
- <text>Instrumentation Toolbar</text>
+ <text>Connection</text>
<Action name="connect_server"/>
<Action name="disconnect_server"/>
</ToolBar>
- <ToolBar name="fpgaToolBar" fullWidth="true" noMerge="1">
- <text>Instrumentation Toolbar</text>
- <Action name="fpga_viewer"/>
+ <ToolBar name="dutToolBar" fullWidth="true" noMerge="1">
+ <text>Device Under Test</text>
+ <ActionList name="dutToolBar_actionlist"/>
</ToolBar>
<ToolBar name="instrumentToolBar" fullWidth="true" noMerge="1">
- <text>Instrumentation Toolbar</text>
- <Action name="oscilloscope"/>
- <Action name="frequency_generator"/>
- <Action name="spectrum_analyzer"/>
+ <text>Instrumentation</text>
+ <ActionList name="instrumentToolBar_actionlist"/>
+ </ToolBar>
+ <ToolBar name="serviceToolBar" fullWidth="true" noMerge="1">
+ <text>Services</text>
+ <ActionList name="serviceToolBar_actionlist"/>
</ToolBar>
</kpartgui> \ No newline at end of file
diff --git a/clients/tde/src/app/remotemdi.cpp b/clients/tde/src/app/remotemdi.cpp
index e6a65a3..11ab75e 100644
--- a/clients/tde/src/app/remotemdi.cpp
+++ b/clients/tde/src/app/remotemdi.cpp
@@ -45,8 +45,6 @@ RemoteMDI::RemoteMDI()
KStdAction::keyBindings(TQT_TQOBJECT(this), TQT_SLOT(configKeys()), ac);
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_fpgaviewer_menu = new KAction(i18n("Launch Spectrum Analyzer"), "remote", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(startSpectrumAnalyzer()), ac, "spectrum_analyzer");
- inst_sa_menu = new KAction(i18n("Launch FPGA Viewer"), "remote", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(startFPGAViewer()), ac, "fpga_viewer");
// Add Window menu
if ( !isFakingSDIApplication() ) {
@@ -65,6 +63,8 @@ RemoteMDI::RemoteMDI()
// Create the status bar
statusBar()->message(i18n("No view!"));
+ processActions();
+
processLockouts();
}
@@ -82,6 +82,61 @@ RemoteMDI::~RemoteMDI()
}
}
+void RemoteMDI::processActions() {
+ // Add dynamic actions
+ // RAJA FIXME
+ KActionCollection *const ac = actionCollection();
+
+ TQPtrList<KAction> dut_actions;
+ inst_fpgaviewer_menu = new KAction(i18n("Launch FPGA Viewer"), "remote", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(startModule()), ac, "libremotelab_fpgaviewer");
+ dut_actions.append(inst_fpgaviewer_menu);
+ unplugActionList("dutMenu_actionlist");
+ unplugActionList("dutToolBar_actionlist");
+ plugActionList("dutMenu_actionlist", dut_actions);
+ plugActionList("dutToolBar_actionlist", dut_actions);
+
+ TQPtrList<KAction> instrument_actions;
+ inst_sa_menu = new KAction(i18n("Launch Spectrum Analyzer"), "remote", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(startModule()), ac, "libremotelab_commanalyzer");
+ instrument_actions.append(inst_sa_menu);
+ unplugActionList("instrumentMenu_actionlist");
+ unplugActionList("instrumentToolBar_actionlist");
+ plugActionList("instrumentMenu_actionlist", instrument_actions);
+ plugActionList("instrumentToolBar_actionlist", instrument_actions);
+
+ TQPtrList<KAction> service_actions;
+ // Nothing here yet!
+ unplugActionList("serviceMenu_actionlist");
+ unplugActionList("serviceToolBar_actionlist");
+ plugActionList("serviceMenu_actionlist", service_actions);
+ plugActionList("serviceToolBar_actionlist", service_actions);
+}
+
+void RemoteMDI::startModule() {
+ const KAction* sendingAction = dynamic_cast<const KAction*>(sender());
+ if (sendingAction) {
+ // RAJA FIXME
+ bool serviceFound = false;
+ ServiceType st;
+ for (ServiceList::Iterator it(m_activeStation.services.begin()); it != m_activeStation.services.end(); ++it) {
+ st = *it;
+ if (st.clientLibrary == sendingAction->name()) {
+ serviceFound = true;
+ }
+ }
+
+ if (!serviceFound) {
+ KMessageBox::error(this, i18n("<qt>The active laboratory workspace does not support the requested service</qt>"), i18n("Service Unavailable"));
+ return;
+ }
+
+ RemoteLab::InstrumentView* view = new RemoteLab::InstrumentView(sendingAction->name(), st.name, (mdiMode() == KMdi::ToplevelMode) ? 0 : this);
+ openNewWindow(view);
+ if (m_serverHost != "") {
+ view->connectServer(m_serverHost);
+ }
+ }
+}
+
void RemoteMDI::connectToServer() {
if (m_rsvSvrSocket) {
if (m_rsvSvrSocket->state() != TQSocket::Idle) {
@@ -102,9 +157,15 @@ void RemoteMDI::connectToServer() {
if (m_serverHost != "") {
m_rsvSvrSocket->setServerFQDN(m_serverHost);
m_rsvSvrSocket->connectToHost(m_serverHost, 4004);
+ TQTimer connectionTimeout;
+ connectionTimeout.start(5000, TRUE);
while ((m_rsvSvrSocket->state() == TQSocket::Connecting) || (m_rsvSvrSocket->state() == TQSocket::HostLookup)) {
tqApp->processEvents();
+ if (!connectionTimeout.isActive()) {
+ break;
+ }
}
+ connectionTimeout.stop();
if (m_rsvSvrSocket->state() == TQSocket::Connected) {
printf("[DEBUG] Initial connection established...\n\r"); fflush(stdout);
if (m_rsvSvrSocket->setUsingKerberos(true) != 0) {
@@ -170,12 +231,17 @@ void RemoteMDI::promptForStationType() {
ds >> result;
printf("[RAJA DEBUG 100.0] '%s'\n\r", result.ascii()); fflush(stdout);
if (result == "OK") {
- // Success, do nothing
+ // Success!
+ m_activeStation = select.m_selectedStation;
}
else if (result == "ERRUNAVAL") {
KMessageBox::error(this, i18n("<qt>No stations of the specified type are currently available<p>Please try again later</qt>"), i18n("Insufficient Laboratory Resources"));
disconnectFromServer();
}
+ else if (result == "ERRPREVCN") {
+ KMessageBox::error(this, i18n("<qt>You are already connected to a laboratory station<p>Please disconnect and try again</qt>"), i18n("Multiple Connections Detected"));
+ disconnectFromServer();
+ }
else {
KMessageBox::error(this, i18n("<qt>Unknown server error<p>Please reconnect and try again</qt>"), i18n("Internal Error"));
disconnectFromServer();
@@ -204,9 +270,8 @@ void RemoteMDI::disconnectFromServer() {
if (m_rsvSvrSocket) {
m_rsvSvrSocket->clearPendingData();
m_rsvSvrSocket->close();
- while (m_rsvSvrSocket->state() == TQSocket::Closing) {
- tqApp->processEvents();
- }
+ delete m_rsvSvrSocket;
+ m_rsvSvrSocket = NULL;
}
connect_action->setEnabled(true);
@@ -249,22 +314,6 @@ void RemoteMDI::setServerHost(TQString server) {
m_serverHost = server;
}
-void RemoteMDI::startSpectrumAnalyzer() {
- RemoteLab::InstrumentView* saview = new RemoteLab::InstrumentView("libremotelab_commanalyzer", i18n("Communications Analyzer"), (mdiMode() == KMdi::ToplevelMode) ? 0 : this);
- openNewWindow(saview);
- if (m_serverHost != "") {
- saview->connectServer(m_serverHost);
- }
-}
-
-void RemoteMDI::startFPGAViewer() {
- RemoteLab::InstrumentView* fpgaview = new RemoteLab::InstrumentView("libremotelab_fpgaviewer", i18n("FPGA Viewer"), (mdiMode() == KMdi::ToplevelMode) ? 0 : this);
- openNewWindow(fpgaview);
- if (m_serverHost != "") {
- fpgaview->connectServer(m_serverHost);
- }
-}
-
void RemoteMDI::openNewWindow(KMdiChildView *view) {
// Add a child view
m_children++;
diff --git a/clients/tde/src/app/remotemdi.h b/clients/tde/src/app/remotemdi.h
index 84b5a82..a7b62b2 100644
--- a/clients/tde/src/app/remotemdi.h
+++ b/clients/tde/src/app/remotemdi.h
@@ -63,8 +63,8 @@ class RemoteMDI : public KMdiMainFrm
void promptForStationType();
void connectionClosedHandler();
void processLockouts();
- void startSpectrumAnalyzer();
- void startFPGAViewer();
+ void processActions();
+ void startModule();
protected:
virtual bool queryClose();
@@ -79,6 +79,7 @@ class RemoteMDI : public KMdiMainFrm
KAction *disconnect_action;
KAction *inst_sa_menu;
KAction *inst_fpgaviewer_menu;
+ StationType m_activeStation;
};
#endif // _REMOTEMDI_H_
diff --git a/clients/tde/src/app/views/instrumentview.cpp b/clients/tde/src/app/views/instrumentview.cpp
index 0b434d4..68b469a 100644
--- a/clients/tde/src/app/views/instrumentview.cpp
+++ b/clients/tde/src/app/views/instrumentview.cpp
@@ -33,9 +33,9 @@ InstrumentView::~InstrumentView() {
void InstrumentView::init() {
KLibFactory *factory = KLibLoader::self()->factory(m_libraryName.ascii());
-
+
if (!factory) {
- KMessageBox::error( this, i18n("TDE could not find the %1 part, or it could not be started. Did you 'make install'?").arg(m_libraryName) );
+ KMessageBox::error( this, i18n("TDE could not find the %1 Part, or the Remote Laboratory Communications Analyzer Part could not be started. Did you make install?").arg(m_libraryName) );
TQTimer::singleShot(0, this, SLOT(close()));
}
else {
@@ -58,7 +58,9 @@ void InstrumentView::closeConnections() {
void InstrumentView::connectServer(TQString server) {
if (m_instrumentPart) {
- m_instrumentPart->openURL(KURL(server));
+ if (m_instrumentPart->openURL(KURL(server))) {
+ close();
+ }
}
}
@@ -72,4 +74,4 @@ void InstrumentView::saveProperties( KConfig *config ) {
void InstrumentView::readProperties( KConfig *config ) {
}
-} //namespace RemoteLab
+} //namespace RemoteLab \ No newline at end of file
diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp
index dab2742..4eae27d 100644
--- a/clients/tde/src/part/fpgaview/part.cpp
+++ b/clients/tde/src/part/fpgaview/part.cpp
@@ -55,14 +55,15 @@ struct exit_exception {
namespace RemoteLab {
typedef KParts::GenericFactory<RemoteLab::FPGAViewPart> Factory;
-K_EXPORT_COMPONENT_FACTORY( libremotelab_fpgaviewer, RemoteLab::Factory )
+#define CLIENT_LIBRARY "libremotelab_fpgaviewer"
+K_EXPORT_COMPONENT_FACTORY(libremotelab_fpgaviewer, RemoteLab::Factory)
FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQStringList&)
: ReadOnlyPart( parent, name ), m_socket(0), m_base(0)
{
// Initialize mutex
- m_instrumentMutex = new TQMutex(false);
+ m_connectionMutex = new TQMutex(false);
// Initialize kpart
setInstance(Factory::instance());
@@ -74,19 +75,36 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj
// Create widgets
m_base = new FPGAViewBase(widget());
+ processLockouts();
+
TQTimer::singleShot(0, this, TQT_SLOT(postInit()));
}
FPGAViewPart::~FPGAViewPart() {
+ if (m_connectionMutex->locked()) {
+ throw exit_exception(-1);
+ }
+
if (m_socket) {
+ m_socket->clearPendingData();
m_socket->close();
- while (m_socket->state() == TQSocket::Closing) {
- tqApp->processEvents();
- }
delete m_socket;
+ m_socket = NULL;
+ }
+ delete m_connectionMutex;
+}
+
+void FPGAViewPart::processLockouts() {
+ if ((m_socket) && (m_socket->state() == TQSocket::Connected)) {
+ widget()->setEnabled(true);
+ }
+ else {
+ widget()->setEnabled(false);
}
+}
- delete m_instrumentMutex;
+void FPGAViewPart::connectionClosed() {
+ closeURL();
}
void FPGAViewPart::postInit() {
@@ -94,23 +112,27 @@ void FPGAViewPart::postInit() {
}
bool FPGAViewPart::openURL(const KURL &url) {
- return connectToServer(url.url());
+ int ret;
+ ret = connectToServer(url.url());
+ processLockouts();
+ return (ret != 0);
}
bool FPGAViewPart::closeURL() {
+ if (m_connectionMutex->locked()) {
+ throw exit_exception(-1);
+ }
+
if (m_socket) {
+ m_socket->clearPendingData();
m_socket->close();
-
- while (m_socket->state() != TQSocket::Idle) {
- tqApp->processEvents();
- }
+ delete m_socket;
+ m_socket = NULL;
}
- m_url = KURL();
+ processLockouts();
- if (m_instrumentMutex->locked()) {
- throw exit_exception(-1);
- }
+ m_url = KURL();
return true;
}
@@ -133,13 +155,54 @@ int FPGAViewPart::connectToServer(TQString server) {
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"));
return -1;
}
- TQDataStream ds(m_socket);
- // RAJA FIXME
- // How do we know which service to request?
-// ds << TQString("SERV");
-// ds <<
+ connect(m_socket, SIGNAL(connectionClosed()), this, SLOT(connectionClosed()));
+ try {
+ m_connectionMutex->lock();
+ TQString response;
+ TQDataStream ds(m_socket);
+ // Read magic number and proto version from server
+ TQ_UINT32 magicnum;
+ TQ_UINT32 protover;
+ ds >> magicnum;
+ ds >> protover;
+ printf("[DEBUG] Got magic number %d and protocol version %d\n\r", magicnum, protover); fflush(stdout);
+ // Request connection to backend server
+ ds << TQString("SERV");
+ ds << TQString(CLIENT_LIBRARY);
+ ds >> response;
+printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r", response.ascii()); fflush(stdout);
+ if (response == "OK") {
+ m_connectionMutex->unlock();
+ return 0;
+ }
+ else if (response == "ERRNOCONN") {
+ KMessageBox::error(0, i18n("<qt>Unable to establish connection with backend server<p>Please verify that you are currently connected to a workspace</qt>"), i18n("Connection Failed"));
+ m_connectionMutex->unlock();
+ return -1;
+ }
+ else if (response == "ERRNOTAVL") {
+ KMessageBox::error(0, i18n("<qt>The backend server is not available at this time<p>Please try a different workspace, or try again later</qt>"), i18n("Connection Failed"));
+ m_connectionMutex->unlock();
+ return -1;
+ }
+ else if (response == "ERRNOSERV") {
+ KMessageBox::error(0, i18n("<qt>The active laboratory workspace does not support the requested service</qt>"), i18n("Service Unavailable"));
+ m_connectionMutex->unlock();
+ return -1;
+ }
+ else {
+ KMessageBox::error(0, i18n("<qt>Unable to establish connection with remote server</qt>"), i18n("Connection Failed"));
+ m_connectionMutex->unlock();
+ return -1;
+ }
- return 0;
+ m_connectionMutex->unlock();
+ return 0;
+ }
+ catch (exit_exception& e) {
+ m_connectionMutex->unlock();
+ return -1;
+ }
}
void FPGAViewPart::updateDisplay() {
diff --git a/clients/tde/src/part/fpgaview/part.h b/clients/tde/src/part/fpgaview/part.h
index ff1a5da..0b03e4f 100644
--- a/clients/tde/src/part/fpgaview/part.h
+++ b/clients/tde/src/part/fpgaview/part.h
@@ -59,11 +59,13 @@ namespace RemoteLab
private slots:
void postInit();
void updateDisplay();
+ void processLockouts();
+ void connectionClosed();
private:
TDEKerberosClientSocket* m_socket;
FPGAViewBase* m_base;
- TQMutex* m_instrumentMutex;
+ TQMutex* m_connectionMutex;
TQTimer* m_updateTimer;
};
}