⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matdispchan.cpp

📁 SDK DVR/DVS HIKVISION
💻 CPP
字号:
// MatDispChan.cpp : implementation file
//
/************************************************************************/
/* CopyRights 2007-2008 
FileName:		MatDispChan.cpp
Description:	获取多路解码器解码通道状态和信息
Author:			sym
Date:		    2007-11-10
Modification History:
<version>	<time>		<author>	<desc>
2.1.11.10	2007-11-10	sym			创建文件,添加新的功能              */
/************************************************************************/
#include "stdafx.h"
#include "newclient.h"
#include "MatDispChan.h"

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

#define DISP_TIMER	WM_USER + 1
/////////////////////////////////////////////////////////////////////////////
// CMatDispChan dialog
extern void g_IPToStr(DWORD dip, char outbuf[16]);

CMatDispChan::CMatDispChan(CWnd* pParent /*=NULL*/)
	: CDialog(CMatDispChan::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMatDispChan)
	m_DIIP = _T("");
	m_DIPort = 0;
	m_DIChanNum = 0;
	m_DIUserName = _T("");
	m_DIPwd = _T("");
	m_FileName = _T("");
	m_CopyRate = 0;
	//}}AFX_DATA_INIT
	m_iChanSel = -1;
}


void CMatDispChan::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMatDispChan)
	DDX_Control(pDX, IDC_COMBOISLINK, m_IsLinkCombo);
	DDX_Control(pDX, IDC_CHANCOMBO, m_ChanCombo);
	DDX_Control(pDX, IDC_DATETIMEPICKER4, m_EndTime);
	DDX_Control(pDX, IDC_DATETIMEPICKER3, m_EndDate);
	DDX_Control(pDX, IDC_DATETIMEPICKER2, m_StartTime);
	DDX_Control(pDX, IDC_DATETIMEPICKER1, m_StartDate);
	DDX_Control(pDX, IDC_TRANSMODECOMBO2, m_DIModeCombo);
	DDX_Control(pDX, IDC_PROTOCOLTYPECOMBO2, m_DIProTypeCombo);
	DDX_Control(pDX, IDC_COMBODECSTATE, m_DecStateCombo);
	DDX_Text(pDX, IDC_LINKIP2, m_DIIP);
	DDX_Text(pDX, IDC_LINKPORT2, m_DIPort);
	DDX_Text(pDX, IDC_LINKCHAN2, m_DIChanNum);
	DDX_Text(pDX, IDC_USERNAME2, m_DIUserName);
	DDX_Text(pDX, IDC_PASSWD2, m_DIPwd);
	DDX_Text(pDX, IDC_FILENAME, m_FileName);
	DDX_Text(pDX, IDC_EDITCOPYRATE, m_CopyRate);
	//}}AFX_DATA_MAP

}


BEGIN_MESSAGE_MAP(CMatDispChan, CDialog)
	//{{AFX_MSG_MAP(CMatDispChan)
	ON_CBN_SELCHANGE(IDC_CHANCOMBO, OnSelchangeChancombo)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMatDispChan message handlers

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

	// TODO: Add extra initialization here

	CString tmp;
	int i=0;
	int ChanNo = -1;
	m_vGetStatus.resize(m_iChannelnumber);
	m_vbGetInfo.resize(m_iChannelnumber);
	TRACE("\nm_iChannelnumber = %d\n", m_iChannelnumber);
	for(i=0; i<m_iChannelnumber; i++)
	{
		ChanNo = m_lStartChan+i;
		tmp.Format("Channel %d", ChanNo);
		m_ChanCombo.AddString(tmp);
		GetChanStatus(ChanNo, i);
	}

	for (i=0; i<m_iChannelnumber; ++i)
	{
		if (m_vbGetInfo[i])
		{
			ShowChanInfo(i);
			if (m_vGetStatus[i])
			{
				m_IsLinkCombo.SetCurSel(m_DecChanStatus[i].dwIsLinked);
				TRACE("m_DecChanStatus[i].dwIsLinked = %d\n", m_DecChanStatus[i].dwIsLinked);
				m_CopyRate = m_DecChanStatus[i].dwStreamCpRate;
			}
			else
			{
				tmp.Format("failed to get state of channel %d!", i+m_lStartChan);
				AfxMessageBox(tmp);
			}
			break;
		}
	}

	UpdateData(FALSE);

	SetTimer(DISP_TIMER, 5000, NULL);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BOOL CMatDispChan::GetChanStatus(DWORD DecChanNum, int index)
{
	CString tmp;

	ZeroMemory(&m_DecChanStatus[index], sizeof(m_DecChanStatus[index]));
	m_DecChanStatus->dwSize = sizeof(m_DecChanStatus[index]);
	if (!NET_DVR_MatrixGetDecChanStatus(m_lServerID, DecChanNum, &m_DecChanStatus[index]))
	{
		tmp.Format("\nNET_DVR_MatrixGetDecChanStatus = %ld", NET_DVR_GetLastError());
		OutputDebugString(tmp);
		m_vGetStatus[index] = FALSE;
	}
	else
	{
		m_vGetStatus[index] = TRUE;
	}

	ZeroMemory(&m_DecChanInfo[index], sizeof(m_DecChanInfo[index]));
	m_DecChanInfo[index].dwSize = sizeof(m_DecChanInfo[index]);
	if (!NET_DVR_MatrixGetDecChanInfo(m_lServerID, DecChanNum, &m_DecChanInfo[index]))
	{
		tmp.Format("\nNET_DVR_MatrixGetDecChanInfo = %ld", NET_DVR_GetLastError());
		OutputDebugString(tmp);
		m_vbGetInfo[index] = FALSE;
	}
	else
	{
		m_vbGetInfo[index] = TRUE;
	}

	return TRUE;
}

void CMatDispChan::ShowChanInfo(int index)
{
	if(index < 0 || index > m_iChannelnumber-1)
	{
		return;
	}

	UpdateData(TRUE);
	CString tmp;
	if(!m_vbGetInfo[index])
	{
		tmp.Format("failed to get info. of channel %d!", index+m_lStartChan);
		OutputDebugString(tmp);
	}
	else
	{
		m_ChanCombo.SetCurSel(index);
		m_DecStateCombo.SetCurSel(m_DecChanInfo[index].dwDecState);
		//Dec info...
		m_DIIP.Format("%s", m_DecChanInfo[index].struDecChanInfo.sDVRIP);
		m_DIPort = m_DecChanInfo[index].struDecChanInfo.wDVRPort;
		m_DIChanNum = m_DecChanInfo[index].struDecChanInfo.byChannel;
		m_DIUserName.Format("%s", m_DecChanInfo[index].struDecChanInfo.sUserName);
		m_DIPwd.Format("%s", m_DecChanInfo[index].struDecChanInfo.sPassword);
		m_DIProTypeCombo.SetCurSel(m_DecChanInfo[index].struDecChanInfo.byTransProtocol);
		m_DIModeCombo.SetCurSel(m_DecChanInfo[index].struDecChanInfo.byTransMode);

		if (m_DecChanInfo[index].dwDecState == 2)
		{
			SYSTEMTIME sysTime;
			ZeroMemory(&sysTime,sizeof(sysTime));
			sysTime.wYear = (WORD)m_DecChanInfo[index].StartTime.dwYear;
			sysTime.wMonth = (WORD)m_DecChanInfo[index].StartTime.dwMonth;
			sysTime.wDay = (WORD)m_DecChanInfo[index].StartTime.dwDay;
			sysTime.wHour = (WORD)m_DecChanInfo[index].StartTime.dwHour;
			sysTime.wMinute = (WORD)m_DecChanInfo[index].StartTime.dwMinute;
			sysTime.wSecond = (WORD)m_DecChanInfo[index].StartTime.dwSecond;
			m_StartDate.SetTime(&sysTime);
			m_StartTime.SetTime(&sysTime);
			ZeroMemory(&sysTime,sizeof(sysTime));
			sysTime.wYear = (WORD)m_DecChanInfo[index].StopTime.dwYear;
			sysTime.wMonth = (WORD)m_DecChanInfo[index].StopTime.dwMonth;
			sysTime.wDay = (WORD)m_DecChanInfo[index].StopTime.dwDay;
			sysTime.wHour = (WORD)m_DecChanInfo[index].StopTime.dwHour;
			sysTime.wMinute = (WORD)m_DecChanInfo[index].StopTime.dwMinute;
			sysTime.wSecond = (WORD)m_DecChanInfo[index].StopTime.dwSecond;
			m_EndDate.SetTime(&sysTime);
			m_EndTime.SetTime(&sysTime);

			m_FileName.Empty();
		}
		else if (m_DecChanInfo[index].dwDecState == 3)
		{
			m_FileName.Format("%s", m_DecChanInfo[index].sFileName);

			CTime now = CTime::GetCurrentTime();
			m_StartDate.SetTime(&now);
			m_StartTime.SetTime(&now);
			m_EndDate.SetTime(&now);
			m_EndTime.SetTime(&now);
		}
		else
		{
			m_FileName.Empty();
			CTime now = CTime::GetCurrentTime();
			m_StartDate.SetTime(&now);
			m_StartTime.SetTime(&now);
			m_EndDate.SetTime(&now);
			m_EndTime.SetTime(&now);
		}
	}
	UpdateData(FALSE);
}

void CMatDispChan::OnSelchangeChancombo() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	int sel = m_ChanCombo.GetCurSel();
	
	ShowChanInfo(sel);
	if (!m_vGetStatus[sel])
	{
		CString tmp;
		tmp.Format("failed to get state of channel %d!", sel + m_lStartChan);
		AfxMessageBox(tmp);
	}
	else
	{
		m_IsLinkCombo.SetCurSel(m_DecChanStatus[sel].dwIsLinked);
		m_CopyRate = m_DecChanStatus[sel].dwStreamCpRate;
	}
	
	UpdateData(FALSE);
}

void CMatDispChan::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	if (nIDEvent == DISP_TIMER)
	{
		UpdateData(TRUE);
		int sel = m_ChanCombo.GetCurSel();

		GetChanStatus(sel+m_lStartChan, sel);

		ShowChanInfo(sel);

		UpdateData(TRUE);
		if (!m_vGetStatus[sel])
		{
			CString tmp;
			tmp.Format("failed to get state of channel %d!", sel + m_lStartChan);
			OutputDebugString(tmp);
		}
		else
		{
			m_IsLinkCombo.SetCurSel(m_DecChanStatus[sel].dwIsLinked);
			m_CopyRate = m_DecChanStatus[sel].dwStreamCpRate;
		}

		UpdateData(FALSE);
	}

	CDialog::OnTimer(nIDEvent);
}

void CMatDispChan::OnCancel() 
{
	// TODO: Add extra cleanup here
	KillTimer(DISP_TIMER);

	CDialog::OnCancel();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -