diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-01 20:43:39 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-01 20:43:39 -0500 |
commit | 963501ff41849e6bbcaa7a5c12c6e04b37a8a130 (patch) | |
tree | a92d85facc6b5168890d78e9ad8944fd96d5507a /clients/tde/src | |
parent | e9dafbb9d016a1aa5e90bb12c63c12b8521cf059 (diff) | |
download | ulab-963501ff41849e6bbcaa7a5c12c6e04b37a8a130.tar.gz ulab-963501ff41849e6bbcaa7a5c12c6e04b37a8a130.zip |
Fix crashes in servers
Start work on FPGA client
Diffstat (limited to 'clients/tde/src')
-rw-r--r-- | clients/tde/src/app/remotemdi.cpp | 8 | ||||
-rw-r--r-- | clients/tde/src/app/remotemdi.h | 1 | ||||
-rw-r--r-- | clients/tde/src/part/fpgaview/layout.ui | 165 | ||||
-rw-r--r-- | clients/tde/src/part/fpgaview/part.cpp | 139 | ||||
-rw-r--r-- | clients/tde/src/part/fpgaview/part.h | 27 |
5 files changed, 330 insertions, 10 deletions
diff --git a/clients/tde/src/app/remotemdi.cpp b/clients/tde/src/app/remotemdi.cpp index 163699f..3c3c436 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_children(0), m_rsvSvrSocket(NULL), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL) + : KMdiMainFrm(0, "RemoteMDI", KMdi::ChildframeMode), m_instrumentActionListPlugged(false), m_children(0), m_rsvSvrSocket(NULL), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL) { setXMLFile("remotelabui.rc"); @@ -420,9 +420,13 @@ void RemoteMDI::currentChanged(KMdiChildView *current) { RemoteLab::InstrumentView* view = dynamic_cast<RemoteLab::InstrumentView*>(current); // Plug/unpug menus - unplugActionList("selectedInstrument_actionlist"); + if (m_instrumentActionListPlugged) { + unplugActionList("selectedInstrument_actionlist"); + m_instrumentActionListPlugged = false; + } if (view) { plugActionList("selectedInstrument_actionlist", view->menuActionList()); + m_instrumentActionListPlugged = true; } // Update status bar and list box diff --git a/clients/tde/src/app/remotemdi.h b/clients/tde/src/app/remotemdi.h index d6dea6c..1502b62 100644 --- a/clients/tde/src/app/remotemdi.h +++ b/clients/tde/src/app/remotemdi.h @@ -77,6 +77,7 @@ class RemoteMDI : public KMdiMainFrm private: TQString m_mainStatusBarMessage; TQString m_windowStatusBarMessage; + bool m_instrumentActionListPlugged; unsigned m_children; TQString m_serverHost; diff --git a/clients/tde/src/part/fpgaview/layout.ui b/clients/tde/src/part/fpgaview/layout.ui index ce29018..a983687 100644 --- a/clients/tde/src/part/fpgaview/layout.ui +++ b/clients/tde/src/part/fpgaview/layout.ui @@ -47,15 +47,175 @@ </property> <widget class="TQGroupBox" row="0" column="0"> <property name="name"> - <cstring>group8Bit</cstring> + <cstring>group8BitInput</cstring> </property> <property name="title"> - <string>8-Bit Input Values</string> + <string></string> </property> <grid> <property name="name"> <cstring>unnamed</cstring> </property> + <widget class="FPGALed" row="0" column="0"> + <property name="name"> + <cstring>group8BitInputLED7</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="1"> + <property name="name"> + <cstring>group8BitInputLED6</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="2"> + <property name="name"> + <cstring>group8BitInputLED5</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="3"> + <property name="name"> + <cstring>group8BitInputLED4</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="4"> + <property name="name"> + <cstring>group8BitInputLED3</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="5"> + <property name="name"> + <cstring>group8BitInputLED2</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="6"> + <property name="name"> + <cstring>group8BitInputLED1</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="7"> + <property name="name"> + <cstring>group8BitInputLED0</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="8"> + <property name="name"> + <cstring>group8BitInputValueText</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="TQGroupBox" row="1" column="0"> + <property name="name"> + <cstring>group8BitOutput</cstring> + </property> + <property name="title"> + <string>8-Bit Output Values</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="FPGALed" row="0" column="0"> + <property name="name"> + <cstring>group8BitOutputLED7</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="1"> + <property name="name"> + <cstring>group8BitOutputLED6</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="2"> + <property name="name"> + <cstring>group8BitOutputLED5</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="3"> + <property name="name"> + <cstring>group8BitOutputLED4</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="4"> + <property name="name"> + <cstring>group8BitOutputLED3</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="5"> + <property name="name"> + <cstring>group8BitOutputLED2</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="6"> + <property name="name"> + <cstring>group8BitOutputLED1</cstring> + </property> + </widget> + <widget class="FPGALed" row="0" column="7"> + <property name="name"> + <cstring>group8BitOutputLED0</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="8"> + <property name="name"> + <cstring>group8BitOutputValueText</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="TQGroupBox" row="2" column="0"> + <property name="name"> + <cstring>group16BitIO</cstring> + </property> + <property name="title"> + <string>16-Bit I/O</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <cstring>Input:</cstring> + </property> + </widget> + <widget class="KIntSpinBox" row="0" column="1"> + <property name="name"> + <cstring>group16BitInputValue</cstring> + </property> + <property name="prefix"> + <cstring>0x</cstring> + </property> + <property name="value"> + <number>0</number> + </property> + <property name="minValue"> + <number>0</number> + </property> + <property name="maxValue"> + <number>65535</number> + </property> + <property name="base"> + <number>16</number> + </property> + </widget> + <widget class="TQLabel" row="0" column="2"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <cstring>Output:</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="3"> + <property name="name"> + <cstring>group16BitOutputValue</cstring> + </property> + <property name="text"> + <cstring></cstring> + </property> + </widget> </grid> </widget> </grid> @@ -71,6 +231,7 @@ <includes> <include location="local" impldecl="in implementation">tracewidget.h</include> <include location="local" impldecl="in implementation">floatspinbox.h</include> + <include location="local" impldecl="in implementation">part.h</include> </includes> <layoutdefaults spacing="3" margin="6"/> <layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp index 6161562..269c05e 100644 --- a/clients/tde/src/part/fpgaview/part.cpp +++ b/clients/tde/src/part/fpgaview/part.cpp @@ -37,24 +37,52 @@ #include <tqmutex.h> #include <tqeventloop.h> #include <tqapplication.h> +#include <tqgroupbox.h> #include <unistd.h> //access() #include <stdint.h> - - #include "tracewidget.h" #include "floatspinbox.h" #include "layout.h" +#define SERVER_TIMEOUT_MS 10000 + +FPGALed::FPGALed(TQWidget *parent, const char *name) + : KLed(parent, name), m_clickable(true) +{ + connect(this, SIGNAL(clicked()), this, SLOT(toggle())); + + setColor(green); + setOffColor(TQApplication::palette(this).active().base().dark(200)); +} + +void FPGALed::setClickable(bool clickable) { + if ((!clickable) && (m_clickable)) { + disconnect(this, SIGNAL(clicked()), this, SLOT(toggle())); + } + else if ((clickable) && (!m_clickable)) { + connect(this, SIGNAL(clicked()), this, SLOT(toggle())); + } + m_clickable = clickable; +} + +void FPGALed::mouseReleaseEvent(TQMouseEvent *e) { + if (e->button() == TQMouseEvent::LeftButton) { + emit(clicked()); + } +} + namespace RemoteLab { typedef KParts::GenericFactory<RemoteLab::FPGAViewPart> Factory; #define CLIENT_LIBRARY "libremotelab_fpgaviewer" K_EXPORT_COMPONENT_FACTORY(libremotelab_fpgaviewer, RemoteLab::Factory) +#define LED_SIZE 20,20 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_socket(0), m_base(0), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL), m_interfaceMode(BasicInterfaceMode), + remoteInputModeEnabled(false), m_8bitInputValue(0), m_8bitOutputValue(0) { // Initialize mutex m_connectionMutex = new TQMutex(false); @@ -82,7 +110,60 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj m_modeAdvancedEnabled = new KToggleAction(i18n("Advanced"), KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(switchToAdvancedMode()), ac, "mode_advanced_enabled"); m_modeSubMenu->insert(m_modeAdvancedEnabled); - processLockouts(); + // Initialize widgets + m_base->group8BitInputLED7->setFixedSize(LED_SIZE); + m_base->group8BitInputLED6->setFixedSize(LED_SIZE); + m_base->group8BitInputLED5->setFixedSize(LED_SIZE); + m_base->group8BitInputLED4->setFixedSize(LED_SIZE); + m_base->group8BitInputLED3->setFixedSize(LED_SIZE); + m_base->group8BitInputLED2->setFixedSize(LED_SIZE); + m_base->group8BitInputLED1->setFixedSize(LED_SIZE); + m_base->group8BitInputLED0->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED7->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED6->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED5->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED4->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED3->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED2->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED1->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED0->setFixedSize(LED_SIZE); + + m_base->group8BitInputLED7->setState(KLed::Off); + m_base->group8BitInputLED6->setState(KLed::Off); + m_base->group8BitInputLED5->setState(KLed::Off); + m_base->group8BitInputLED4->setState(KLed::Off); + m_base->group8BitInputLED3->setState(KLed::Off); + m_base->group8BitInputLED2->setState(KLed::Off); + m_base->group8BitInputLED1->setState(KLed::Off); + m_base->group8BitInputLED0->setState(KLed::Off); + m_base->group8BitOutputLED7->setState(KLed::Off); + m_base->group8BitOutputLED6->setState(KLed::Off); + m_base->group8BitOutputLED5->setState(KLed::Off); + m_base->group8BitOutputLED4->setState(KLed::Off); + m_base->group8BitOutputLED3->setState(KLed::Off); + m_base->group8BitOutputLED2->setState(KLed::Off); + m_base->group8BitOutputLED1->setState(KLed::Off); + m_base->group8BitOutputLED0->setState(KLed::Off); + + m_base->group8BitOutputLED7->setClickable(false); + m_base->group8BitOutputLED6->setClickable(false); + m_base->group8BitOutputLED5->setClickable(false); + m_base->group8BitOutputLED4->setClickable(false); + m_base->group8BitOutputLED3->setClickable(false); + m_base->group8BitOutputLED2->setClickable(false); + m_base->group8BitOutputLED1->setClickable(false); + m_base->group8BitOutputLED0->setClickable(false); + + 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())); + connect(m_base->group8BitInputLED4, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + connect(m_base->group8BitInputLED3, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + connect(m_base->group8BitInputLED2, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + connect(m_base->group8BitInputLED1, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + connect(m_base->group8BitInputLED0, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + + processAllGraphicsUpdates(); TQTimer::singleShot(0, this, TQT_SLOT(postInit())); } @@ -96,6 +177,52 @@ FPGAViewPart::~FPGAViewPart() { delete m_connectionMutex; } +void FPGAViewPart::processAllGraphicsUpdates() { + // This is an expensive operation + // Use it sparingly! + + process8BitInputChanges(); + process8BitOutputChanges(); + + processLockouts(); +} + +void FPGAViewPart::process8BitInputChanges() { + // Read LED status into m_8bitInputValue + m_8bitInputValue = 0; + if (m_base->group8BitInputLED7->state() == KLed::On) m_8bitInputValue |= 0x80; + if (m_base->group8BitInputLED6->state() == KLed::On) m_8bitInputValue |= 0x40; + if (m_base->group8BitInputLED5->state() == KLed::On) m_8bitInputValue |= 0x20; + if (m_base->group8BitInputLED4->state() == KLed::On) m_8bitInputValue |= 0x10; + if (m_base->group8BitInputLED3->state() == KLed::On) m_8bitInputValue |= 0x08; + if (m_base->group8BitInputLED2->state() == KLed::On) m_8bitInputValue |= 0x04; + if (m_base->group8BitInputLED1->state() == KLed::On) m_8bitInputValue |= 0x02; + if (m_base->group8BitInputLED0->state() == KLed::On) m_8bitInputValue |= 0x01; + + m_base->group8BitInputValueText->setText(TQString("0x%1").arg(m_8bitInputValue, 0, 16)); + + if (remoteInputModeEnabled) { + m_base->group8BitInput->setTitle(i18n("8-Bit Input Values") + " [" + i18n("Remote Input Mode") + "]"); + } + else { + m_base->group8BitInput->setTitle(i18n("8-Bit Input Values") + " [" + i18n("Local Input Mode") + "]"); + } +} + +void FPGAViewPart::process8BitOutputChanges() { + // Write m_8bitOutputValue to LEDs + m_base->group8BitOutputLED7->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED6->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED5->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED4->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED3->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED2->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED1->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED0->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + + m_base->group8BitOutputValueText->setText(TQString("0x%1").arg(m_8bitOutputValue, 0, 16)); +} + void FPGAViewPart::processLockouts() { TQWidget* mainWidget = widget(); if (mainWidget) { @@ -183,7 +310,7 @@ void FPGAViewPart::finishConnectingToServer() { case 0: if (!connToServerTimeoutTimer) { connToServerTimeoutTimer = new TQTimer; - connToServerTimeoutTimer->start(5000, TRUE); + connToServerTimeoutTimer->start(SERVER_TIMEOUT_MS, TRUE); } if ((m_socket->state() == TQSocket::Connecting) || (m_socket->state() == TQSocket::HostLookup)) { if (!connToServerTimeoutTimer->isActive()) { @@ -196,7 +323,7 @@ void FPGAViewPart::finishConnectingToServer() { else { if (m_socket->state() == TQSocket::Connected) { printf("[DEBUG] Initial connection established...\n\r"); fflush(stdout); - m_socket->setDataTimeout(5000); + m_socket->setDataTimeout(SERVER_TIMEOUT_MS); m_socket->setUsingKerberos(true); connToServerState = 1; } diff --git a/clients/tde/src/part/fpgaview/part.h b/clients/tde/src/part/fpgaview/part.h index 3e8ac07..65c03bd 100644 --- a/clients/tde/src/part/fpgaview/part.h +++ b/clients/tde/src/part/fpgaview/part.h @@ -29,6 +29,7 @@ #include <kparts/statusbarextension.h> #include <kparts/part.h> #include <kurl.h> +#include <kled.h> #include <tqtrla.h> @@ -40,6 +41,24 @@ class TQTimer; class TQMutex; class FPGAViewBase; +class FPGALed : public KLed +{ + Q_OBJECT + + public: + FPGALed(TQWidget *parent=0, const char *name=0); + void setClickable(bool clickable); + + protected: + virtual void mouseReleaseEvent(TQMouseEvent *); + + signals: + void clicked(); + + private: + bool m_clickable; +}; + namespace RemoteLab { class FPGAViewPart : public KParts::RemoteInstrumentPart @@ -76,6 +95,10 @@ namespace RemoteLab void switchToBasicMode(); void switchToIntermediateMode(); void switchToAdvancedMode(); + void processAllGraphicsUpdates(); + + void process8BitInputChanges(); + void process8BitOutputChanges(); private: TDEKerberosClientSocket* m_socket; @@ -94,6 +117,10 @@ namespace RemoteLab KToggleAction* m_modeAdvancedEnabled; InterfaceMode m_interfaceMode; + + bool remoteInputModeEnabled; + unsigned char m_8bitInputValue; + unsigned char m_8bitOutputValue; }; } |