From 623cde93fda148d0c36ba13701a7006bd6bea294 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Mon, 2 Jul 2012 18:33:41 -0500 Subject: [PATCH] Stabilize clients and complete basic view layout/widgets --- clients/tde/misc/remotelabui.rc | 21 +- clients/tde/src/app/remotemdi.cpp | 55 ++--- clients/tde/src/app/remotemdi.h | 4 +- clients/tde/src/app/views/instrumentview.cpp | 7 + clients/tde/src/app/views/instrumentview.h | 1 + clients/tde/src/part/fpgaview/layout.ui | 216 +++++++++++++++++++ clients/tde/src/part/fpgaview/part.cpp | 112 +++++++++- clients/tde/src/part/fpgaview/part.h | 34 +++ lib/libtqtrla/src/tqtrla.cpp | 7 + lib/libtqtrla/src/tqtrla.h | 1 + 10 files changed, 399 insertions(+), 59 deletions(-) diff --git a/clients/tde/misc/remotelabui.rc b/clients/tde/misc/remotelabui.rc index 76535f5..8377945 100644 --- a/clients/tde/misc/remotelabui.rc +++ b/clients/tde/misc/remotelabui.rc @@ -6,38 +6,19 @@ - - Current Instrument - - - - Device Under Test - - + Instrumentation - - Services - - Connection - - Device Under Test - - Instrumentation - - Services - - \ No newline at end of file diff --git a/clients/tde/src/app/remotemdi.cpp b/clients/tde/src/app/remotemdi.cpp index 3c3c436..4c3cb20 100644 --- a/clients/tde/src/app/remotemdi.cpp +++ b/clients/tde/src/app/remotemdi.cpp @@ -30,7 +30,7 @@ using namespace std; #include "dialogs/selectserverdlg.h" RemoteMDI::RemoteMDI() - : KMdiMainFrm(0, "RemoteMDI", KMdi::ChildframeMode), m_instrumentActionListPlugged(false), m_children(0), m_rsvSvrSocket(NULL), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL) + : KMdiMainFrm(0, "RemoteMDI", KMdi::ChildframeMode), m_children(0), m_rsvSvrSocket(NULL), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL) { setXMLFile("remotelabui.rc"); @@ -108,43 +108,29 @@ void RemoteMDI::resizeEvent(TQResizeEvent *e) { void RemoteMDI::processActions() { // Add dynamic actions - // RAJA FIXME KActionCollection *const ac = actionCollection(); - TQPtrList 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 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 service_actions; - // Nothing here yet! - unplugActionList("serviceMenu_actionlist"); - unplugActionList("serviceToolBar_actionlist"); - plugActionList("serviceMenu_actionlist", service_actions); - plugActionList("serviceToolBar_actionlist", service_actions); + KAction* action; + ServiceType st; + for (ServiceList::Iterator it(m_activeStation.services.begin()); it != m_activeStation.services.end(); ++it) { + st = *it; + action = new KAction(i18n("Launch")+" "+st.name, st.clientLibrary, KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(startModule()), ac, st.clientLibrary.ascii()); + m_instrumentActionList.append(action); + } + plugActionList("instrumentMenu_actionlist", m_instrumentActionList); + plugActionList("instrumentToolBar_actionlist", m_instrumentActionList); } void RemoteMDI::startModule() { const KAction* sendingAction = dynamic_cast(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; + break; } } @@ -153,7 +139,7 @@ void RemoteMDI::startModule() { return; } - RemoteLab::InstrumentView* view = new RemoteLab::InstrumentView(sendingAction->name(), st.name, (mdiMode() == KMdi::ToplevelMode) ? 0 : this); + RemoteLab::InstrumentView* view = new RemoteLab::InstrumentView(st.clientLibrary, st.name, (mdiMode() == KMdi::ToplevelMode) ? 0 : this); connect(view, SIGNAL(statusMessageSet(const TQString&)), this, SLOT(updateStatusBarWindowMessage(const TQString&))); openNewWindow(view); if (m_serverHost != "") { @@ -301,6 +287,7 @@ printf("[RAJA DEBUG 100.0] '%s'\n\r", result.ascii()); fflush(stdout); if (result == "OK") { // Success! m_activeStation = select.m_selectedStation; + processActions(); } else if (result == "ERRUNAVAL") { KMessageBox::error(this, i18n("No stations of the specified type are currently available

Please try again later"), i18n("Insufficient Laboratory Resources")); @@ -361,8 +348,9 @@ printf("[RAJA DEBUG 600.0] connected: %d\n\r", connected); fflush(stdout); connect_action->setEnabled(!connected); disconnect_action->setEnabled(connected); - inst_fpgaviewer_menu->setEnabled(connected); - inst_sa_menu->setEnabled(connected); + for (TQPtrList::Iterator it(m_instrumentActionList.begin()); it != m_instrumentActionList.end(); ++it) { + (*it)->setEnabled(connected); + } } void RemoteMDI::configToolbars() { @@ -419,14 +407,10 @@ void RemoteMDI::childWindowCloseRequest(KMdiChildView *pWnd) { void RemoteMDI::currentChanged(KMdiChildView *current) { RemoteLab::InstrumentView* view = dynamic_cast(current); - // Plug/unpug menus - if (m_instrumentActionListPlugged) { - unplugActionList("selectedInstrument_actionlist"); - m_instrumentActionListPlugged = false; - } + // Plug/unplug menus if (view) { + unplugActionList("selectedInstrument_actionlist"); plugActionList("selectedInstrument_actionlist", view->menuActionList()); - m_instrumentActionListPlugged = true; } // Update status bar and list box @@ -464,6 +448,9 @@ void RemoteMDI::childClosed(KMdiChildView * w) { w->activate(); assert(w == m_pCurrentWindow); + // Unplug menus + unplugActionList("selectedInstrument_actionlist"); + // Notify the status bar of the removal of the window updateStatusBarWindowMessage(TQString::null); updateStatusBarMainMessage(i18n("Instrument %1 removed").arg(w->tabCaption())); diff --git a/clients/tde/src/app/remotemdi.h b/clients/tde/src/app/remotemdi.h index 1502b62..75c6c31 100644 --- a/clients/tde/src/app/remotemdi.h +++ b/clients/tde/src/app/remotemdi.h @@ -77,7 +77,6 @@ class RemoteMDI : public KMdiMainFrm private: TQString m_mainStatusBarMessage; TQString m_windowStatusBarMessage; - bool m_instrumentActionListPlugged; unsigned m_children; TQString m_serverHost; @@ -90,8 +89,7 @@ class RemoteMDI : public KMdiMainFrm KAction *connect_action; KAction *disconnect_action; - KAction *inst_sa_menu; - KAction *inst_fpgaviewer_menu; + TQPtrList m_instrumentActionList; StationType m_activeStation; }; diff --git a/clients/tde/src/app/views/instrumentview.cpp b/clients/tde/src/app/views/instrumentview.cpp index 0d287a7..24d0632 100644 --- a/clients/tde/src/app/views/instrumentview.cpp +++ b/clients/tde/src/app/views/instrumentview.cpp @@ -48,6 +48,13 @@ void InstrumentView::init() { } } +void InstrumentView::resizeEvent(TQResizeEvent *) { + TQWidget *childPartWidget = m_instrumentPart->widget(); + if (childPartWidget) { + setFixedSize(childPartWidget->sizeHint()); + } +} + TQPtrList InstrumentView::menuActionList() { return m_instrumentPart->menuActionList(); } diff --git a/clients/tde/src/app/views/instrumentview.h b/clients/tde/src/app/views/instrumentview.h index 6482fd1..e62b0de 100644 --- a/clients/tde/src/app/views/instrumentview.h +++ b/clients/tde/src/app/views/instrumentview.h @@ -33,6 +33,7 @@ class InstrumentView : public KMdiChildView virtual void saveProperties(KConfig *); virtual void readProperties(KConfig *); virtual bool queryExit(); + virtual void resizeEvent(TQResizeEvent *); private slots: void setStatusMessage(const TQString& message); diff --git a/clients/tde/src/part/fpgaview/layout.ui b/clients/tde/src/part/fpgaview/layout.ui index a983687..a2619eb 100644 --- a/clients/tde/src/part/fpgaview/layout.ui +++ b/clients/tde/src/part/fpgaview/layout.ui @@ -218,6 +218,222 @@ + + + group4BitInput + + + Buttons: + + + + unnamed + + + + unnamed + + + + unnamed + + + + unnamed_spacer + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + group4BitInputLED0 + + + + + unnamed_spacer + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + + + group4BitInputLED3 + + + + + group4BitInputLED1 + + + + + unnamed + + + + unnamed + + + + unnamed_spacer + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + group4BitInputLED2 + + + + + unnamed_spacer + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + + + group4BitInputValueLabel + + + In: + + + AlignBottom|AlignLeft + + + + + group4BitOutputValueLabel + + + Out: + + + AlignTop|AlignLeft + + + + + group4BitInputValueText + + + AlignBottom|AlignRight + + + + + group4BitOutputValueText + + + AlignTop|AlignRight + + + + + + + unnamed + + + + + groupLCDDisplay + + + LCD Display: + + + + unnamed + + + unnamed + + + + LCDOutputLabel + + + AlignTop|AlignLeft + + + + 14 + monospace + + + + \n + + + + + + + unnamed_spacer + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp index 269c05e..8876e44 100644 --- a/clients/tde/src/part/fpgaview/part.cpp +++ b/clients/tde/src/part/fpgaview/part.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include //encodeName() #include //postInit() hack #include @@ -72,17 +73,62 @@ void FPGALed::mouseReleaseEvent(TQMouseEvent *e) { } } +FPGAPushButton::FPGAPushButton(TQWidget *parent, const char *name) + : KLed(parent, name), mouseDown(false) +{ + off(); + setColor(green); + setOffColor(TQApplication::palette(this).active().base().dark(200)); +} + +void FPGAPushButton::mousePressEvent(TQMouseEvent *e) { + if (e->button() == TQMouseEvent::LeftButton) { + on(); + mouseDown = true; + emit(buttonPressed()); + emit(changed()); + } +} + +void FPGAPushButton::mouseReleaseEvent(TQMouseEvent *e) { + if (e->button() == TQMouseEvent::LeftButton) { + off(); + mouseDown = false; + emit(buttonReleased()); + emit(changed()); + } +} + +void FPGAPushButton::enterEvent(TQEvent *e) { + Q_UNUSED(e); + if (mouseDown) { + on(); + emit(buttonPressed()); + emit(changed()); + } +} + +void FPGAPushButton::leaveEvent(TQEvent *e) { + Q_UNUSED(e); + if (mouseDown) { + off(); + emit(buttonReleased()); + emit(changed()); + } +} + namespace RemoteLab { typedef KParts::GenericFactory Factory; #define CLIENT_LIBRARY "libremotelab_fpgaviewer" K_EXPORT_COMPONENT_FACTORY(libremotelab_fpgaviewer, RemoteLab::Factory) -#define LED_SIZE 20,20 +#define LED_BASE_SIZE 20 +#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), - remoteInputModeEnabled(false), m_8bitInputValue(0), m_8bitOutputValue(0) + remoteInputModeEnabled(false), m_4bitInputValue(0), m_4bitOutputValue(0), m_8bitInputValue(0), m_8bitOutputValue(0), m_16bitInputValue(0), m_16bitOutputValue(0) { // Initialize mutex m_connectionMutex = new TQMutex(false); @@ -111,6 +157,15 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj m_modeSubMenu->insert(m_modeAdvancedEnabled); // Initialize widgets + m_base->group4BitInputValueLabel->setFixedSize(LED_BASE_SIZE*2, LED_BASE_SIZE*2); + m_base->group4BitOutputValueLabel->setFixedSize(LED_BASE_SIZE*2, LED_BASE_SIZE*2); + m_base->group4BitInputValueText->setFixedSize(LED_BASE_SIZE*2, LED_BASE_SIZE*2); + m_base->group4BitOutputValueText->setFixedSize(LED_BASE_SIZE*2, LED_BASE_SIZE*2); + + m_base->group4BitInputLED3->setFixedSize(LED_SIZE); + m_base->group4BitInputLED2->setFixedSize(LED_SIZE); + m_base->group4BitInputLED1->setFixedSize(LED_SIZE); + m_base->group4BitInputLED0->setFixedSize(LED_SIZE); m_base->group8BitInputLED7->setFixedSize(LED_SIZE); m_base->group8BitInputLED6->setFixedSize(LED_SIZE); m_base->group8BitInputLED5->setFixedSize(LED_SIZE); @@ -128,6 +183,10 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj m_base->group8BitOutputLED1->setFixedSize(LED_SIZE); m_base->group8BitOutputLED0->setFixedSize(LED_SIZE); + m_base->group4BitInputLED3->setState(KLed::Off); + m_base->group4BitInputLED2->setState(KLed::Off); + m_base->group4BitInputLED1->setState(KLed::Off); + m_base->group4BitInputLED0->setState(KLed::Off); m_base->group8BitInputLED7->setState(KLed::Off); m_base->group8BitInputLED6->setState(KLed::Off); m_base->group8BitInputLED5->setState(KLed::Off); @@ -154,6 +213,11 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj m_base->group8BitOutputLED1->setClickable(false); m_base->group8BitOutputLED0->setClickable(false); + connect(m_base->group4BitInputLED3, SIGNAL(changed()), this, SLOT(process4BitInputChanges())); + connect(m_base->group4BitInputLED2, SIGNAL(changed()), this, SLOT(process4BitInputChanges())); + connect(m_base->group4BitInputLED1, SIGNAL(changed()), this, SLOT(process4BitInputChanges())); + connect(m_base->group4BitInputLED0, SIGNAL(changed()), this, SLOT(process4BitInputChanges())); + connect(m_base->group8BitInputLED7, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); connect(m_base->group8BitInputLED6, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); connect(m_base->group8BitInputLED5, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); @@ -163,6 +227,8 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj connect(m_base->group8BitInputLED1, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); connect(m_base->group8BitInputLED0, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + connect(m_base->group16BitInputValue, SIGNAL(valueChanged(int)), this, SLOT(process16BitInputChanges())); + processAllGraphicsUpdates(); TQTimer::singleShot(0, this, TQT_SLOT(postInit())); @@ -181,12 +247,34 @@ void FPGAViewPart::processAllGraphicsUpdates() { // This is an expensive operation // Use it sparingly! + process4BitInputChanges(); + process4BitOutputChanges(); process8BitInputChanges(); process8BitOutputChanges(); + process16BitInputChanges(); + process16BitOutputChanges(); + + processLCDOutputChanges(); processLockouts(); } +void FPGAViewPart::process4BitInputChanges() { + // Read LED status into m_4bitInputValue + m_4bitInputValue = 0; + if (m_base->group4BitInputLED3->state() == KLed::On) m_4bitInputValue |= 0x08; + if (m_base->group4BitInputLED2->state() == KLed::On) m_4bitInputValue |= 0x04; + if (m_base->group4BitInputLED1->state() == KLed::On) m_4bitInputValue |= 0x02; + if (m_base->group4BitInputLED0->state() == KLed::On) m_4bitInputValue |= 0x01; + + m_base->group4BitInputValueText->setText(TQString("0x%1").arg(m_4bitInputValue, 0, 16)); +} + +void FPGAViewPart::process4BitOutputChanges() { + // Write m_4bitOutputValue to label + m_base->group4BitOutputValueText->setText(TQString("0x%1").arg(m_16bitOutputValue, 0, 16)); +} + void FPGAViewPart::process8BitInputChanges() { // Read LED status into m_8bitInputValue m_8bitInputValue = 0; @@ -223,6 +311,25 @@ void FPGAViewPart::process8BitOutputChanges() { m_base->group8BitOutputValueText->setText(TQString("0x%1").arg(m_8bitOutputValue, 0, 16)); } +void FPGAViewPart::process16BitInputChanges() { + // Read input into m_16bitInputValue + m_16bitInputValue = m_base->group16BitInputValue->value(); +} + +void FPGAViewPart::process16BitOutputChanges() { + // Write m_16bitOutputValue to label + m_base->group16BitOutputValue->setText(TQString("0x%1").arg(m_16bitOutputValue, 0, 16)); +} + +void FPGAViewPart::processLCDOutputChanges() { + // Write m_LCDOutputValue to label + TQString topLine = m_LCDOutputValue; + TQString bottomLine = m_LCDOutputValue; + topLine.truncate(16); + bottomLine.remove(0,8); + m_base->LCDOutputLabel->setText(topLine + "\n" + bottomLine); +} + void FPGAViewPart::processLockouts() { TQWidget* mainWidget = widget(); if (mainWidget) { @@ -438,6 +545,7 @@ TQPtrList FPGAViewPart::menuActionList() { void FPGAViewPart::updateDisplay() { // RAJA FIXME + // setStatusMessage(i18n("Debug interface timeout, still waiting for data. Please verify that the FPGA is properly configured.")); // or setStatusMessage(i18n("Running")+"... \|/-" } KAboutData* FPGAViewPart::createAboutData() { diff --git a/clients/tde/src/part/fpgaview/part.h b/clients/tde/src/part/fpgaview/part.h index 65c03bd..c46ad6b 100644 --- a/clients/tde/src/part/fpgaview/part.h +++ b/clients/tde/src/part/fpgaview/part.h @@ -25,6 +25,8 @@ #include +#include + #include #include #include @@ -59,6 +61,28 @@ class FPGALed : public KLed bool m_clickable; }; +class FPGAPushButton : public KLed +{ + Q_OBJECT + + public: + FPGAPushButton(TQWidget *parent=0, const char *name=0); + + protected: + virtual void enterEvent(TQEvent *); + virtual void leaveEvent(TQEvent *); + virtual void mousePressEvent(TQMouseEvent *); + virtual void mouseReleaseEvent(TQMouseEvent *); + + signals: + void buttonPressed(); + void buttonReleased(); + void changed(); + + private: + bool mouseDown; +}; + namespace RemoteLab { class FPGAViewPart : public KParts::RemoteInstrumentPart @@ -97,8 +121,13 @@ namespace RemoteLab void switchToAdvancedMode(); void processAllGraphicsUpdates(); + void process4BitInputChanges(); + void process4BitOutputChanges(); void process8BitInputChanges(); void process8BitOutputChanges(); + void process16BitInputChanges(); + void process16BitOutputChanges(); + void processLCDOutputChanges(); private: TDEKerberosClientSocket* m_socket; @@ -119,8 +148,13 @@ namespace RemoteLab InterfaceMode m_interfaceMode; bool remoteInputModeEnabled; + unsigned char m_4bitInputValue; + unsigned char m_4bitOutputValue; unsigned char m_8bitInputValue; unsigned char m_8bitOutputValue; + unsigned int m_16bitInputValue; + unsigned int m_16bitOutputValue; + TQCString m_LCDOutputValue; }; } diff --git a/lib/libtqtrla/src/tqtrla.cpp b/lib/libtqtrla/src/tqtrla.cpp index 7ec457c..a9bfddf 100644 --- a/lib/libtqtrla/src/tqtrla.cpp +++ b/lib/libtqtrla/src/tqtrla.cpp @@ -60,6 +60,13 @@ namespace KParts return TQPtrList(); } + void RemoteInstrumentPart::resize(TQSize size) { + TQWidget* parentWidget = dynamic_cast(parent()); + if (parentWidget) { + parentWidget->resize(size); + } + } + void RemoteInstrumentPart::close() { TQWidget* parentWidget = dynamic_cast(parent()); if (parentWidget) { diff --git a/lib/libtqtrla/src/tqtrla.h b/lib/libtqtrla/src/tqtrla.h index fe3c5ee..a31131a 100644 --- a/lib/libtqtrla/src/tqtrla.h +++ b/lib/libtqtrla/src/tqtrla.h @@ -52,6 +52,7 @@ namespace KParts protected slots: void close(); + void resize(TQSize size); void setStatusMessage(const TQString& message); signals: