|
|
//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright � 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: EnableDlg.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of EnableDlg.cpp
//----------------------------------------------------------------------------
// EnableDlg.cpp : implementation file
//
#include "stdafx.h"
#include "chicago.h"
#include "EnableDlg.h"
#include "..\DLIB\SensorSPRU.h"
#include "..\..\LgLib\Version.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;#endif
/////////////////////////////////////////////////////////////////////////////
// CEnableDlg dialog
CEnableDlg::CEnableDlg(CWnd* pParent /*=NULL*/) : CDialog(CEnableDlg::IDD, pParent){ //{{AFX_DATA_INIT(CEnableDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_nMode = COMMON; m_nZone = -1; m_nSensor = -1; m_nBit = -1; m_pSensorArray = NULL;
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CEnableDlg::CEnableDlg") );}
void CEnableDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CEnableDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEnableDlg, CDialog) //{{AFX_MSG_MAP(CEnableDlg)
ON_CBN_SELCHANGE(IDC_ENABLE_COMBO_ZONE, OnSelchangeEnableComboZone) ON_CBN_SELCHANGE(IDC_ENABLE_COMBO_SENSOR, OnSelchangeEnableComboSensor) ON_BN_CLICKED(IDC_ENABLE, OnEnable) ON_BN_CLICKED(IDC_DISABLE, OnDisable) ON_CBN_SELCHANGE(IDC_ENABLE_COMBO_DTRBIT, OnSelchangeEnableComboDtrbit) //}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEnableDlg message handlers
void CEnableDlg::SetParam( CSensorArray *pSensorArray){ m_pSensorArray = pSensorArray; m_nZone = -1; m_nSensor = -1; m_nBit = -1; m_nMode = COMMON;}
void CEnableDlg::SetParam( CSensorArray *pSensorArray, CZone *pZone ){ m_pSensorArray = pSensorArray; m_nZone = pZone->GetIndex(); m_nSensor = -1; m_nBit = -1; m_nMode = ZONE;}
void CEnableDlg::SetParam( CSensorArray *pSensorArray, CSensor *pSensor ){ m_pSensorArray = pSensorArray; m_nZone = pSensor->GetZone()->GetIndex(); m_nSensor = pSensor->GetZone()->GetSensorIndex( pSensor ); m_nBit = -1; m_nMode = SENSOR;}
void CEnableDlg::SetParam( CSensorArray *pSensorArray, CSensor *pSensor, int nBit ){ m_pSensorArray = pSensorArray; m_nZone = pSensor->GetZone()->GetIndex(); m_nSensor = pSensor->GetZone()->GetSensorIndex( pSensor ); m_nBit = nBit; m_nMode = DTRBIT;}
BOOL CEnableDlg::OnInitDialog() { CDialog::OnInitDialog(); CComboBox *pCB; CZone *pZone; CSensorSPRU *pSensor; BOOL bAutoSelect = FALSE; int z, s, b; switch( m_nMode ) { case COMMON: pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_ZONE ); pCB->ResetContent(); pSensor = NULL; for( z = 0; z < m_pSensorArray->GetZoneCount(); z++ ) { pZone = m_pSensorArray->GetZone( z ); if( pZone->GetState() == CVisual::TIMEOUT ) { m_nZone = z; bAutoSelect = TRUE; goto CASE_ZONE; } pCB->AddString( pZone->GetName() ); } pCB->AddString( "- ALL -" ); pCB->SetCurSel( m_nZone = pCB->AddString( "- NONE -" ) );
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_SENSOR ); pCB->ResetContent(); pCB->AddString( "- ALL -" ); pCB->SetCurSel( m_nSensor = pCB->AddString( "- NONE -" ) ); pCB->EnableWindow( FALSE );
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_DTRBIT ); pCB->ResetContent(); pCB->AddString( "- ALL -" ); pCB->SetCurSel( m_nBit = pCB->AddString( "- NONE -" ) ); pCB->EnableWindow( FALSE );
GetDlgItem( IDC_DISABLE )->EnableWindow(FALSE); GetDlgItem( IDC_ENABLE )->EnableWindow(FALSE);
break;
CASE_ZONE:
case ZONE: pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_ZONE ); pCB->ResetContent(); for( z = 0; z < m_pSensorArray->GetZoneCount(); z++ ) pCB->AddString( m_pSensorArray->GetZone( z )->GetName() ); pCB->AddString( "- ALL -" ); pCB->AddString( "- NONE -" ); pCB->SetCurSel( m_nZone );
pZone = m_pSensorArray->GetZone( m_nZone );
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_SENSOR ); pCB->ResetContent(); for( s = 0; s < pZone->GetCount(); s++ ) { pCB->AddString( pZone->GetSensor( s )->GetName() ); if( pZone->GetSensor( s )->GetState() ==CVisual::TIMEOUT ) { m_nSensor = s; bAutoSelect = TRUE; goto CASE_SENSOR; } } pCB->AddString( "- ALL -" ); pCB->SetCurSel( m_nSensor = pCB->AddString( "- NONE -" ) ); pCB->EnableWindow( TRUE );
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_DTRBIT ); pCB->ResetContent(); pCB->AddString( "- ALL -" ); pCB->SetCurSel( m_nBit = pCB->AddString( "- NONE -" ) ); pCB->EnableWindow( FALSE );
GetDlgItem( IDC_DISABLE )->EnableWindow(FALSE); GetDlgItem( IDC_ENABLE )->EnableWindow(FALSE);
break;
CASE_SENSOR:
case SENSOR: pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_ZONE ); pCB->ResetContent(); for( z = 0; z < m_pSensorArray->GetZoneCount(); z++ ) pCB->AddString( m_pSensorArray->GetZone( z )->GetName() ); pCB->AddString( "- ALL -" ); pCB->AddString( "- NONE -" ); pCB->SetCurSel( m_nZone );
pZone = m_pSensorArray->GetZone( m_nZone );
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_SENSOR ); pCB->ResetContent(); for( s = 0; s < pZone->GetCount(); s++ ) pCB->AddString( pZone->GetSensor( s )->GetName() ); pCB->AddString( "- ALL -" ); pCB->AddString( "- NONE -" ); pCB->SetCurSel( m_nSensor ); pCB->EnableWindow( TRUE );
pSensor = (CSensorSPRU*)pZone->GetSensor( m_nSensor ); pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_DTRBIT ); pCB->ResetContent(); for( b = 0; b < pSensor->GetBitCount(); b++ ) { CString str; str.Format( "%d", b ); pCB->AddString( str ); }
if( !bAutoSelect ) { pCB->AddString( "- ALL -" ); pCB->SetCurSel( m_nBit = pCB->AddString( "- NONE -" ) ); GetDlgItem( IDC_DISABLE )->EnableWindow(FALSE); GetDlgItem( IDC_ENABLE )->EnableWindow(FALSE); } else { pCB->SetCurSel( m_nBit = pCB->AddString( "- ALL -" ) ); pCB->AddString( "- NONE -" ); GetDlgItem( IDC_DISABLE )->EnableWindow(TRUE); GetDlgItem( IDC_ENABLE )->EnableWindow(TRUE); } pCB->EnableWindow( TRUE );
break;
case DTRBIT: pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_ZONE ); pCB->ResetContent(); for( z = 0; z < m_pSensorArray->GetZoneCount(); z++ ) pCB->AddString( m_pSensorArray->GetZone( z )->GetName() ); pCB->AddString( "- ALL -" ); pCB->AddString( "- NONE -" ); pCB->SetCurSel( m_nZone );
pZone = m_pSensorArray->GetZone( m_nZone );
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_SENSOR ); pCB->ResetContent(); for( s = 0; s < pZone->GetCount(); s++ ) pCB->AddString( pZone->GetSensor( s )->GetName() ); pCB->AddString( "- ALL -" ); pCB->AddString( "- NONE -" ); pCB->SetCurSel( m_nSensor ); pCB->EnableWindow( TRUE );
pSensor = (CSensorSPRU*)pZone->GetSensor( m_nSensor ); pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_DTRBIT ); pCB->ResetContent(); for( b = 0; b < pSensor->GetBitCount(); b++ ) { CString str; str.Format( "%d", b ); pCB->AddString( str ); } pCB->AddString( "- ALL -" ); pCB->AddString( "- NONE -" ); pCB->SetCurSel( m_nBit ); pCB->EnableWindow( TRUE );
GetDlgItem( IDC_DISABLE )->EnableWindow(TRUE); GetDlgItem( IDC_ENABLE )->EnableWindow(TRUE);
break; }// SetZone( m_pSensorArray, m_nZone );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CEnableDlg::OnSelchangeEnableComboZone() { CComboBox *pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_ZONE ); m_nZone = pCB->GetCurSel(); if( m_nZone < m_pSensorArray->GetZoneCount() ) { CZone *pZone = m_pSensorArray->GetZone( m_nZone );
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_SENSOR ); pCB->ResetContent(); for( int s = 0; s < pZone->GetCount(); s++ ) pCB->AddString( pZone->GetSensor( s )->GetName() ); pCB->AddString( "- ALL -" ); pCB->SetCurSel( m_nSensor = pCB->AddString( "- NONE -" ) ); pCB->EnableWindow( TRUE ); GetDlgItem( IDC_DISABLE )->EnableWindow(FALSE); GetDlgItem( IDC_ENABLE )->EnableWindow(FALSE); } else if( m_nZone == m_pSensorArray->GetZoneCount() ) { pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_SENSOR ); pCB->ResetContent(); pCB->SetCurSel( m_nSensor = pCB->AddString( "- ALL -" ) ); pCB->AddString( "- NONE -" ); pCB->EnableWindow( FALSE ); GetDlgItem( IDC_DISABLE )->EnableWindow(TRUE); GetDlgItem( IDC_ENABLE )->EnableWindow(TRUE); } else { pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_SENSOR ); pCB->ResetContent(); pCB->AddString( "- ALL -" ); pCB->SetCurSel( m_nSensor = pCB->AddString( "- NONE -" ) ); pCB->EnableWindow( FALSE ); GetDlgItem( IDC_DISABLE )->EnableWindow(FALSE); GetDlgItem( IDC_ENABLE )->EnableWindow(FALSE); }
if( m_nZone == m_pSensorArray->GetZoneCount() ) { pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_DTRBIT ); pCB->ResetContent(); pCB->SetCurSel( m_nBit = pCB->AddString( "- ALL -" ) ); pCB->AddString( "- NONE -" ); pCB->EnableWindow( FALSE ); } else { pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_DTRBIT ); pCB->ResetContent(); pCB->AddString( "- ALL -" ); pCB->SetCurSel( m_nBit = pCB->AddString( "- NONE -" ) ); pCB->EnableWindow( FALSE ); }}
void CEnableDlg::OnSelchangeEnableComboSensor() { if( m_nZone < m_pSensorArray->GetZoneCount() ) { CComboBox *pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_SENSOR ); m_nSensor = pCB->GetCurSel();
CZone *pZone = m_pSensorArray->GetZone( m_nZone ); if( m_nSensor < pZone->GetCount() ) { CSensorSPRU *pSensor = (CSensorSPRU*)pZone->GetSensor( m_nSensor ); pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_DTRBIT ); pCB->ResetContent(); for( int b = 0; b < pSensor->GetBitCount(); b++ ) { CString str; str.Format( "%d", b ); pCB->AddString( str ); } pCB->AddString( "- ALL -" ); pCB->SetCurSel( m_nBit = pCB->AddString( "- NONE -" ) ); pCB->EnableWindow( TRUE ); GetDlgItem( IDC_DISABLE )->EnableWindow(FALSE); GetDlgItem( IDC_ENABLE )->EnableWindow(FALSE); } else if( m_nSensor == pZone->GetCount() ) { pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_DTRBIT ); pCB->ResetContent(); pCB->SetCurSel( m_nBit = pCB->AddString( "- ALL -" ) ); pCB->AddString( "- NONE -" ); pCB->EnableWindow( FALSE ); GetDlgItem( IDC_DISABLE )->EnableWindow(TRUE); GetDlgItem( IDC_ENABLE )->EnableWindow(TRUE); } else { pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_DTRBIT ); pCB->ResetContent(); pCB->AddString( "- ALL -" ); pCB->SetCurSel( m_nBit = pCB->AddString( "- NONE -" ) ); pCB->EnableWindow( FALSE ); GetDlgItem( IDC_DISABLE )->EnableWindow(FALSE); GetDlgItem( IDC_ENABLE )->EnableWindow(FALSE); } }}
void CEnableDlg::OnSelchangeEnableComboDtrbit() { CZone *pZone = m_pSensorArray->GetZone( m_nZone ); CSensorSPRU *pSensor = (CSensorSPRU*)pZone->GetSensor( m_nSensor ); CComboBox *pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_DTRBIT ); m_nBit = pCB->GetCurSel(); if( m_nBit <= pSensor->GetBitCount() ) { GetDlgItem( IDC_DISABLE )->EnableWindow(TRUE); GetDlgItem( IDC_ENABLE )->EnableWindow(TRUE); } else { GetDlgItem( IDC_DISABLE )->EnableWindow(FALSE); GetDlgItem( IDC_ENABLE )->EnableWindow(FALSE); }}
void CEnableDlg::OnEnable(){ CComboBox *pCB; pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_ZONE ); m_nZone = pCB->GetCurSel(); if( m_nZone < m_pSensorArray->GetZoneCount() ) { CZone *pZone = m_pSensorArray->GetZone( m_nZone ); pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_SENSOR ); m_nSensor = pCB->GetCurSel(); if( m_nSensor < pZone->GetCount() ) { CSensorSPRU *pSensor = (CSensorSPRU*)pZone->GetSensor( m_nSensor ); pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_DTRBIT ); m_nBit = pCB->GetCurSel(); if( m_nBit < pSensor->GetBitCount() ) { pSensor->Enable( TRUE, m_nBit ); } else { pSensor->Enable( TRUE ); } } else { for( int s = 0; s < pZone->GetCount(); s++ ) pZone->GetSensor( s )->Enable( TRUE ); } pZone->UpdateState(); } else { for( int z = 0; z < m_pSensorArray->GetZoneCount(); z++ ) m_pSensorArray->GetZone( z )->Enable( TRUE ); } EndDialog( IDOK ); }
void CEnableDlg::OnDisable() { MoveWindow( CRect( -1, -1, -1, -1 ) ); if( !GetParent()->SendMessage( WM_AUTORIZATION, 0, 0 ) ) { EndDialog( IDOK ); return; } CComboBox *pCB; pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_ZONE ); m_nZone = pCB->GetCurSel(); if( m_nZone < m_pSensorArray->GetZoneCount() ) { CZone *pZone = m_pSensorArray->GetZone( m_nZone ); pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_SENSOR ); m_nSensor = pCB->GetCurSel(); if( m_nSensor < pZone->GetCount() ) { CSensorSPRU *pSensor = (CSensorSPRU*)pZone->GetSensor( m_nSensor ); pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_DTRBIT ); m_nBit = pCB->GetCurSel(); if( m_nBit < pSensor->GetBitCount() ) { pSensor->Enable( FALSE, m_nBit ); } else { pSensor->Enable( FALSE ); } } else { for( int s = 0; s < pZone->GetCount(); s++ ) pZone->GetSensor( s )->Enable( FALSE ); } pZone->UpdateState(); } else { for( int z = 0; z < m_pSensorArray->GetZoneCount(); z++ ) m_pSensorArray->GetZone( z )->Enable( FALSE ); } EndDialog( IDOK ); }
/*
void CEnableDlg::OnButtonSoundDisable() { CComboBox *pCB; pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_ZONE ); m_nZone = pCB->GetCurSel(); if( m_nZone < m_pSensorArray->GetZoneCount() ) { CZone *pZone = m_pSensorArray->GetZone( m_nZone ); pZone->EnableSoundAlarm( FALSE ); } else { for( int z = 0; z < m_pSensorArray->GetZoneCount(); z++ ) m_pSensorArray->GetZone( z )->EnableSoundAlarm( FALSE ); } EndDialog( IDOK ); }
void CEnableDlg::OnButtonSoundEnable() { CComboBox *pCB; pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_COMBO_ZONE ); m_nZone = pCB->GetCurSel(); if( m_nZone < m_pSensorArray->GetZoneCount() ) { CZone *pZone = m_pSensorArray->GetZone( m_nZone ); pZone->EnableSoundAlarm( TRUE ); } else { for( int z = 0; z < m_pSensorArray->GetZoneCount(); z++ ) m_pSensorArray->GetZone( z )->EnableSoundAlarm( TRUE ); } EndDialog( IDOK ); }*/
|