ExceptionCFG.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // ExceptionCFG.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "StoneU_HC_OCX.h"
  5. #include "ExceptionCFG.h"
  6. #include "RemoteParamsCfg.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CExceptionCFG dialog
  14. extern CRemoteParamsCfg *m_pRemoteParam;
  15. CExceptionCFG::CExceptionCFG(CWnd* pParent /*=NULL*/)
  16. : CDialog(CExceptionCFG::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(CExceptionCFG)
  19. m_bHandleType1 = FALSE;
  20. m_bHandleType2 = FALSE;
  21. m_bHandleType3 = FALSE;
  22. m_bHandleType4 = FALSE;
  23. m_bAlarmOut1 = FALSE;
  24. m_bAlarmOut2 = FALSE;
  25. m_bAlarmOut3 = FALSE;
  26. m_bAlarmOut4 = FALSE;
  27. //}}AFX_DATA_INIT
  28. }
  29. void CExceptionCFG::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CDialog::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(CExceptionCFG)
  33. DDX_Control(pDX, IDC_COMEXCEPTION, m_ExceptionCtrl);
  34. DDX_Check(pDX, IDC_CHECKHANDLETYPE1, m_bHandleType1);
  35. DDX_Check(pDX, IDC_CHECKHANDLETYPE2, m_bHandleType2);
  36. DDX_Check(pDX, IDC_CHECKHANDLETYPE3, m_bHandleType3);
  37. DDX_Check(pDX, IDC_CHECKHANDLETYPE4, m_bHandleType4);
  38. DDX_Check(pDX, IDC_CHKALARMOUT1, m_bAlarmOut1);
  39. DDX_Check(pDX, IDC_CHKALARMOUT2, m_bAlarmOut2);
  40. DDX_Check(pDX, IDC_CHKALARMOUT3, m_bAlarmOut3);
  41. DDX_Check(pDX, IDC_CHKALARMOUT4, m_bAlarmOut4);
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(CExceptionCFG, CDialog)
  45. //{{AFX_MSG_MAP(CExceptionCFG)
  46. ON_BN_CLICKED(IDC_BUTOK, OnButok)
  47. ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
  48. ON_BN_CLICKED(IDC_CHECKHANDLETYPE4, OnCheckhandletype4)
  49. ON_CBN_SELCHANGE(IDC_COMEXCEPTION, OnSelchangeComexception)
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CExceptionCFG message handlers
  54. BOOL CExceptionCFG::CheckPara()
  55. {
  56. DWORD dwReturned;
  57. CString sTemp;
  58. m_SelType = 0;
  59. m_ExceptionCtrl.SetCurSel(m_SelType);
  60. if (m_bConnectServer)
  61. {
  62. if (!NET_DVR_GetDVRConfig(m_lServerID, NET_DVR_GET_EXCEPTIONCFG, 0,&m_ExceptionInfo, sizeof(NET_DVR_EXCEPTION), &dwReturned))
  63. {
  64. sTemp.Format("ERROR: NET_DVR_GET_EXCEPTIONCFG = %d \n", NET_DVR_GetLastError());
  65. MessageBox(sTemp, "ÎÂܰÌáʾ", MB_ICONINFORMATION);
  66. }
  67. else
  68. {
  69. m_bHandleType1 = m_ExceptionInfo.struExceptionHandleType[m_SelType].dwHandleType &0x01;
  70. m_bHandleType2 = (m_ExceptionInfo.struExceptionHandleType[m_SelType].dwHandleType>>1)&0x01;
  71. m_bHandleType3 = (m_ExceptionInfo.struExceptionHandleType[m_SelType].dwHandleType>>2)&0x01;
  72. m_bHandleType4 = (m_ExceptionInfo.struExceptionHandleType[m_SelType].dwHandleType>>3)&0x01;
  73. EnableControl(m_bHandleType4);
  74. }
  75. }
  76. UpdateData(FALSE);
  77. return TRUE;
  78. }
  79. BOOL CExceptionCFG::OnInitDialog()
  80. {
  81. CDialog::OnInitDialog();
  82. // TODO: Add extra initialization here
  83. CRect rc(0, 0, 0, 0);
  84. GetParent()->GetClientRect(&rc);
  85. ((CTabCtrl*)GetParent())->AdjustRect(FALSE, &rc);
  86. MoveWindow(&rc);
  87. if(m_pRemoteParam->m_dvrSelect != -1)
  88. CheckPara();
  89. return TRUE; // return TRUE unless you set the focus to a control
  90. // EXCEPTION: OCX Property Pages should return FALSE
  91. }
  92. void CExceptionCFG::OnCancel()
  93. {
  94. // TODO: Add extra cleanup here
  95. // CDialog::OnCancel();
  96. }
  97. void CExceptionCFG::OnOK()
  98. {
  99. // TODO: Add extra validation here
  100. // CDialog::OnOK();
  101. }
  102. void CExceptionCFG::OnButok()
  103. {
  104. if(m_pRemoteParam->m_dvrSelect == -1)
  105. return;
  106. // TODO: Add your control notification handler code here
  107. UpdateData(TRUE);
  108. m_SelType = m_ExceptionCtrl.GetCurSel();
  109. m_ExceptionInfo.struExceptionHandleType[m_SelType].dwHandleType = 0;
  110. m_ExceptionInfo.struExceptionHandleType[m_SelType].dwHandleType |= (m_bHandleType1 << 0);
  111. m_ExceptionInfo.struExceptionHandleType[m_SelType].dwHandleType |= (m_bHandleType2 << 1);
  112. m_ExceptionInfo.struExceptionHandleType[m_SelType].dwHandleType |= (m_bHandleType3 << 2);
  113. m_ExceptionInfo.struExceptionHandleType[m_SelType].dwHandleType |= (m_bHandleType4 << 3);
  114. m_ExceptionInfo.struExceptionHandleType[m_SelType].byRelAlarmOut[0] = m_bAlarmOut1;
  115. m_ExceptionInfo.struExceptionHandleType[m_SelType].byRelAlarmOut[1] = m_bAlarmOut2;
  116. m_ExceptionInfo.struExceptionHandleType[m_SelType].byRelAlarmOut[2] = m_bAlarmOut3;
  117. m_ExceptionInfo.struExceptionHandleType[m_SelType].byRelAlarmOut[3] = m_bAlarmOut4;
  118. m_bSetPara = TRUE;
  119. }
  120. void CExceptionCFG::OnButexit()
  121. {
  122. // TODO: Add your control notification handler code here
  123. m_bSetPara = FALSE;
  124. }
  125. void CExceptionCFG::OnCheckhandletype4()
  126. {
  127. // TODO: Add your control notification handler code here
  128. UpdateData(TRUE);
  129. EnableControl(m_bHandleType4);
  130. }
  131. void CExceptionCFG::OnSelchangeComexception()
  132. {
  133. if(m_pRemoteParam->m_dvrSelect == -1)
  134. return;
  135. // TODO: Add your control notification handler code here
  136. UpdateData(TRUE);
  137. m_SelType = m_ExceptionCtrl.GetCurSel();
  138. m_bHandleType1 = m_ExceptionInfo.struExceptionHandleType[m_SelType].dwHandleType &0x01;
  139. m_bHandleType2 = (m_ExceptionInfo.struExceptionHandleType[m_SelType].dwHandleType>>1)&0x01;
  140. m_bHandleType3 = (m_ExceptionInfo.struExceptionHandleType[m_SelType].dwHandleType>>2)&0x01;
  141. m_bHandleType4 = (m_ExceptionInfo.struExceptionHandleType[m_SelType].dwHandleType>>3)&0x01;
  142. EnableControl(m_bHandleType4);
  143. UpdateData(FALSE);
  144. }
  145. void CExceptionCFG::EnableControl(BOOL bEnable)
  146. {
  147. if (m_dwAlarmOutNum >= 1)
  148. {
  149. GetDlgItem(IDC_CHKALARMOUT1)->EnableWindow(bEnable);
  150. m_bAlarmOut1 = m_ExceptionInfo.struExceptionHandleType[m_SelType].byRelAlarmOut[0];
  151. }
  152. if (m_dwAlarmOutNum >= 2)
  153. {
  154. GetDlgItem(IDC_CHKALARMOUT2)->EnableWindow(bEnable);
  155. m_bAlarmOut2 = m_ExceptionInfo.struExceptionHandleType[m_SelType].byRelAlarmOut[1];
  156. }
  157. if (m_dwAlarmOutNum >= 3)
  158. {
  159. GetDlgItem(IDC_CHKALARMOUT3)->EnableWindow(bEnable);
  160. m_bAlarmOut3 = m_ExceptionInfo.struExceptionHandleType[m_SelType].byRelAlarmOut[2];
  161. }
  162. if (m_dwAlarmOutNum >= 4)
  163. {
  164. GetDlgItem(IDC_CHKALARMOUT4)->EnableWindow(bEnable);
  165. m_bAlarmOut4 = m_ExceptionInfo.struExceptionHandleType[m_SelType].byRelAlarmOut[3];
  166. }
  167. }