MatCycLink.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. // MatCycLink.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "StoneU_HC_OCX.h"
  5. #include "MatCycLink.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CMatCycLink dialog
  13. CMatCycLink::CMatCycLink(CWnd* pParent /*=NULL*/)
  14. : CDialog(CMatCycLink::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CMatCycLink)
  17. m_DVRChannel = 0;
  18. m_DVRIP = _T("");
  19. m_DVRPasswd = _T("");
  20. m_DVRPort = 0;
  21. m_DVRUser = _T("");
  22. m_PoolTime = 0;
  23. m_bCheckConnectChan = FALSE;
  24. //}}AFX_DATA_INIT
  25. m_iChanSel = -1;
  26. for (int i=0; i<MAXCHANNUM; i++)
  27. {
  28. m_CycLink[i] = FALSE;
  29. }
  30. }
  31. void CMatCycLink::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CDialog::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(CMatCycLink)
  35. DDX_Control(pDX, IDC_COMBOTRANSTYPE, m_TransModesCombo);
  36. DDX_Control(pDX, IDC_COMBOTRANSMODE, m_TransProtocolCombo);
  37. DDX_Control(pDX, IDC_COMBOSWITCH, m_SwitchCombo);
  38. DDX_Control(pDX, IDC_COMBODECCHAN2, m_DecChanCombo2);
  39. DDX_Control(pDX, IDC_COMBODECCHAN, m_DecChanCombo);
  40. DDX_Control(pDX, IDC_COMBOCONCHAN, m_ConnectChanCombo);
  41. DDX_Text(pDX, IDC_EDITDVRCHAN, m_DVRChannel);
  42. DDX_Text(pDX, IDC_EDITDVRIP, m_DVRIP);
  43. DDX_Text(pDX, IDC_EDITDVRPASSWD, m_DVRPasswd);
  44. DDX_Text(pDX, IDC_EDITDVRPORT, m_DVRPort);
  45. DDX_Text(pDX, IDC_EDITDVRUSER, m_DVRUser);
  46. DDX_Text(pDX, IDC_EDITPOOLTIME, m_PoolTime);
  47. DDX_Check(pDX, IDC_CHECKCONCHAN, m_bCheckConnectChan);
  48. //}}AFX_DATA_MAP
  49. }
  50. BEGIN_MESSAGE_MAP(CMatCycLink, CDialog)
  51. //{{AFX_MSG_MAP(CMatCycLink)
  52. ON_CBN_SELCHANGE(IDC_COMBODECCHAN, OnSelchangeCombodecchan)
  53. ON_CBN_SELCHANGE(IDC_COMBOCONCHAN, OnSelchangeComboconchan)
  54. ON_BN_CLICKED(IDC_SAVEPARA, OnSavepara)
  55. ON_BN_CLICKED(IDC_SETPARAM, OnSetparam)
  56. ON_BN_CLICKED(IDC_SINGLEGET, OnSingleget)
  57. ON_BN_CLICKED(IDC_WHOLEGET, OnWholeget)
  58. ON_BN_CLICKED(IDC_SINGLESET, OnSingleset)
  59. ON_BN_CLICKED(IDC_CHECKCONCHAN, OnCheckconchan)
  60. ON_CBN_SELCHANGE(IDC_COMBODECCHAN2, OnSelchangeCombodecchan2)
  61. //}}AFX_MSG_MAP
  62. END_MESSAGE_MAP()
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CMatCycLink message handlers
  65. BOOL CMatCycLink::OnInitDialog()
  66. {
  67. CDialog::OnInitDialog();
  68. int i = 0;
  69. for (i=0; i<MAXCHANNUM; i++)
  70. {
  71. ZeroMemory(&m_MatLoopDec[i], sizeof(NET_DVR_MATRIX_LOOP_DECINFO));
  72. }
  73. // TODO: Add extra initialization here
  74. DWORD chanNum = 0;
  75. CString tmp;
  76. for (i=0; i<m_iChannelnumber; i++)
  77. {
  78. chanNum = i + m_lStartChan;
  79. tmp.Format("%d", chanNum);
  80. m_DecChanCombo.AddString(tmp);
  81. m_DecChanCombo2.AddString(tmp);
  82. if (!NET_DVR_MatrixGetLoopDecChanInfo(m_lServerID, chanNum, &m_MatLoopDec[i]))
  83. {
  84. TRACE("\nError: NET_DVR_MatrixGetLoopDecChanInfo[%d] = %d\n", i, NET_DVR_GetLastError());
  85. }
  86. for (int j=0; j<MAX_CYCLE_CHAN; j++)
  87. {
  88. TRACE("0x%x ", m_MatLoopDec[i].struchanConInfo[j].dwEnable);
  89. }
  90. TRACE("\n### pool time = %d\n", m_MatLoopDec[i].dwPoolTime);
  91. }
  92. if (!NET_DVR_MatrixGetLoopDecChanEnable(m_lServerID, m_lStartChan, &chanNum))
  93. {
  94. TRACE("\nError: NET_DVR_MatrixGetLoopDecChanEnable = %d\n", NET_DVR_GetLastError());
  95. }
  96. else
  97. {
  98. m_SwitchCombo.SetCurSel(chanNum);
  99. }
  100. m_DecChanCombo.SetCurSel(0);
  101. m_DecChanCombo2.SetCurSel(0);
  102. m_iChanSel = 0;
  103. for (i=0; i<MAX_CYCLE_CHAN; i++)
  104. {
  105. tmp.Format("%d", i);
  106. m_ConnectChanCombo.AddString(tmp);
  107. }
  108. m_ConnectChanCombo.SetCurSel(0);
  109. m_PoolTime = m_MatLoopDec[m_iChanSel].dwPoolTime;
  110. m_bCheckConnectChan = m_MatLoopDec[m_iChanSel].struchanConInfo[0].dwEnable;
  111. if (m_MatLoopDec[m_iChanSel].struchanConInfo[0].dwEnable)
  112. {
  113. m_DVRIP.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.sDVRIP);
  114. m_DVRPort = m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.wDVRPort;
  115. m_DVRUser.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.sUserName);
  116. m_DVRPasswd.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.sPassword);
  117. m_DVRChannel = m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byChannel;
  118. m_TransModesCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byTransMode);
  119. m_TransProtocolCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byTransProtocol);
  120. }
  121. else
  122. {
  123. EnableConChan(FALSE);
  124. }
  125. UpdateData(FALSE);
  126. return TRUE; // return TRUE unless you set the focus to a control
  127. // EXCEPTION: OCX Property Pages should return FALSE
  128. }
  129. void CMatCycLink::EnableConChan(BOOL bEnable)
  130. {
  131. GetDlgItem(IDC_EDITDVRIP)->EnableWindow(bEnable);
  132. GetDlgItem(IDC_EDITDVRPORT)->EnableWindow(bEnable);
  133. GetDlgItem(IDC_EDITDVRCHAN)->EnableWindow(bEnable);
  134. GetDlgItem(IDC_EDITDVRUSER)->EnableWindow(bEnable);
  135. GetDlgItem(IDC_EDITDVRPASSWD)->EnableWindow(bEnable);
  136. GetDlgItem(IDC_COMBOTRANSMODE)->EnableWindow(bEnable);
  137. GetDlgItem(IDC_COMBOTRANSTYPE)->EnableWindow(bEnable);
  138. UpdateData(FALSE);
  139. }
  140. void CMatCycLink::OnSelchangeCombodecchan()
  141. {
  142. // TODO: Add your control notification handler code here
  143. int sel = m_DecChanCombo.GetCurSel();
  144. if (sel == m_iChanSel)
  145. {
  146. return;
  147. }
  148. m_iChanSel = sel;
  149. m_PoolTime = m_MatLoopDec[m_iChanSel].dwPoolTime;
  150. m_ConnectChanCombo.SetCurSel(0);
  151. m_bCheckConnectChan = m_MatLoopDec[m_iChanSel].struchanConInfo[0].dwEnable;
  152. if (m_MatLoopDec[m_iChanSel].struchanConInfo[0].dwEnable)
  153. {
  154. EnableConChan(TRUE);
  155. m_DVRIP.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.sDVRIP);
  156. m_DVRPort = m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.wDVRPort;
  157. m_DVRUser.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.sUserName);
  158. m_DVRPasswd.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.sPassword);
  159. m_DVRChannel = m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byChannel;
  160. m_TransModesCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byTransMode);
  161. m_TransProtocolCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[0].struDecChanInfo.byTransProtocol);
  162. }
  163. else
  164. {
  165. EnableConChan(FALSE);
  166. }
  167. UpdateData(FALSE);
  168. }
  169. void CMatCycLink::OnSelchangeComboconchan()
  170. {
  171. // TODO: Add your control notification handler code here
  172. int sel = m_ConnectChanCombo.GetCurSel();
  173. m_bCheckConnectChan = m_MatLoopDec[m_iChanSel].struchanConInfo[sel].dwEnable;
  174. TRACE("\n### m_bCheckConnectChan = 0x%x\n", m_bCheckConnectChan);
  175. if (m_MatLoopDec[m_iChanSel].struchanConInfo[sel].dwEnable)
  176. {
  177. EnableConChan(TRUE);
  178. m_DVRIP.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sDVRIP);
  179. m_DVRPort = m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.wDVRPort;
  180. m_DVRUser.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sUserName);
  181. m_DVRPasswd.Format("%s", m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sPassword);
  182. m_DVRChannel = m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byChannel;
  183. m_TransModesCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransMode);
  184. m_TransProtocolCombo.SetCurSel(m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransProtocol);
  185. }
  186. else
  187. {
  188. EnableConChan(FALSE);
  189. }
  190. UpdateData(FALSE);
  191. }
  192. void CMatCycLink::OnSavepara()
  193. {
  194. // TODO: Add your control notification handler code here
  195. UpdateData(TRUE);
  196. int sel = m_ConnectChanCombo.GetCurSel();
  197. ZeroMemory(&m_MatLoopDec[m_iChanSel].struchanConInfo[sel], sizeof(m_MatLoopDec[m_iChanSel].struchanConInfo[sel]));
  198. m_MatLoopDec[m_iChanSel].struchanConInfo[sel].dwEnable = m_bCheckConnectChan;
  199. if (m_bCheckConnectChan)
  200. {
  201. m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byChannel = m_DVRChannel;
  202. m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransMode = m_TransModesCombo.GetCurSel();
  203. m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransProtocol = m_TransProtocolCombo.GetCurSel();
  204. m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.wDVRPort = m_DVRPort;
  205. sprintf(m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sDVRIP, "%s", m_DVRIP);
  206. sprintf((char *)m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sUserName, "%s", m_DVRUser);
  207. sprintf((char *)m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sPassword, "%s", m_DVRPasswd);
  208. }
  209. }
  210. void CMatCycLink::OnSetparam()
  211. {
  212. // TODO: Add your control notification handler code here
  213. UpdateData(TRUE);
  214. int sel = m_ConnectChanCombo.GetCurSel();
  215. ZeroMemory(&m_MatLoopDec[m_iChanSel].struchanConInfo[sel], sizeof(m_MatLoopDec[m_iChanSel].struchanConInfo[sel]));
  216. m_MatLoopDec[m_iChanSel].struchanConInfo[sel].dwEnable = m_bCheckConnectChan;
  217. if (m_bCheckConnectChan)
  218. {
  219. m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byChannel = m_DVRChannel;
  220. m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransMode = m_TransModesCombo.GetCurSel();
  221. m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.byTransProtocol = m_TransProtocolCombo.GetCurSel();
  222. m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.wDVRPort = m_DVRPort;
  223. sprintf(m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sDVRIP, "%s", m_DVRIP);
  224. sprintf((char *)m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sUserName, "%s", m_DVRUser);
  225. sprintf((char *)m_MatLoopDec[m_iChanSel].struchanConInfo[sel].struDecChanInfo.sPassword, "%s", m_DVRPasswd);
  226. }
  227. m_MatLoopDec[m_iChanSel].dwPoolTime = m_PoolTime;
  228. BOOL error = FALSE;
  229. for (int i=0; i<m_iChannelnumber; i++)
  230. {
  231. if (!NET_DVR_MatrixSetLoopDecChanInfo(m_lServerID, i+m_lStartChan, &m_MatLoopDec[i]))
  232. {
  233. TRACE("\nError: NET_DVR_MatrixSetLoopDecChanInfo = %d\n", NET_DVR_GetLastError());
  234. error = TRUE;
  235. }
  236. }
  237. if (!error)
  238. {
  239. MessageBox("保存成功!");
  240. }
  241. }
  242. void CMatCycLink::OnSingleget()
  243. {
  244. // TODO: Add your control notification handler code here
  245. UpdateData(TRUE);
  246. int sel = m_DecChanCombo2.GetCurSel();
  247. DWORD flg = 0;
  248. if (!NET_DVR_MatrixGetLoopDecChanEnable(m_lServerID, sel+m_lStartChan, &flg))
  249. {
  250. TRACE("\nError: NET_DVR_MatrixGetLoopDecChanEnable[%d] = %d\n", sel+m_lStartChan, NET_DVR_GetLastError());
  251. return;
  252. }
  253. if (flg)
  254. {
  255. m_CycLink[sel] = TRUE;
  256. }
  257. else
  258. {
  259. m_CycLink[sel] = FALSE;
  260. }
  261. m_SwitchCombo.SetCurSel(m_CycLink[sel]);
  262. UpdateData(FALSE);
  263. MessageBox("获取成功!");
  264. }
  265. void CMatCycLink::OnWholeget()
  266. {
  267. // TODO: Add your control notification handler code here
  268. UpdateData(TRUE);
  269. int sel = m_DecChanCombo2.GetCurSel();
  270. DWORD flg = 0;
  271. if (!NET_DVR_MatrixGetLoopDecEnable(m_lServerID, &flg))
  272. {
  273. TRACE("\nError: NET_DVR_MatrixGetLoopDecEnable = %d\n", NET_DVR_GetLastError());
  274. return;
  275. }
  276. TRACE("\n### 0x%x\n", flg);
  277. for (int i=0; i<m_iChannelnumber; i++)
  278. {
  279. if (flg&0x1)
  280. {
  281. m_CycLink[i] = TRUE;
  282. }
  283. else
  284. {
  285. m_CycLink[i] = FALSE;
  286. }
  287. flg = flg>>1;
  288. TRACE("\n### %d\n", m_CycLink[i]);
  289. }
  290. m_SwitchCombo.SetCurSel(m_CycLink[sel]);
  291. UpdateData(FALSE);
  292. MessageBox("获取成功!");
  293. }
  294. void CMatCycLink::OnSingleset()
  295. {
  296. // TODO: Add your control notification handler code here
  297. UpdateData(TRUE);
  298. int sel = m_DecChanCombo2.GetCurSel();
  299. BOOL flg = FALSE;
  300. if (m_SwitchCombo.GetCurSel())
  301. {
  302. flg = TRUE;
  303. }
  304. if (!NET_DVR_MatrixSetLoopDecChanEnable(m_lServerID, sel+m_lStartChan, flg))
  305. {
  306. TRACE("\nError: NET_DVR_MatrixSetLoopDecChanEnable[%d] = %d\n", sel+m_lStartChan, NET_DVR_GetLastError());
  307. return;
  308. }
  309. MessageBox("设置成功!");
  310. }
  311. void CMatCycLink::OnCheckconchan()
  312. {
  313. // TODO: Add your control notification handler code here
  314. UpdateData(TRUE);
  315. EnableConChan(m_bCheckConnectChan);
  316. }
  317. void CMatCycLink::OnSelchangeCombodecchan2()
  318. {
  319. // TODO: Add your control notification handler code here
  320. int sel = m_DecChanCombo2.GetCurSel();
  321. m_SwitchCombo.SetCurSel(m_CycLink[sel]);
  322. UpdateData(FALSE);
  323. }