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): * Author(s):
* Volker Fischer * Volker Fischer
@ -34,6 +34,11 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
// init timing jitter text label // init timing jitter text label
TextLabelStdDevTimer->setText ( "" ); TextLabelStdDevTimer->setText ( "" );
// ping time controls
CLEDPingTime->SetUpdateTime ( 2 * PING_UPDATE_TIME );
CLEDPingTime->Reset();
TextLabelPingTime->setText ( "" );
// init slider controls --- // init slider controls ---
// sound buffer in // sound buffer in
#ifdef _WIN32 #ifdef _WIN32
@ -93,6 +98,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
QObject::connect ( &TimerStatus, SIGNAL ( timeout() ), QObject::connect ( &TimerStatus, SIGNAL ( timeout() ),
this, SLOT ( OnTimerStatus() ) ); this, SLOT ( OnTimerStatus() ) );
QObject::connect ( &TimerPing, SIGNAL ( timeout() ),
this, SLOT ( OnTimerPing() ) );
// sliders // sliders
QObject::connect ( SliderSndBufIn, SIGNAL ( valueChanged ( int ) ), QObject::connect ( SliderSndBufIn, SIGNAL ( valueChanged ( int ) ),
this, SLOT ( OnSliderSndBufInChange ( int ) ) ); this, SLOT ( OnSliderSndBufInChange ( int ) ) );
@ -121,6 +129,18 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
TimerStatus.start ( DISPLAY_UPDATE_TIME ); 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 ) void CClientSettingsDlg::OnSliderSndBufInChange ( int value )
{ {
pClient->GetSndInterface()->SetInNumBuf ( value ); pClient->GetSndInterface()->SetInNumBuf ( value );
@ -166,25 +186,35 @@ void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value )
UpdateDisplay(); UpdateDisplay();
} }
void CClientSettingsDlg::OnTimerPing()
{
// send ping message to server
pClient->SendPingMess();
}
void CClientSettingsDlg::OnPingTimeResult ( int iPingTime ) void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
{ {
// color definition: < 20 ms green, < 50 ms yellow, otherwise red
// TEST if ( iPingTime < 20 )
//TextLabelStdDevTimer->setText ( QString().setNum ( iPingTime ) + " ms" ); {
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() void CClientSettingsDlg::UpdateDisplay()
{ {
// TEST
//pClient->SendPingMess();
// response time // response time
TextLabelStdDevTimer->setText ( QString(). TextLabelStdDevTimer->setText ( QString().
setNum ( pClient->GetTimingStdDev(), 'f', 2 ) + " ms" ); setNum ( pClient->GetTimingStdDev(), 'f', 2 ) + " ms" );

View file

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

View file

@ -6,7 +6,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>425</width> <width>425</width>
<height>271</height> <height>257</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
@ -750,12 +750,58 @@
</property> </property>
<property name="sizeHint" > <property name="sizeHint" >
<size> <size>
<width>20</width> <width>98</width>
<height>71</height> <height>51</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </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> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="spacing" > <property name="spacing" >