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.

192 lines
5.7 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: 13/04/2001
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: EnableDTRDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of EnableDTRDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // EnableDTRDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "EnableDTRDlg.h"
  19. #include "SensorSPRU.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CEnableDTRDlg dialog
  27. CEnableDTRDlg::CEnableDTRDlg(CWnd* pParent /*=NULL*/)
  28. : CDialog(CEnableDTRDlg::IDD, pParent)
  29. {
  30. //{{AFX_DATA_INIT(CEnableDTRDlg)
  31. // NOTE: the ClassWizard will add member initialization here
  32. //}}AFX_DATA_INIT
  33. }
  34. void CEnableDTRDlg::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CDialog::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(CEnableDTRDlg)
  38. // NOTE: the ClassWizard will add DDX and DDV calls here
  39. //}}AFX_DATA_MAP
  40. }
  41. BEGIN_MESSAGE_MAP(CEnableDTRDlg, CDialog)
  42. //{{AFX_MSG_MAP(CEnableDTRDlg)
  43. ON_CBN_SELCHANGE(IDC_ENABLE_DTR_COMBO_ZONE, OnSelchangeEnableDtrComboZone)
  44. ON_CBN_SELCHANGE(IDC_ENABLE_DTR_COMBO_SENSOR, OnSelchangeEnableDtrComboSensor)
  45. //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CEnableDTRDlg message handlers
  49. void CEnableDTRDlg::SetParam( CSensorArray *pSensorArray, int nZone, int nSensor, int nBit )
  50. {
  51. m_pSensorArray = pSensorArray;
  52. m_nZone = nZone;
  53. m_nSensor = nSensor;
  54. m_nBit = nBit;
  55. }
  56. void CEnableDTRDlg::SetZone(CSensorArray *pSensorArray, int nZone )
  57. {
  58. m_nZone = nZone;
  59. CZone *pZone = m_pSensorArray->GetZone( m_nZone );
  60. CComboBox *pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_ZONE );
  61. pCB->ResetContent();
  62. for( int z = 0; z < m_pSensorArray->GetZoneCount(); z++ )
  63. pCB->AddString( m_pSensorArray->GetZone( z )->GetName() );
  64. pCB->AddString( "- ALL -" );
  65. pCB->SetCurSel( m_nZone );
  66. pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_SENSOR );
  67. pCB->ResetContent();
  68. for( int s = 0; s < pZone->GetCount(); s++ )
  69. pCB->AddString( pZone->GetSensor( s )->GetName() );
  70. pCB->SetCurSel( m_nSensor = pCB->AddString( "- ALL -" ) );
  71. pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_BIT );
  72. pCB->ResetContent();
  73. pCB->SetCurSel( m_nBit = pCB->AddString( "- ALL -" ) );
  74. }
  75. void CEnableDTRDlg::SetSensor(CSensorArray *pSensorArray, int nSensor )
  76. {
  77. m_nSensor = nSensor;
  78. CSensorSPRU *pSensor = (CSensorSPRU*)m_pSensorArray->GetSensor( nSensor );
  79. m_nZone = pSensor->GetZone()->GetIndex();
  80. CZone *pZone = m_pSensorArray->GetZone( m_nZone );
  81. CComboBox *pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_ZONE );
  82. pCB->ResetContent();
  83. for( int z = 0; z < m_pSensorArray->GetZoneCount(); z++ )
  84. pCB->AddString( m_pSensorArray->GetZone( z )->GetName() );
  85. pCB->AddString( "- ALL -" );
  86. pCB->SetCurSel( m_nZone );
  87. pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_SENSOR );
  88. pCB->ResetContent();
  89. for( int s = 0; s < pZone->GetCount(); s++ )
  90. pCB->AddString( pZone->GetSensor( s )->GetName() );
  91. pCB->AddString( "- ALL -" );
  92. pCB->SetCurSel( pSensor->GetZoneIndex() );
  93. pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_BIT );
  94. pCB->ResetContent();
  95. pCB->SetCurSel( pCB->AddString( "- ALL -" ) );
  96. }
  97. void CEnableDTRDlg::SetBit(CSensorArray *pSensorArray, int nSensor, int nBit )
  98. {
  99. }
  100. BOOL CEnableDTRDlg::OnInitDialog()
  101. {
  102. CDialog::OnInitDialog();
  103. SetZone( m_pSensorArray, m_nZone );
  104. return TRUE; // return TRUE unless you set the focus to a control
  105. // EXCEPTION: OCX Property Pages should return FALSE
  106. }
  107. void CEnableDTRDlg::OnSelchangeEnableDtrComboZone()
  108. {
  109. CComboBox *pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_ZONE );
  110. m_nZone = pCB->GetCurSel();
  111. if( m_nZone < m_pSensorArray->GetZoneCount() )
  112. {
  113. CZone *pZone = m_pSensorArray->GetZone( m_nZone );
  114. pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_SENSOR );
  115. pCB->ResetContent();
  116. for( int s = 0; s < pZone->GetCount(); s++ )
  117. pCB->AddString( pZone->GetSensor( s )->GetName() );
  118. pCB->SetCurSel( m_nSensor = pCB->AddString( "- ALL -" ) );
  119. pCB->EnableWindow( TRUE );
  120. }
  121. else
  122. {
  123. pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_SENSOR );
  124. pCB->ResetContent();
  125. pCB->SetCurSel( m_nSensor = pCB->AddString( "- ALL -" ) );
  126. pCB->EnableWindow( FALSE );
  127. }
  128. pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_BIT );
  129. pCB->ResetContent();
  130. pCB->SetCurSel( m_nBit = pCB->AddString( "- ALL -" ) );
  131. pCB->EnableWindow( FALSE );
  132. }
  133. void CEnableDTRDlg::OnSelchangeEnableDtrComboSensor()
  134. {
  135. if( m_nZone < m_pSensorArray->GetZoneCount() )
  136. {
  137. CComboBox *pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_SENSOR );
  138. m_nSensor = pCB->GetCurSel();
  139. CZone *pZone = m_pSensorArray->GetZone( m_nZone );
  140. if( m_nSensor < pZone->GetCount() )
  141. {
  142. CSensorSPRU *pSensor = (CSensorSPRU*)pZone->GetSensor( m_nSensor );
  143. pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_BIT );
  144. pCB->ResetContent();
  145. for( int b = 0; b < pSensor->GetCount(); b++ )
  146. {
  147. CString str;
  148. str.Format( "%d", b );
  149. pCB->AddString( str );
  150. }
  151. pCB->SetCurSel( m_nBit = pCB->AddString( "- ALL -" ) );
  152. pCB->EnableWindow( TRUE );
  153. }
  154. else
  155. {
  156. pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_BIT );
  157. pCB->ResetContent();
  158. pCB->SetCurSel( m_nBit = pCB->AddString( "- ALL -" ) );
  159. pCB->EnableWindow( FALSE );
  160. }
  161. }
  162. }