@ -30,6 +30,7 @@
# include <kparts/genericfactory.h>
# include <kparts/genericfactory.h>
# include <kstatusbar.h>
# include <kstatusbar.h>
# include <kstdaction.h>
# include <kstdaction.h>
# include <knuminput.h>
# include <tqfile.h> //encodeName()
# include <tqfile.h> //encodeName()
# include <tqtimer.h> //postInit() hack
# include <tqtimer.h> //postInit() hack
# include <tqvbox.h>
# 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 {
namespace RemoteLab {
typedef KParts : : GenericFactory < RemoteLab : : FPGAViewPart > Factory ;
typedef KParts : : GenericFactory < RemoteLab : : FPGAViewPart > Factory ;
# define CLIENT_LIBRARY "libremotelab_fpgaviewer"
# define CLIENT_LIBRARY "libremotelab_fpgaviewer"
K_EXPORT_COMPONENT_FACTORY ( libremotelab_fpgaviewer , RemoteLab : : Factory )
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 & )
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 )
remoteInputModeEnabled ( false ) , m_ 4bitInputValue( 0 ) , m_4bitOutputValue ( 0 ) , m_ 8bitInputValue( 0 ) , m_8bitOutputValue ( 0 ) , m_16bitInputValue ( 0 ) , m_16bitOutputValue ( 0 )
{
{
// Initialize mutex
// Initialize mutex
m_connectionMutex = new TQMutex ( false ) ;
m_connectionMutex = new TQMutex ( false ) ;
@ -111,6 +157,15 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj
m_modeSubMenu - > insert ( m_modeAdvancedEnabled ) ;
m_modeSubMenu - > insert ( m_modeAdvancedEnabled ) ;
// Initialize widgets
// 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 - > group8BitInputLED7 - > setFixedSize ( LED_SIZE ) ;
m_base - > group8BitInputLED6 - > setFixedSize ( LED_SIZE ) ;
m_base - > group8BitInputLED6 - > setFixedSize ( LED_SIZE ) ;
m_base - > group8BitInputLED5 - > 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 - > group8BitOutputLED1 - > setFixedSize ( LED_SIZE ) ;
m_base - > group8BitOutputLED0 - > 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 - > group8BitInputLED7 - > setState ( KLed : : Off ) ;
m_base - > group8BitInputLED6 - > setState ( KLed : : Off ) ;
m_base - > group8BitInputLED6 - > setState ( KLed : : Off ) ;
m_base - > group8BitInputLED5 - > 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 - > group8BitOutputLED1 - > setClickable ( false ) ;
m_base - > group8BitOutputLED0 - > 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 - > group8BitInputLED7 , SIGNAL ( clicked ( ) ) , this , SLOT ( process8BitInputChanges ( ) ) ) ;
connect ( m_base - > group8BitInputLED6 , 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 - > 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 - > group8BitInputLED1 , SIGNAL ( clicked ( ) ) , this , SLOT ( process8BitInputChanges ( ) ) ) ;
connect ( m_base - > group8BitInputLED0 , 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 ( ) ;
processAllGraphicsUpdates ( ) ;
TQTimer : : singleShot ( 0 , this , TQT_SLOT ( postInit ( ) ) ) ;
TQTimer : : singleShot ( 0 , this , TQT_SLOT ( postInit ( ) ) ) ;
@ -181,12 +247,34 @@ void FPGAViewPart::processAllGraphicsUpdates() {
// This is an expensive operation
// This is an expensive operation
// Use it sparingly!
// Use it sparingly!
process4BitInputChanges ( ) ;
process4BitOutputChanges ( ) ;
process8BitInputChanges ( ) ;
process8BitInputChanges ( ) ;
process8BitOutputChanges ( ) ;
process8BitOutputChanges ( ) ;
process16BitInputChanges ( ) ;
process16BitOutputChanges ( ) ;
processLCDOutputChanges ( ) ;
processLockouts ( ) ;
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 ( ) {
void FPGAViewPart : : process8BitInputChanges ( ) {
// Read LED status into m_8bitInputValue
// Read LED status into m_8bitInputValue
m_8bitInputValue = 0 ;
m_8bitInputValue = 0 ;
@ -223,6 +311,25 @@ void FPGAViewPart::process8BitOutputChanges() {
m_base - > group8BitOutputValueText - > setText ( TQString ( " 0x%1 " ) . arg ( m_8bitOutputValue , 0 , 16 ) ) ;
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 ( ) {
void FPGAViewPart : : processLockouts ( ) {
TQWidget * mainWidget = widget ( ) ;
TQWidget * mainWidget = widget ( ) ;
if ( mainWidget ) {
if ( mainWidget ) {
@ -438,6 +545,7 @@ TQPtrList<KAction> FPGAViewPart::menuActionList() {
void FPGAViewPart : : updateDisplay ( ) {
void FPGAViewPart : : updateDisplay ( ) {
// RAJA FIXME
// 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 ( ) {
KAboutData * FPGAViewPart : : createAboutData ( ) {