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

//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright © 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 13/04/2001
// PROJECT:
// SUBSYSTEM:
// FILE: EnableDTRDlg.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of EnableDTRDlg.cpp
//----------------------------------------------------------------------------
// EnableDTRDlg.cpp : implementation file
//
#include "stdafx.h"
#include "chicago.h"
#include "EnableDTRDlg.h"
#include "SensorSPRU.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEnableDTRDlg dialog
CEnableDTRDlg::CEnableDTRDlg(CWnd* pParent /*=NULL*/)
: CDialog(CEnableDTRDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEnableDTRDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CEnableDTRDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEnableDTRDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEnableDTRDlg, CDialog)
//{{AFX_MSG_MAP(CEnableDTRDlg)
ON_CBN_SELCHANGE(IDC_ENABLE_DTR_COMBO_ZONE, OnSelchangeEnableDtrComboZone)
ON_CBN_SELCHANGE(IDC_ENABLE_DTR_COMBO_SENSOR, OnSelchangeEnableDtrComboSensor)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEnableDTRDlg message handlers
void CEnableDTRDlg::SetParam( CSensorArray *pSensorArray, int nZone, int nSensor, int nBit )
{
m_pSensorArray = pSensorArray;
m_nZone = nZone;
m_nSensor = nSensor;
m_nBit = nBit;
}
void CEnableDTRDlg::SetZone(CSensorArray *pSensorArray, int nZone )
{
m_nZone = nZone;
CZone *pZone = m_pSensorArray->GetZone( m_nZone );
CComboBox *pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_ZONE );
pCB->ResetContent();
for( int z = 0; z < m_pSensorArray->GetZoneCount(); z++ )
pCB->AddString( m_pSensorArray->GetZone( z )->GetName() );
pCB->AddString( "- ALL -" );
pCB->SetCurSel( m_nZone );
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_SENSOR );
pCB->ResetContent();
for( int s = 0; s < pZone->GetCount(); s++ )
pCB->AddString( pZone->GetSensor( s )->GetName() );
pCB->SetCurSel( m_nSensor = pCB->AddString( "- ALL -" ) );
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_BIT );
pCB->ResetContent();
pCB->SetCurSel( m_nBit = pCB->AddString( "- ALL -" ) );
}
void CEnableDTRDlg::SetSensor(CSensorArray *pSensorArray, int nSensor )
{
m_nSensor = nSensor;
CSensorSPRU *pSensor = (CSensorSPRU*)m_pSensorArray->GetSensor( nSensor );
m_nZone = pSensor->GetZone()->GetIndex();
CZone *pZone = m_pSensorArray->GetZone( m_nZone );
CComboBox *pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_ZONE );
pCB->ResetContent();
for( int z = 0; z < m_pSensorArray->GetZoneCount(); z++ )
pCB->AddString( m_pSensorArray->GetZone( z )->GetName() );
pCB->AddString( "- ALL -" );
pCB->SetCurSel( m_nZone );
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_SENSOR );
pCB->ResetContent();
for( int s = 0; s < pZone->GetCount(); s++ )
pCB->AddString( pZone->GetSensor( s )->GetName() );
pCB->AddString( "- ALL -" );
pCB->SetCurSel( pSensor->GetZoneIndex() );
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_BIT );
pCB->ResetContent();
pCB->SetCurSel( pCB->AddString( "- ALL -" ) );
}
void CEnableDTRDlg::SetBit(CSensorArray *pSensorArray, int nSensor, int nBit )
{
}
BOOL CEnableDTRDlg::OnInitDialog()
{
CDialog::OnInitDialog();
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 CEnableDTRDlg::OnSelchangeEnableDtrComboZone()
{
CComboBox *pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_ZONE );
m_nZone = pCB->GetCurSel();
if( m_nZone < m_pSensorArray->GetZoneCount() )
{
CZone *pZone = m_pSensorArray->GetZone( m_nZone );
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_SENSOR );
pCB->ResetContent();
for( int s = 0; s < pZone->GetCount(); s++ )
pCB->AddString( pZone->GetSensor( s )->GetName() );
pCB->SetCurSel( m_nSensor = pCB->AddString( "- ALL -" ) );
pCB->EnableWindow( TRUE );
}
else
{
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_SENSOR );
pCB->ResetContent();
pCB->SetCurSel( m_nSensor = pCB->AddString( "- ALL -" ) );
pCB->EnableWindow( FALSE );
}
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_BIT );
pCB->ResetContent();
pCB->SetCurSel( m_nBit = pCB->AddString( "- ALL -" ) );
pCB->EnableWindow( FALSE );
}
void CEnableDTRDlg::OnSelchangeEnableDtrComboSensor()
{
if( m_nZone < m_pSensorArray->GetZoneCount() )
{
CComboBox *pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_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_DTR_COMBO_BIT );
pCB->ResetContent();
for( int b = 0; b < pSensor->GetCount(); b++ )
{
CString str;
str.Format( "%d", b );
pCB->AddString( str );
}
pCB->SetCurSel( m_nBit = pCB->AddString( "- ALL -" ) );
pCB->EnableWindow( TRUE );
}
else
{
pCB = (CComboBox*) GetDlgItem( IDC_ENABLE_DTR_COMBO_BIT );
pCB->ResetContent();
pCB->SetCurSel( m_nBit = pCB->AddString( "- ALL -" ) );
pCB->EnableWindow( FALSE );
}
}
}