From 25161fa55a1f2cf804b59c96d5609b97af43c9f6 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Fri, 28 Mar 2008 21:46:13 +0000 Subject: [PATCH] bug fix for server --- src/aboutdlgbase.ui | 2 +- src/llconserverdlg.cpp | 36 ++++++++++++++--------------- src/multicolorled.cpp | 52 +++++++++++++++++++++++------------------- src/multicolorled.h | 23 +++++++++++-------- src/util.h | 26 ++++++++++----------- 5 files changed, 74 insertions(+), 65 deletions(-) diff --git a/src/aboutdlgbase.ui b/src/aboutdlgbase.ui index 51e02d30..0813c8ef 100755 --- a/src/aboutdlgbase.ui +++ b/src/aboutdlgbase.ui @@ -114,7 +114,7 @@ - Copyright (C) 2005 - 2006 + Copyright (C) 2005 - 2008 false diff --git a/src/llconserverdlg.cpp b/src/llconserverdlg.cpp index 8cdd80e6..7e8fd199 100755 --- a/src/llconserverdlg.cpp +++ b/src/llconserverdlg.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2006 + * Copyright (c) 2004-2008 * * Author(s): * Volker Fischer @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * \******************************************************************************/ @@ -28,8 +28,8 @@ /* Implementation *************************************************************/ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent ) : pServer ( pNServP ), QDialog ( parent ), - BitmCubeGreen ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ), - BitmCubeRed ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ), + BitmCubeGreen ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ), + BitmCubeRed ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ), BitmCubeYellow ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ) { setupUi ( this ); @@ -39,8 +39,8 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent ) tr ( " server " ) + QString ( VERSION ) ); // create bitmaps - BitmCubeGreen.fill ( QColor ( 0, 255, 0 ) ); - BitmCubeRed.fill ( QColor ( 255, 0, 0 ) ); + BitmCubeGreen.fill ( QColor ( 0, 255, 0 ) ); + BitmCubeRed.fill ( QColor ( 255, 0, 0 ) ); BitmCubeYellow.fill ( QColor ( 255, 255, 0 ) ); // set up list view for connected clients @@ -63,7 +63,7 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent ) for ( int i = MAX_NUM_CHANNELS - 1; i >= 0; i-- ) { vecpListViewItems[i] = new CServerListViewItem ( ListViewClients ); - vecpListViewItems[i]->setHidden ( false ); + vecpListViewItems[i]->setHidden ( true ); } // Init timing jitter text label @@ -108,9 +108,9 @@ void CLlconServerDlg::OnTimer() if ( !( vecHostAddresses[i].InetAddr == QHostAddress ( (quint32) 0 ) ) ) { // IP, port number - vecpListViewItems[i]->setText ( 0, QString().sprintf ( "%s : %d", - vecHostAddresses[i].InetAddr.toString(), - vecHostAddresses[i].iPort ) /* IP, port */); + vecpListViewItems[i]->setText ( 0, QString("%1 : %2" ). + arg ( vecHostAddresses[i].InetAddr.toString() ). + arg ( vecHostAddresses[i].iPort ) ); // name vecpListViewItems[i]->setText ( 1, vecsName[i] ); @@ -123,15 +123,15 @@ void CLlconServerDlg::OnTimer() vecpListViewItems[i]->setText ( 5, QString().setNum ( double ( veciNetwInBlSiFact[i] * MIN_BLOCK_DURATION_MS ), 'f', 2 ) ); - vecpListViewItems[i]->setText(6, + vecpListViewItems[i]->setText ( 6, QString().setNum ( double ( veciNetwOutBlSiFact[i] * MIN_BLOCK_DURATION_MS ), 'f', 2 ) ); - vecpListViewItems[i]->setHidden ( true ); + vecpListViewItems[i]->setHidden ( false ); } else { - vecpListViewItems[i]->setHidden ( false ); + vecpListViewItems[i]->setHidden ( true ); } } @@ -156,8 +156,8 @@ void CLlconServerDlg::customEvent ( QEvent* Event ) ListViewMutex.lock(); const int iMessType = ( (CLlconEvent*) Event )->iMessType; - const int iStatus = ( (CLlconEvent*) Event )->iStatus; - const int iChanNum = ( (CLlconEvent*) Event )->iChanNum; + const int iStatus = ( (CLlconEvent*) Event )->iStatus; + const int iChanNum = ( (CLlconEvent*) Event )->iChanNum; switch(iMessType) { diff --git a/src/multicolorled.cpp b/src/multicolorled.cpp index 47093b9b..77bd2423 100755 --- a/src/multicolorled.cpp +++ b/src/multicolorled.cpp @@ -6,22 +6,22 @@ * * Description: * Implements a multi-color LED - * + * * ****************************************************************************** * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * \******************************************************************************/ @@ -32,9 +32,9 @@ /* Implementation *************************************************************/ CMultiColorLED::CMultiColorLED ( QWidget* parent, Qt::WindowFlags f ) : QLabel ( parent, f ), - BitmCubeGreen ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ), - BitmCubeRed ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ), - BitmCubeGrey ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ), + BitmCubeGreen ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ), + BitmCubeRed ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ), + BitmCubeGrey ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ), BitmCubeYellow ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ) { // create bitmaps @@ -56,12 +56,12 @@ CMultiColorLED::CMultiColorLED ( QWidget* parent, Qt::WindowFlags f ) eColorFlag = RL_GREY; // init update time - SetUpdateTime ( DEFAULT_UPDATE_TIME ); + SetUpdateTime ( DEFAULT_UPDATE_TIME ); - // init timers -> we want to have single shot timers - TimerRedLight.setSingleShot ( true ); - TimerGreenLight.setSingleShot ( true ); - TimerYellowLight.setSingleShot ( true ); + // init timers -> we want to have single shot timers + TimerRedLight.setSingleShot ( true ); + TimerGreenLight.setSingleShot ( true ); + TimerYellowLight.setSingleShot ( true ); // connect timer events to the desired slots connect ( &TimerRedLight, SIGNAL ( timeout() ), @@ -70,6 +70,9 @@ CMultiColorLED::CMultiColorLED ( QWidget* parent, Qt::WindowFlags f ) this, SLOT ( OnTimerGreenLight() ) ); connect ( &TimerYellowLight, SIGNAL ( timeout() ), this, SLOT ( OnTimerYellowLight() ) ); + + connect ( this, SIGNAL ( newPixmap ( const QPixmap& ) ), + this, SLOT ( OnNewPixmap ( const QPixmap& ) ) ); } void CMultiColorLED::Reset() @@ -109,7 +112,8 @@ void CMultiColorLED::UpdateColor() { if ( eColorFlag != RL_RED ) { - setPixmap ( BitmCubeRed ); + //setPixmap ( BitmCubeRed ); +emit newPixmap ( BitmCubeRed ); eColorFlag = RL_RED; } return; @@ -119,7 +123,8 @@ void CMultiColorLED::UpdateColor() { if ( eColorFlag != RL_YELLOW ) { - setPixmap ( BitmCubeYellow ); + //setPixmap ( BitmCubeYellow ); +emit newPixmap ( BitmCubeYellow ); eColorFlag = RL_YELLOW; } return; @@ -129,7 +134,8 @@ void CMultiColorLED::UpdateColor() { if ( eColorFlag != RL_GREEN ) { - setPixmap ( BitmCubeGreen ); + //setPixmap ( BitmCubeGreen ); +emit newPixmap ( BitmCubeGreen ); eColorFlag = RL_GREEN; } return; @@ -173,15 +179,15 @@ void CMultiColorLED::SetUpdateTime ( const int iNUTi ) { // avoid too short intervals if ( iNUTi < MIN_TIME_FOR_RED_LIGHT ) - { + { iUpdateTime = MIN_TIME_FOR_RED_LIGHT; - } + } else - { + { iUpdateTime = iNUTi; - } + } - TimerGreenLight.setInterval ( iUpdateTime ); - TimerYellowLight.setInterval ( iUpdateTime ); - TimerRedLight.setInterval ( iUpdateTime ); + TimerGreenLight.setInterval ( iUpdateTime ); + TimerYellowLight.setInterval ( iUpdateTime ); + TimerRedLight.setInterval ( iUpdateTime ); } diff --git a/src/multicolorled.h b/src/multicolorled.h index 7cf840e2..a0566f2a 100755 --- a/src/multicolorled.h +++ b/src/multicolorled.h @@ -82,18 +82,20 @@ protected: bool bFlagYellowLi; protected slots: - void OnTimerRedLight(); - void OnTimerGreenLight(); - void OnTimerYellowLight(); + void OnTimerRedLight(); + void OnTimerGreenLight(); + void OnTimerYellowLight(); + virtual void OnNewPixmap ( const QPixmap& newPixmap ) { setPixmap ( newPixmap ); } + +signals: + void newPixmap ( const QPixmap& newPixmap ); }; - - -// TODO list view item LED does not work anymore - class CMultColLEDListViewItem : public CMultiColorLED { + Q_OBJECT + public: CMultColLEDListViewItem ( const int iNewCol ) : iColumn ( iNewCol ), pListViewItem ( NULL ) {} @@ -103,15 +105,16 @@ public: pListViewItem = pNewListViewItem; } -protected: - virtual void SetPixmap ( QPixmap& NewBitmap ) +protected slots: + virtual void OnNewPixmap ( const QPixmap& newPixmap ) { if ( pListViewItem != NULL ) { - pListViewItem->setIcon ( iColumn, QIcon ( NewBitmap ) ); + pListViewItem->setIcon ( iColumn, QIcon ( newPixmap ) ); } } +protected: QTreeWidgetItem* pListViewItem; int iColumn; }; diff --git a/src/util.h b/src/util.h index 80b79b67..51b3f5c9 100755 --- a/src/util.h +++ b/src/util.h @@ -110,7 +110,7 @@ public: DebugError ( "Writing vector out of bounds", "Vector size", iVectorSize, "New parameter", iPos ); } -#endif +#endif return pData[iPos]; } inline TData operator[] ( const int iPos ) const { @@ -256,13 +256,13 @@ public: inline TData GetAverage() { if ( this->iNorm == 0 ) - { - return TData ( 0 ); - } + { + return TData ( 0 ); + } else - { - return tCurAvResult / this->iNorm; - } + { + return tCurAvResult / this->iNorm; + } } virtual void Init ( const int iNewSize ); @@ -299,15 +299,15 @@ template void CMovingAv::Add ( const TData tNewD ) // increase position pointer and test if wrap iCurIdx++; if ( iCurIdx >= this->iVectorSize ) - { + { iCurIdx = 0; - } + } // take care of norm if ( this->iNorm < this->iVectorSize ) - { + { this->iNorm++; - } + } } @@ -477,9 +477,9 @@ public: const QDateTime curDateTime = QDateTime::currentDateTime(); // format date and time output according to "3.9.2006 11:38:08: " - return QString().setNum ( curDateTime.date().day() ) + "." + + return QString().setNum ( curDateTime.date().day() ) + "." + QString().setNum ( curDateTime.date().month() ) + "." + - QString().setNum ( curDateTime.date().year() ) + " " + + QString().setNum ( curDateTime.date().year() ) + " " + curDateTime.time().toString() + ": "; } };