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.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: ResetDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of ResetDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // ResetDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "ResetDlg.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. // CResetDlg dialog
  27. CResetDlg::CResetDlg(CWnd* pParent /*=NULL*/)
  28. : CDialog(CResetDlg::IDD, pParent)
  29. {
  30. //{{AFX_DATA_INIT(CResetDlg)
  31. m_ResetReason = 0;
  32. m_strReason = _T("");
  33. //}}AFX_DATA_INIT
  34. m_pSensorArray = NULL;
  35. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CResetDlg::CResetDlg") );
  36. }
  37. void CResetDlg::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CDialog::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CResetDlg)
  41. DDX_Control(pDX, IDC_COMBO_SENSOR, m_ComboSensor);
  42. DDX_Control(pDX, IDC_EDIT_REASON, m_EditReason);
  43. DDX_Radio(pDX, IDC_RADIO_RESET_REASON, m_ResetReason);
  44. DDX_Text(pDX, IDC_EDIT_REASON, m_strReason);
  45. DDV_MaxChars(pDX, m_strReason, 20);
  46. //}}AFX_DATA_MAP
  47. }
  48. BEGIN_MESSAGE_MAP(CResetDlg, CDialog)
  49. //{{AFX_MSG_MAP(CResetDlg)
  50. ON_BN_CLICKED(IDC_RADIO_RESET_REASON, OnRadioResetReason)
  51. ON_BN_CLICKED(IDC_RADIO1, OnRadioResetReason)
  52. ON_BN_CLICKED(IDC_RADIO2, OnRadioResetReason)
  53. ON_BN_CLICKED(IDC_RADIO3, OnRadioResetReason)
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CResetDlg message handlers
  58. void CResetDlg::OnOK()
  59. {
  60. UpdateData( TRUE );
  61. CSensor *pSensor = m_pSensorArray->GetSensor( m_ComboSensor.GetCurSel() );
  62. m_pSensorArray->Reset( pSensor );
  63. LPCTSTR pSensorName = pSensor ? (LPCTSTR)pSensor->GetName() : _T("full");
  64. TCHAR pText[MAX_PATH];
  65. switch( m_ResetReason )
  66. {
  67. case 0: _sntprintf( pText, MAX_PATH, _T("%s clear (intruder)"), pSensorName ); break;
  68. case 1: _sntprintf( pText, MAX_PATH, _T("%s clear (weather)"), pSensorName ); break;
  69. case 2: _sntprintf( pText, MAX_PATH, _T("%s clear (technical)"), pSensorName ); break;
  70. case 3: _sntprintf( pText, MAX_PATH, _T("%s clear (%s)"), pSensorName, (LPCTSTR)m_strReason ); break;
  71. default:
  72. _sntprintf( pText, MAX_PATH, _T("%s clear (%s)"), pSensorName, (LPSTR)(LPCTSTR)m_strReason );
  73. break;
  74. }
  75. m_pSensorArray->GetEventQueue()->PostEvent( LGS_EVENT_PROGRAM_RESET, 0, 0, m_ResetReason, RGB(0xFF,0xFF,0xFF), (LPSTR)(LPCTSTR)pText );
  76. if( pSensor )
  77. CDialog::OnCancel();
  78. else
  79. CDialog::OnOK();
  80. }
  81. void CResetDlg::SetSensorArray(CSensorArray *pSensorArray)
  82. {
  83. m_pSensorArray = pSensorArray;
  84. }
  85. void CResetDlg::OnRadioResetReason()
  86. {
  87. UpdateData(TRUE);
  88. if( m_ResetReason == 3 )
  89. m_EditReason.EnableWindow( TRUE );
  90. else
  91. m_EditReason.EnableWindow( FALSE );
  92. }
  93. BOOL CResetDlg::OnInitDialog()
  94. {
  95. CDialog::OnInitDialog();
  96. for( int i = 0; i < m_pSensorArray->GetSensorCount(); i++ )
  97. {
  98. CSensor *pSensor = m_pSensorArray->GetSensor(i);
  99. ASSERT( pSensor );
  100. m_ComboSensor.AddString( pSensor->GetName() );
  101. }
  102. int nIndex = m_ComboSensor.AddString( _T("- ALL SENSORS -") );
  103. m_ComboSensor.SetCurSel( nIndex );
  104. return TRUE;
  105. }