📄 matcyclink.cpp
字号:
// MatCycLink.cpp : implementation file
//
#include "stdafx.h"
#include "newclient.h"
#include "MatCycLink.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMatCycLink dialog
CMatCycLink::CMatCycLink(CWnd* pParent /*=NULL*/)
: CDialog(CMatCycLink::IDD, pParent)
{
//{{AFX_DATA_INIT(CMatCycLink)
m_DVRChannel = 0;
m_DVRIP = _T("");
m_DVRPasswd = _T("");
m_DVRPort = 0;
m_DVRUser = _T("");
m_PoolTime = 0;
m_bCheckConnectChan = FALSE;
//}}AFX_DATA_INIT
m_iChanSel = -1;
for (int i=0; i<MAXCHANNUM; i++)
{
m_CycLink[i] = FALSE;
}
}
void CMatCycLink::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMatCycLink)
DDX_Control(pDX, IDC_COMBOTRANSTYPE, m_TransTypeCombo);
DDX_Control(pDX, IDC_COMBOTRANSMODE, m_TransModeCombo);
DDX_Control(pDX, IDC_COMBODECCHAN, m_DecChanCombo);
DDX_Control(pDX, IDC_COMBOCONCHAN, m_ConnectChanCombo);
DDX_Text(pDX, IDC_EDITDVRCHAN, m_DVRChannel);
DDX_Text(pDX, IDC_EDITDVRIP, m_DVRIP);
DDX_Text(pDX, IDC_EDITDVRPASSWD, m_DVRPasswd);
DDX_Text(pDX, IDC_EDITDVRPORT, m_DVRPort);
DDX_Text(pDX, IDC_EDITDVRUSER, m_DVRUser);
DDX_Text(pDX, IDC_EDITPOOLTIME, m_PoolTime);
DDX_Check(pDX, IDC_CHECKCONCHAN, m_bCheckConnectChan);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMatCycLink, CDialog)
//{{AFX_MSG_MAP(CMatCycLink)
ON_CBN_SELCHANGE(IDC_COMBODECCHAN, OnSelchangeCombodecchan)
ON_CBN_SELCHANGE(IDC_COMBOCONCHAN, OnSelchangeComboconchan)
ON_BN_CLICKED(IDC_SAVEPARA, OnSavepara)
ON_BN_CLICKED(IDC_SETPARAM, OnSetparam)
ON_BN_CLICKED(IDC_CHECKCONCHAN, OnCheckconchan)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMatCycLink message handlers
BOOL CMatCycLink::OnInitDialog()
{
CDialog::OnInitDialog();
int i = 0;
for (i=0; i<MAXCHANNUM; i++)
{
ZeroMemory(&m_MatLoopDec[i], sizeof(NET_DVR_MATRIX_LOOP_DECINFO));
}
// TODO: Add extra initialization here
DWORD chanNum = 0;
CString tmp;
for (i=0; i<m_iChannelnumber; i++)
{
chanNum = i + m_lStartChan;
tmp.Format("%d", chanNum);
m_DecChanCombo.AddString(tmp);
if (!NET_DVR_MatrixGetLoopDecChanInfo(m_lServerID, chanNum, &m_MatLoopDec[i]))
{
TRACE("\nError: NET_DVR_MatrixGetLoopDecChanInfo[%d] = %d\n", i, NET_DVR_GetLastError());
}
for (int j=0; j<MAX_CYCLE_CHAN; j++)
{
TRACE("0x%x ", m_MatLoopDec[i].struchanConInfo[j].dwEnable);
}
TRACE("\n### pool time = %d\n", m_MatLoopDec[i].dwPoolTime);
}
m_DecChanCombo.SetCurSel(0);
m_iChanSel = 0;
for (i=0; i<MAX_CYCLE_CHAN; i++)
{
tmp.Format("%d", i);
m_ConnectChanCombo.AddString(tmp);
}
m_ConnectChanCombo.SetCurSel(0);
m_PoolTime = m_MatLoopDec[m_iChanSel].dwPoolTime;
m_bCheckConnectChan = m_MatLoopDec[m_iChanSel].struchanConInfo[0].dwEnable;
if (m_MatLoopDec[m_iChanSel].struchanConInfo[0].dwEnable)
{
m_DVRIP.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.sDVRIP);
m_DVRPort = m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.wDVRPort;
m_DVRUser.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.sUserName);
m_DVRPasswd.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.sPassword);
m_DVRChannel = m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byChannel;
m_TransModeCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byTransMode);
m_TransTypeCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byTransProtocol);
}
else
{
EnableConChan(FALSE);
}
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMatCycLink::EnableConChan(BOOL bEnable)
{
GetDlgItem(IDC_EDITDVRIP)->EnableWindow(bEnable);
GetDlgItem(IDC_EDITDVRPORT)->EnableWindow(bEnable);
GetDlgItem(IDC_EDITDVRCHAN)->EnableWindow(bEnable);
GetDlgItem(IDC_EDITDVRUSER)->EnableWindow(bEnable);
GetDlgItem(IDC_EDITDVRPASSWD)->EnableWindow(bEnable);
GetDlgItem(IDC_COMBOTRANSMODE)->EnableWindow(bEnable);
GetDlgItem(IDC_COMBOTRANSTYPE)->EnableWindow(bEnable);
UpdateData(FALSE);
}
void CMatCycLink::OnSelchangeCombodecchan()
{
// TODO: Add your control notification handler code here
int sel = m_DecChanCombo.GetCurSel();
if (sel == m_iChanSel)
{
return;
}
m_iChanSel = sel;
m_PoolTime = m_MatLoopDec[m_iChanSel].dwPoolTime;
m_ConnectChanCombo.SetCurSel(0);
m_bCheckConnectChan = m_MatLoopDec[m_iChanSel].struchanConInfo[0].dwEnable;
if (m_MatLoopDec[m_iChanSel].struchanConInfo[0].dwEnable)
{
EnableConChan(TRUE);
m_DVRIP.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.sDVRIP);
m_DVRPort = m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.wDVRPort;
m_DVRUser.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.sUserName);
m_DVRPasswd.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.sPassword);
m_DVRChannel = m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byChannel;
m_TransModeCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byTransMode);
m_TransTypeCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byTransProtocol);
}
else
{
EnableConChan(FALSE);
}
UpdateData(FALSE);
}
void CMatCycLink::OnSelchangeComboconchan()
{
// TODO: Add your control notification handler code here
int sel = m_ConnectChanCombo.GetCurSel();
m_bCheckConnectChan = m_MatLoopDec[m_iChanSel].struchanConInfo[sel].dwEnable;
TRACE("\n### m_bCheckConnectChan = 0x%x\n", m_bCheckConnectChan);
if (m_MatLoopDec[m_iChanSel].struchanConInfo[sel].dwEnable)
{
EnableConChan(TRUE);
m_DVRIP.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sDVRIP);
m_DVRPort = m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.wDVRPort;
m_DVRUser.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sUserName);
m_DVRPasswd.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sPassword);
m_DVRChannel = m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byChannel;
m_TransModeCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransMode);
m_TransTypeCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransProtocol);
}
else
{
EnableConChan(FALSE);
}
UpdateData(FALSE);
}
void CMatCycLink::OnSavepara()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
int sel = m_ConnectChanCombo.GetCurSel();
ZeroMemory(&m_MatLoopDec[m_iChanSel].struchanConInfo[sel], sizeof(m_MatLoopDec[m_iChanSel].struchanConInfo[sel]));
m_MatLoopDec[m_iChanSel].struchanConInfo[sel].dwEnable = m_bCheckConnectChan;
if (m_bCheckConnectChan)
{
m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byChannel = m_DVRChannel;
m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransMode = m_TransModeCombo.GetCurSel();
m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransProtocol = m_TransTypeCombo.GetCurSel();
m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.wDVRPort = m_DVRPort;
sprintf(m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sDVRIP, "%s", m_DVRIP);
sprintf((char *)m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sUserName, "%s", m_DVRUser);
sprintf((char *)m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sPassword, "%s", m_DVRPasswd);
}
}
void CMatCycLink::OnSetparam()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
int sel = m_ConnectChanCombo.GetCurSel();
ZeroMemory(&m_MatLoopDec[m_iChanSel].struchanConInfo[sel], sizeof(m_MatLoopDec[m_iChanSel].struchanConInfo[sel]));
m_MatLoopDec[m_iChanSel].struchanConInfo[sel].dwEnable = m_bCheckConnectChan;
if (m_bCheckConnectChan)
{
m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byChannel = m_DVRChannel;
m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransMode = m_TransModeCombo.GetCurSel();
m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransProtocol = m_TransTypeCombo.GetCurSel();
m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.wDVRPort = m_DVRPort;
sprintf(m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sDVRIP, "%s", m_DVRIP);
sprintf((char *)m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sUserName, "%s", m_DVRUser);
sprintf((char *)m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sPassword, "%s", m_DVRPasswd);
}
m_MatLoopDec[m_iChanSel].dwPoolTime = m_PoolTime;
BOOL error = FALSE;
for (int i=0; i<m_iChannelnumber; i++)
{
if (!NET_DVR_MatrixSetLoopDecChanInfo(m_lServerID, i+m_lStartChan, &m_MatLoopDec[i]))
{
TRACE("\nError: NET_DVR_MatrixSetLoopDecChanInfo = %d\n", NET_DVR_GetLastError());
error = TRUE;
}
}
if (!error)
{
MessageBox("success!");
}
}
void CMatCycLink::OnCheckconchan()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
EnableConChan(m_bCheckConnectChan);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -