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

//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright © 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: ResetDlg.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of ResetDlg.cpp
//----------------------------------------------------------------------------
// ResetDlg.cpp : implementation file
//
#include "stdafx.h"
#include "chicago.h"
#include "ResetDlg.h"
#include "..\..\LgLib\Version.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CResetDlg dialog
CResetDlg::CResetDlg(CWnd* pParent /*=NULL*/)
: CDialog(CResetDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CResetDlg)
m_ResetReason = 0;
m_strReason = _T("");
//}}AFX_DATA_INIT
m_pSensorArray = NULL;
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CResetDlg::CResetDlg") );
}
void CResetDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CResetDlg)
DDX_Control(pDX, IDC_COMBO_SENSOR, m_ComboSensor);
DDX_Control(pDX, IDC_EDIT_REASON, m_EditReason);
DDX_Radio(pDX, IDC_RADIO_RESET_REASON, m_ResetReason);
DDX_Text(pDX, IDC_EDIT_REASON, m_strReason);
DDV_MaxChars(pDX, m_strReason, 20);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CResetDlg, CDialog)
//{{AFX_MSG_MAP(CResetDlg)
ON_BN_CLICKED(IDC_RADIO_RESET_REASON, OnRadioResetReason)
ON_BN_CLICKED(IDC_RADIO1, OnRadioResetReason)
ON_BN_CLICKED(IDC_RADIO2, OnRadioResetReason)
ON_BN_CLICKED(IDC_RADIO3, OnRadioResetReason)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResetDlg message handlers
void CResetDlg::OnOK()
{
UpdateData( TRUE );
CSensor *pSensor = m_pSensorArray->GetSensor( m_ComboSensor.GetCurSel() );
m_pSensorArray->Reset( pSensor );
LPCTSTR pSensorName = pSensor ? (LPCTSTR)pSensor->GetName() : _T("full");
TCHAR pText[MAX_PATH];
switch( m_ResetReason )
{
case 0: _sntprintf( pText, MAX_PATH, _T("%s clear (intruder)"), pSensorName ); break;
case 1: _sntprintf( pText, MAX_PATH, _T("%s clear (weather)"), pSensorName ); break;
case 2: _sntprintf( pText, MAX_PATH, _T("%s clear (technical)"), pSensorName ); break;
case 3: _sntprintf( pText, MAX_PATH, _T("%s clear (%s)"), pSensorName, (LPCTSTR)m_strReason ); break;
default:
_sntprintf( pText, MAX_PATH, _T("%s clear (%s)"), pSensorName, (LPSTR)(LPCTSTR)m_strReason );
break;
}
m_pSensorArray->GetEventQueue()->PostEvent( LGS_EVENT_PROGRAM_RESET, 0, 0, m_ResetReason, RGB(0xFF,0xFF,0xFF), (LPSTR)(LPCTSTR)pText );
if( pSensor )
CDialog::OnCancel();
else
CDialog::OnOK();
}
void CResetDlg::SetSensorArray(CSensorArray *pSensorArray)
{
m_pSensorArray = pSensorArray;
}
void CResetDlg::OnRadioResetReason()
{
UpdateData(TRUE);
if( m_ResetReason == 3 )
m_EditReason.EnableWindow( TRUE );
else
m_EditReason.EnableWindow( FALSE );
}
BOOL CResetDlg::OnInitDialog()
{
CDialog::OnInitDialog();
for( int i = 0; i < m_pSensorArray->GetSensorCount(); i++ )
{
CSensor *pSensor = m_pSensorArray->GetSensor(i);
ASSERT( pSensor );
m_ComboSensor.AddString( pSensor->GetName() );
}
int nIndex = m_ComboSensor.AddString( _T("- ALL SENSORS -") );
m_ComboSensor.SetCurSel( nIndex );
return TRUE;
}