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.

133 lines
3.3 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: ResetLgsDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of ResetLgsDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // ResetLgsDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "ResetLgsDlg.h"
  19. #include "..\Dlib\SensorLGS.h"
  20. #include "..\..\LgLib\Version.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. CResetLgsDlg::CResetLgsDlg(CWnd* pParent /*=NULL*/)
  27. : CDialog(CResetLgsDlg::IDD, pParent)
  28. {
  29. //{{AFX_DATA_INIT(CResetLgsDlg)
  30. // NOTE: the ClassWizard will add member initialization here
  31. //}}AFX_DATA_INIT
  32. m_pSensorArray = NULL;
  33. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CResetLgsDlg::CResetLgsDlg") );
  34. }
  35. void CResetLgsDlg::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CDialog::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(CResetLgsDlg)
  39. DDX_Control(pDX, IDC_BUTTON_LGS_RESET, m_bnLgsReset);
  40. DDX_Control(pDX, IDC_COMBO_LGS, m_ComboLgsSensor);
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CResetLgsDlg, CDialog)
  44. //{{AFX_MSG_MAP(CResetLgsDlg)
  45. ON_BN_CLICKED(IDC_BUTTON_LGS_RESET, OnButtonLgsReset)
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CResetLgsDlg message handlers
  50. void CResetLgsDlg::SetSensorArray(CSensorArray *pSensorArray)
  51. {
  52. m_pSensorArray = pSensorArray;
  53. }
  54. BOOL CResetLgsDlg::OnInitDialog()
  55. {
  56. CDialog::OnInitDialog();
  57. ASSERT( m_pSensorArray );
  58. INT nDeviceCount = 0;
  59. for( int i = 0; i < m_pSensorArray->GetSensorCount(); i++ )
  60. {
  61. CSensor *pSensor = m_pSensorArray->GetSensor(i);
  62. ASSERT( pSensor );
  63. if( pSensor->GetType() == CSensor::LGS &&
  64. !((CSensorLGS*)pSensor)->IsSpyMode() )
  65. {
  66. int nIndex = m_ComboLgsSensor.AddString( pSensor->GetName() );
  67. m_ComboLgsSensor.SetItemDataPtr( nIndex, pSensor );
  68. nDeviceCount++;
  69. }
  70. }
  71. if( nDeviceCount )
  72. {
  73. int nIndex = m_ComboLgsSensor.AddString( _T("- ALL LGS -") );
  74. m_ComboLgsSensor.SetItemDataPtr( nIndex, NULL );
  75. m_ComboLgsSensor.SetCurSel( nIndex );
  76. }
  77. else
  78. {
  79. // disable all controls
  80. m_ComboLgsSensor.EnableWindow( FALSE );
  81. m_bnLgsReset.EnableWindow( FALSE );
  82. }
  83. return TRUE;
  84. }
  85. void CResetLgsDlg::OnButtonLgsReset()
  86. {
  87. CSensorLGS *pSensor = (CSensorLGS*)m_ComboLgsSensor.GetItemDataPtr( m_ComboLgsSensor.GetCurSel() );
  88. if( pSensor )
  89. pSensor->CmdReset( FALSE );
  90. else
  91. {
  92. for( int i = 0; i < m_pSensorArray->GetSensorCount(); i++ )
  93. {
  94. CSensorLGS *pSensorLgs = (CSensorLGS*)m_pSensorArray->GetSensor(i);
  95. ASSERT( pSensorLgs );
  96. if( pSensorLgs->GetType() == CSensor::LGS )
  97. {
  98. pSensorLgs->CmdReset( FALSE );
  99. }
  100. }
  101. }
  102. LPCTSTR pSensorName = pSensor ? (LPCTSTR)pSensor->GetName() : _T("full");
  103. CString str;
  104. str.Format( _T("%s hardware reset"), pSensorName );
  105. m_pSensorArray->GetEventQueue()->PostEvent( LGS_EVENT_PROGRAM_RESET, 0, 0, 0, RGB(0xFF,0xFF,0xFF), (LPSTR)(LPCTSTR)str );
  106. CDialog::OnOK();
  107. }