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

📄 remoteparamscfg.cpp

📁 SDK DVR/DVS HIKVISION
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// RemoteParamsCfg.cpp : implementation file
//

#include "stdafx.h"
#include "newclient.h"
#include "RemoteParamsCfg.h"

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

extern SERVER_INFO	serverinfo[MAXIPNUMBER];
extern IP_INFO		selipinfo[MAXNUMBER];
extern IP_INFO		allipinfo[MAXIPNUMBER][MAXCHANNUM];
/////////////////////////////////////////////////////////////////////////////
// CRemoteParamsCfg dialog

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


void CRemoteParamsCfg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CRemoteParamsCfg)
	DDX_Control(pDX, IDC_TABREMOTECFG, m_Tab);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CRemoteParamsCfg, CDialog)
	//{{AFX_MSG_MAP(CRemoteParamsCfg)
	ON_BN_CLICKED(IDC_SAVEPARA, OnSavepara)
	ON_NOTIFY(TCN_SELCHANGE, IDC_TABREMOTECFG, OnSelchangeTabremotecfg)
	ON_BN_CLICKED(IDEXIT, OnExit)
	ON_BN_CLICKED(IDC_RESTORE, OnRestore)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRemoteParamsCfg message handlers

BOOL CRemoteParamsCfg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	if (m_iServertype == DEC_MAT)
	{
		m_Tab.InsertItem(0, "Server Para.");
		m_Tab.InsertItem(1, "Serial Para.");
		m_Tab.InsertItem(2, "User Para.");
		m_Tab.InsertItem(3, "Multi-Decoder Para.");
	}
	else
	{
		m_Tab.InsertItem(0, "Server Para.");
		m_Tab.InsertItem(1, "Channel Para.");
		m_Tab.InsertItem(2, "Serial Para.");
		m_Tab.InsertItem(3, "Alarm Para.");
		m_Tab.InsertItem(4, "User Para.");
		m_Tab.InsertItem(5, "Transaction Para.");
		m_Tab.InsertItem(6, "Exception Para.");
	}
	m_bConnectServer = TRUE;
	
	m_RemoteServerCfgDlg.m_lServerID = m_lServerID;
	m_RemoteServerCfgDlg.m_lStartChannel = m_lStartChannel;
	m_RemoteServerCfgDlg.m_iChannelnumber = m_iChannelnumber;
	m_RemoteServerCfgDlg.m_iServer = m_iServer;
	
	m_RemoteChannelCfgDlg.m_iChannelnumber = m_iChannelnumber;
	m_RemoteChannelCfgDlg.m_lServerID = m_lServerID;
	m_RemoteChannelCfgDlg.m_lStartChannel = m_lStartChannel;
	m_RemoteChannelCfgDlg.m_dwAlarmOutNum = m_dwAlarmOutNum;
	m_RemoteChannelCfgDlg.m_iServer = m_iServer;

	m_RemoteSerialCfgDlg.m_iChannelnumber = m_iChannelnumber;
	m_RemoteSerialCfgDlg.m_lServerID = m_lServerID;
	m_RemoteSerialCfgDlg.m_lStartChannel = m_lStartChannel;		

	m_RemoteAlarmCfgDlg.m_iChannelnumber = m_iChannelnumber;
	m_RemoteAlarmCfgDlg.m_lServerID = m_lServerID;
	m_RemoteAlarmCfgDlg.m_lStartChannel = m_lStartChannel;
	m_RemoteAlarmCfgDlg.m_dwAlarmInNum = m_dwAlarmInNum;
	m_RemoteAlarmCfgDlg.m_dwAlarmOutNum = m_dwAlarmOutNum;
			
	m_RemoteUserCfgDlg.m_iChannelnumber = m_iChannelnumber;
	m_RemoteUserCfgDlg.m_lServerID = m_lServerID;
	m_RemoteUserCfgDlg.m_lStartChannel = m_lStartChannel;
	m_RemoteUserCfgDlg.m_bSuperUser = m_bSuperUser;	
	m_RemoteUserCfgDlg.m_loginname = m_Username;

	m_RemoteATMInfoDlg.m_lServerID = m_lServerID;

	m_ExceptionCfgDlg.m_lServerID = m_lServerID;
	m_ExceptionCfgDlg.m_dwAlarmOutNum = m_dwAlarmOutNum;

	m_MatDecCfgDlg.m_lServerID = m_lServerID;
	m_MatDecCfgDlg.m_iChannelnumber = m_iChannelnumber;
	m_MatDecCfgDlg.m_lStartChan = m_lStartChannel;
	
	//Create and Show/Hide...
	m_RemoteServerCfgDlg.Create(IDD_SUBDLG_SERVERCFG, &m_Tab);
	m_bConnectServer = m_RemoteServerCfgDlg.m_bConnectServer;
	m_RemoteServerCfgDlg.ShowWindow(SW_SHOW);

	if (m_iServertype != DEC_MAT)
	{
		m_RemoteChannelCfgDlg.m_bConnectServer = m_bConnectServer;
		m_RemoteChannelCfgDlg.Create(IDD_SUBDLG_CHANCFG, &m_Tab);
		m_RemoteChannelCfgDlg.ShowWindow(SW_HIDE);
	}
	
	m_RemoteSerialCfgDlg.Create(IDD_SUBDLG_SERIALCFG, &m_Tab);
	m_RemoteSerialCfgDlg.m_bConnectServer = m_bConnectServer;
	m_RemoteSerialCfgDlg.ShowWindow(SW_HIDE);

	if (m_iServertype != DEC_MAT)
	{
		m_RemoteAlarmCfgDlg.m_bConnectServer = m_bConnectServer;
		m_RemoteAlarmCfgDlg.Create(IDD_SUBDLG_ALARMCFG, &m_Tab);
		m_RemoteAlarmCfgDlg.ShowWindow(SW_HIDE);

		m_RemoteATMInfoDlg.m_bConnectServer = m_bConnectServer;
		m_RemoteATMInfoDlg.Create(IDD_SUBDLG_ATMINFO, &m_Tab);
		m_RemoteATMInfoDlg.ShowWindow(SW_HIDE);

		m_RemoteUserCfgDlg.m_bConnectServer = m_bConnectServer;
		m_RemoteUserCfgDlg.Create(IDD_DLG_USERCFG, &m_Tab);
		m_RemoteUserCfgDlg.ShowWindow(SW_HIDE);
		
		m_ExceptionCfgDlg.m_bConnectServer = m_bConnectServer;
		m_ExceptionCfgDlg.Create(IDD_SUBDLG_EXCEPTION, &m_Tab);
		m_ExceptionCfgDlg.ShowWindow(SW_HIDE);
	}
	else
	{
		m_RemoteUserCfgDlg.m_bConnectServer = m_bConnectServer;
		m_RemoteUserCfgDlg.Create(IDD_DLG_USERCFG, &m_Tab);
		m_RemoteUserCfgDlg.ShowWindow(SW_HIDE);

		m_MatDecCfgDlg.m_bConnectServer = m_bConnectServer;
		m_MatDecCfgDlg.Create(IDD_DLG_MATDECCFG, &m_Tab);
		m_MatDecCfgDlg.ShowWindow(SW_HIDE);
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void CRemoteParamsCfg::OnSavepara() 
{
	// TODO: Add your control notification handler code here
	int i, j;
	BOOL Done = TRUE;
	if(m_RemoteServerCfgDlg.bSetServerParams)
	{	
		if (m_RemoteServerCfgDlg.m_bSupScale)
		{
			if (!NET_DVR_SetScaleCFG(m_lServerID, m_RemoteServerCfgDlg.m_dwUseZoom))
			{
				m_NotifyMess.Format("Setup use zoom failed: NET_DVR_GetLastError = %d \n", NET_DVR_GetLastError());
				TRACE(m_NotifyMess);
				Done = FALSE;
				NotifyToolTip();	
			}	
		}

		m_RemoteServerCfgDlg.m_devicecfg.dwSize = sizeof(m_RemoteServerCfgDlg.m_devicecfg);
		if(!NET_DVR_SetDVRConfig(m_lServerID, NET_DVR_SET_DEVICECFG, 0, &(m_RemoteServerCfgDlg.m_devicecfg), sizeof(NET_DVR_DEVICECFG)))
		{
			m_NotifyMess.Format("Setup server parameters failed: NET_DVR_GET_DEVICECFG = %d \n", NET_DVR_GetLastError());
			TRACE(m_NotifyMess);
			Done = FALSE;
			NotifyToolTip();
		}

		m_RemoteServerCfgDlg.m_netcfg.dwSize = sizeof(m_RemoteServerCfgDlg.m_netcfg);
		if(!NET_DVR_SetDVRConfig(m_lServerID, NET_DVR_SET_NETCFG, 0, &(m_RemoteServerCfgDlg.m_netcfg), sizeof(NET_DVR_NETCFG)))
		{
			m_NotifyMess.Format("Setup server parameters failed: NET_DVR_SET_NETCFG = %d \n", NET_DVR_GetLastError());
			TRACE(m_NotifyMess);
			Done = FALSE;
			NotifyToolTip();	
		}
		serverinfo[m_iServer].m_csServerMultiIP = m_RemoteServerCfgDlg.m_netcfg.sMultiCastIP;
		serverinfo[m_iServer].m_dwServerMultiIPvalue = inet_addr(m_RemoteServerCfgDlg.m_netcfg.sMultiCastIP);
		for(j=0; j<m_iChannelnumber; j++)
		{
			allipinfo[m_iServer][j].m_csMultiIP = m_RemoteServerCfgDlg.m_netcfg.sMultiCastIP;
			allipinfo[m_iServer][j].m_dwMultiIPvalue = inet_addr(allipinfo[m_iServer][j].m_csMultiIP);
			if( (allipinfo[m_iServer][j].m_bChoosed) && (allipinfo[m_iServer][j].m_iSequence != -1) )
			{
				selipinfo[allipinfo[m_iServer][j].m_iSequence].m_csMultiIP = allipinfo[m_iServer][j].m_csMultiIP;
				selipinfo[allipinfo[m_iServer][j].m_iSequence].m_dwMultiIPvalue = allipinfo[m_iServer][j].m_dwMultiIPvalue;
			}
		}

		if (serverinfo[m_iServer].m_wServerType == DEC_MAT)
		{
			m_RemoteServerCfgDlg.m_MultiDecoder.dwSize = sizeof(m_RemoteServerCfgDlg.m_MultiDecoder);
			if (!NET_DVR_SetDVRConfig(m_lServerID, NET_DVR_SET_NETCFG_OTHER, 0, &(m_RemoteServerCfgDlg.m_MultiDecoder), sizeof(NET_DVR_NETCFG_OTHER)))
			{
				m_NotifyMess.Format("ERROR: NET_DVR_SET_NETCFG_OTHER = %d \n", NET_DVR_GetLastError());
				TRACE(m_NotifyMess);
				Done = FALSE;
				NotifyToolTip();
			}
		}
		m_RemoteServerCfgDlg.bSetServerParams = FALSE;
	}

	int m_nChanNum = 0;
	if (serverinfo[m_iServer].m_dwDevSoftVersion >= 0x20001 && m_iServertype != DEC_MAT)
	{
		for(i=0; i<m_iChannelnumber; i++)
		{
			m_nChanNum = i + m_lStartChannel;
			if(m_RemoteChannelCfgDlg.bSetChannelPara[i])
			{
				m_RemoteChannelCfgDlg.m_compressioncfg_new[i].dwSize = sizeof(m_RemoteChannelCfgDlg.m_compressioncfg_new[i]);
				if(!NET_DVR_SetDVRConfig(m_lServerID, NET_DVR_SET_EVENTCOMPCFG, m_nChanNum, &(m_RemoteChannelCfgDlg.m_compressioncfg_new[i]), sizeof(NET_DVR_COMPRESSIONCFG)))
				{
					m_NotifyMess.Format("%d ERROR: NET_DVR_SET_EVENTCOMPCFG = %d \n", m_nChanNum, NET_DVR_GetLastError());
					TRACE(m_NotifyMess); 
					Done = FALSE;
					NotifyToolTip();
				}
			}
		}
	}

	if (m_iServertype != DEC_MAT)
	{
		for(i=0; i<m_iChannelnumber; i++)
		{
			m_nChanNum = i + m_lStartChannel;
			if(m_RemoteChannelCfgDlg.bSetChannelPara[i])
			{
				m_RemoteChannelCfgDlg.m_piccfg[i].dwSize = sizeof(m_RemoteChannelCfgDlg.m_piccfg[i]);
				if(!NET_DVR_SetDVRConfig(m_lServerID, NET_DVR_SET_PICCFG_EX, m_nChanNum, &(m_RemoteChannelCfgDlg.m_piccfg[i]), sizeof(NET_DVR_PICCFG_EX)))
				{
					m_NotifyMess.Format("%d ERROR: NET_DVR_SET_PICCFG_EX = %d \n", m_nChanNum, NET_DVR_GetLastError());
					TRACE(m_NotifyMess);
					Done = FALSE;
					NotifyToolTip();	
				}
				m_RemoteChannelCfgDlg.m_compressioncfg[i].dwSize = sizeof(m_RemoteChannelCfgDlg.m_compressioncfg[i]);
				if(!NET_DVR_SetDVRConfig(m_lServerID, NET_DVR_SET_COMPRESSCFG_EX, m_nChanNum, &(m_RemoteChannelCfgDlg.m_compressioncfg[i]), sizeof(NET_DVR_COMPRESSIONCFG_EX)))
				{
					m_NotifyMess.Format("%d ERROR: NET_DVR_SET_COMPRESSCFG_EX = %d \n", m_nChanNum, NET_DVR_GetLastError());
					TRACE(m_NotifyMess); 
					Done = FALSE;
					NotifyToolTip();
				}
				m_RemoteChannelCfgDlg.m_record[i].dwSize = sizeof(m_RemoteChannelCfgDlg.m_record[i]);
				if(!NET_DVR_SetDVRConfig(m_lServerID, NET_DVR_SET_RECORDCFG, m_nChanNum, &(m_RemoteChannelCfgDlg.m_record[i]), sizeof(NET_DVR_RECORD)))	
				{
					m_NotifyMess.Format("%d ERROR: NET_DVR_SET_RECORDCFG = %d \n", m_nChanNum, NET_DVR_GetLastError());
					TRACE(m_NotifyMess);
					Done = FALSE;
					NotifyToolTip();
				}

⌨️ 快捷键说明

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