ping time measurement finished

This commit is contained in:
Volker Fischer 2008-08-02 22:01:19 +00:00
parent d8621f5839
commit fa50030513
3 changed files with 99 additions and 17 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************\
* Copyright (c) 2004-2006
* Copyright (c) 2004-2008
*
* Author(s):
* Volker Fischer
@ -34,6 +34,11 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
// init timing jitter text label
TextLabelStdDevTimer->setText ( "" );
// ping time controls
CLEDPingTime->SetUpdateTime ( 2 * PING_UPDATE_TIME );
CLEDPingTime->Reset();
TextLabelPingTime->setText ( "" );
// init slider controls ---
// sound buffer in
#ifdef _WIN32
@ -93,6 +98,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
QObject::connect ( &TimerStatus, SIGNAL ( timeout() ),
this, SLOT ( OnTimerStatus() ) );
QObject::connect ( &TimerPing, SIGNAL ( timeout() ),
this, SLOT ( OnTimerPing() ) );
// sliders
QObject::connect ( SliderSndBufIn, SIGNAL ( valueChanged ( int ) ),
this, SLOT ( OnSliderSndBufInChange ( int ) ) );
@ -121,6 +129,18 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
TimerStatus.start ( DISPLAY_UPDATE_TIME );
}
void CClientSettingsDlg::showEvent ( QShowEvent* showEvent )
{
// only activate ping timer if window is actually shown
TimerPing.start ( PING_UPDATE_TIME );
}
void CClientSettingsDlg::hideEvent ( QHideEvent* hideEvent )
{
// if window is closed, stop timer for ping
TimerPing.stop();
}
void CClientSettingsDlg::OnSliderSndBufInChange ( int value )
{
pClient->GetSndInterface()->SetInNumBuf ( value );
@ -166,25 +186,35 @@ void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value )
UpdateDisplay();
}
void CClientSettingsDlg::OnTimerPing()
{
// send ping message to server
pClient->SendPingMess();
}
void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
{
// TEST
//TextLabelStdDevTimer->setText ( QString().setNum ( iPingTime ) + " ms" );
// color definition: < 20 ms green, < 50 ms yellow, otherwise red
if ( iPingTime < 20 )
{
CLEDPingTime->SetLight ( MUL_COL_LED_GREEN );
}
else
{
if ( iPingTime < 50 )
{
CLEDPingTime->SetLight ( MUL_COL_LED_YELLOW );
}
else
{
CLEDPingTime->SetLight ( MUL_COL_LED_RED );
}
}
TextLabelPingTime->setText ( QString().setNum ( iPingTime ) + " ms" );
}
void CClientSettingsDlg::UpdateDisplay()
{
// TEST
//pClient->SendPingMess();
// response time
TextLabelStdDevTimer->setText ( QString().
setNum ( pClient->GetTimingStdDev(), 'f', 2 ) + " ms" );

View file

@ -46,6 +46,7 @@
/* Definitions ****************************************************************/
// update time for GUI controls
#define DISPLAY_UPDATE_TIME 1000 // ms
#define PING_UPDATE_TIME 500 // ms
/* Classes ********************************************************************/
@ -62,10 +63,15 @@ public:
protected:
CClient* pClient;
QTimer TimerStatus;
QTimer TimerPing;
void UpdateDisplay();
virtual void showEvent ( QShowEvent* showEvent );
virtual void hideEvent ( QHideEvent* hideEvent );
public slots:
void OnTimerStatus() { UpdateDisplay(); }
void OnTimerPing();
void OnSliderSndBufInChange ( int value );
void OnSliderSndBufOutChange ( int value );
void OnSliderNetBuf ( int value );

View file

@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>425</width>
<height>271</height>
<height>257</height>
</rect>
</property>
<property name="windowTitle" >
@ -750,12 +750,58 @@
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>71</height>
<width>98</width>
<height>51</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="TextLabel1_3" >
<property name="text" >
<string>Ping Time:</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="TextLabelPingTime" >
<property name="text" >
<string>val</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="CMultiColorLED" native="1" name="CLEDPingTime" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>13</width>
<height>13</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>13</width>
<height>13</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" >