www.pudn.com > RADAR-ALARM.rar > RadarViewDlg.cpp, change:2011-08-15,size:20580b


// RadarViewDlg.cpp : 实现文件 
// 
 
#include "stdafx.h" 
#include "RadarView.h" 
#include "RadarViewDlg.h" 
#include "ReadRadarBaseData.h" 
#include "RadarAlert.h" 
#include "ParInfoGraph.h" 
#include "ThresholdSetDlg.h" 
#include   "mmsystem.h" 
#pragma    comment(lib,"winmm.lib")  
#include   "AlertLight.h" 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#endif 
 
 
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 
 
class CAboutDlg : public CDialog 
{ 
public: 
	CAboutDlg(); 
 
// 对话框数据 
	enum { IDD = IDD_ABOUTBOX }; 
 
	protected: 
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持 
 
// 实现 
protected: 
	DECLARE_MESSAGE_MAP() 
public: 
}; 
 
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 
{ 
} 
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
} 
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 
 
END_MESSAGE_MAP() 
 
 
// CRadarViewDlg 对话框 
 
 
 
 
CRadarViewDlg::CRadarViewDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CRadarViewDlg::IDD, pParent) 
	, m_ShowElIndex(0)	 
	, RBinNum(2) 
	, RAziNum(2) 
	, RRange(60) 
	, R05ValueThreshold(40) 
	, R05SingleAreaThreshold(100) 
	, R05TotalAreaThreshold(1000) 
	, R15ValueThreshold(40) 
	, R15SingleAreaThreshold(100) 
	, R15TotalAreaThreshold(1000) 
	, VBinNum(2) 
	, VAziNum(2) 
	, VRange(60) 
	, V05ValueThreshold(20) 
	, V05SingleAreaThreshold(100) 
	, V05TotalAreaThreshold(1000) 
	, V15ValueThreshold(20) 
	, V15SingleAreaThreshold(100) 
	, V15TotalAreaThreshold(1000) 
	, m_LastProcessFileName(_T("")) 
	, m_LastFileIndex(0) 
	, m_ProcessFoldername(_T("")) 
{ 
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); 
} 
 
void CRadarViewDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	DDX_Control(pDX, IDC_STATIC1, m_graph1); 
	DDX_Control(pDX, IDC_STATIC2, m_graph2); 
	DDX_Control(pDX, IDC_STATIC3, m_InfoGraph1); 
	DDX_Control(pDX, IDC_STATIC4, m_InfoGraph2); 
	DDX_Control(pDX, IDC_LIST2, m_RAlertList); 
	DDX_Control(pDX, IDC_LIST1, m_VAlertList); 
	DDX_Control(pDX, IDC_STATIC5, m_ShowR05TotalAreaString); 
	DDX_Control(pDX, IDC_STATIC6, m_ShowV05TotalAreaString); 
	DDX_Control(pDX, IDC_STATIC7, m_ShowR15TotalAreaString); 
	DDX_Control(pDX, IDC_STATIC8, m_ShowV15TotalAreaString); 
	DDX_Control(pDX, IDC_STATIC9, m_RLight); 
	DDX_Control(pDX, IDC_STATIC10, m_VLight); 
	DDX_Control(pDX, IDC_RADIO1, m_ElStatus1); 
} 
 
BEGIN_MESSAGE_MAP(CRadarViewDlg, CDialog) 
	ON_WM_SYSCOMMAND() 
	ON_WM_PAINT() 
	ON_WM_QUERYDRAGICON() 
	//}}AFX_MSG_MAP 
	ON_BN_CLICKED(IDC_BUTTON1, &CRadarViewDlg::OnBnClickedButton1) 
	ON_COMMAND(ID_32772, &CRadarViewDlg::On32772) 
	ON_COMMAND(ID_32774, &CRadarViewDlg::On32774) 
	ON_BN_CLICKED(IDC_BUTTON2, &CRadarViewDlg::OnBnClickedButton2) 
	ON_BN_CLICKED(IDC_RADIO1, &CRadarViewDlg::OnBnClickedRadio1) 
	ON_BN_CLICKED(IDC_RADIO2, &CRadarViewDlg::OnBnClickedRadio2) 
	ON_BN_CLICKED(IDC_BUTTON3, &CRadarViewDlg::OnBnClickedButton3) 
	ON_BN_CLICKED(IDC_BUTTON4, &CRadarViewDlg::OnBnClickedButton4) 
	ON_COMMAND(ID_32775, &CRadarViewDlg::On32775) 
	ON_WM_TIMER() 
END_MESSAGE_MAP() 
 
 
// CRadarViewDlg 消息处理程序 
 
BOOL CRadarViewDlg::OnInitDialog() 
{ 
	CDialog::OnInitDialog(); 
 
	// 将“关于...”菜单项添加到系统菜单中。 
 
	// IDM_ABOUTBOX 必须在系统命令范围内。 
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); 
	ASSERT(IDM_ABOUTBOX < 0xF000); 
 
	CMenu* pSysMenu = GetSystemMenu(FALSE); 
	if (pSysMenu != NULL) 
	{ 
		CString strAboutMenu; 
		strAboutMenu.LoadString(IDS_ABOUTBOX); 
		if (!strAboutMenu.IsEmpty()) 
		{ 
			pSysMenu->AppendMenu(MF_SEPARATOR); 
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); 
		} 
	} 
 
	// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 
	//  执行此操作 
	SetIcon(m_hIcon, TRUE);			// 设置大图标 
	SetIcon(m_hIcon, FALSE);		// 设置小图标 
 
	// TODO: 在此添加额外的初始化代码 
	m_InfoGraph1.m_GraphMode=0; 
	m_InfoGraph2.m_GraphMode=1; 
	 
	m_graph1.m_ZoomFlag=true; 
	m_graph2.m_ZoomFlag=true; 
 
	m_graph1.m_alertfilename=_T("R05Alert"); 
	m_graph2.m_alertfilename=_T("V05Alert"); 
 
	m_ElStatus1.SetCheck(1); 
	ReadAlertPram(); 
 
    InitCtrlPos(); 
	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE 
} 
 
void CRadarViewDlg::OnSysCommand(UINT nID, LPARAM lParam) 
{ 
	if ((nID & 0xFFF0) == IDM_ABOUTBOX) 
	{ 
		CAboutDlg dlgAbout; 
		dlgAbout.DoModal(); 
	} 
	else 
	{ 
		CDialog::OnSysCommand(nID, lParam); 
	} 
} 
 
// 如果向对话框添加最小化按钮,则需要下面的代码 
//  来绘制该图标。对于使用文档/视图模型的 MFC 应用程序, 
//  这将由框架自动完成。 
 
void CRadarViewDlg::OnPaint() 
{ 
	if (IsIconic()) 
	{ 
		CPaintDC dc(this); // 用于绘制的设备上下文 
 
		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); 
 
		// 使图标在工作区矩形中居中 
		int cxIcon = GetSystemMetrics(SM_CXICON); 
		int cyIcon = GetSystemMetrics(SM_CYICON); 
		CRect rect; 
		GetClientRect(&rect); 
		int x = (rect.Width() - cxIcon + 1) / 2; 
		int y = (rect.Height() - cyIcon + 1) / 2; 
 
		// 绘制图标 
		dc.DrawIcon(x, y, m_hIcon); 
	} 
	else 
	{ 
		CDialog::OnPaint(); 
	} 
} 
 
//当用户拖动最小化窗口时系统调用此函数取得光标 
//显示。 
HCURSOR CRadarViewDlg::OnQueryDragIcon() 
{ 
	return static_cast<HCURSOR>(m_hIcon); 
} 
 
 
void CRadarViewDlg::OnBnClickedButton1() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	 
	 
	 
	 
     
	/*CRadarAlert a; 
	a.m_Value=m_data.RData; 
	a.m_MaxBinNum=460; 
	a.test(); 
	int max=a.GetTotalArea(); 
	CString aa; 
	aa.Format(_T("%d"),max); 
	MessageBox(aa);*/ 
	 
	 
	 
	//PlayAlertSound(); 
 
} 
 
void CRadarViewDlg::InitCtrlPos(void) 
{ 
	CRect rect; 
	MoveWindow(0, 0, 1280, 750); 
 
	m_graph1.MoveWindow(5,0,460,460); 
	m_graph2.MoveWindow(580,0,460,460); 
	GetDlgItem(IDOK)->MoveWindow(600,580,70,20); 
	GetDlgItem(IDCANCEL)->MoveWindow(700,580,70,20); 
	GetDlgItem(IDC_BUTTON1)->MoveWindow(800,580,70,20); 
	m_InfoGraph1.MoveWindow(465,0,110,460); 
	m_InfoGraph2.MoveWindow(1040,0,110,460); 
	m_RAlertList.MoveWindow(5,490,510,200); 
	m_VAlertList.MoveWindow(630,490,510,200); 
	m_ShowR05TotalAreaString.MoveWindow(515,490,110,70); 
	m_ShowV05TotalAreaString.MoveWindow(1140,490,110,70); 
	m_ShowR15TotalAreaString.MoveWindow(515,560,110,70); 
    m_ShowV15TotalAreaString.MoveWindow(1140,560,110,70); 
	m_RLight.MoveWindow(515,632,110,50); 
	m_VLight.MoveWindow(1140,632,110,50); 
	GetDlgItem(IDC_BUTTON2)->MoveWindow(1150,140,120,50); 
	GetDlgItem(IDC_RADIO1)->MoveWindow(20,462,200,28); 
	GetDlgItem(IDC_RADIO2)->MoveWindow(250,462,200,28); 
	GetDlgItem(IDC_BUTTON3)->MoveWindow(1150,200,120,50); 
	GetDlgItem(IDC_BUTTON4)->MoveWindow(1150,80,120,50); 
	GetDlgItem(IDC_STATIC14)->MoveWindow(1150,0,120,70); 
 
 
} 
 
void CRadarViewDlg::OnOpenFile(CString filename) 
{   
    
	GetDlgItem(IDC_STATIC14)->SetWindowTextW(filename.Right(14)); 
	bool readflag=m_Data.ReadBaseData(filename); 
	if (readflag==false) 
	{ 
		MessageBox(_T("文件无法打开,请重试")); 
		return; 
	} 
	else 
	{ 
		m_graph1.RData=m_Data.RData; 
		m_graph1.m_GraphMode=0; 
		m_graph1.m_ShowMaxRadius=230; 
		m_graph1.m_DataReadyFlag=true; 
		m_graph1.m_LayerIndex=this->m_ShowElIndex; 
		m_graph1.Invalidate(); 
 
		m_graph2.VData=m_Data.VData; 
		m_graph2.m_GraphMode=1; 
		m_graph2.m_ShowMaxRadius=230; 
		m_graph2.m_DataReadyFlag=true; 
		m_graph2.m_LayerIndex=this->m_ShowElIndex; 
		m_graph2.Invalidate(); 
	} 
	bool flag1=AlertR05(filename); 
	bool flag2=AlertR15(filename); 
	bool flag3=AlertV05(filename); 
	bool flag4=AlertV15(filename); 
	UpdateData(false); 
	m_RLight.SetLight(flag1||flag2); 
	m_VLight.SetLight(flag3||flag4); 
	if(flag1||flag2||flag3||flag4) 
	{ 
		this->PlayAlertSound(); 
		m_graph1.m_GraphAlertFlag=true; 
		m_graph1.GraphLightAlert(); 
		m_graph2.m_GraphAlertFlag=true; 
		m_graph2.GraphLightAlert(); 
	} 
	//MessageBox(_T("ok")); 
	 
} 
 
void CRadarViewDlg::On32772() 
{ 
	// TODO: 在此添加命令处理程序代码 
	CFileDialog dlg(true,NULL,NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR); 
	CString filepath; 
	if(dlg.DoModal()==IDOK) 
	{ 
		filepath=dlg.GetPathName(); 
		OnOpenFile(filepath); 
	} 
 
} 
 
void CRadarViewDlg::On32774() 
{ 
	// TODO: 在此添加命令处理程序代码 
    CThresholdSetDlg dlg; 
	 if(dlg.DoModal()==IDOK) 
		 ReadAlertPram(); 
	//::PlaySound(NULL,NULL,NULL); 
} 
 
bool CRadarViewDlg::PlayAlertSound(void) 
{ 
	::PlaySound(_T("Alarm.WAV"),NULL,SND_ASYNC | SND_NOWAIT|SND_LOOP); 
	return false; 
} 
 
void CRadarViewDlg::ReadAlertPram(void) 
{ 
		CFile file; 
	if(file.Open(_T("config.dat"),CFile::modeRead)==true) 
	{ 
		file.Read (&RAziNum,sizeof(RAziNum)); 
		file.Read (&RBinNum,sizeof(int)); 
		file.Read (&RRange,sizeof(int)); 
		file.Read (&R05ValueThreshold,sizeof(int)); 
		file.Read (&R05SingleAreaThreshold,sizeof(int)); 
		file.Read (&R05TotalAreaThreshold,sizeof(int)); 
		file.Read (&R15ValueThreshold,sizeof(int)); 
		file.Read (&R15SingleAreaThreshold,sizeof(int)); 
		file.Read (&R15TotalAreaThreshold,sizeof(int)); 
 
		file.Read (&VAziNum,sizeof(RAziNum)); 
		file.Read (&VBinNum,sizeof(int)); 
		file.Read (&VRange,sizeof(int)); 
		file.Read (&V05ValueThreshold,sizeof(int)); 
		file.Read (&V05SingleAreaThreshold,sizeof(int)); 
		file.Read (&V05TotalAreaThreshold,sizeof(int)); 
		file.Read (&V15ValueThreshold,sizeof(int)); 
		file.Read (&V15SingleAreaThreshold,sizeof(int)); 
		file.Read (&V15TotalAreaThreshold,sizeof(int)); 
		file.Close(); 
	} 
	else 
	{ 
		RAziNum=2; 
		RBinNum=2; 
		RRange=60; 
		R05ValueThreshold=40; 
		R05SingleAreaThreshold=100; 
		R05TotalAreaThreshold=1000; 
		R15ValueThreshold=40; 
		R15SingleAreaThreshold=100; 
		R15TotalAreaThreshold=1000; 
         
		VAziNum=2; 
		VBinNum=2; 
		VRange=60; 
		V05ValueThreshold=20; 
		V05SingleAreaThreshold=100; 
		V05TotalAreaThreshold=1000; 
		V15ValueThreshold=20; 
		V15SingleAreaThreshold=100; 
		V15TotalAreaThreshold=1000; 
 
 
 
	} 
} 
 
bool CRadarViewDlg::AlertR05(CString filename) 
{ 
	bool R05flag=false; 
	CRadarAlert R05; 
	R05.m_Value=m_Data.RData; 
	R05.m_AlertBinNum=RBinNum; 
	R05.m_AlertAziNum=RAziNum; 
	R05.m_MaxBinNum=460; 
	R05.m_MaxElNum=20; 
	R05.m_Threshold=R05ValueThreshold; 
	R05.m_AlertRangeBin=RRange; 
	R05.m_ElIndex=0; 
	R05.m_SingleAreaThreshold=R05SingleAreaThreshold; 
	R05.m_AlertAreaFileName=_T("R05Alert"); 
	R05.AlertProcess(); 
	for(int i=0;i<R05.m_vectarea.size();i++) 
	{ 
		if(R05.m_vectarea[i].Area>=R05SingleAreaThreshold) 
		{ 
			WriteSigleAlert(0.5,R05.m_vectarea[i].MinAzi,R05.m_vectarea[i].MaxAzi,R05.m_vectarea[i].MinBin,R05.m_vectarea[i].MaxBin,R05.m_vectarea[i].Area,R05SingleAreaThreshold,0,filename); 
            R05flag=true; 
		} 
	} 
	if(R05.m_AlertTotalArea>R05TotalAreaThreshold) 
	{ 
		R05flag=true; 
		WriteTotalAlert(0.5,R05.m_AlertTotalArea,R05TotalAreaThreshold,0,filename); 
		 
		 
	} 
    CString str; 
		str.Format(_T("0.5度闭合强度场总面积为%d个库"),R05.m_AlertTotalArea); 
		this->m_ShowR05TotalAreaString.SetWindowTextW(str); 
	return R05flag; 
} 
 
bool CRadarViewDlg::AlertR15(CString filename) 
{ 
	bool R15flag=false; 
	CRadarAlert R15; 
	R15.m_Value=m_Data.RData; 
	R15.m_AlertBinNum=RBinNum; 
	R15.m_AlertAziNum=RAziNum; 
	R15.m_MaxBinNum=460; 
	R15.m_MaxElNum=20; 
	R15.m_Threshold=R15ValueThreshold; 
	R15.m_AlertRangeBin=RRange; 
	R15.m_ElIndex=1; 
	R15.m_SingleAreaThreshold=R15SingleAreaThreshold; 
	R15.m_AlertAreaFileName=_T("R15Alert"); 
	R15.AlertProcess(); 
	 
	for(int i=0;i<R15.m_vectarea.size();i++) 
	{ 
		if(R15.m_vectarea[i].Area>=R15SingleAreaThreshold) 
		{ 
			this->WriteSigleAlert(1.5,R15.m_vectarea[i].MinAzi,R15.m_vectarea[i].MaxAzi,R15.m_vectarea[i].MinBin,R15.m_vectarea[i].MaxBin,R15.m_vectarea[i].Area,R15SingleAreaThreshold,0,filename); 
            R15flag=true; 
		} 
	} 
	if(R15.m_AlertTotalArea>R15TotalAreaThreshold) 
	{ 
		R15flag=true; 
		WriteTotalAlert(1.5,R15.m_AlertTotalArea,R15TotalAreaThreshold,0,filename); 
		 
	} 
    CString str; 
		str.Format(_T("1.5度闭合强度场总面积为%d个库"),R15.m_AlertTotalArea); 
		this->m_ShowR15TotalAreaString.SetWindowTextW(str); 
	return R15flag; 
} 
 
bool CRadarViewDlg::AlertV05(CString filename) 
{ 
	bool V05flag=false; 
	CRadarAlert V05; 
	V05.m_Value=m_Data.VData; 
	V05.m_AlertBinNum=VBinNum; 
	V05.m_AlertAziNum=VAziNum; 
	V05.m_MaxBinNum=920; 
	V05.m_MaxElNum=20; 
	V05.m_Threshold=V05ValueThreshold; 
	V05.m_AlertRangeBin=VRange*4; 
	V05.m_ElIndex=0; 
	V05.m_SingleAreaThreshold=V05SingleAreaThreshold; 
	V05.m_AlertAreaFileName=_T("V05Alert"); 
	V05.AlertProcess(); 
	for(int i=0;i<V05.m_vectarea.size();i++) 
	{ 
		if(V05.m_vectarea[i].Area>=V05SingleAreaThreshold) 
		{ 
			WriteSigleAlert(0.5,V05.m_vectarea[i].MinAzi,V05.m_vectarea[i].MaxAzi,V05.m_vectarea[i].MinBin,V05.m_vectarea[i].MaxBin,V05.m_vectarea[i].Area,V05SingleAreaThreshold,1,filename); 
            V05flag=true; 
		} 
	} 
	if(V05.m_AlertTotalArea>V05TotalAreaThreshold) 
	{ 
		V05flag=true; 
		WriteTotalAlert(0.5,V05.m_AlertTotalArea,V05TotalAreaThreshold,1,filename); 
		 
	} 
    CString str; 
		str.Format(_T("0.5度闭合强度场总面积为%d个库"),V05.m_AlertTotalArea); 
		this->m_ShowV05TotalAreaString.SetWindowTextW(str);; 
	return V05flag; 
} 
 
bool CRadarViewDlg::AlertV15(CString filename) 
{ 
	bool V15flag=false; 
	CRadarAlert V15; 
	V15.m_Value=m_Data.VData; 
	V15.m_AlertBinNum=VBinNum; 
	V15.m_AlertAziNum=VAziNum; 
	V15.m_MaxBinNum=920; 
	V15.m_MaxElNum=20; 
	V15.m_Threshold=V15ValueThreshold; 
	V15.m_AlertRangeBin=VRange*4; 
	V15.m_ElIndex=1; 
	V15.m_SingleAreaThreshold=V15SingleAreaThreshold; 
	V15.m_AlertAreaFileName=_T("V15Alert"); 
	V15.AlertProcess(); 
	for(int i=0;i<V15.m_vectarea.size();i++) 
	{ 
		if(V15.m_vectarea[i].Area>=V15SingleAreaThreshold) 
		{ 
			WriteSigleAlert(1.5,V15.m_vectarea[i].MinAzi,V15.m_vectarea[i].MaxAzi,V15.m_vectarea[i].MinBin,V15.m_vectarea[i].MaxBin,V15.m_vectarea[i].Area,V15SingleAreaThreshold,1,filename); 
            V15flag=true; 
		} 
	} 
	if(V15.m_AlertTotalArea>V15TotalAreaThreshold) 
	{ 
		V15flag=true; 
		WriteTotalAlert(1.5,V15.m_AlertTotalArea,V15TotalAreaThreshold,1,filename); 
		 
	} 
    CString str; 
		str.Format(_T("1.5度闭合强度场总面积为%d个库"),V15.m_AlertTotalArea); 
		this->m_ShowV15TotalAreaString.SetWindowTextW(str); 
		 
	return V15flag; 
} 
 
void CRadarViewDlg::WriteSigleAlert(float El,int StartAzi,int EndAzi,int StartBin,int EndBin,int Area,int Threshold,int type,CString filename) 
{ 
	CString content,title; 
 
	CFile file; 
	file.Open(_T("alert.txt"),CFile::modeWrite|CFile::modeNoTruncate|CFile::modeCreate); 
	file.SeekToEnd(); 
//	file.Write("/xff/xfe", 2);  
	 
	if(type == 0) 
	{ 
		title.Format(_T("%s 强度场: 仰角:%6.2lf 单个面积报警\r\n"),filename,El); 
	   content.Format( _T("方位角:%d-%d,距离库:%d-%d,闭合区域面积:%d,门限:%d\r\n") 
		,StartAzi,EndAzi,StartBin,EndBin,Area,Threshold); 
		m_RAlertList.AddString(title); 
		m_RAlertList.AddString(content); 
		int nCount = m_RAlertList.GetCount(); 
		if (nCount > 0) 
		m_RAlertList.SetCurSel(nCount - 1); 
 
		 
	} 
	else 
	{ 
		title.Format(_T("%s 速度场:仰角:%6.2lf 单个面积报警\r\n"),filename,El); 
    	content.Format( _T("方位角:%d-%d,距离库:%d-%d,闭合区域面积:%d,门限:%d\r\n") 
		,StartAzi,EndAzi,StartBin,EndBin,Area,Threshold); 
		m_VAlertList.AddString(title); 
		m_VAlertList.AddString(content); 
		int nCount = m_VAlertList.GetCount(); 
		if (nCount > 0) 
		m_VAlertList.SetCurSel(nCount - 1); 
	} 
	file.Write(title,title.GetLength()*2); 
	file.Write(content,content.GetLength()*2); 
	file.Close(); 
	 
} 
 
void CRadarViewDlg::WriteTotalAlert(float El,int TotalArea ,int Threshold,int type,CString filename) 
{ 
	CString content,title; 
	CFile file; 
	file.Open(_T("alert.txt"),CFile::modeWrite|CFile::modeNoTruncate|CFile::modeCreate); 
	file.SeekToEnd(); 
	if(type == 0) 
	{ 
		title.Format(_T("%s 强度场: 仰角:%6.2lf 总面积报警\r\n"),filename,El); 
	   content.Format( _T("总面积%d,门限:%d\r\n") 
		,TotalArea,Threshold); 
		m_RAlertList.AddString(title); 
		m_RAlertList.AddString(content); 
		int nCount = m_RAlertList.GetCount(); 
		if (nCount > 0) 
		m_RAlertList.SetCurSel(nCount - 1); 
		 
	} 
	else 
	{ 
		title.Format(_T("速度场:仰角:%6.2lf 总面积报警\r\n"),El); 
    	content.Format( _T("总面积%d,门限:%d\r\n") 
		,TotalArea,Threshold); 
		m_VAlertList.AddString(title); 
		m_VAlertList.AddString(content); 
		int nCount = m_VAlertList.GetCount(); 
		if (nCount > 0) 
		m_VAlertList.SetCurSel(nCount - 1); 
	} 
	file.Write(title,title.GetLength()*2); 
	file.Write(content,content.GetLength()*2); 
	file.Close(); 
} 
 
void CRadarViewDlg::OnBnClickedButton2() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	::PlaySound(NULL,NULL,NULL); 
	m_RLight.SetLight(false); 
	m_VLight.SetLight(false); 
 
} 
 
void CRadarViewDlg::OnBnClickedRadio1() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	 m_ShowElIndex=0; 
	 m_graph1.m_LayerIndex=0; 
	 m_graph2.m_LayerIndex=0; 
 
	 m_graph1.m_alertfilename=_T("R05Alert"); 
	m_graph2.m_alertfilename=_T("V05Alert"); 
 
 
	 m_graph1.Invalidate(); 
	 m_graph2.Invalidate(); 
 
} 
 
void CRadarViewDlg::OnBnClickedRadio2() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	 m_ShowElIndex=1; 
	 m_graph1.m_LayerIndex=1; 
     m_graph2.m_LayerIndex=1; 
 
	 m_graph1.m_alertfilename=_T("R15Alert"); 
	m_graph2.m_alertfilename=_T("V15Alert"); 
 
	 m_graph1.Invalidate(); 
	 m_graph2.Invalidate(); 
} 
 
void CRadarViewDlg::OnBnClickedButton3() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	m_RAlertList.ResetContent(); 
	m_VAlertList.ResetContent(); 
    
} 
 
// 从名字算朱诺日 
int CRadarViewDlg::GetJulianDateFromName(CString filename) 
{ 
	int year; 
	int month; 
	int day; 
	int hour; 
	int minute; 
 
	int mdays=0; 
     
	int yearday1[12]={31,28,31,30,31,30,31,31,30,31,30,31}; 
    int yearday2[12]={31,29,31,30,31,30,31,31,30,31,30,31}; 
 
 
	CString temp; 
	temp=filename.Left(4); 
	year=_ttoi(temp); 
	temp=filename.Left(6); 
	temp=temp.Right(2); 
	month=_ttoi(temp); 
	temp=filename.Left(8); 
	temp=temp.Right(2); 
	day=_ttoi(temp); 
	temp=filename.Left(10); 
	temp=temp.Right(2); 
	hour=_ttoi(temp); 
	temp=filename.Left(13); 
	temp=temp.Right(2); 
	minute=_ttoi(temp); 
 
 
	if(year%400==0||(year%4==0&&year%100!=0))/*闰年*/ 
	{for(int i=1;i<month;i++) 
	   mdays=mdays+yearday2[i-1]; 
	} 
	else 
	{for(int i=1;i<month;i++) 
	   mdays=mdays+yearday1[i-1]; 
	} 
	return int((year-2000)*365.25) *24*60+mdays*24*60+day*24*60+hour*60+minute; 
} 
 
void CRadarViewDlg::OnBnClickedButton4() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
		m_graph1.m_GraphAlertFlag=false; 
		m_graph1.m_lightflag=false; 
		m_graph1.GraphLightAlert(); 
		m_graph1.Invalidate(); 
		m_graph2.m_GraphAlertFlag=false; 
		m_graph2.m_lightflag=false; 
		m_graph2.GraphLightAlert(); 
		m_graph2.Invalidate(); 
} 
 
bool CRadarViewDlg::DistinguishNewFile(CString foldername) 
{ 
	 CFileFind filefd; 
		CString str; 
		str.Format(_T("%s\\*.*A"),foldername); 
		BOOL bfinded = filefd.FindFile(str); 
		while			 
			(bfinded) 
		{    
			 
			 bfinded=filefd.FindNextFile();  
			 if(!filefd.IsDots()) 
			{ 
				int num=GetJulianDateFromName(filefd.GetFileName()); 
				CString fullpath; 
				fullpath=foldername+_T("\\")+filefd.GetFileName(); 
				if(num>this->m_LastFileIndex) 
				{ 
					m_LastFileIndex=num; 
					this->OnOpenFile(fullpath); 
                   
                    
				} 
				 
			} 
		} 
		return true; 
	 
} 
 
 
void CRadarViewDlg::On32775() 
{ 
	// TODO: 在此添加命令处理程序代码 
	  CString foldername; 
 
	   TCHAR szDir[MAX_PATH]; 
       BROWSEINFO bi; 
       ITEMIDLIST *pidl; 
       bi.hwndOwner = this->m_hWnd; 
       bi.pidlRoot = NULL; 
       bi.pszDisplayName = szDir; 
       bi.lpszTitle = _T("请选择目录"); 
       bi.ulFlags = BIF_STATUSTEXT | BIF_RETURNONLYFSDIRS; 
       bi.lpfn = NULL; 
       bi.lParam = 0; 
       bi.iImage = 0; 
       pidl = SHBrowseForFolder(&bi); 
       if(pidl == NULL)  return; 
       if(!SHGetPathFromIDList(pidl, szDir))   return; 
       else  m_ProcessFoldername = szDir; 
 
	    
	   CFileDialog dlg(true,NULL,NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR); 
		dlg.m_ofn.lpstrInitialDir=m_ProcessFoldername; 
		CString filepath; 
		if(dlg.DoModal()==IDOK) 
		{ 
			m_LastProcessFileName=dlg.GetFileName(); 
			m_LastFileIndex=GetJulianDateFromName(m_LastProcessFileName); 
			//OnOpenFile(filepath); 
			 
		} 
		else 
		{ 
			m_LastProcessFileName=dlg.GetFileName(); 
			m_LastFileIndex=0; 
			//OnOpenFile(filepath); 
			 
		} 
		SetTimer(1,10000,NULL); 
 
} 
 
 
 
 
void CRadarViewDlg::OnTimer(UINT_PTR nIDEvent) 
{ 
	// TODO: 在此添加消息处理程序代码和/或调用默认值 
	switch (nIDEvent) 
	{ 
		case 1: 
			DistinguishNewFile(m_ProcessFoldername); 
			break; 
 
	} 
	CDialog::OnTimer(nIDEvent); 
}