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.
126 lines
3.5 KiB
126 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: PatrolDlg.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of PatrolDlg.cpp
|
|
//----------------------------------------------------------------------------
|
|
// PatrolDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "chicago.h"
|
|
#include "PatrolDlg.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CPatrolDlg dialog
|
|
|
|
|
|
CPatrolDlg::CPatrolDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CPatrolDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CPatrolDlg)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPatrolDlg::CPatrolDlg") );
|
|
}
|
|
|
|
|
|
void CPatrolDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CPatrolDlg)
|
|
DDX_Control(pDX, IDC_LIST_PATROL, m_ListPatrol);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CPatrolDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CPatrolDlg)
|
|
ON_NOTIFY(NM_DBLCLK, IDC_LIST_PATROL, OnDblclkListPatrol)
|
|
ON_WM_TIMER()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CPatrolDlg message handlers
|
|
|
|
BOOL CPatrolDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
CRect rect;
|
|
m_ListPatrol.GetClientRect( &rect );
|
|
|
|
int width = rect.Width();
|
|
|
|
m_ListPatrol.InsertColumn( 0, "Name", LVCFMT_LEFT, width / 2, 0 );
|
|
m_ListPatrol.InsertColumn( 1, "State", LVCFMT_LEFT, width / 2, 1 );
|
|
|
|
CPatrol *pPatrol = m_pSensorArray->GetPatrol();
|
|
for( int i = 0; i < pPatrol->GetCount(); i++ )
|
|
{
|
|
m_ListPatrol.InsertItem( i, pPatrol->GetName( i ) );
|
|
if( pPatrol->IsActive( i ) )
|
|
m_ListPatrol.SetItemText( i, 1, "ACTIVATED" );
|
|
else
|
|
m_ListPatrol.SetItemText( i, 1, "NOT ACTIVE" );
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CPatrolDlg::SetSensorArray(CSensorArray *pSensorArray)
|
|
{
|
|
m_pSensorArray = pSensorArray;
|
|
}
|
|
|
|
void CPatrolDlg::OnDblclkListPatrol(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
LPNMLISTVIEW pNMLV = (LPNMLISTVIEW)pNMHDR;
|
|
if( pNMLV->iItem != -1 )
|
|
{
|
|
m_pSensorArray->GetPatrol()->Activate( pNMLV->iItem, TRUE );
|
|
/*
|
|
if( !m_pSensorArray->GetPatrol()->IsActive( pNMLV->iItem ) )
|
|
{
|
|
PATROL *pPatrol = m_pSensorArray->GetPatrol( pNMLV->iItem );
|
|
DWORD dwCT = ::GetTickCount();
|
|
pPatrol->nActive = 0;
|
|
pPatrol->maxTime = dwCT + pPatrol->pPoints[ pPatrol->nActive ].nTime *
|
|
( 100 + pPatrol->pPoints[ pPatrol->nActive ].nTolerance ) / 100;
|
|
pPatrol->minTime = dwCT + pPatrol->pPoints[ pPatrol->nActive ].nTime *
|
|
( 100 - pPatrol->pPoints[ pPatrol->nActive ].nTolerance ) / 100;
|
|
pPatrol->bActive = TRUE;
|
|
m_pSensorArray->GetEventQueue()->PostEvent( EVENT_PATROL, TRUE, 0, 0, RGB(0,0xFF,0), "patrol started" );
|
|
}
|
|
*/ }
|
|
*pResult = 0;
|
|
}
|
|
|
|
void CPatrolDlg::OnTimer(UINT nIDEvent)
|
|
{
|
|
CPatrol *pPatrol = m_pSensorArray->GetPatrol();
|
|
for( int i = 0; i < pPatrol->GetCount(); i++ )
|
|
{
|
|
if( pPatrol->IsActive( i ) )
|
|
m_ListPatrol.SetItemText( i, 1, "ACTIVATED" );
|
|
else
|
|
m_ListPatrol.SetItemText( i, 1, "NOT ACTIVE" );
|
|
}
|
|
CDialog::OnTimer(nIDEvent);
|
|
}
|