📄 gtmpegwnd.cpp
字号:
// GtMpegWnd.cpp : implementation file
//
#include "stdafx.h"
#include "GtMpeg.h"
#include "GtMpegWnd.h"
#include "about.h"
#include "ImageObject.h"
#include "FacePage.h"
#include "PlaybackListDlg.h"
#include "ColorPage.h"
#include "VideoPage.h"
#include "TimeSearchDlg.h"
#include "SystemPage.h"
#include "AddressPage.h"
#include "About.h"
#include "SplashWnd.h"
#include "MpegSheet.h"
#include "DayPlayDlg.h"
#include "VideoBackupDlg.h"
#include "LinkageAlarmSet.h"
#include "ZoneOperator.h"
#include "AlarmInfo.h"
#include "ListenSock.h"
#include "ClientSock.h"
#include "CommandMsg.h"
#include "DataMsg.h"
#include "TimerRec.h"
#include "PassWordDlg.h"
#include "ExitDlg.h"
#include "MapDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define _SHOW_WIDTH 23
///////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
CMutex g_RecordMutex;
CMutex g_PlayMutex;
CMutex g_ComMutex;
CStringArray g_arDriveList;
CString g_sZoneType[9];
//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
#define ASCII_XON 0x11
#define ASCII_XOFF 0x13
///////////////////////////////////////////////////////////////
void CheckRecord(CGtMpegWnd * pWnd);
void CheckPlay(CGtMpegWnd * pWnd);
void ReadCom(CGtMpegWnd * pWnd);
////////////////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////////////////
void CheckRecord(CGtMpegWnd * pWnd)
{
CSingleLock SingleLock(&g_RecordMutex);
while(pWnd->m_nRecords>0)
{
SingleLock.Lock();
for(DWORD i=0;i<g_dwNumberOfSlots;i++)
{
g_pDevice[i]->RecordSubsection();
}
SingleLock.Unlock();
}
#ifdef _DEBUG
pWnd->m_cMsgListBox.AddString("录像线程停止");
#endif
}
////////////////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////////////////
void CheckPlay(CGtMpegWnd * pWnd)
{
CSingleLock SingleLock(&g_PlayMutex);
while(pWnd->m_nPlays>0)
{
SingleLock.Lock();
for(DWORD i=0;i<g_dwNumberOfSlots;i++)
{
g_pDevice[i]->PlaySubsection();
}
SingleLock.Unlock();
}
#ifdef _DEBUG
pWnd->m_cMsgListBox.AddString("回放线程停止");
#endif
}
//////////////////////////////////////////////////
//
//////////////////////////////////////////////////
void ReadCom(CGtMpegWnd * pMainWnd)
{
COMSTAT cs;
CString sMsg=_T("");
CSingleLock SingleLock(&g_ComMutex);
while(pMainWnd->m_bComWorking)
{
SingleLock.Lock();
DWORD dwEvent=0,dwError=0,dwComEvent=0;
BOOL bResult=WaitCommEvent(pMainWnd->m_hCom,&dwEvent,NULL);
if(!bResult)
{
}
else
{
bResult=ClearCommError(pMainWnd->m_hCom,&dwError,&cs);
}
int nID=IDC_COMM_EVENT,nEventID=0;
NMHDR Msg;
Msg.hwndFrom=pMainWnd->m_hWnd;
switch(dwEvent)
{
case 0:
break;
case 1:
GetCommMask(pMainWnd->m_hCom,&dwComEvent);
if((dwComEvent&EV_CTS)==EV_CTS)//清除发送
{
Msg.code=COM_CTS_DECTED;
pMainWnd->SendMessage(WM_NOTIFY,nID,(LPARAM)&Msg);
}
if((dwComEvent&EV_RXCHAR)==EV_RXCHAR)
{
Msg.code=COM_RXCHAR_DECTED;
pMainWnd->SendMessage(WM_NOTIFY,nID,(LPARAM)&Msg);
}
}
SingleLock.Unlock();
}
}
/////////////////////////////////////////////////////////////////////////////
// CGtMpegWnd dialog
/////////////////////////////////////////////////////////////////////////////
CGtMpegWnd::CGtMpegWnd(CWnd* pParent /*=NULL*/)
: CDialog(CGtMpegWnd::IDD)
{
//{{AFX_DATA_INIT(CGtMpegWnd)
//}}AFX_DATA_INIT
m_bComWorking=FALSE;
m_bControl=TRUE;
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_bStart=FALSE;
m_PalQSIFPicSize.cx=176;
m_PalQSIFPicSize.cy=144;
m_PalSIFPicSize.cx=352;
m_PalSIFPicSize.cy=288;
VERIFY(m_BackgndBrush.CreateStockObject(HOLLOW_BRUSH));
CString sPath=AfxGetApp()->GetProfileString("Face","ScreenBK",GetAppPath()+"FacePlug\\屏幕背景.jpg");
m_pVideoBK=new CImageObject(sPath);
m_pMenuBK=NULL;
//
m_sLogoPath=GetAppPath();
m_sLogoPath+="FacePlug\\logo.jpg";
m_pLogoObject=new CImageObject(m_sLogoPath);
//
g_arDriveList.SetSize(0);
GetDriveList(DRIVE_FIXED,g_arDriveList);
m_nRecords=0;
m_nPlays=0;
m_dwMinDiskSpace=AfxGetApp()->GetProfileInt("系统参数","最小磁盘空间",500);
m_dwTimeslice=AfxGetApp()->GetProfileInt("系统参数","检测时间段",2)*60000;
m_bCompressCard=FALSE;
m_bAlarming=FALSE;
g_sZoneType[0]="无";
g_sZoneType[1]="红外探测器";
g_sZoneType[2]="门磁";
g_sZoneType[3]="紧急按钮";
g_sZoneType[4]="烟感探测器";
g_sZoneType[5]="门锁";
g_sZoneType[6]="巡逻点";
g_sZoneType[7]="撤布防防区";
g_sZoneType[8]="其他";
m_pClientSocket=NULL;
}
CGtMpegWnd::~CGtMpegWnd()
{
}
///////////////////////////////////////////////////
//
///////////////////////////////////////////////////
void CGtMpegWnd::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGtMpegWnd)
DDX_Control(pDX, IDC_OPEN_MAP, m_cOpenMap);
DDX_Control(pDX, IDC_DISK_SPACE_TXT, m_cDiskSpaceTxt);
DDX_Control(pDX, IDC_DISK_SPACE, m_cDiskSpace);
DDX_Control(pDX, IDM_ABOUTBOX, m_cAbout);
DDX_Control(pDX, IDC_BUILD_UNIT, m_wndBuildLogo);
DDX_Control(pDX, IDC_VIDEO_POS, m_cVideoPos0);
DDX_Control(pDX, IDC_VIDEO_POS1, m_cVideoPos1);
DDX_Control(pDX, IDC_VIDEO_POS2, m_cVideoPos2);
DDX_Control(pDX, IDC_VIDEO_POS3, m_cVideoPos3);
DDX_Control(pDX, IDC_VIDEO_POS4, m_cVideoPos4);
DDX_Control(pDX, IDC_VIDEO_POS5, m_cVideoPos5);
DDX_Control(pDX, IDC_VIDEO_POS6, m_cVideoPos6);
DDX_Control(pDX, IDC_VIDEO_POS7, m_cVideoPos7);
DDX_Control(pDX, IDC_VIDEO_POS8, m_cVideoPos8);
DDX_Control(pDX, IDC_CHANNEL_SHOW8, m_cChannelShow8);
DDX_Control(pDX, IDC_CHANNEL_SHOW7, m_cChannelShow7);
DDX_Control(pDX, IDC_CHANNEL_SHOW6, m_cChannelShow6);
DDX_Control(pDX, IDC_CHANNEL_SHOW5, m_cChannelShow5);
DDX_Control(pDX, IDC_CHANNEL_SHOW4, m_cChannelShow4);
DDX_Control(pDX, IDC_CHANNEL_SHOW3, m_cChannelShow3);
DDX_Control(pDX, IDC_CHANNEL_SHOW2, m_cChannelShow2);
DDX_Control(pDX, IDC_CHANNEL_SHOW1, m_cChannelShow1);
DDX_Control(pDX, IDC_CHANNEL_SHOW0, m_cChannelShow0);
DDX_Control(pDX, IDC_MSG_LIST, m_cMsgListBox);
DDX_Control(pDX, IDC_SNAP, m_cSnap);
DDX_Control(pDX, IDC_BACKUP, m_cBackup);
DDX_Control(pDX, IDC_SYSTEM_SET, m_cSystemSet);
DDX_Control(pDX, IDC_LOGO, m_cLogo);
DDX_Control(pDX, IDC_PIC_PLANE_9, m_cPicPlane9);
DDX_Control(pDX, IDC_PIC_PLANE_4, m_cPicPlane4);
DDX_Control(pDX, IDC_PIC_PLANE_1, m_cPicPlane1);
DDX_Control(pDX, IDC_SETING_POS, m_cSetingPos);
DDX_Control(pDX, IDC_MPEG_POS, m_cMpegPos);
DDX_Control(pDX, IDC_START_VIDEO, m_cStartVideo);
DDX_Control(pDX, IDOK, m_cOK);
DDX_Control(pDX, IDC_STOP, m_cStop);
DDX_Control(pDX, IDC_VIDEO_SETTING, m_cVideoSeting);
DDX_Control(pDX, IDC_RECORD, m_cRecord);
DDX_Control(pDX, IDC_PLAY, m_cPlay);
DDX_Control(pDX, IDC_CLOCK, m_cClock);
//}}AFX_DATA_MAP
}
//////////////////////////////////////
//
//////////////////////////////////////
BEGIN_MESSAGE_MAP(CGtMpegWnd, CDialog)
//{{AFX_MSG_MAP(CGtMpegWnd)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_VIDEO_SETTING, OnVideoSetting)
ON_BN_CLICKED(IDC_FREEZE_VIDEO, OnFreezeVideo)
ON_BN_CLICKED(IDC_START_VIDEO, OnStartVideo)
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_PLAY, OnPlay)
ON_BN_CLICKED(IDC_RECORD, OnRecord)
ON_BN_CLICKED(IDC_STOP, OnStop)
ON_BN_CLICKED(IDC_PIC_PLANE_1, OnPicPlane1)
ON_BN_CLICKED(IDC_PIC_PLANE_4, OnPicPlane4)
ON_BN_CLICKED(IDC_PIC_PLANE_9, OnPicPlane9)
ON_BN_CLICKED(IDC_SYSTEM_SET, OnSystemSet)
ON_BN_CLICKED(IDC_BACKUP, OnBackup)
ON_WM_LBUTTONDBLCLK()
ON_BN_CLICKED(IDM_ABOUTBOX, OnAboutbox)
ON_WM_MOUSEMOVE()
ON_BN_CLICKED(IDC_SNAP, OnSnap)
ON_LBN_DBLCLK(IDC_MSG_LIST, OnDblclkMsgList)
ON_BN_CLICKED(IDC_BUILD_UNIT, OnBuildUnit)
ON_BN_CLICKED(IDC_OPEN_MAP, OnOpenMap)
//}}AFX_MSG_MAP
ON_COMMAND_EX_RANGE(IDC_CHANNEL0, IDC_CHANNEL7, OnChoiceChannel)
ON_WM_ERASEBKGND()
ON_WM_QUERYNEWPALETTE()
ON_WM_PALETTECHANGED()
END_MESSAGE_MAP()
/////////////////////////////////
// CGtMpegWnd message handlers
////////////////////////////////
BOOL CGtMpegWnd::OnInitDialog()
{
CDialog::OnInitDialog();
POINT points[4]={{0,0},{0,768},{1024,768},{1024,0}};
HRGN hRgn = ::CreatePolygonRgn(points,4,WINDING);
SetWindowRgn(hRgn,TRUE);
SetWindowText(_T("高特数字视频王"));
BeginWaitCursor();
#ifndef _DEBUG
OnBuildUnit();
#endif
if(g_dwNumberOfSlots<=8&&g_dwNumberOfSlots>4)
{
m_nPicNumX=3;
m_nPicNumY=3;
}
if(g_dwNumberOfSlots<=4&&g_dwNumberOfSlots>1)
{
m_nPicNumX=2;
m_nPicNumY=2;
}
if(g_dwNumberOfSlots<2)
{
m_nPicNumX=1;
m_nPicNumY=1;
}
g_RGBColorBits=YUV422;
CString sPath1=AfxGetApp()->GetProfileString("Face","VideoBK");
CString sPath2=AfxGetApp()->GetProfileString("Face","VideoFrameBK",GetAppPath()+"FacePlug\\视频边框.jpg");
m_cMpegPos.SetObject(sPath2,"");
sPath1=AfxGetApp()->GetProfileString("Face","MenuBK");
sPath2=AfxGetApp()->GetProfileString("Face","MenuFrameBK",GetAppPath()+"FacePlug\\视频边框.jpg");
m_cSetingPos.SetObject(sPath2,"");
//获取屏幕分辨率设置
CClientDC pDC(NULL);
m_MaxHorzSize=pDC.GetDeviceCaps(HORZRES);
m_MaxVertSize=pDC.GetDeviceCaps(VERTRES);
m_MaxPixelBits=pDC.GetDeviceCaps(BITSPIXEL);
switch(m_MaxPixelBits)
{
case 8:return FALSE;
case 16:
g_RGBColorBits=RGB565;
break;
case 15:
g_RGBColorBits=RGB555;
break;
case 24:
g_RGBColorBits=RGB888;
break;
case 32:
g_RGBColorBits=RGB8888;
break;
}
//
MoveMenu();
SetMenuIcon();
//视频显示部分
CRect rSetingRect;
GetDlgItem(IDC_SETING_POS)->GetWindowRect(rSetingRect);
rSetingRect.top=0;
rSetingRect.bottom=m_MaxVertSize;
ScreenToClient(rSetingRect);
GetDlgItem(IDC_SETING_POS)->MoveWindow(rSetingRect);
//
GetDlgItem(IDC_MPEG_POS)->GetWindowRect(m_rMpegRect);
m_rMpegRect.left=0;
m_rMpegRect.top=0;
m_rMpegRect.right=rSetingRect.left;
m_rMpegRect.bottom=m_MaxVertSize;
ScreenToClient(m_rMpegRect);
GetDlgItem(IDC_MPEG_POS)->MoveWindow(m_rMpegRect);
GetDlgItem(IDC_MPEG_POS)->GetWindowRect(m_rMpegRect);
int nTmp=theApp.m_nMaxChannels;
if(theApp.m_nMaxChannels==8)
nTmp++;
for(int i=0;i<nTmp;i++)
{
if(i>=theApp.m_nChannels)
{
CVideoPos *pWnd=(CVideoPos *)GetDlgItem(IDC_VIDEO_POS+i);
pWnd->SetBkBitmap(AfxGetApp()->GetProfileString("Face","VideoBK",GetAppPath()+"FacePlug\\视频窗口背景.jpg"));
}
else
{
CString sCaption;
sCaption.Format("频道%02d:",i+1);
CString sEntry;
sEntry.Format("Channel%02d_Txt",i+1);
sCaption+=AfxGetApp()->GetProfileString("Info",sEntry);
((CCaption* )GetDlgItem(IDC_CHANNEL_SHOW0+i))->SetCaptionText(sCaption);
}
}
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
AdjustMpegWindow();
InitChoiceChannel();
if(g_dwNumberOfSlots<=4)
{
m_cPicPlane9.EnableWindow(FALSE);
}
if(theApp.m_bNetTran)
{
m_pSocket = new CListenSocket();
if(m_pSocket->Create(700))
{
if(!m_pSocket->Listen())
{
}
}
}
m_cDiskSpace.SetRange(0,100);
m_cDiskSpace.SetStep(1);
m_cDiskSpace.SetPos(GetDiskFreeSpaceScale(GetAppPath()));
return TRUE;
}
//////////////////////////////////////////////////////
//当485控制卡掉电时,用来使得程序与485控制卡设置同步
//程序启动时,对特殊防区(撤布防、紧急按钮防区)进行自动布防操作
//////////////////////////////////////////////////////
void CGtMpegWnd::InitZoneSet()
{
//
BYTE byCommand[5];
byCommand[0]=(BYTE)0xcc;
byCommand[4]=(BYTE)0x10;
for(int j=0;j<theApp.m_nChunnel;j++)
{
byCommand[1]=(BYTE)j;
int nTmp=GetZonesStates(j);
byCommand[2]=LOBYTE(nTmp);
byCommand[3]=HIBYTE(nTmp);
CChunnel *pChunnel=GetChunnel(j);
CZone *pZone=NULL;
for(int i=0;i<16;i++)
{
BYTE byTmp=1;
pZone=pChunnel->GetZone(i);
if(pZone->m_nType==7||pZone->m_nType==3)
{
if(i>=0&&i<=7)
{
byTmp<<=i;
byCommand[2]|=byTmp;
}
else
{
byTmp<<=(i-8);
byCommand[3]|=byTmp;
}
pZone->SetStates(TRUE);
}
}
WriteCommCommand(byCommand,5);
//if(j!=theApp.m_nChannels-1)
Delay(40);
}
SaveAlarmSet();
}
//////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////
void CGtMpegWnd::InitAlarmChunnel()
{
CString sAlarmFile=GetAppPath()+"AlarmSet.hsn";
CFileFind FindFile;
if(!FindFile.FindFile(sAlarmFile))
{
for(int i=0;i<8;i++)
{
CChunnel* pChunnel=new CChunnel;
pChunnel->InitList(i);
m_lstAlarmChunnel.AddTail(pChunnel);
}
CFile AlarmFile;
if(AlarmFile.Open(sAlarmFile,CFile::modeCreate|CFile::modeWrite))
{
CArchive ar(&AlarmFile,CArchive::store);
m_lstAlarmChunnel.Serialize(ar);
ar.Close();
AlarmFile.Close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -