bool ResultLog::AddResult(wxString resultname, StringValueList &row) { AppConfig *ac = AppConfig::GetInstance(); wxString maxrows; ac->GetValue( wxString(wxT("HISTORY_COUNT")), maxrows ); long imax; maxrows.ToLong( &imax ); Result *r = GetResults( resultname ); if( r->GetRowCount() > imax-1 ) { r->DeleteRow( 0 ); } r->AddRow( row ); return false; }
bool ResultLog::LoadResults(void) { wxFile file; wxString strPath, strDefaultCwd; strPath = wxStandardPaths::Get().GetUserDataDir(); if( !wxFileName::DirExists(strPath) ) { wxFileName::Mkdir( strPath, 0777, wxPATH_MKDIR_FULL ); } strDefaultCwd = wxGetCwd(); wxSetWorkingDirectory( strPath ); if( !file.Exists(wxT("standard.log")) ) { file.Create(wxT("standard.log")); file.Close(); } if( !file.Exists(wxT("rtt.log") )) { file.Create(wxT("rtt.log")); file.Close(); } if( !file.Exists(wxT("availability.log")) ) { file.Create(wxT("availability.log")); file.Close(); } if( !file.Exists(wxT("throughput.log")) ) { file.Create(wxT("throughput.log")); file.Close(); } // The standard results Result *r = (*m_Results)[wxT("standard")]; wxFileInputStream input( wxT("standard.log") ); if( input.Ok() ) { wxTextInputStream text( input ); do { wxString str = text.ReadLine(); // Just skip empty lines if( str.Trim().Trim(false).Length() == 0 ) continue; wxStringTokenizer tkz(str, wxT("\t"), wxTOKEN_RET_EMPTY ); StringValueList *row = new StringValueList(); wxString *Date = new wxString( tkz.GetNextToken() ); wxString *Bandwidth = new wxString( tkz.GetNextToken() ); row->Append( Date ); row->Append( Bandwidth ); r->AddRow( *row ); } while( input.IsOk() ); } // The availability results r = (*m_Results)[wxT("availability")]; wxFileInputStream input_avail( wxT("availability.log") ); if( input_avail.Ok() ) { wxTextInputStream text_avail( input_avail ); do { wxString str = text_avail.ReadLine(); // Just skip empty lines if( str.Trim().Trim(false).Length() == 0 ) continue; wxStringTokenizer tkz(str, wxT("\t"), wxTOKEN_RET_EMPTY ); StringValueList *row = new StringValueList(); wxString *Date = new wxString( tkz.GetNextToken() ); wxString *TCP_Connects = new wxString( tkz.GetNextToken() ); wxString *TCP_Count = new wxString( tkz.GetNextToken() ); wxString *ICMP_Sent = new wxString( tkz.GetNextToken() ); wxString *ICMP_Rec = new wxString( tkz.GetNextToken() ); wxString *ICMP_Count = new wxString( tkz.GetNextToken() ); wxString *ICMP_Values = new wxString( tkz.GetNextToken() ); wxString *TCP_Values = new wxString( tkz.GetNextToken() ); // TEMPORARY FIX FOR CHANGE OF FORMAT // FROM VERSION 5.0 -> 5.0.1 ICMP_Values->Replace( wxT(","), wxT("|") ); TCP_Values->Replace( wxT(","), wxT("|") ); row->Append( Date ); row->Append( TCP_Connects ); row->Append( TCP_Count ); row->Append( ICMP_Sent ); row->Append( ICMP_Rec ); row->Append( ICMP_Count ); row->Append( ICMP_Values ); row->Append( TCP_Values ); r->AddRow( *row ); } while( input_avail.IsOk() ); } // The rtt packeloss results r = (*m_Results)[wxT("rtt")]; wxFileInputStream input_rtt( wxT("rtt.log") ); if( input_rtt.Ok() ) { wxTextInputStream text_rtt( input_rtt ); do { wxString str = text_rtt.ReadLine(); // Just skip empty lines if( str.Trim().Trim(false).Length() == 0 ) continue; wxStringTokenizer tkz(str, wxT("\t"), wxTOKEN_RET_EMPTY ); StringValueList *row = new StringValueList(); wxString *Date = new wxString( tkz.GetNextToken() ); wxString *Responding = new wxString( tkz.GetNextToken() ); wxString *HostCount = new wxString( tkz.GetNextToken() ); wxString *Packets_Sent = new wxString( tkz.GetNextToken() ); wxString *Packets_Recieved = new wxString( tkz.GetNextToken() ); wxString *RTT_Max = new wxString( tkz.GetNextToken() ); wxString *RTT_Min = new wxString( tkz.GetNextToken() ); wxString *RTT_Average = new wxString( tkz.GetNextToken() ); wxString *Jitter = new wxString( tkz.GetNextToken() ); wxString *RTT_Values = new wxString( tkz.GetNextToken() ); // TEMPORARY FIX FOR CHANGE OF FORMAT // FROM VERSION 5.0 -> 5.0.1 RTT_Values->Replace(wxT(","), wxT("|")); row->Append( Date ); row->Append( Responding); row->Append( HostCount ); row->Append( Packets_Sent ); row->Append( Packets_Recieved ); row->Append( RTT_Max ); row->Append( RTT_Min ); row->Append( RTT_Average ); row->Append( Jitter ); row->Append( RTT_Values ); r->AddRow( *row ); } while( input_rtt.IsOk() ); } // The throughput packeloss results r = (*m_Results)[wxT("throughput")]; wxFileInputStream input_thr( wxT("throughput.log") ); if( input_thr.Ok() ) { wxTextInputStream text_thr( input_thr ); do { wxString str = text_thr.ReadLine(); // Just skip empty lines if( str.Trim().Trim(false).Length() == 0 ) continue; wxStringTokenizer tkz(str, wxT("\t"), wxTOKEN_RET_EMPTY ); StringValueList *row = new StringValueList(); wxString *Date = new wxString( tkz.GetNextToken() ); wxString *TPDown = new wxString( tkz.GetNextToken() ); wxString *TPUp = new wxString( tkz.GetNextToken() ); wxString *HTTP = new wxString( tkz.GetNextToken() ); wxString *FTP = new wxString( tkz.GetNextToken() ); wxString *D_TP_Values = new wxString( tkz.GetNextToken() ); wxString *U_TP_Values = new wxString( tkz.GetNextToken() ); wxString *HTTP_Values = new wxString( tkz.GetNextToken() ); wxString *FTP_Values = new wxString( tkz.GetNextToken() ); // TEMPORARY FIX FOR CHANGE OF FORMAT // FROM VERSION 5.0 -> 5.0.1 D_TP_Values->Replace(wxT(","), wxT("|")); U_TP_Values->Replace(wxT(","), wxT("|")); HTTP_Values->Replace(wxT(","), wxT("|")); FTP_Values->Replace(wxT(","), wxT("|")); row->Append( Date ); row->Append( TPDown ); row->Append( TPUp ); row->Append( HTTP ); row->Append( FTP ); row->Append( D_TP_Values ); row->Append( U_TP_Values ); row->Append( HTTP_Values ); row->Append( FTP_Values ); r->AddRow( *row ); } while( input_thr.IsOk() ); } wxSetWorkingDirectory( strDefaultCwd ); return true; }