// DlgIntelligentLog.cpp : implementation file
//

#include "stdafx.h"
#include "Smart_Smart.h"
#include "DlgIntelligentLog.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgSmartLog dialog
CDlgSmartLog*     g_dlgSmartSetLog = NULL;

CDlgSmartLog::CDlgSmartLog(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgSmartLog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgSmartLog)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	g_dlgSmartSetLog = this;
}


void CDlgSmartLog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgSmartLog)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgSmartLog, CDialog)
	//{{AFX_MSG_MAP(CDlgSmartLog)
	ON_BN_CLICKED(IDC_BTN_CLEANALARM, OnBtnCleanalarm)
	ON_WM_DESTROY()
	ON_MESSAGE(WM_UPALARMLOG,OnVAAlarm)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgSmartLog message handlers

void CDlgSmartLog::OnOK() 
{

}

void CDlgSmartLog::OnCancel() 
{

}

BOOL CDlgSmartLog::OnInitDialog() 
{
	CDialog::OnInitDialog();

	CRect rc(0,0,0,0);
	GetParent()->GetClientRect(&rc);
	((CTabCtrl*)GetParent())->AdjustRect(FALSE,&rc);
	MoveWindow(&rc);
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgSmartLog::OnBtnCleanalarm() 
{
	// TODO: Add your control notification handler code here
	SetDlgItemText(IDC_EDIT_ALARMMSG,"");
}
LRESULT CDlgSmartLog::OnVAAlarm(WPARAM wParam,LPARAM lParam)
{
    CString    szAlarm;
    CTime      curTime;
	CString    szAlarmMsg;
	
	GetDlgItemText(IDC_EDIT_ALARMMSG,szAlarmMsg);

    curTime = CTime::GetCurrentTime();
    szAlarm.Format("%02d:%02d:%02d : ",curTime.GetHour(),curTime.GetMinute(),curTime.GetSecond());
	
    switch (wParam)
    {
    case LAUMSG_VAALARM_SINGLELINE:
        szAlarm += "绊线规则报警\r\n";
        break;
    case LAUMSG_VAALARM_DOUBLELINE:
        szAlarm += "双线规则报警\r\n";
        break;
    case LAUMSG_VAALARM_REGIONENTER:
        szAlarm += "区域进入报警\r\n";
        break;
    case LAUMSG_VAALARM_REGIONLEFT:
        szAlarm += "区域离开报警\r\n";
        break;
    case LAUMSG_VAALARM_REGIONWANDER:
        szAlarm += "区域徘徊报警\r\n";
        break;
    }
	
    szAlarmMsg += szAlarm;
    GetDlgItem(IDC_EDIT_ALARMMSG)->SetWindowText(szAlarmMsg);
	UpdateWindow();
	return 0;
}

void CDlgSmartLog::OnDestroy() 
{
	CDialog::OnDestroy();
	
	// TODO: Add your message handler code here
	g_dlgSmartSetLog = NULL;
}
