summaryrefslogtreecommitdiffstats
path: root/clients/tde/src/part/fpgaview
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-02 18:33:41 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-02 18:33:41 -0500
commit623cde93fda148d0c36ba13701a7006bd6bea294 (patch)
treeae991921965d6a87926695d122af82e4b676db00 /clients/tde/src/part/fpgaview
parent963501ff41849e6bbcaa7a5c12c6e04b37a8a130 (diff)
downloadulab-623cde93fda148d0c36ba13701a7006bd6bea294.tar.gz
ulab-623cde93fda148d0c36ba13701a7006bd6bea294.zip
Stabilize clients and complete basic view layout/widgets
Diffstat (limited to 'clients/tde/src/part/fpgaview')
-rw-r--r--clients/tde/src/part/fpgaview/layout.ui216
-rw-r--r--clients/tde/src/part/fpgaview/part.cpp112
-rw-r--r--clients/tde/src/part/fpgaview/part.h34
3 files changed, 360 insertions, 2 deletions
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 @@
</widget>
</grid>
</widget>
+ <widget class="TQGroupBox" row="0" column="1" rowspan="3">
+ <property name="name">
+ <cstring>group4BitInput</cstring>
+ </property>
+ <property name="title">
+ <string>Buttons:</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLayoutWidget" row="0" column="1" colspan="2">
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="0" column="0">
+ <property name="name">
+ <cstring>unnamed_spacer</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="FPGAPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>group4BitInputLED0</cstring>
+ </property>
+ </widget>
+ <spacer row="0" column="2">
+ <property name="name">
+ <cstring>unnamed_spacer</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="FPGAPushButton" row="1" column="0" rowspan="2">
+ <property name="name">
+ <cstring>group4BitInputLED3</cstring>
+ </property>
+ </widget>
+ <widget class="FPGAPushButton" row="1" column="3" rowspan="2">
+ <property name="name">
+ <cstring>group4BitInputLED1</cstring>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="3" column="1" colspan="2">
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="0" column="0">
+ <property name="name">
+ <cstring>unnamed_spacer</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="FPGAPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>group4BitInputLED2</cstring>
+ </property>
+ </widget>
+ <spacer row="0" column="2">
+ <property name="name">
+ <cstring>unnamed_spacer</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="TQLabel" row="1" column="1">
+ <property name="name">
+ <cstring>group4BitInputValueLabel</cstring>
+ </property>
+ <property name="text">
+ <cstring>In:</cstring>
+ </property>
+ <property name="alignment">
+ <set>AlignBottom|AlignLeft</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="1">
+ <property name="name">
+ <cstring>group4BitOutputValueLabel</cstring>
+ </property>
+ <property name="text">
+ <cstring>Out:</cstring>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignLeft</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="2">
+ <property name="name">
+ <cstring>group4BitInputValueText</cstring>
+ </property>
+ <property name="alignment">
+ <set>AlignBottom|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="2">
+ <property name="name">
+ <cstring>group4BitOutputValueText</cstring>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQLayoutWidget" row="0" column="2" rowspan="3">
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <grid>
+ <widget class="TQGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupLCDDisplay</cstring>
+ </property>
+ <property name="title">
+ <string>LCD Display:</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>LCDOutputLabel</cstring>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignLeft</set>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>14</pointsize>
+ <family>monospace</family>
+ </font>
+ </property>
+ <property name="text">
+ <cstring> \n </cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>unnamed_spacer</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
</grid>
</widget>
</grid>
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 <kparts/genericfactory.h>
#include <kstatusbar.h>
#include <kstdaction.h>
+#include <knuminput.h>
#include <tqfile.h> //encodeName()
#include <tqtimer.h> //postInit() hack
#include <tqvbox.h>
@@ -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<RemoteLab::FPGAViewPart> 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<KAction> 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 <tdekrbclientsocket.h>
+#include <tqcstring.h>
+
#include <kparts/browserextension.h>
#include <kparts/statusbarextension.h>
#include <kparts/part.h>
@@ -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;
};
}