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.

126 lines
3.5 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: PatrolDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of PatrolDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // PatrolDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "PatrolDlg.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. // CPatrolDlg dialog
  27. CPatrolDlg::CPatrolDlg(CWnd* pParent /*=NULL*/)
  28. : CDialog(CPatrolDlg::IDD, pParent)
  29. {
  30. //{{AFX_DATA_INIT(CPatrolDlg)
  31. // NOTE: the ClassWizard will add member initialization here
  32. //}}AFX_DATA_INIT
  33. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPatrolDlg::CPatrolDlg") );
  34. }
  35. void CPatrolDlg::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CDialog::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(CPatrolDlg)
  39. DDX_Control(pDX, IDC_LIST_PATROL, m_ListPatrol);
  40. //}}AFX_DATA_MAP
  41. }
  42. BEGIN_MESSAGE_MAP(CPatrolDlg, CDialog)
  43. //{{AFX_MSG_MAP(CPatrolDlg)
  44. ON_NOTIFY(NM_DBLCLK, IDC_LIST_PATROL, OnDblclkListPatrol)
  45. ON_WM_TIMER()
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CPatrolDlg message handlers
  50. BOOL CPatrolDlg::OnInitDialog()
  51. {
  52. CDialog::OnInitDialog();
  53. CRect rect;
  54. m_ListPatrol.GetClientRect( &rect );
  55. int width = rect.Width();
  56. m_ListPatrol.InsertColumn( 0, "Name", LVCFMT_LEFT, width / 2, 0 );
  57. m_ListPatrol.InsertColumn( 1, "State", LVCFMT_LEFT, width / 2, 1 );
  58. CPatrol *pPatrol = m_pSensorArray->GetPatrol();
  59. for( int i = 0; i < pPatrol->GetCount(); i++ )
  60. {
  61. m_ListPatrol.InsertItem( i, pPatrol->GetName( i ) );
  62. if( pPatrol->IsActive( i ) )
  63. m_ListPatrol.SetItemText( i, 1, "ACTIVATED" );
  64. else
  65. m_ListPatrol.SetItemText( i, 1, "NOT ACTIVE" );
  66. }
  67. return TRUE;
  68. }
  69. void CPatrolDlg::SetSensorArray(CSensorArray *pSensorArray)
  70. {
  71. m_pSensorArray = pSensorArray;
  72. }
  73. void CPatrolDlg::OnDblclkListPatrol(NMHDR* pNMHDR, LRESULT* pResult)
  74. {
  75. LPNMLISTVIEW pNMLV = (LPNMLISTVIEW)pNMHDR;
  76. if( pNMLV->iItem != -1 )
  77. {
  78. m_pSensorArray->GetPatrol()->Activate( pNMLV->iItem, TRUE );
  79. /*
  80. if( !m_pSensorArray->GetPatrol()->IsActive( pNMLV->iItem ) )
  81. {
  82. PATROL *pPatrol = m_pSensorArray->GetPatrol( pNMLV->iItem );
  83. DWORD dwCT = ::GetTickCount();
  84. pPatrol->nActive = 0;
  85. pPatrol->maxTime = dwCT + pPatrol->pPoints[ pPatrol->nActive ].nTime *
  86. ( 100 + pPatrol->pPoints[ pPatrol->nActive ].nTolerance ) / 100;
  87. pPatrol->minTime = dwCT + pPatrol->pPoints[ pPatrol->nActive ].nTime *
  88. ( 100 - pPatrol->pPoints[ pPatrol->nActive ].nTolerance ) / 100;
  89. pPatrol->bActive = TRUE;
  90. m_pSensorArray->GetEventQueue()->PostEvent( EVENT_PATROL, TRUE, 0, 0, RGB(0,0xFF,0), "patrol started" );
  91. }
  92. */ }
  93. *pResult = 0;
  94. }
  95. void CPatrolDlg::OnTimer(UINT nIDEvent)
  96. {
  97. CPatrol *pPatrol = m_pSensorArray->GetPatrol();
  98. for( int i = 0; i < pPatrol->GetCount(); i++ )
  99. {
  100. if( pPatrol->IsActive( i ) )
  101. m_ListPatrol.SetItemText( i, 1, "ACTIVATED" );
  102. else
  103. m_ListPatrol.SetItemText( i, 1, "NOT ACTIVE" );
  104. }
  105. CDialog::OnTimer(nIDEvent);
  106. }