123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- // MatCycLink.cpp : implementation file
- //
- #include "stdafx.h"
- #include "StoneU_HC_OCX.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_TransModesCombo);
- DDX_Control(pDX, IDC_COMBOTRANSMODE, m_TransProtocolCombo);
- DDX_Control(pDX, IDC_COMBOSWITCH, m_SwitchCombo);
- DDX_Control(pDX, IDC_COMBODECCHAN2, m_DecChanCombo2);
- 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_SINGLEGET, OnSingleget)
- ON_BN_CLICKED(IDC_WHOLEGET, OnWholeget)
- ON_BN_CLICKED(IDC_SINGLESET, OnSingleset)
- ON_BN_CLICKED(IDC_CHECKCONCHAN, OnCheckconchan)
- ON_CBN_SELCHANGE(IDC_COMBODECCHAN2, OnSelchangeCombodecchan2)
- //}}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);
- m_DecChanCombo2.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);
- }
- if (!NET_DVR_MatrixGetLoopDecChanEnable(m_lServerID, m_lStartChan, &chanNum))
- {
- TRACE("\nError: NET_DVR_MatrixGetLoopDecChanEnable = %d\n", NET_DVR_GetLastError());
- }
- else
- {
- m_SwitchCombo.SetCurSel(chanNum);
- }
- m_DecChanCombo.SetCurSel(0);
- m_DecChanCombo2.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_TransModesCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byTransMode);
- m_TransProtocolCombo.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_TransModesCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byTransMode);
- m_TransProtocolCombo.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_TransModesCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransMode);
- m_TransProtocolCombo.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_TransModesCombo.GetCurSel();
- m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransProtocol = m_TransProtocolCombo.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_TransModesCombo.GetCurSel();
- m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransProtocol = m_TransProtocolCombo.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("保存成功!");
- }
- }
- void CMatCycLink::OnSingleget()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- int sel = m_DecChanCombo2.GetCurSel();
- DWORD flg = 0;
- if (!NET_DVR_MatrixGetLoopDecChanEnable(m_lServerID, sel+m_lStartChan, &flg))
- {
- TRACE("\nError: NET_DVR_MatrixGetLoopDecChanEnable[%d] = %d\n", sel+m_lStartChan, NET_DVR_GetLastError());
- return;
- }
- if (flg)
- {
- m_CycLink[sel] = TRUE;
- }
- else
- {
- m_CycLink[sel] = FALSE;
- }
- m_SwitchCombo.SetCurSel(m_CycLink[sel]);
- UpdateData(FALSE);
- MessageBox("获取成功!");
- }
- void CMatCycLink::OnWholeget()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
-
- int sel = m_DecChanCombo2.GetCurSel();
- DWORD flg = 0;
- if (!NET_DVR_MatrixGetLoopDecEnable(m_lServerID, &flg))
- {
- TRACE("\nError: NET_DVR_MatrixGetLoopDecEnable = %d\n", NET_DVR_GetLastError());
- return;
- }
- TRACE("\n### 0x%x\n", flg);
- for (int i=0; i<m_iChannelnumber; i++)
- {
- if (flg&0x1)
- {
- m_CycLink[i] = TRUE;
- }
- else
- {
- m_CycLink[i] = FALSE;
- }
- flg = flg>>1;
- TRACE("\n### %d\n", m_CycLink[i]);
- }
- m_SwitchCombo.SetCurSel(m_CycLink[sel]);
- UpdateData(FALSE);
- MessageBox("获取成功!");
- }
- void CMatCycLink::OnSingleset()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- int sel = m_DecChanCombo2.GetCurSel();
- BOOL flg = FALSE;
- if (m_SwitchCombo.GetCurSel())
- {
- flg = TRUE;
- }
- if (!NET_DVR_MatrixSetLoopDecChanEnable(m_lServerID, sel+m_lStartChan, flg))
- {
- TRACE("\nError: NET_DVR_MatrixSetLoopDecChanEnable[%d] = %d\n", sel+m_lStartChan, NET_DVR_GetLastError());
- return;
- }
- MessageBox("设置成功!");
- }
- void CMatCycLink::OnCheckconchan()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- EnableConChan(m_bCheckConnectChan);
- }
- void CMatCycLink::OnSelchangeCombodecchan2()
- {
- // TODO: Add your control notification handler code here
- int sel = m_DecChanCombo2.GetCurSel();
-
- m_SwitchCombo.SetCurSel(m_CycLink[sel]);
- UpdateData(FALSE);
- }
|