📄 systempage.cpp
字号:
// SystemPage.cpp : implementation file
//
#include "stdafx.h"
#include "gtmpeg.h"
#include "SystemPage.h"
#include "ModiFyPwdDlg.h"
#include "GtMpegWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
DWORD BaudTable[] =
{
CBR_110, CBR_300, CBR_600, CBR_1200, CBR_2400,
CBR_4800, CBR_9600, CBR_14400, CBR_19200, CBR_38400,
CBR_56000, CBR_128000, CBR_256000
} ;
DWORD ParityTable[] ={NOPARITY,ODDPARITY,EVENPARITY} ;
DWORD StopBitsTable[] ={ONESTOPBIT, ONE5STOPBITS, TWOSTOPBITS} ;
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNCREATE(CSystemPage, CPropertyPage)
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
CSystemPage::CSystemPage() : CPropertyPage(CSystemPage::IDD)
{
//{{AFX_DATA_INIT(CSystemPage)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
//m_nCom=1,COM1;m_nCom=2,COM2;缺省:m_nCom=2
m_nCom=AfxGetApp()->GetProfileInt("系统参数","串口",2);
//m_nPlaybackWay=0,选择起始时间回放;m_nPlaybackWay=1,智能检索时间段回放;m_nPlaybackWay=2,全天自动回放;缺省:m_nPlaybackWay=1
m_nPlaybackWay=AfxGetApp()->GetProfileInt("系统参数","回放方式",1);
//m_nVideoWay=0,FRAME(帧)方式;m_nVideoWay=0,FIELD(场)方式;
m_nVideoWay=AfxGetApp()->GetProfileInt("系统参数","采集方式",0);
m_nRate=theApp.GetProfileInt("通讯参数","波特率",CBR_9600);
m_nBits=theApp.GetProfileInt("通讯参数","数据位",8);
m_nParity=theApp.GetProfileInt("通讯参数","奇偶校验",0);
m_sStopBits=theApp.GetProfileString("通讯参数","停止位","1");
m_bAutoClean=theApp.GetProfileInt("系统参数","自动清理",0);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
CSystemPage::~CSystemPage()
{
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CSystemPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSystemPage)
DDX_Control(pDX, IDC_RETAIN, m_cRetain);
DDX_Control(pDX, IDC_STOP_BIT, m_cStopBits);
DDX_Control(pDX, IDC_RATE, m_cRate);
DDX_Control(pDX, IDC_PARITY, m_cParity);
DDX_Control(pDX, IDC_BITS, m_cBits);
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CSystemPage, CPropertyPage)
//{{AFX_MSG_MAP(CSystemPage)
ON_BN_CLICKED(IDC_COM_1, OnCom1)
ON_BN_CLICKED(IDC_COM_2, OnCom2)
ON_BN_CLICKED(IDC_PLAYBAC_1, OnPlaybac1)
ON_BN_CLICKED(IDC_PLAYBAC_2, OnPlaybac2)
ON_BN_CLICKED(IDC_PLAYBAC_3, OnPlaybac3)
ON_BN_CLICKED(IDC_FIELD, OnField)
ON_BN_CLICKED(IDC_FRAME, OnFrame)
ON_CBN_CLOSEUP(IDC_RATE, OnCloseupRate)
ON_CBN_CLOSEUP(IDC_PARITY, OnCloseupParity)
ON_CBN_CLOSEUP(IDC_STOP_BIT, OnCloseupStopBit)
ON_CBN_CLOSEUP(IDC_BITS, OnCloseupBits)
ON_BN_CLICKED(IDC_MODIFY_PWD, OnModifyPwd)
ON_BN_CLICKED(IDC_AUTO_CLEAN, OnAutoClean)
ON_BN_CLICKED(IDC_CLEAN_FILE, OnCleanFile)
ON_BN_CLICKED(IDC_ZONE_INIT, OnZoneInit)
ON_BN_CLICKED(IDC_RESET, OnReset)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BOOL CSystemPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
SetComMode();
SetPlaybackWay();
SetVideoWay();
SetDlgItemInt(IDC_RECORD_TIMER,theApp.GetProfileInt("系统参数","报警录像持续时间",300),FALSE);
SetDlgItemInt(IDC_SECONDARY_TIMER,theApp.GetProfileInt("系统参数","报警持续时间",60),FALSE);
SetDlgItemInt(IDC_EXIT_DELAY,theApp.GetProfileInt("系统参数","退出延时",30),FALSE);
SetDlgItemInt(IDC_ENTER_DELAY,theApp.GetProfileInt("系统参数","进入延时",30),FALSE);
SetDlgItemText(IDC_BUILD_NAME,theApp.GetProfileString("系统参数","建设单位",""));
SetDlgItemInt(IDC_RETAIN,theApp.GetProfileInt("系统参数","保存",3),FALSE);
CString sTmp;
for(int i=0;i<13;i++)
{
sTmp.Format("%d",BaudTable[i]);
m_cRate.AddString(sTmp);
}
sTmp.Format("%d",m_nRate);
m_cRate.SetCurSel(m_cRate.FindString(0,sTmp));
m_cStopBits.SetCurSel(m_cStopBits.FindString(0,m_sStopBits+"位"));
m_cParity.SetCurSel(m_nParity);
sTmp.Format("%d",m_nBits);
m_cBits.SetCurSel(m_cBits.FindString(0,sTmp));
CButton *pButton=(CButton *)GetDlgItem(IDC_AUTO_CLEAN);
pButton->SetCheck(m_bAutoClean);
GetDlgItem(IDC_CLEAN_FILE)->EnableWindow(!m_bAutoClean);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CSystemPage::SetComMode()
{
CButton *pButton=(CButton *)GetDlgItem(IDC_COM_1);
pButton->SetCheck(m_nCom==1);
pButton=(CButton *)GetDlgItem(IDC_COM_2);
pButton->SetCheck(m_nCom==2);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CSystemPage::SetPlaybackWay()
{
CButton *pButton=(CButton *)GetDlgItem(IDC_PLAYBAC_1);
pButton->SetCheck(m_nPlaybackWay==0);
pButton=(CButton *)GetDlgItem(IDC_PLAYBAC_2);
pButton->SetCheck(m_nPlaybackWay==1);
pButton=(CButton *)GetDlgItem(IDC_PLAYBAC_3);
pButton->SetCheck(m_nPlaybackWay==2);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CSystemPage::SetVideoWay()
{
CButton *pButton=(CButton *)GetDlgItem(IDC_FRAME);
pButton->SetCheck(m_nVideoWay==0);
pButton=(CButton *)GetDlgItem(IDC_FIELD);
pButton->SetCheck(m_nVideoWay==1);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CSystemPage::OnCom1()
{
m_nCom=1;
SetComMode();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CSystemPage::OnCom2()
{
m_nCom=2;
SetComMode();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CSystemPage::OnPlaybac1()
{
m_nPlaybackWay=0;
SetPlaybackWay();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CSystemPage::OnPlaybac2()
{
m_nPlaybackWay=1;
SetPlaybackWay();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CSystemPage::OnPlaybac3()
{
m_nPlaybackWay=2;
SetPlaybackWay();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CSystemPage::OnField()
{
m_nVideoWay=1;
SetVideoWay();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CSystemPage::OnFrame()
{
m_nVideoWay=0;
SetVideoWay();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CSystemPage::OnOK()
{
AfxGetApp()->WriteProfileInt("系统参数","串口",m_nCom);
AfxGetApp()->WriteProfileInt("系统参数","回放方式",m_nPlaybackWay);
AfxGetApp()->WriteProfileInt("系统参数","采集方式",m_nVideoWay);
int nTmp=0;
nTmp=GetDlgItemInt(IDC_RECORD_TIMER,NULL,FALSE);
if(nTmp<=0)
nTmp=300;
AfxGetApp()->WriteProfileInt("系统参数","报警录像持续时间",nTmp);
theApp.m_nAlarmRecordTimer=nTmp*1000;
nTmp=GetDlgItemInt(IDC_SECONDARY_TIMER,NULL,FALSE);
if(nTmp<=0)
nTmp=60;
AfxGetApp()->WriteProfileInt("系统参数","报警持续时间",nTmp);
theApp.m_nAlarmTimer=nTmp*1000;
//
nTmp=GetDlgItemInt(IDC_EXIT_DELAY,NULL,FALSE);
if(nTmp>60)
nTmp=60;
AfxGetApp()->WriteProfileInt("系统参数","退出延时",nTmp);
theApp.m_nExitDelay=nTmp;
nTmp=GetDlgItemInt(IDC_ENTER_DELAY,NULL,FALSE);
if(nTmp>60)
nTmp=60;
AfxGetApp()->WriteProfileInt("系统参数","进入延时",nTmp);
theApp.m_nEnterDelay=nTmp;
theApp.WriteProfileInt("通讯参数","波特率",m_nRate);
theApp.WriteProfileInt("通讯参数","数据位",m_nBits);
theApp.WriteProfileInt("通讯参数","奇偶校验",m_nParity);
theApp.WriteProfileString("通讯参数","停止位",m_sStopBits);
CString sTmp;
GetDlgItemText(IDC_BUILD_NAME,sTmp);
theApp.WriteProfileString("系统参数","建设单位",sTmp);
m_cRetain.GetWindowText(sTmp);
nTmp=StringToInt(sTmp);//GetDlgItemInt(IDC_RETAIN,NULL,FALSE);
theApp.WriteProfileInt("系统参数","保存",nTmp);
CPropertyPage::OnOK();
}
/////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////
void CSystemPage::OnCloseupRate()
{
int nIndex=m_cRate.GetCurSel();
CString sTxt;
m_cRate.GetLBText(nIndex,sTxt);
m_nRate=StringToInt(sTxt);
}
/////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////
void CSystemPage::OnCloseupParity()
{
int nIndex=m_cParity.GetCurSel();
m_nParity=nIndex;
}
/////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////
void CSystemPage::OnCloseupStopBit()
{
int nIndex=m_cStopBits.GetCurSel();
CString sTxt;
m_cStopBits.GetLBText(nIndex,sTxt);
sTxt=sTxt.Left(sTxt.Find("位"));
m_sStopBits=sTxt;
}
/////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////
void CSystemPage::OnCloseupBits()
{
int nIndex=m_cBits.GetCurSel();
CString sTxt;
m_cBits.GetLBText(nIndex,sTxt);
m_nBits=StringToInt(sTxt);
}
/////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////
void CSystemPage::OnModifyPwd()
{
if(theApp.m_bAlarm)
{
CModiFyPwdDlg dlg;
dlg.DoModal();
}
}
/////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////
void CSystemPage::OnAutoClean()
{
m_bAutoClean=!m_bAutoClean;
CButton *pButton=(CButton *)GetDlgItem(IDC_AUTO_CLEAN);
pButton->SetCheck(m_bAutoClean);
theApp.WriteProfileInt("系统参数","自动清理",m_bAutoClean);
GetDlgItem(IDC_CLEAN_FILE)->EnableWindow(!m_bAutoClean);
}
/////////////////////////////////////////////
//
/////////////////////////////////////////////
void CSystemPage::OnCleanFile()
{
CleanMpegFile(GetAppPath()+"mpeg");
}
//////////////////////////////////////////////
//
/////////////////////////////////////////////
void CSystemPage::OnZoneInit()
{
CGtMpegWnd *pWnd=(CGtMpegWnd*)theApp.m_pMainWnd;
pWnd->InitZoneSet();
}
//////////////////////////////////////////////
//
/////////////////////////////////////////////
void CSystemPage::OnReset()
{
CGtMpegWnd *pWnd=(CGtMpegWnd*)theApp.m_pMainWnd;
pWnd->AlarmReset();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -