📄 statisticsdlg.cpp
字号:
m_Led2[ ElmtIdx ].SetBackgroundColor( m_UploadOMeter.GetPlotColor( ElmtIdx ) );
m_Led2[ ElmtIdx ].SetFrameColor( RGB( 0x00, 0x00, 0x00 ) );
} else if (legendNr==3){
if (!m_Led3[ ElmtIdx ]) m_Led3[ ElmtIdx ].Create( WS_VISIBLE | WS_CHILD, Rect, this );
m_Led3[ ElmtIdx ].SetBackgroundColor( m_Statistics.GetPlotColor( ElmtIdx ) );
m_Led3[ ElmtIdx ].SetFrameColor( RGB( 0x00, 0x00, 0x00 ) );
}
}
void CStatisticsDlg::RepaintMeters() {
m_DownloadOMeter.SetBackgroundColor(theApp.glob_prefs->GetStatsColor(0)) ;
m_DownloadOMeter.SetGridColor(theApp.glob_prefs->GetStatsColor(1)) ;
m_DownloadOMeter.SetPlotColor( theApp.glob_prefs->GetStatsColor(4) ,0) ;
m_DownloadOMeter.SetPlotColor( theApp.glob_prefs->GetStatsColor(3) ,1) ;
m_DownloadOMeter.SetPlotColor( theApp.glob_prefs->GetStatsColor(2) ,2) ;
m_UploadOMeter.SetBackgroundColor(theApp.glob_prefs->GetStatsColor(0)) ;
m_UploadOMeter.SetGridColor(theApp.glob_prefs->GetStatsColor(1)) ;
m_UploadOMeter.SetPlotColor( theApp.glob_prefs->GetStatsColor(7) ,0) ;
m_UploadOMeter.SetPlotColor( theApp.glob_prefs->GetStatsColor(6) ,1) ;
m_UploadOMeter.SetPlotColor( theApp.glob_prefs->GetStatsColor(5) ,2) ;
m_Statistics.SetBackgroundColor(theApp.glob_prefs->GetStatsColor(0)) ;
m_Statistics.SetGridColor(theApp.glob_prefs->GetStatsColor(1)) ;
m_Statistics.SetPlotColor( theApp.glob_prefs->GetStatsColor(8),0) ;
m_Statistics.SetPlotColor( theApp.glob_prefs->GetStatsColor(10),1) ;
//m_Statistics.SetPlotColor( theApp.glob_prefs->GetStatsColor(10),2) ;
m_Statistics.SetPlotColor( theApp.glob_prefs->GetStatsColor(9),3) ;
SetupLegend( IDC_C0_2, 0 ,1);
SetupLegend( IDC_C0_3, 1 ,1);
SetupLegend( IDC_C0, 2 ,1);
SetupLegend( IDC_C1_2, 0 ,2 );
SetupLegend( IDC_C1_3, 1 ,2 );
SetupLegend( IDC_C1, 2 ,2 );
SetupLegend( IDC_S0, 0 ,3);
SetupLegend( IDC_S1, 1 ,3);
//SetupLegend( IDC_S2, 2 ,3);
SetupLegend( IDC_S3, 3 ,3);
}
void CStatisticsDlg::SetCurrentRate(float uploadrate, float downloadrate) {
double m_dPlotDataUp[ 3 ];
double m_dPlotDataDown[ 3 ];
int myStats[6];
// current rate
m_dPlotDataDown[2]=downloadrate;
m_dPlotDataUp[2]=uploadrate;
if (maxDown<downloadrate) maxDown=downloadrate;
// Websever [kuchin]
UpDown updown;
updown.upload = uploadrate;
updown.download = downloadrate;
theApp.webserver->AddStatsLine(updown);
// averages
m_dPlotDataDown[0]= GetAvgDownloadRate(AVG_SESSION);
m_dPlotDataUp[0]= GetAvgUploadRate(AVG_SESSION);
m_dPlotDataDown[1]= GetAvgDownloadRate(AVG_TIME);
m_dPlotDataUp[1]= GetAvgUploadRate(AVG_TIME);
// show
m_DownloadOMeter.AppendPoints(m_dPlotDataDown);
m_UploadOMeter.AppendPoints(m_dPlotDataUp);
// get Partialfiles summary
theApp.downloadqueue->GetDownloadStats(myStats);
m_dPlotDataMore[0]=(activeconnections/3);//myStats[0];
m_dPlotDataMore[1]=theApp.uploadqueue->GetUploadQueueLength();
m_dPlotDataMore[2]=0;//theApp.uploadqueue->GetWaitingUserCount();
m_dPlotDataMore[3]=myStats[1];
//for (int i=0;i<4;i++) if (m_dPlotDataMore[i]>theApp.glob_prefs->GetStatsMax()) {resize=true;theApp.glob_prefs->GetStatsMax()=(int)m_dPlotDataMore[i];}
//if (resize) m_Statistics.SetRanges(0, theApp.glob_prefs->GetStatsMax()+15) ;
m_Statistics.AppendPoints(m_dPlotDataMore);
}
void CStatisticsDlg::UpdateConnectionsStatus(){
activeconnections = theApp.listensocket->GetOpenSockets();
if( peakconnections < activeconnections )
peakconnections = activeconnections;
if( theApp.serverconnect->IsConnected() ){
totalconnectionchecks++;
float percent;
percent = (float)(totalconnectionchecks-1)/(float)totalconnectionchecks;
if( percent > .99f )
percent = .99f;
averageconnections = (averageconnections*percent) + (float)activeconnections*(1.0f-percent);
}
}
float CStatisticsDlg::GetMaxConperFiveModifier(){
//This is a alpha test.. Will clean up for b version.
float SpikeSize = theApp.listensocket->GetOpenSockets() - averageconnections ;
if ( SpikeSize < 1 )
return 1;
float SpikeTolerance = 25.0f*(float)theApp.glob_prefs->GetMaxConperFive()/10.0f;
if ( SpikeSize > SpikeTolerance )
return 0;
float Modifier = (1.0f-(SpikeSize/SpikeTolerance));
return Modifier;
}
void CStatisticsDlg::RecordRate() {
if (theApp.stat_transferStarttime==0) return;
// every second
downrateHistory.push_front(theApp.stat_sessionReceivedBytes);
uprateHistory.push_front(theApp.stat_sessionSentBytes);
// limit to maxmins
while ((int)downrateHistory.size()>(int)( theApp.glob_prefs->GetStatsAverageMinutes()*60)) downrateHistory.pop_back();
while ((int)uprateHistory.size()>(int)( theApp.glob_prefs->GetStatsAverageMinutes()*60)) uprateHistory.pop_back();
}
void CStatisticsDlg::ShowStatistics() {
CString cbuffer;
CString cbuffer2;
bool resize;
DWORD running;
int myStats[10];
float DownAvgRate;
resize=false;
theApp.downloadqueue->GetDownloadStats(myStats);
uint64 DownOHTotal = theApp.downloadqueue->GetDownDataOverheadFileRequest() + theApp.downloadqueue->GetDownDataOverheadSourceExchange() + theApp.downloadqueue->GetDownDataOverheadServer() + theApp.downloadqueue->GetDownDataOverheadOther();
uint64 DownOHTotalPackets = theApp.downloadqueue->GetDownDataOverheadFileRequestPackets() + theApp.downloadqueue->GetDownDataOverheadSourceExchangePackets() + theApp.downloadqueue->GetDownDataOverheadServerPackets() + theApp.downloadqueue->GetDownDataOverheadOtherPackets();
cbuffer.Format(GetResString(IDS_STATS_DDATA),CastItoXBytes( theApp.stat_sessionReceivedBytes), CastItoXBytes( theApp.stat_sessionReceivedBytes+theApp.glob_prefs->GetTotalDownloaded()));
stattree.SetItemText(down1, cbuffer);
cbuffer.Format(GetResString(IDS_TOVERHEAD), CastItoXBytes(DownOHTotal), CastItoIShort(DownOHTotalPackets));
stattree.SetItemText(down2, cbuffer);
cbuffer.Format(GetResString(IDS_FROVERHEAD), CastItoXBytes( theApp.downloadqueue->GetDownDataOverheadFileRequest()), CastItoIShort(theApp.downloadqueue->GetDownDataOverheadFileRequestPackets()));
stattree.SetItemText(down3, cbuffer);
cbuffer.Format(GetResString(IDS_SSOVERHEAD), CastItoXBytes( theApp.downloadqueue->GetDownDataOverheadSourceExchange()), CastItoIShort(theApp.downloadqueue->GetDownDataOverheadSourceExchangePackets()) );
stattree.SetItemText(down4, cbuffer);
cbuffer.Format(GetResString(IDS_SOVERHEAD), CastItoXBytes( theApp.downloadqueue->GetDownDataOverheadServer()), CastItoIShort(theApp.downloadqueue->GetDownDataOverheadServerPackets()));
stattree.SetItemText(down5, cbuffer);
cbuffer.Format(GetResString(IDS_STATS_FOUNDSRC),myStats[0]);
stattree.SetItemText(down6, cbuffer);
cbuffer.Format(GetResString(IDS_STATS_ACTDL),myStats[1]);
stattree.SetItemText(down7, cbuffer);
uint64 UpOHTotal = theApp.uploadqueue->GetUpDataOverheadFileRequest() + theApp.uploadqueue->GetUpDataOverheadSourceExchange() + theApp.uploadqueue->GetUpDataOverheadServer() + theApp.uploadqueue->GetUpDataOverheadOther();
uint64 UpOHTotalPackets = theApp.uploadqueue->GetUpDataOverheadFileRequestPackets() + theApp.uploadqueue->GetUpDataOverheadSourceExchangePackets() + theApp.uploadqueue->GetUpDataOverheadServerPackets() + theApp.uploadqueue->GetUpDataOverheadOtherPackets();
cbuffer.Format(GetResString(IDS_STATS_UDATA),CastItoXBytes( theApp.stat_sessionSentBytes),CastItoXBytes( theApp.stat_sessionSentBytes+theApp.glob_prefs->GetTotalUploaded()));
stattree.SetItemText(up1, cbuffer);
cbuffer.Format(GetResString(IDS_TOVERHEAD), CastItoXBytes( UpOHTotal), CastItoIShort(UpOHTotalPackets));
stattree.SetItemText(up2, cbuffer);
cbuffer.Format(GetResString(IDS_FROVERHEAD), CastItoXBytes( theApp.uploadqueue->GetUpDataOverheadFileRequest()), CastItoIShort(theApp.uploadqueue->GetUpDataOverheadFileRequestPackets()));
stattree.SetItemText(up3, cbuffer);
cbuffer.Format(GetResString(IDS_SSOVERHEAD), CastItoXBytes( theApp.uploadqueue->GetUpDataOverheadSourceExchange()), CastItoIShort(theApp.uploadqueue->GetUpDataOverheadSourceExchangePackets()));
stattree.SetItemText(up4, cbuffer);
cbuffer.Format(GetResString(IDS_SOVERHEAD), CastItoXBytes( theApp.uploadqueue->GetUpDataOverheadServer()), CastItoIShort(theApp.uploadqueue->GetUpDataOverheadServerPackets()));
stattree.SetItemText(up5, cbuffer);
cbuffer.Format(GetResString(IDS_STATS_ACTUL),theApp.uploadqueue->GetUploadQueueLength());
stattree.SetItemText(up6, cbuffer);
cbuffer.Format(GetResString(IDS_STATS_WAITINGUSERS),theApp.uploadqueue->GetWaitingUserCount());
stattree.SetItemText(up7, cbuffer);
cbuffer.Format(GetResString(IDS_STATS_SUCCUPCOUNT),theApp.uploadqueue->GetSuccessfullUpCount());
stattree.SetItemText(up8, cbuffer);
cbuffer.Format(GetResString(IDS_STATS_FAILUPCOUNT),theApp.uploadqueue->GetFailedUpCount());
stattree.SetItemText(up9, cbuffer);
running=theApp.uploadqueue->GetAverageUpTime();
cbuffer.Format(GetResString(IDS_STATS_AVEUPTIME),CastSecondsToHM(running));
stattree.SetItemText(up10, cbuffer);
if (theApp.stat_transferStarttime>0) {
cbuffer.Format(GetResString(IDS_STATS_AVGDL),GetAvgDownloadRate(AVG_SESSION));
stattree.SetItemText(con1, cbuffer);
cbuffer.Format(GetResString(IDS_STATS_AVGUL),GetAvgUploadRate(AVG_SESSION));
stattree.SetItemText(con2, cbuffer);
DownAvgRate=GetAvgDownloadRate(AVG_SESSION);
if (maxDownavg<DownAvgRate) maxDownavg=DownAvgRate;
cbuffer.Format(GetResString(IDS_STATS_MAXAVGDL),maxDownavg);
stattree.SetItemText(con12, cbuffer);
cbuffer.Format(GetResString(IDS_STATS_MAXDL),maxDown);
stattree.SetItemText(con13, cbuffer);
}
if (theApp.stat_reconnects>0) cbuffer.Format(GetResString(IDS_STATS_RECONNECTS),theApp.stat_reconnects-1);
else cbuffer.Format(GetResString(IDS_STATS_RECONNECTS),0);
stattree.SetItemText(con3, cbuffer);
if (theApp.stat_transferStarttime==0) cbuffer.Format(GetResString(IDS_STATS_WAITTRANSF)); else {
running=(GetTickCount()-theApp.stat_transferStarttime)/1000;
cbuffer.Format(GetResString(IDS_TRANSFERTIME),CastSecondsToHM(running));
}
stattree.SetItemText(con4, cbuffer);
if (theApp.stat_serverConnectTime==0) cbuffer.Format(GetResString(IDS_STATS_WAITCONN)); else {
running=(GetTickCount()-theApp.stat_serverConnectTime)/1000;
cbuffer.Format(GetResString(IDS_STATS_CONNECTEDSINCE),CastSecondsToHM(running));
}
stattree.SetItemText(con5, cbuffer);
if (theApp.stat_sessionReceivedBytes>0 && theApp.stat_sessionSentBytes>0 )
if (theApp.stat_sessionReceivedBytes<theApp.stat_sessionSentBytes) {
cbuffer.Format("%s %.2f : 1",GetResString(IDS_STATS_RATIO),(float)theApp.stat_sessionSentBytes/theApp.stat_sessionReceivedBytes);
stattree.SetItemText(tran0, cbuffer);
} else {
cbuffer.Format("%s 1 : %.2f",GetResString(IDS_STATS_RATIO),(float)theApp.stat_sessionReceivedBytes/theApp.stat_sessionSentBytes);
stattree.SetItemText(tran0, cbuffer);
}
running=(GetTickCount()-theApp.stat_starttime)/1000;
cbuffer=GetResString(IDS_STATS_RUNTIME)+": "+CastSecondsToHM(running);
stattree.SetItemText(tran1, cbuffer);
// shared files stats
cbuffer.Format(GetResString(IDS_SHAREDFILESCOUNT),theApp.sharedfiles->GetCount());stattree.SetItemText(shar1, cbuffer);
uint64 allsize=theApp.sharedfiles->GetDatasize();
cbuffer.Format(GetResString(IDS_SF_SIZE),CastItoXBytes(allsize));stattree.SetItemText(shar2, cbuffer);
if(theApp.sharedfiles->GetCount() != 0)
cbuffer2.Format( "%s", CastItoXBytes((uint64)allsize/theApp.sharedfiles->GetCount()));
else {
cbuffer2 = "-";
}
cbuffer.Format(GetResString(IDS_SF_AVERAGESIZE),cbuffer2);
stattree.SetItemText(shar3, cbuffer);
// get clientversion-counts
// statsclientstatus : original idea and code by xrmb
// CMap<uint8, uint8, uint32, uint32> clientStatus;
CMap<uint16, uint16, uint32, uint32> clientVersionEDonkey;
CMap<uint16, uint16, uint32, uint32> clientVersionEDonkeyHybrid;
CMap<uint16, uint16, uint32, uint32> clientVersionEMule;
uint32 totalclient;
theApp.clientlist->GetStatistics(totalclient, myStats, &clientVersionEDonkeyHybrid, &clientVersionEDonkey, &clientVersionEMule);
totalclient -= myStats[0];
if( !totalclient )
totalclient = 1;
cbuffer.Format("eMule: %i (%1.1f%%)",myStats[2],(double)100*myStats[2]/totalclient);stattree.SetItemText(cli1, cbuffer);
cbuffer.Format("lMule: %i (%1.1f%%)",myStats[6],(double)100*myStats[6]/totalclient);stattree.SetItemText(cli2, cbuffer);
cbuffer.Format("eDonkeyHybrid: %i (%1.1f%%)",myStats[4],(double)100*myStats[4]/totalclient);stattree.SetItemText(cli3, cbuffer);
cbuffer.Format("eDonkey: %i (%1.1f%%)",myStats[1],(double)100*myStats[1]/totalclient);stattree.SetItemText(cli4, cbuffer);
cbuffer.Format("cDonkey: %i (%1.1f%%)",myStats[5],(double)100*myStats[5]/totalclient);stattree.SetItemText(cli5, cbuffer);
cbuffer.Format("Old MLDonkey: %i (%1.1f%%)",myStats[3],(double)100*myStats[3]/totalclient);stattree.SetItemText(cli6, cbuffer);
cbuffer.Format(GetResString(IDS_STATS_UNKNOWNCLIENT),myStats[0]);stattree.SetItemText(cli7, cbuffer);
cbuffer.Format(GetResString(IDS_STATS_FILTEREDCLIENTS),theApp.stat_filteredclients);stattree.SetItemText(cli8, cbuffer);
if (stattree.GetItemState(cli4, TVIS_EXPANDED)&&TVIS_EXPANDED == TVIS_EXPANDED ) {
uint32 totcnt = myStats[1];
//--- find top 4 eDonkey client versions ---
uint32 currtop = 0;
uint32 lasttop = 0xFFFFFFFF;
for(uint32 i=0; i<2; i++)
{
POSITION pos=clientVersionEDonkey.GetStartPosition();
uint32 topver=0;
uint32 topcnt=0;
double topper=0;
while(pos)
{
uint16 ver;
uint32 cnt;
clientVersionEDonkey.GetNextAssoc(pos, ver, cnt);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -