123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- // MatRow.cpp : implementation file
- //
- #include "stdafx.h"
- #include "StoneU_HC_OCX.h"
- #include "MatRow.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- LONG g_lAmount = 0;
- CMatRow *MatRow;
- /////////////////////////////////////////////////////////////////////////////
- // CMatRow dialog
- void CALLBACK fRowDataCallBack(LONG lUserID, char *sIPAddr, LONG lRowAmout, char *pRecvDataBuffer,DWORD dwBufSize,DWORD dwUser)
- {
- // NET_DVR_MATRIX_ROW_ELEMENT stru;
- // CString sTemp;
- // if (lRowAmout <= 0)
- // {
- // AfxMessageBox("无矩阵行信息!");
- // return;
- // }
- // if ((g_lAmount <= lRowAmout) && (lRowAmout > 0))
- // {
- // if (dwBufSize == sizeof(NET_DVR_MATRIX_ROW_ELEMENT))
- // {
- // memcpy(&stru, pRecvDataBuffer, dwBufSize);
- // sTemp.Format("%d", stru.dwRowNum);
- // MatRow->m_List.InsertItem(MatRow->m_iRowNum, sTemp, 0);
- // sTemp.Format("%s", stru.sSurvChanName);
- // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 1, sTemp);
- // sTemp.Format("%s", stru.struDecChanInfo.sDVRIP);
- // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 2, sTemp);
- // sTemp.Format("%d", stru.struDecChanInfo.wDVRPort);
- // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 3, sTemp);
- // sTemp.Format("%s", stru.struDecChanInfo.sUserName);
- // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 4, sTemp);
- // sTemp.Format("%d", stru.struDecChanInfo.byChannel);
- // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 5, sTemp);
- // if (stru.struDecChanInfo.byTransMode == 0)
- // {
- // sTemp.Format("%s", "主码流");
- // }
- // else if (stru.struDecChanInfo.byTransMode == 1)
- // {
- // sTemp.Format("%s", "子码流");
- // }
- // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 6, sTemp);
- // if (stru.struDecChanInfo.byTransProtocol == 0)
- // {
- // sTemp.Format("%s", "TCP");
- // }
- // else if (stru.struDecChanInfo.byTransProtocol == 1)
- // {
- // sTemp.Format("%s", "UDP");
- // }
- // else if (stru.struDecChanInfo.byTransProtocol == 2)
- // {
- // sTemp.Format("%s", "MULTICAST");
- // }
- // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 7, sTemp);
- // MatRow->m_iRowNum++;
- // }
- // g_lAmount++;
- // }
- // if (lRowAmout == g_lAmount)
- // {
- // AfxMessageBox("矩阵行信息已经全部列完!");
- // }
-
- }
- CMatRow::CMatRow(CWnd* pParent /*=NULL*/)
- : CDialog(CMatRow::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CMatRow)
- m_UserPSW = _T("12345");
- m_UserName = _T("admin");
- m_Port = 8000;
- m_Ip = _T("192.0.1.139");
- m_ChanName = _T("test");
- m_RowNUM = 1;
- //}}AFX_DATA_INIT
- }
- void CMatRow::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CMatRow)
- DDX_Control(pDX, IDC_COMBONUM, m_DecChanCtrl);
- DDX_Control(pDX, IDC_COMBOPROTYPE, m_TypeCtrl);
- DDX_Control(pDX, IDC_COMBOPROTOCOL, m_ProtocalCtrl);
- DDX_Control(pDX, IDC_COMCHAN, m_ChanCtrl);
- DDX_Control(pDX, IDC_LIST1, m_List);
- DDX_Text(pDX, IDC_EDITUSERPSW, m_UserPSW);
- DDX_Text(pDX, IDC_EDITUSERNAME, m_UserName);
- DDX_Text(pDX, IDC_EDITPORT, m_Port);
- DDX_Text(pDX, IDC_EDITIP, m_Ip);
- DDX_Text(pDX, IDC_EDITCHANNAME, m_ChanName);
- DDX_Text(pDX, IDC_EDITROWNUM, m_RowNUM);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CMatRow, CDialog)
- //{{AFX_MSG_MAP(CMatRow)
- ON_BN_CLICKED(IDC_BUTDECSTART, OnButdecstart)
- ON_BN_CLICKED(IDC_BUTDECSTOP, OnButdecstop)
- ON_BN_CLICKED(IDC_BUTGETROW, OnButgetrow)
- ON_BN_CLICKED(IDC_BUTANO, OnButano)
- ON_BN_CLICKED(IDC_BUTAO, OnButao)
- ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
- ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnRclickList1)
- ON_BN_CLICKED(IDC_BUTDEL, OnButdel)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMatRow message handlers
- void CMatRow::OnCancel()
- {
- // TODO: Add extra cleanup here
-
- // CDialog::OnCancel();
- }
- void CMatRow::OnOK()
- {
- // TODO: Add extra validation here
-
- // CDialog::OnOK();
- }
- BOOL CMatRow::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- CString sTemp;
- m_nChanSel = 0;
- m_DecChanCtrl.ResetContent();
- for(int i=0; i<m_iChannelnumber; i++)
- {
- sTemp.Format("通道%d", (m_lStartChan+i));
- m_DecChanCtrl.AddString(sTemp);
- }
- m_ChanCtrl.SetCurSel(1);
- m_DecChanCtrl.SetCurSel(m_nChanSel);
- m_TypeCtrl.SetCurSel(0);
- m_ProtocalCtrl.SetCurSel(0);
- m_List.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
- m_List.InsertColumn(0,"行号",LVCFMT_LEFT,50,-1);
- m_List.InsertColumn(1,"监控通道名称",LVCFMT_LEFT,120,-1);
- m_List.InsertColumn(2,"IP地址",LVCFMT_LEFT,110,-1);
- m_List.InsertColumn(3,"端口号",LVCFMT_LEFT,50,-1);
- m_List.InsertColumn(4,"用户名",LVCFMT_LEFT,120,-1);
- m_List.InsertColumn(5,"通道号",LVCFMT_LEFT,50,-1);
- m_List.InsertColumn(6,"传输模式",LVCFMT_LEFT,70,-1);
- m_List.InsertColumn(7,"传输协议",LVCFMT_LEFT,70,-1);
- m_iRowNum = 0;
- MatRow = this;
- UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CMatRow::OnButdecstart()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- // NET_DVR_MATRIX_DYNAMIC_DEC stru;
- // stru.dwSize = sizeof(NET_DVR_MATRIX_DYNAMIC_DEC);
- //
- // stru.struDecChanInfo.byChannel = m_ChanCtrl.GetCurSel();
- // stru.struDecChanInfo.byTransMode = m_TypeCtrl.GetCurSel();
- // stru.struDecChanInfo.byTransProtocol = m_ProtocalCtrl.GetCurSel();
- // memcpy(stru.struDecChanInfo.sDVRIP, m_Ip, 16);
- // memcpy(stru.struDecChanInfo.sPassword, m_UserPSW, PASSWD_LEN);
- // memcpy(stru.struDecChanInfo.sUserName, m_UserName, NAME_LEN);
- // stru.struDecChanInfo.wDVRPort = m_Port;
- // if (!NET_DVR_MatrixStartDynamic(m_lServerID, m_DecChanCtrl.GetCurSel()+m_lStartChan, &stru))
- // {
- // CString sTemp;
- // sTemp.Format("ERROR: NET_DVR_MatrixStartDynamic = %d \n", NET_DVR_GetLastError());
- // TRACE(sTemp);
- // // return FALSE;
- // }
- }
- void CMatRow::OnButdecstop()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- // if (!NET_DVR_MatrixStopDynamic(m_lServerID, m_DecChanCtrl.GetCurSel()+m_lStartChan))
- // {
- // CString sTemp;
- // sTemp.Format("ERROR: NET_DVR_MatrixStopDynamic = %d \n", NET_DVR_GetLastError());
- // TRACE(sTemp);
- // // return FALSE;
- // }
-
- }
- void CMatRow::OnButgetrow()
- {
- // TODO: Add your control notification handler code here
- // m_iRowNum = 0;
- // g_lAmount = 0;
- // m_List.DeleteAllItems();
- // if (!NET_DVR_MatrixGetRowInfo(m_lServerID, fRowDataCallBack, 0))
- // {
- // CString sTemp;
- // sTemp.Format("ERROR: NET_DVR_MatrixGetRowInfo = %d \n", NET_DVR_GetLastError());
- // AfxMessageBox(sTemp);
- // return;
- // }
- }
- void CMatRow::OnButano()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- // NET_DVR_MATRIX_ROW_ELEMENT stru;
- // stru.struDecChanInfo.byChannel = m_ChanCtrl.GetCurSel();
- // stru.struDecChanInfo.byTransMode = m_TypeCtrl.GetCurSel();
- // stru.struDecChanInfo.byTransProtocol = m_ProtocalCtrl.GetCurSel();
- // memcpy(stru.sSurvChanName, m_ChanName, 128);
- // memcpy(stru.struDecChanInfo.sDVRIP, m_Ip, 16);
- // memcpy(stru.struDecChanInfo.sPassword, m_UserPSW, PASSWD_LEN);
- // memcpy(stru.struDecChanInfo.sUserName, m_UserName, NAME_LEN);
- // stru.struDecChanInfo.wDVRPort = m_Port;
- // stru.dwRowNum = m_RowNUM;
- // if (!NET_DVR_MatrixAddNoOverlayRowInfo(m_lServerID, 1, &stru))
- // {
- // CString sTemp;
- // sTemp.Format("ERROR: NET_DVR_MatrixAddNoOverlayRowInfo = %d \n", NET_DVR_GetLastError());
- // AfxMessageBox(sTemp);
- // return;
- // }
- }
- void CMatRow::OnButao()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- // NET_DVR_MATRIX_ROW_ELEMENT stru;
- // stru.struDecChanInfo.byChannel = m_ChanCtrl.GetCurSel();
- // stru.struDecChanInfo.byTransMode = m_TypeCtrl.GetCurSel();
- // stru.struDecChanInfo.byTransProtocol = m_ProtocalCtrl.GetCurSel();
- // memcpy(stru.sSurvChanName, m_ChanName, 128);
- // memcpy(stru.struDecChanInfo.sDVRIP, m_Ip, 16);
- // memcpy(stru.struDecChanInfo.sPassword, m_UserPSW, PASSWD_LEN);
- // memcpy(stru.struDecChanInfo.sUserName, m_UserName, NAME_LEN);
- // stru.struDecChanInfo.wDVRPort = m_Port;
- // stru.dwRowNum = m_RowNUM;
- // if (!NET_DVR_MatrixAddAndOverlayRowInfo(m_lServerID, 1, &stru))
- // {
- // CString sTemp;
- // sTemp.Format("ERROR: NET_DVR_MatrixAddAndOverlayRowInfo = %d \n", NET_DVR_GetLastError());
- // TRACE(sTemp);
- // // return FALSE;
- // }
- }
- void CMatRow::OnButexit()
- {
- // TODO: Add your control notification handler code here
- CDialog::OnOK();
- }
- void CMatRow::OnRclickList1(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
-
- *pResult = 0;
- }
- void CMatRow::OnButdel()
- {
- // TODO: Add your control notification handler code here
- // POSITION pos;
- // int selpos = 0;
- // CString csName;
- // NET_DVR_MATRIX_ROW_INDEX stru;
- //
- // UpdateData(TRUE);
- // pos = m_List.GetFirstSelectedItemPosition();
- // if(pos == NULL)
- // {
- // AfxMessageBox("请选择要刪除的行!");
- // return;
- // }
- // selpos = m_List.GetNextSelectedItem(pos);
- // //监控通道名称
- // csName.Format("%s", m_List.GetItemText(selpos, 1));
- // if(csName.IsEmpty())
- // return;
- // sprintf((char *)(stru.sSurvChanName), "%s", csName);
- // //行号
- // csName.Format("%s", m_List.GetItemText(selpos, 0));
- // stru.dwRowNum = atoi(csName);
- //
- // if (!NET_DVR_MatrixDelRowInfo(m_lServerID, 1, &stru))
- // {
- // CString sTemp;
- // sTemp.Format("ERROR: NET_DVR_MatrixDelRowInfo = %d \n", NET_DVR_GetLastError());
- // TRACE(sTemp);
- // // return FALSE;
- // }
- // else
- // {
- // m_iRowNum = 0;
- // g_lAmount = 0;
- // m_List.DeleteAllItems();
- // if (!NET_DVR_MatrixGetRowInfo(m_lServerID, fRowDataCallBack, 0))
- // {
- // CString sTemp;
- // sTemp.Format("ERROR: NET_DVR_MatrixGetRowInfo = %d \n", NET_DVR_GetLastError());
- // TRACE(sTemp);
- // // return FALSE;
- // }
- // }
- }
|