MatRow.cpp 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. // MatRow.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "StoneU_HC_OCX.h"
  5. #include "MatRow.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. LONG g_lAmount = 0;
  12. CMatRow *MatRow;
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CMatRow dialog
  15. void CALLBACK fRowDataCallBack(LONG lUserID, char *sIPAddr, LONG lRowAmout, char *pRecvDataBuffer,DWORD dwBufSize,DWORD dwUser)
  16. {
  17. // NET_DVR_MATRIX_ROW_ELEMENT stru;
  18. // CString sTemp;
  19. // if (lRowAmout <= 0)
  20. // {
  21. // AfxMessageBox("无矩阵行信息!");
  22. // return;
  23. // }
  24. // if ((g_lAmount <= lRowAmout) && (lRowAmout > 0))
  25. // {
  26. // if (dwBufSize == sizeof(NET_DVR_MATRIX_ROW_ELEMENT))
  27. // {
  28. // memcpy(&stru, pRecvDataBuffer, dwBufSize);
  29. // sTemp.Format("%d", stru.dwRowNum);
  30. // MatRow->m_List.InsertItem(MatRow->m_iRowNum, sTemp, 0);
  31. // sTemp.Format("%s", stru.sSurvChanName);
  32. // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 1, sTemp);
  33. // sTemp.Format("%s", stru.struDecChanInfo.sDVRIP);
  34. // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 2, sTemp);
  35. // sTemp.Format("%d", stru.struDecChanInfo.wDVRPort);
  36. // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 3, sTemp);
  37. // sTemp.Format("%s", stru.struDecChanInfo.sUserName);
  38. // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 4, sTemp);
  39. // sTemp.Format("%d", stru.struDecChanInfo.byChannel);
  40. // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 5, sTemp);
  41. // if (stru.struDecChanInfo.byTransMode == 0)
  42. // {
  43. // sTemp.Format("%s", "主码流");
  44. // }
  45. // else if (stru.struDecChanInfo.byTransMode == 1)
  46. // {
  47. // sTemp.Format("%s", "子码流");
  48. // }
  49. // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 6, sTemp);
  50. // if (stru.struDecChanInfo.byTransProtocol == 0)
  51. // {
  52. // sTemp.Format("%s", "TCP");
  53. // }
  54. // else if (stru.struDecChanInfo.byTransProtocol == 1)
  55. // {
  56. // sTemp.Format("%s", "UDP");
  57. // }
  58. // else if (stru.struDecChanInfo.byTransProtocol == 2)
  59. // {
  60. // sTemp.Format("%s", "MULTICAST");
  61. // }
  62. // MatRow->m_List.SetItemText(MatRow->m_iRowNum, 7, sTemp);
  63. // MatRow->m_iRowNum++;
  64. // }
  65. // g_lAmount++;
  66. // }
  67. // if (lRowAmout == g_lAmount)
  68. // {
  69. // AfxMessageBox("矩阵行信息已经全部列完!");
  70. // }
  71. }
  72. CMatRow::CMatRow(CWnd* pParent /*=NULL*/)
  73. : CDialog(CMatRow::IDD, pParent)
  74. {
  75. //{{AFX_DATA_INIT(CMatRow)
  76. m_UserPSW = _T("12345");
  77. m_UserName = _T("admin");
  78. m_Port = 8000;
  79. m_Ip = _T("192.0.1.139");
  80. m_ChanName = _T("test");
  81. m_RowNUM = 1;
  82. //}}AFX_DATA_INIT
  83. }
  84. void CMatRow::DoDataExchange(CDataExchange* pDX)
  85. {
  86. CDialog::DoDataExchange(pDX);
  87. //{{AFX_DATA_MAP(CMatRow)
  88. DDX_Control(pDX, IDC_COMBONUM, m_DecChanCtrl);
  89. DDX_Control(pDX, IDC_COMBOPROTYPE, m_TypeCtrl);
  90. DDX_Control(pDX, IDC_COMBOPROTOCOL, m_ProtocalCtrl);
  91. DDX_Control(pDX, IDC_COMCHAN, m_ChanCtrl);
  92. DDX_Control(pDX, IDC_LIST1, m_List);
  93. DDX_Text(pDX, IDC_EDITUSERPSW, m_UserPSW);
  94. DDX_Text(pDX, IDC_EDITUSERNAME, m_UserName);
  95. DDX_Text(pDX, IDC_EDITPORT, m_Port);
  96. DDX_Text(pDX, IDC_EDITIP, m_Ip);
  97. DDX_Text(pDX, IDC_EDITCHANNAME, m_ChanName);
  98. DDX_Text(pDX, IDC_EDITROWNUM, m_RowNUM);
  99. //}}AFX_DATA_MAP
  100. }
  101. BEGIN_MESSAGE_MAP(CMatRow, CDialog)
  102. //{{AFX_MSG_MAP(CMatRow)
  103. ON_BN_CLICKED(IDC_BUTDECSTART, OnButdecstart)
  104. ON_BN_CLICKED(IDC_BUTDECSTOP, OnButdecstop)
  105. ON_BN_CLICKED(IDC_BUTGETROW, OnButgetrow)
  106. ON_BN_CLICKED(IDC_BUTANO, OnButano)
  107. ON_BN_CLICKED(IDC_BUTAO, OnButao)
  108. ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
  109. ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnRclickList1)
  110. ON_BN_CLICKED(IDC_BUTDEL, OnButdel)
  111. //}}AFX_MSG_MAP
  112. END_MESSAGE_MAP()
  113. /////////////////////////////////////////////////////////////////////////////
  114. // CMatRow message handlers
  115. void CMatRow::OnCancel()
  116. {
  117. // TODO: Add extra cleanup here
  118. // CDialog::OnCancel();
  119. }
  120. void CMatRow::OnOK()
  121. {
  122. // TODO: Add extra validation here
  123. // CDialog::OnOK();
  124. }
  125. BOOL CMatRow::OnInitDialog()
  126. {
  127. CDialog::OnInitDialog();
  128. // TODO: Add extra initialization here
  129. CString sTemp;
  130. m_nChanSel = 0;
  131. m_DecChanCtrl.ResetContent();
  132. for(int i=0; i<m_iChannelnumber; i++)
  133. {
  134. sTemp.Format("通道%d", (m_lStartChan+i));
  135. m_DecChanCtrl.AddString(sTemp);
  136. }
  137. m_ChanCtrl.SetCurSel(1);
  138. m_DecChanCtrl.SetCurSel(m_nChanSel);
  139. m_TypeCtrl.SetCurSel(0);
  140. m_ProtocalCtrl.SetCurSel(0);
  141. m_List.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
  142. m_List.InsertColumn(0,"行号",LVCFMT_LEFT,50,-1);
  143. m_List.InsertColumn(1,"监控通道名称",LVCFMT_LEFT,120,-1);
  144. m_List.InsertColumn(2,"IP地址",LVCFMT_LEFT,110,-1);
  145. m_List.InsertColumn(3,"端口号",LVCFMT_LEFT,50,-1);
  146. m_List.InsertColumn(4,"用户名",LVCFMT_LEFT,120,-1);
  147. m_List.InsertColumn(5,"通道号",LVCFMT_LEFT,50,-1);
  148. m_List.InsertColumn(6,"传输模式",LVCFMT_LEFT,70,-1);
  149. m_List.InsertColumn(7,"传输协议",LVCFMT_LEFT,70,-1);
  150. m_iRowNum = 0;
  151. MatRow = this;
  152. UpdateData(FALSE);
  153. return TRUE; // return TRUE unless you set the focus to a control
  154. // EXCEPTION: OCX Property Pages should return FALSE
  155. }
  156. void CMatRow::OnButdecstart()
  157. {
  158. // TODO: Add your control notification handler code here
  159. UpdateData(TRUE);
  160. // NET_DVR_MATRIX_DYNAMIC_DEC stru;
  161. // stru.dwSize = sizeof(NET_DVR_MATRIX_DYNAMIC_DEC);
  162. //
  163. // stru.struDecChanInfo.byChannel = m_ChanCtrl.GetCurSel();
  164. // stru.struDecChanInfo.byTransMode = m_TypeCtrl.GetCurSel();
  165. // stru.struDecChanInfo.byTransProtocol = m_ProtocalCtrl.GetCurSel();
  166. // memcpy(stru.struDecChanInfo.sDVRIP, m_Ip, 16);
  167. // memcpy(stru.struDecChanInfo.sPassword, m_UserPSW, PASSWD_LEN);
  168. // memcpy(stru.struDecChanInfo.sUserName, m_UserName, NAME_LEN);
  169. // stru.struDecChanInfo.wDVRPort = m_Port;
  170. // if (!NET_DVR_MatrixStartDynamic(m_lServerID, m_DecChanCtrl.GetCurSel()+m_lStartChan, &stru))
  171. // {
  172. // CString sTemp;
  173. // sTemp.Format("ERROR: NET_DVR_MatrixStartDynamic = %d \n", NET_DVR_GetLastError());
  174. // TRACE(sTemp);
  175. // // return FALSE;
  176. // }
  177. }
  178. void CMatRow::OnButdecstop()
  179. {
  180. // TODO: Add your control notification handler code here
  181. UpdateData(TRUE);
  182. // if (!NET_DVR_MatrixStopDynamic(m_lServerID, m_DecChanCtrl.GetCurSel()+m_lStartChan))
  183. // {
  184. // CString sTemp;
  185. // sTemp.Format("ERROR: NET_DVR_MatrixStopDynamic = %d \n", NET_DVR_GetLastError());
  186. // TRACE(sTemp);
  187. // // return FALSE;
  188. // }
  189. }
  190. void CMatRow::OnButgetrow()
  191. {
  192. // TODO: Add your control notification handler code here
  193. // m_iRowNum = 0;
  194. // g_lAmount = 0;
  195. // m_List.DeleteAllItems();
  196. // if (!NET_DVR_MatrixGetRowInfo(m_lServerID, fRowDataCallBack, 0))
  197. // {
  198. // CString sTemp;
  199. // sTemp.Format("ERROR: NET_DVR_MatrixGetRowInfo = %d \n", NET_DVR_GetLastError());
  200. // AfxMessageBox(sTemp);
  201. // return;
  202. // }
  203. }
  204. void CMatRow::OnButano()
  205. {
  206. // TODO: Add your control notification handler code here
  207. UpdateData(TRUE);
  208. // NET_DVR_MATRIX_ROW_ELEMENT stru;
  209. // stru.struDecChanInfo.byChannel = m_ChanCtrl.GetCurSel();
  210. // stru.struDecChanInfo.byTransMode = m_TypeCtrl.GetCurSel();
  211. // stru.struDecChanInfo.byTransProtocol = m_ProtocalCtrl.GetCurSel();
  212. // memcpy(stru.sSurvChanName, m_ChanName, 128);
  213. // memcpy(stru.struDecChanInfo.sDVRIP, m_Ip, 16);
  214. // memcpy(stru.struDecChanInfo.sPassword, m_UserPSW, PASSWD_LEN);
  215. // memcpy(stru.struDecChanInfo.sUserName, m_UserName, NAME_LEN);
  216. // stru.struDecChanInfo.wDVRPort = m_Port;
  217. // stru.dwRowNum = m_RowNUM;
  218. // if (!NET_DVR_MatrixAddNoOverlayRowInfo(m_lServerID, 1, &stru))
  219. // {
  220. // CString sTemp;
  221. // sTemp.Format("ERROR: NET_DVR_MatrixAddNoOverlayRowInfo = %d \n", NET_DVR_GetLastError());
  222. // AfxMessageBox(sTemp);
  223. // return;
  224. // }
  225. }
  226. void CMatRow::OnButao()
  227. {
  228. // TODO: Add your control notification handler code here
  229. UpdateData(TRUE);
  230. // NET_DVR_MATRIX_ROW_ELEMENT stru;
  231. // stru.struDecChanInfo.byChannel = m_ChanCtrl.GetCurSel();
  232. // stru.struDecChanInfo.byTransMode = m_TypeCtrl.GetCurSel();
  233. // stru.struDecChanInfo.byTransProtocol = m_ProtocalCtrl.GetCurSel();
  234. // memcpy(stru.sSurvChanName, m_ChanName, 128);
  235. // memcpy(stru.struDecChanInfo.sDVRIP, m_Ip, 16);
  236. // memcpy(stru.struDecChanInfo.sPassword, m_UserPSW, PASSWD_LEN);
  237. // memcpy(stru.struDecChanInfo.sUserName, m_UserName, NAME_LEN);
  238. // stru.struDecChanInfo.wDVRPort = m_Port;
  239. // stru.dwRowNum = m_RowNUM;
  240. // if (!NET_DVR_MatrixAddAndOverlayRowInfo(m_lServerID, 1, &stru))
  241. // {
  242. // CString sTemp;
  243. // sTemp.Format("ERROR: NET_DVR_MatrixAddAndOverlayRowInfo = %d \n", NET_DVR_GetLastError());
  244. // TRACE(sTemp);
  245. // // return FALSE;
  246. // }
  247. }
  248. void CMatRow::OnButexit()
  249. {
  250. // TODO: Add your control notification handler code here
  251. CDialog::OnOK();
  252. }
  253. void CMatRow::OnRclickList1(NMHDR* pNMHDR, LRESULT* pResult)
  254. {
  255. // TODO: Add your control notification handler code here
  256. *pResult = 0;
  257. }
  258. void CMatRow::OnButdel()
  259. {
  260. // TODO: Add your control notification handler code here
  261. // POSITION pos;
  262. // int selpos = 0;
  263. // CString csName;
  264. // NET_DVR_MATRIX_ROW_INDEX stru;
  265. //
  266. // UpdateData(TRUE);
  267. // pos = m_List.GetFirstSelectedItemPosition();
  268. // if(pos == NULL)
  269. // {
  270. // AfxMessageBox("请选择要刪除的行!");
  271. // return;
  272. // }
  273. // selpos = m_List.GetNextSelectedItem(pos);
  274. // //监控通道名称
  275. // csName.Format("%s", m_List.GetItemText(selpos, 1));
  276. // if(csName.IsEmpty())
  277. // return;
  278. // sprintf((char *)(stru.sSurvChanName), "%s", csName);
  279. // //行号
  280. // csName.Format("%s", m_List.GetItemText(selpos, 0));
  281. // stru.dwRowNum = atoi(csName);
  282. //
  283. // if (!NET_DVR_MatrixDelRowInfo(m_lServerID, 1, &stru))
  284. // {
  285. // CString sTemp;
  286. // sTemp.Format("ERROR: NET_DVR_MatrixDelRowInfo = %d \n", NET_DVR_GetLastError());
  287. // TRACE(sTemp);
  288. // // return FALSE;
  289. // }
  290. // else
  291. // {
  292. // m_iRowNum = 0;
  293. // g_lAmount = 0;
  294. // m_List.DeleteAllItems();
  295. // if (!NET_DVR_MatrixGetRowInfo(m_lServerID, fRowDataCallBack, 0))
  296. // {
  297. // CString sTemp;
  298. // sTemp.Format("ERROR: NET_DVR_MatrixGetRowInfo = %d \n", NET_DVR_GetLastError());
  299. // TRACE(sTemp);
  300. // // return FALSE;
  301. // }
  302. // }
  303. }