Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

189 lines
5.2 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: StatisticDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of StatisticDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // StatisticDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "StatisticDlg.h"
  19. #include "..\..\LgLib\Version.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CStatisticDlg dialog
  27. CStatisticDlg::CStatisticDlg(CWnd* pParent /*=NULL*/)
  28. : CDialog(CStatisticDlg::IDD, pParent)
  29. {
  30. //{{AFX_DATA_INIT(CStatisticDlg)
  31. // NOTE: the ClassWizard will add member initialization here
  32. //}}AFX_DATA_INIT
  33. m_pSensorArray = NULL;
  34. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CStatisticDlg::CStatisticDlg") );
  35. }
  36. void CStatisticDlg::DoDataExchange(CDataExchange* pDX)
  37. {
  38. CDialog::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(CStatisticDlg)
  40. DDX_Control(pDX, IDC_EDIT_USER, m_Win9XUser);
  41. DDX_Control(pDX, IDC_EDIT_SYSTEM, m_Win9XSystem);
  42. DDX_Control(pDX, IDC_EDIT_GDI, m_Win9XGDI);
  43. DDX_Control(pDX, IDC_EDIT_VIRTUAL, m_Virtual);
  44. DDX_Control(pDX, IDC_EDIT_PHYSICAL, m_Physical);
  45. DDX_Control(pDX, IDC_EDIT_PAGEFILE, m_PageFile);
  46. DDX_Control(pDX, IDC_LIST_SOCKETS, m_Sockets);
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(CStatisticDlg, CDialog)
  50. //{{AFX_MSG_MAP(CStatisticDlg)
  51. ON_WM_TIMER()
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CStatisticDlg message handlers
  56. void CStatisticDlg::SetSensorArray(CSensorArray *pSensorArray)
  57. {
  58. m_pSensorArray = pSensorArray;
  59. }
  60. void CStatisticDlg::OnTimer(UINT nIDEvent)
  61. {
  62. if( m_pSensorArray )
  63. {
  64. for( int i = 0; i < m_pSensorArray->GetSocketCount(); i++ )
  65. {
  66. CString str;
  67. str.Format( "%d", m_pSensorArray->GetSocket(i)->GetPerformance() );
  68. m_Sockets.SetItemText( i, 1, str );
  69. __int64 s = m_pSensorArray->GetSocket(i)->GetSuccess();
  70. __int64 f = m_pSensorArray->GetSocket(i)->GetFailure();
  71. if( !s )
  72. {
  73. if( !f ) m_Sockets.SetItemText( i, 2, "0" );
  74. else
  75. {
  76. // str.Format( "%I64u(100%%)", f );
  77. str.Format( "%I64u", f );
  78. m_Sockets.SetItemText( i, 2, str );
  79. }
  80. m_Sockets.SetItemText( i, 3, "0" );
  81. }
  82. else
  83. {
  84. if( !f )
  85. {
  86. m_Sockets.SetItemText( i, 2, "0" );
  87. // str.Format( "%I64u(100%%)", s );
  88. str.Format( "%I64u", s );
  89. m_Sockets.SetItemText( i, 3, str );
  90. }
  91. else
  92. {
  93. // double p = 100.0 * f / ( s + f );
  94. // str.Format( "%I64u(~%0.1f%%)", f, p );
  95. str.Format( "%I64u", f );
  96. m_Sockets.SetItemText( i, 2, str );
  97. // str.Format( "%I64u(~%0.1f%%)", s, 100.0-p );
  98. str.Format( "%I64u", s );
  99. m_Sockets.SetItemText( i, 3, str );
  100. }
  101. }
  102. }
  103. }
  104. CString strParameter;
  105. MEMORYSTATUS ms;
  106. ::GlobalMemoryStatus( &ms );
  107. /*
  108. #define MAKE_PRETTY_BYTES( s, n ) \
  109. if( n > 1024 * 1024 ) \
  110. s.Format( _T("%dMb"), n >> 20 ); \
  111. else if( n > 1024 ) \
  112. s.Format( _T("%dKb"), n >> 10 ); \
  113. else \
  114. s.Format( _T("%d"), n );
  115. MAKE_PRETTY_BYTES( strParameter, ms.dwAvailPhys );
  116. m_Physical.SetWindowText( strParameter );
  117. MAKE_PRETTY_BYTES( strParameter, ms.dwAvailPageFile );
  118. m_PageFile.SetWindowText( strParameter );
  119. MAKE_PRETTY_BYTES( strParameter, ms.dwAvailVirtual );
  120. m_Virtual.SetWindowText( strParameter );
  121. */
  122. strParameter.Format( _T("%d"), ms.dwAvailPhys );
  123. m_Physical.SetWindowText( strParameter );
  124. strParameter.Format( _T("%d"), ms.dwAvailPageFile );
  125. m_PageFile.SetWindowText( strParameter );
  126. strParameter.Format( _T("%d"), ms.dwAvailVirtual );
  127. m_Virtual.SetWindowText( strParameter );
  128. strParameter.Format( _T("%d%%"), m_ResourceMeterWin9x.GetSystemResources() );
  129. m_Win9XSystem.SetWindowText( strParameter );
  130. strParameter.Format( _T("%d%%"), m_ResourceMeterWin9x.GetUserResources() );
  131. m_Win9XUser.SetWindowText( strParameter );
  132. strParameter.Format( _T("%d%%"), m_ResourceMeterWin9x.GetGDIResources() );
  133. m_Win9XGDI.SetWindowText( strParameter );
  134. CDialog::OnTimer(nIDEvent);
  135. }
  136. BOOL CStatisticDlg::OnInitDialog()
  137. {
  138. CDialog::OnInitDialog();
  139. CRect rect;
  140. m_Sockets.GetClientRect( &rect );
  141. int nWidth = rect.Width() / 4;
  142. m_Sockets.InsertColumn( 0, "Line", LVCFMT_LEFT, nWidth, 0 );
  143. m_Sockets.InsertColumn( 1, "Speed", LVCFMT_LEFT, nWidth, 1 );
  144. m_Sockets.InsertColumn( 2, "Failure", LVCFMT_LEFT, nWidth, 2 );
  145. m_Sockets.InsertColumn( 3, "Success", LVCFMT_LEFT, nWidth, 3 );
  146. if( m_pSensorArray )
  147. {
  148. for( int i = 0; i < m_pSensorArray->GetSocketCount(); i++ )
  149. {
  150. CString str = m_pSensorArray->GetSocket( i )->GetName();
  151. m_Sockets.InsertItem( i, str );
  152. }
  153. }
  154. m_ResourceMeterWin9x.Create();
  155. return TRUE; // return TRUE unless you set the focus to a control
  156. // EXCEPTION: OCX Property Pages should return FALSE
  157. }