Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2313 lines
70 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 12/11/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: ChicagoDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of ChicagoDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // ChicagoDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "Chicago.h"
  18. #include "ChicagoDlg.h"
  19. #include "..\DLIB\AuxLib.h"
  20. #include "..\DLIB\EventQueue.h"
  21. #include "..\DLIB\SocketBackup.h"
  22. #include "..\..\LgLib\Version.h"
  23. #include "..\..\LgLib\MaskSchedule\LgMaskScheduleDlg.h"
  24. #include "..\DLIB\ObjectFactory.h"
  25. #include "EnableDlg.h"
  26. #include "StatisticDlg.h"
  27. #include "ViewOptionsDlg.h"
  28. #include "ProgramModeDlg.h"
  29. #include "DateTimeDlg.h"
  30. #include "VideoSettingsDlg.h"
  31. #include "SetupDlg.h"
  32. #include "SettingsDlg.h"
  33. #include "PhoneDlg.h"
  34. #include "RepairDlg.h"
  35. #ifdef _DEBUG
  36. #define new DEBUG_NEW
  37. #undef THIS_FILE
  38. static char THIS_FILE[] = __FILE__;
  39. #endif
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CAboutDlg dialog used for App About
  42. class CAboutDlg : public CDialog
  43. {
  44. public:
  45. CAboutDlg();
  46. // Dialog Data
  47. //{{AFX_DATA(CAboutDlg)
  48. enum { IDD = IDD_ABOUTBOX };
  49. CStatic m_BuildTime;
  50. //}}AFX_DATA
  51. // ClassWizard generated virtual function overrides
  52. //{{AFX_VIRTUAL(CAboutDlg)
  53. protected:
  54. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  55. //}}AFX_VIRTUAL
  56. // Implementation
  57. protected:
  58. //{{AFX_MSG(CAboutDlg)
  59. virtual BOOL OnInitDialog();
  60. //}}AFX_MSG
  61. DECLARE_MESSAGE_MAP()
  62. };
  63. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  64. {
  65. //{{AFX_DATA_INIT(CAboutDlg)
  66. //}}AFX_DATA_INIT
  67. }
  68. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  69. {
  70. CDialog::DoDataExchange(pDX);
  71. //{{AFX_DATA_MAP(CAboutDlg)
  72. DDX_Control(pDX, IDC_STATIC_BUILD_TIME, m_BuildTime);
  73. //}}AFX_DATA_MAP
  74. }
  75. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  76. //{{AFX_MSG_MAP(CAboutDlg)
  77. //}}AFX_MSG_MAP
  78. END_MESSAGE_MAP()
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CChicagoDlg dialog
  81. CChicagoDlg::CChicagoDlg(CWnd* pParent /*=NULL*/)
  82. : CDialog(CChicagoDlg::IDD, pParent)
  83. {
  84. //{{AFX_DATA_INIT(CChicagoDlg)
  85. // NOTE: the ClassWizard will add member initialization here
  86. //}}AFX_DATA_INIT
  87. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  88. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  89. // m_pSensorEvent = NULL;
  90. m_pAutorizationDlg = NULL;
  91. // ::ZeroMemory( &m_Print, sizeof(m_Print) );
  92. // m_ScaleFactor = 1;
  93. m_pSensorCurrent = NULL;
  94. m_bStarted = FALSE;
  95. m_bWaitDisconnect = FALSE;
  96. m_bWaitConnect = FALSE;
  97. // m_Print.bDlg = FALSE;
  98. m_nViewMode = VIEW_NONE;
  99. m_bSoundEnabled = TRUE;
  100. m_pVideoFrameWnd = NULL;
  101. m_pVideoFrameWnd = NULL;
  102. m_pVideoBase = NULL;
  103. m_pVideoListWnd = NULL;
  104. m_pWholeAreaWnd = NULL;
  105. m_pZoomAreaWnd = NULL;
  106. m_pTroubleListWnd = NULL;
  107. m_pCameraNavigateDlg = NULL;
  108. for( int i = 0; i < CONTROL_COUNT; i++ )
  109. {
  110. m_pControlPanel[ i ] = NULL;
  111. }
  112. m_bDebugMode = FALSE;
  113. m_pVideoWnd = NULL;
  114. m_pReport = NULL;
  115. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CChicagoDlg::CChicagoDlg") );
  116. }
  117. void CChicagoDlg::DoDataExchange(CDataExchange* pDX)
  118. {
  119. CDialog::DoDataExchange(pDX);
  120. //{{AFX_DATA_MAP(CChicagoDlg)
  121. // NOTE: the ClassWizard will add DDX and DDV calls here
  122. //}}AFX_DATA_MAP
  123. }
  124. BEGIN_MESSAGE_MAP(CChicagoDlg, CDialog)
  125. //{{AFX_MSG_MAP(CChicagoDlg)
  126. ON_WM_SYSCOMMAND()
  127. ON_WM_PAINT()
  128. ON_WM_QUERYDRAGICON()
  129. ON_WM_NCLBUTTONDOWN()
  130. ON_WM_NCLBUTTONDBLCLK()
  131. ON_COMMAND(IDM_VIEW_MAIN, OnViewMain)
  132. ON_COMMAND(IDM_VIEW_DETAIL, OnViewAlarm)
  133. ON_WM_INITMENU()
  134. ON_WM_TIMER()
  135. ON_COMMAND(IDM_SYSTEM_RESET, OnSystemReset)
  136. ON_COMMAND(IDM_SYSTEM_ENABLE, OnSystemEnable)
  137. ON_COMMAND( IDM_SUPPORT_REPORT, OnSupportReport )
  138. ON_COMMAND(IDM_SUPPORT_STATISTIC, OnSupportStatistic)
  139. ON_COMMAND(IDM_VIEW_OPTIONS, OnViewOptions)
  140. ON_COMMAND(IDM_SUPPORT_SOUND, OnSupportSound)
  141. ON_COMMAND(IDM_SUPPORT_DATETIME, OnSupportDatetime)
  142. ON_COMMAND(IDM_SUPPORT_MUTE, OnSupportMute)
  143. ON_COMMAND(IDM_SUPPORT_GUARD, OnSupportGuard)
  144. ON_WM_HELPINFO()
  145. ON_COMMAND(IDM_HELP_ABOUT, OnHelpAbout)
  146. ON_COMMAND(IDM_SUPPORT_INTERFACE_FLY, OnSupportInterfaceFly)
  147. ON_COMMAND(IDM_SUPPORT_INTERFACE_FIX, OnSupportInterfaceFix)
  148. ON_COMMAND(IDM_SUPPORT_LGS_RESET, OnSupportLgsReset)
  149. ON_COMMAND(IDM_SUPPORT_INTERFACE_DEFAULT, OnSupportInterfaceDefault)
  150. ON_COMMAND(IDM_SUPPORT_VIDEO_SETTINGS, OnSupportVideoSettings)
  151. ON_COMMAND(ID_SUPPORT_SETTINGS, OnSupportSettings)
  152. ON_COMMAND(ID_SUPPORT_REPORTSETTINGS, OnSupportReportSettings)
  153. ON_COMMAND(ID_SUPPORT_PHONECALLLIST, OnSupportPhonecalllist)
  154. ON_COMMAND(ID_VIEW_EVENTS, OnViewEvents)
  155. ON_COMMAND(ID_VIEW_MAGNIFIEDMAP, OnViewMagnifiedmap)
  156. ON_COMMAND(ID_VIEW_MAP, OnViewMap)
  157. ON_COMMAND(ID_VIEW_PTZCONTROL, OnViewPtzcontrol)
  158. ON_COMMAND(ID_VIEW_SENSORPROPERTIES, OnViewSensorproperties)
  159. ON_COMMAND(ID_VIEW_TROUBLES, OnViewTroubles)
  160. ON_COMMAND(ID_VIEW_VIDEO, OnViewVideo)
  161. ON_COMMAND(ID_VIEW_VIDEOLIST, OnViewVideolist)
  162. ON_COMMAND(ID_VIEW_TOOLBAR, OnViewToolbar)
  163. ON_WM_DESTROY()
  164. ON_MESSAGE( WM_SENSOR_SHOW, OnWMSensorShow )
  165. ON_MESSAGE( WM_SENSOR_UPDATE, OnWMSensorUpdate )
  166. ON_MESSAGE( WM_ENABLE_SENSOR, OnWMEnableSensor )
  167. ON_MESSAGE( WM_ENABLE_ZONE, OnWMEnableZone )
  168. ON_MESSAGE( WM_ENABLE_DTRBIT, OnWMEnableDTRBit )
  169. // ON_MESSAGE( WM_PRINT_FILE, OnWMPrintFile )
  170. ON_MESSAGE( WM_SHOW_TROUBLE, OnWMShowTrouble )
  171. ON_MESSAGE( WM_AUTORIZATION, OnWMAutorization )
  172. ON_MESSAGE( WM_AUTORIZATION, OnWMAutorization )
  173. ON_MESSAGE( WM_POWERBROADCAST, OnWMPowerBroadcast )
  174. ON_COMMAND(IDM_SYSTEM_EXIT, OnCancel)
  175. ON_COMMAND(ID_SUPPORT_LGSHZSCHEDULE, OnSupportLgsHzSchedule)
  176. ON_COMMAND(IDM_SYSTEM_REPAIR, OnSystemRepair)
  177. //}}AFX_MSG_MAP
  178. END_MESSAGE_MAP()
  179. BOOL CChicagoDlg::OnInitDialog()
  180. {
  181. CDialog::OnInitDialog();
  182. CWinApp *pApp = AfxGetApp();
  183. ASSERT( pApp );
  184. LPCTSTR pCmdLine = pApp->m_lpCmdLine;
  185. m_bDebugMode = (_tcsstr( pCmdLine, _T("DEBUG") ) != NULL) || (_tcsstr( pCmdLine, _T("debug") ) != NULL);
  186. m_bDemoMode = (_tcsstr( pCmdLine, _T("DEMO") ) != NULL) || (_tcsstr( pCmdLine, _T("demo") ) != NULL);
  187. // select best program mode
  188. DEVMODE DevMode, DevModeBest;
  189. memset( &DevMode, 0, sizeof(DevMode) );
  190. DevMode.dmSize = sizeof(DevMode);
  191. DevMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
  192. DevModeBest = DevMode;
  193. if( ::EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &DevModeBest ) )
  194. {
  195. BOOL bBestModePresent = FALSE;
  196. switch( DevModeBest.dmBitsPerPel )
  197. {
  198. case 8:
  199. case 15:
  200. case 16:
  201. case 32:
  202. bBestModePresent = TRUE;
  203. break;
  204. }
  205. if( !bBestModePresent )
  206. {
  207. BOOL bBestModeFound = FALSE;
  208. for( INT nDisplayMode = 0; ; nDisplayMode++ )
  209. {
  210. if( !::EnumDisplaySettings( NULL, nDisplayMode, &DevMode ) )
  211. break;
  212. switch( DevMode.dmBitsPerPel )
  213. {
  214. case 8:
  215. case 15:
  216. case 16:
  217. case 32:
  218. if( ( DevModeBest.dmBitsPerPel < DevMode.dmBitsPerPel ||
  219. DevModeBest.dmDisplayFrequency < DevMode.dmDisplayFrequency ) &&
  220. DevModeBest.dmPelsWidth == DevMode.dmPelsWidth &&
  221. DevModeBest.dmPelsHeight == DevMode.dmPelsHeight )
  222. {
  223. DevModeBest = DevMode;
  224. bBestModeFound = TRUE;
  225. }
  226. break;
  227. }
  228. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CApplication::OnCreate"), _T("Found display mode %dx%dx%dx%d"), DevMode.dmPelsWidth, DevMode.dmPelsHeight, DevMode.dmBitsPerPel, DevMode.dmDisplayFrequency );
  229. }
  230. if( bBestModeFound )
  231. ::ChangeDisplaySettings( &DevModeBest, 0 );
  232. }
  233. }
  234. SetIcon(m_hIcon, TRUE);
  235. SetIcon(m_hIcon, FALSE);
  236. srand( ::GetTickCount() );
  237. CString strSetupFileName = _T("setup.lgs");
  238. if( m_bDebugMode )
  239. {
  240. CSetupDlg SetupDlg;
  241. if( SetupDlg.DoModal() != IDOK )
  242. {
  243. EndDialog( IDOK );
  244. return TRUE;
  245. }
  246. strSetupFileName = SetupDlg.GetSetupName();
  247. }
  248. m_hAccelerators = ::LoadAccelerators( AfxGetInstanceHandle(), (LPCTSTR)IDR_ACCELERATORS );
  249. m_TaskSwitch.Lock();
  250. m_Settings.Create( _T("LaserGuard\\ISSC") );
  251. LoadControlSettings();
  252. m_nRunningMode = MODE_HOST;
  253. m_pMainMenu = new CMenu; //+++
  254. switch( m_nRunningMode )
  255. {
  256. case MODE_HOST:
  257. m_pMainMenu->LoadMenu( IDR_MENU_HOST );
  258. SetMenu( m_pMainMenu );
  259. break;
  260. case MODE_MOBILEMAP:
  261. m_pMainMenu->LoadMenu( IDR_MENU_MOBILEMAP );
  262. SetWindowLong( GetSafeHwnd(), GWL_STYLE, GetWindowLong( GetSafeHwnd(), GWL_STYLE ) ^ WS_CAPTION );
  263. break;
  264. case MODE_BACKUP:
  265. m_pMainMenu->LoadMenu( IDR_MENU_HOST );
  266. SetMenu( m_pMainMenu );
  267. break;
  268. }
  269. LOGFONT lf;
  270. lf.lfHeight = -10;
  271. lf.lfWidth = 0;
  272. lf.lfEscapement = 0;
  273. lf.lfOrientation = 0;
  274. lf.lfWeight = 1000;
  275. lf.lfItalic = FALSE;
  276. lf.lfUnderline = FALSE;
  277. lf.lfStrikeOut = FALSE;
  278. lf.lfCharSet = OEM_CHARSET;
  279. lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
  280. lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
  281. lf.lfQuality = DEFAULT_QUALITY;
  282. lf.lfPitchAndFamily = FIXED_PITCH|FF_MODERN;
  283. strcpy( lf.lfFaceName, "Courier" );
  284. m_pFont = new CFont();
  285. m_pFont->CreateFontIndirect( &lf );
  286. SetFont( m_pFont );
  287. m_pAlarm = new CLgAlarm();
  288. m_pAlarm->Create( _T("ISSC.wav") );
  289. #ifdef _DEBUG
  290. m_pAlarm->Enable( TRUE );
  291. #else
  292. m_pAlarm->Enable( TRUE );
  293. #endif
  294. m_pEventQueue = new CEventQueue();
  295. m_pSensorArray = new CSensorArray();
  296. m_pSensorArray->SetEventQueue( m_pEventQueue );
  297. m_pSensorArray->SetEventWnd( GetSafeHwnd() );
  298. m_pSensorArray->SetDebugMode( m_bDebugMode );
  299. if( !m_pSensorArray->Load( strSetupFileName, m_nRunningMode, &m_Settings, m_bDemoMode ) )
  300. {
  301. MessageBox( "Error loading configuration" );
  302. CDialog::OnCancel();
  303. return FALSE;
  304. }
  305. m_pReport = new CReport();
  306. m_pReport->SetSensorArray( m_pSensorArray );
  307. m_pReport->Create( _T("\\REPORT"), m_pSensorArray->GetProgramSettings().nReportDays );
  308. // create external alarm
  309. m_AlarmExternal.Create( m_pSensorArray->GetProgramSettings() );
  310. CRect rectClient;
  311. GetClientRect( &rectClient );
  312. m_pPropertySensorDlg = new CPropertySensorFrameWnd();
  313. m_pPropertySensorDlg->Create( this, 0,0, 1,1 );
  314. m_pEventWnd = new CEventWnd();
  315. m_pEventWnd->SetSensorArray( m_pSensorArray );
  316. m_pEventWnd->Create( NULL, NULL, WS_CHILD, rectClient, this, 0UL );
  317. m_ResetDlg.SetSensorArray( m_pSensorArray );
  318. m_ResetLgsDlg.SetSensorArray( m_pSensorArray );
  319. m_pStatisticDlg = new CStatisticDlg( this );
  320. m_pStatisticDlg->SetSensorArray( m_pSensorArray );
  321. m_pPatrolDlg = new CPatrolDlg; /*+++*/
  322. m_pPatrolDlg->SetSensorArray( m_pSensorArray );
  323. m_pToolBarDlg = new CToolBarDlg; /*+++*/
  324. m_pToolBarDlg->Create( IDD_TOOLBAR_DLG, this, m_pMainMenu );
  325. switch( m_nRunningMode )
  326. {
  327. case MODE_HOST:
  328. m_pToolBarDlg->SetModeText( "HOST" );
  329. break;
  330. case MODE_MOBILEMAP:
  331. m_pToolBarDlg->SetModeText( "" );
  332. break;
  333. case MODE_BACKUP:
  334. m_pToolBarDlg->SetModeText( "BACKUP" );
  335. break;
  336. }
  337. m_pSoundDlg = new CSoundDlg; /*+++*/
  338. m_pSoundDlg->SetSensorArray( m_pSensorArray );
  339. m_pGuardDlg = new CGuardDlg; /*+++*/
  340. m_pGuardDlg->SetSensorArray( m_pSensorArray );
  341. m_pVideoCapture = new CVideoCapture();
  342. m_pVideoCapture->SetSensorArray( m_pSensorArray );
  343. m_pVideoCapture->SetReport( m_pReport );
  344. m_pAutorizationDlg = new CAutorizationDlg( this );
  345. m_pAutorizationDlg->SetSensorArray( m_pSensorArray );
  346. m_pAutorizationDlg->Enable( m_pSensorArray->GetOptions().bNeedAutorization );
  347. m_pVideoBase = new CVideoBase;
  348. m_pVideoBase->SetSensorArray( m_pSensorArray );
  349. if( !m_pVideoBase->Create( this, &m_Settings ) )
  350. MessageBox( "Not enough video capturing boards for this configuration.\nProgram will work incorrectly!" );
  351. m_pVideoFrameWnd = new CVideoFrameWnd;
  352. m_pVideoFrameWnd->Create( this, 0, 0, 120, 120 );
  353. m_pVideoListWnd = new CVideoListWnd;
  354. m_pVideoListWnd->Create( this, -100, -100, 10, 10 );
  355. // attach video windows to main window and to list window
  356. for( int i = 0; i < m_pVideoBase->GetVideoWndCount(); i++ )
  357. {
  358. if( i == 0 ) m_pVideoFrameWnd->SetVideoWnd( m_pVideoBase->GetVideoWnd(i) );
  359. else m_pVideoListWnd->Add( m_pVideoBase->GetVideoWnd(i) );
  360. }
  361. m_pWholeAreaWnd = new CWholeAreaWnd();
  362. m_pWholeAreaWnd->Create( this, m_pSensorArray->GetBackground(), 0,0,10,10 );
  363. m_pWholeAreaWnd->ShowWindow( SW_SHOW );
  364. m_pZoomAreaWnd = new CLgUIMapZoomWnd();
  365. m_pZoomAreaWnd->Create( this, m_pSensorArray->GetBackground(), 0,0,10,10 );
  366. m_pZoomAreaWnd->SetScale( 3 );
  367. m_pZoomAreaWnd->ShowWindow( SW_SHOW );
  368. m_pZoomAreaWnd->CLgLinkS<CLgUIMapZoomWnd,CLgUIMapWholeWnd>::Link( m_pWholeAreaWnd );
  369. {
  370. // register objects in map
  371. for( INT i = 0; i < m_pSensorArray->GetSensorCount(); i++ )
  372. m_pZoomAreaWnd->Link( m_pSensorArray->GetSensor(i) );
  373. }
  374. m_pTroubleListWnd = new CTroubleListWnd();
  375. m_pTroubleListWnd->Create( this, 0, 0, 10, 10, m_pSensorArray->GetBackground() );
  376. m_pTroubleListWnd->SetSensorArray( m_pSensorArray );
  377. m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ] = new CPanelWnd();
  378. m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->Create( this, 0, 0, 10, 10 );
  379. m_pCameraNavigateDlg = new CCameraNavigateDlg();
  380. m_pCameraNavigateDlg->Create( m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ], 0, 0, 10, 10 );
  381. m_pCameraNavigateDlg->SetVideoBase( m_pVideoBase );
  382. m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->PlaceChildCenter( m_pCameraNavigateDlg );
  383. m_pCameraNavigateDlg->SetFocus();
  384. m_pCameraNavigateDlg->SetSensorArray( m_pSensorArray );
  385. m_pCameraNavigateDlg->SetVideoSource( (CVideoCaptureWnd*)m_pVideoFrameWnd->GetVideoWnd() );
  386. m_pVideoBase->SetVideoFrameWnd( m_pVideoFrameWnd );
  387. m_pVideoBase->SetVideoListWnd( m_pVideoListWnd );
  388. m_pVideoBase->SetCameraNavigateDlg( m_pCameraNavigateDlg );
  389. m_pVideoBase->Initialize();
  390. SetWindowPos( &CWnd::wndTop, 0, 0, GetSystemMetrics( SM_CXSCREEN ), GetSystemMetrics( SM_CYSCREEN ), 0 );
  391. Reposition(VIEW_MAIN);
  392. OnSupportInterfaceFix();
  393. m_pMaskSchedule = new CMaskSchedule();
  394. m_pMaskSchedule->Create( this );
  395. m_bTimerOdd = FALSE;
  396. SetTimer( 2, 2000, NULL ); // start timer
  397. m_pSensorArray->CommandLoop( m_nRunningMode );
  398. m_bStarted = TRUE;
  399. // draw copyright
  400. CheckCopyright();
  401. // log info
  402. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnInitDialog", "Done successefully" );
  403. return FALSE;
  404. }
  405. void CChicagoDlg::OnSysCommand(UINT nID, LPARAM lParam)
  406. {
  407. /* if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  408. {
  409. CAboutDlg dlgAbout;
  410. dlgAbout.DoModal();
  411. }
  412. else
  413. */ {
  414. CDialog::OnSysCommand(nID, lParam);
  415. }
  416. }
  417. // If you add a minimize button to your dialog, you will need the code below
  418. // to draw the icon. For MFC applications using the document/view model,
  419. // this is automatically done for you by the framework.
  420. void CChicagoDlg::OnPaint()
  421. {
  422. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CChicagoDlg::OnPaint"), _T("Started...") );
  423. if (IsIconic())
  424. {
  425. CPaintDC dc(this); // device context for painting
  426. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  427. // Center icon in client rectangle
  428. int cxIcon = GetSystemMetrics(SM_CXICON);
  429. int cyIcon = GetSystemMetrics(SM_CYICON);
  430. CRect rect;
  431. GetClientRect(&rect);
  432. int x = (rect.Width() - cxIcon + 1) / 2;
  433. int y = (rect.Height() - cyIcon + 1) / 2;
  434. // Draw the icon
  435. dc.DrawIcon(x, y, m_hIcon);
  436. }
  437. else
  438. {
  439. CDialog::OnPaint();
  440. }
  441. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CChicagoDlg::OnPaint"), _T("Done") );
  442. }
  443. // The system calls this to obtain the cursor to display while the user drags
  444. // the minimized window.
  445. HCURSOR CChicagoDlg::OnQueryDragIcon()
  446. {
  447. return (HCURSOR) m_hIcon;
  448. }
  449. LRESULT CChicagoDlg::OnWMSensorShow( WPARAM wParam, LPARAM lParam )
  450. {
  451. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnWMSensorShow", "begin..." );
  452. CSensor *pSensor = (CSensor*)wParam;
  453. if( pSensor )
  454. {
  455. m_pPropertySensorDlg->SetSensor( pSensor );
  456. if( m_pWholeAreaWnd->SetActiveObject( pSensor ) )
  457. // if( m_pWholeAreaWnd->SetActiveSensor( pSensor ) )
  458. {
  459. CLgDPoint dp( pSensor->GetPosition().x, pSensor->GetPosition().y );
  460. m_pZoomAreaWnd->SetCenter( &dp );
  461. }
  462. // sould be rewritten for multiplexors !!!!
  463. CVideoCamera *pCamera = pSensor->GetVideoCamera();
  464. if( pCamera )
  465. {
  466. CVideoCaptureSource *pVideoCaptureSource = pCamera->GetVideoCaptureSource();
  467. if( pVideoCaptureSource )
  468. {
  469. m_pVideoBase->SetControlledVideo( (CVideoCaptureWnd*)pVideoCaptureSource );
  470. }
  471. else
  472. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnWMSensorShow", "camera %p has no video capture source", pCamera );
  473. }
  474. else
  475. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnWMSensorShow", "sensor %p has no connected camera", pSensor );
  476. }
  477. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnWMSensorShow", "end" );
  478. return 0UL;
  479. }
  480. LRESULT CChicagoDlg::OnWMSensorUpdate( WPARAM wParam, LPARAM lParam )
  481. {
  482. // m_pMapSite->SendMessage( WM_SENSOR_UPDATE, wParam, lParam );
  483. // m_pMapZoomDlg->SendMessage( WM_SENSOR_UPDATE, wParam, lParam );
  484. // m_pSensorPropertyDlg->UpdateSensor();
  485. // m_pTroubleWnd->Update();
  486. return 0UL;
  487. }
  488. void CChicagoDlg::OnNcLButtonDown(UINT nHitTest, CPoint point)
  489. {
  490. #ifndef _DEBUG
  491. if( nHitTest != HTCAPTION )
  492. #endif
  493. CDialog::OnNcLButtonDown(nHitTest, point);
  494. #ifndef _DEBUG
  495. else SetFocus();
  496. #endif
  497. }
  498. void CChicagoDlg::OnNcLButtonDblClk(UINT nHitTest, CPoint point)
  499. {
  500. #ifndef _DEBUG
  501. if( nHitTest != HTCAPTION )
  502. #endif
  503. CDialog::OnNcLButtonDblClk(nHitTest, point);
  504. #ifndef _DEBUG
  505. else SetFocus();
  506. #endif
  507. }
  508. void CChicagoDlg::OnCancel()
  509. {
  510. try
  511. {
  512. BOOL bAutorized = TRUE;
  513. if( m_bStarted && m_nRunningMode != MODE_MOBILEMAP )
  514. bAutorized = Autorization();
  515. if( bAutorized )
  516. {
  517. /* if( m_Print.bPresent )
  518. if( m_pEventPrinter->IsBusy() || m_pEventPrinter->IsPrintFile() )
  519. {
  520. if( MessageBox( "Cancel print?", NULL, MB_YESNO | MB_ICONEXCLAMATION ) != IDYES )
  521. return;
  522. }
  523. */
  524. #ifndef _DEBUG
  525. ::SystemParametersInfo ( SPI_SCREENSAVERRUNNING, 0, NULL, 0 );
  526. #endif
  527. KillTimer( 0 );
  528. KillTimer( 1 );
  529. SaveControlSettings();
  530. m_pAutorizationDlg->DestroyWindow();
  531. m_pPropertySensorDlg->DestroyWindow();
  532. m_pEventWnd->DestroyWindow();
  533. m_ResetDlg.DestroyWindow();
  534. m_pToolBarDlg->DestroyWindow();
  535. m_pCameraNavigateDlg->DestroyWindow();
  536. m_pZoomAreaWnd->DestroyWindow();
  537. m_pWholeAreaWnd->DestroyWindow();
  538. m_pTroubleListWnd->DestroyWindow();
  539. m_pVideoListWnd->DestroyWindow();
  540. m_pControlPanel[CONTROL_VIDEO_NAVIGATE]->DestroyWindow();
  541. m_pVideoFrameWnd->DestroyWindow();
  542. // log info
  543. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnCancel", "All controls destroyed" );
  544. m_pSensorArray->CommandLoop( MODE_STOP );
  545. // Sleep( 1000 );
  546. delete m_pVideoCapture;
  547. delete m_pStatisticDlg;
  548. // delete m_pEventPrinter;
  549. delete m_pEventQueue;
  550. delete m_pAlarm;
  551. delete m_pFont;
  552. delete m_pMainMenu;
  553. delete m_pPatrolDlg;
  554. // delete m_pTroubleDlg;
  555. // delete m_pReportDlg;
  556. delete m_pSoundDlg;
  557. delete m_pGuardDlg;
  558. delete m_pAutorizationDlg;
  559. delete m_pCameraNavigateDlg;
  560. delete m_pPropertySensorDlg;
  561. delete m_pEventWnd;
  562. delete m_pToolBarDlg;
  563. delete m_pZoomAreaWnd;
  564. delete m_pWholeAreaWnd;
  565. delete m_pTroubleListWnd;
  566. delete m_pVideoListWnd;
  567. delete m_pControlPanel[CONTROL_VIDEO_NAVIGATE];
  568. delete m_pVideoFrameWnd;
  569. m_pVideoBase->Destroy();
  570. // if( !m_bDemoMode )
  571. delete m_pVideoBase;
  572. delete [] m_pVideoWnd;
  573. delete m_pReport;
  574. delete m_pMaskSchedule;
  575. delete m_pSensorArray;
  576. // destroy external alarm
  577. m_AlarmExternal.Destroy();
  578. // log info
  579. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnCancel", "All operational objects deleted" );
  580. CDialog::OnCancel();
  581. // log info
  582. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnCancel", "Report storage engine deleted" );
  583. }
  584. }
  585. catch(...)
  586. {
  587. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnCancel", "exception" );
  588. }
  589. }
  590. using namespace OFNS;
  591. BOOL CChicagoDlg::Reposition( INT nViewMode )
  592. {
  593. if( m_nRunningMode == MODE_BACKUP && nViewMode != VIEW_BACKUP )
  594. return FALSE;
  595. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CChicagoDlg::Reposition"), _T("Started...") );
  596. // if( m_nViewMode == nViewMode )
  597. // return FALSE;
  598. CRect rect;
  599. GetClientRect( &rect );
  600. switch( m_nRunningMode )
  601. {
  602. case MODE_MOBILEMAP:
  603. case MODE_HOST:
  604. switch( nViewMode )
  605. {
  606. case VIEW_MAIN:
  607. m_pToolBarDlg->EnableButton( IDM_VIEW_MAIN, FALSE );
  608. m_pToolBarDlg->EnableButton( IDM_VIEW_DETAIL, TRUE );
  609. m_pMainMenu->EnableMenuItem( IDM_VIEW_MAIN, MF_BYCOMMAND | MF_GRAYED );
  610. m_pMainMenu->EnableMenuItem( IDM_VIEW_DETAIL, MF_BYCOMMAND | MF_ENABLED );
  611. break;
  612. case VIEW_DETAIL:
  613. m_pToolBarDlg->EnableButton( IDM_VIEW_MAIN, TRUE );
  614. m_pToolBarDlg->EnableButton( IDM_VIEW_DETAIL, FALSE );
  615. m_pMainMenu->EnableMenuItem( IDM_VIEW_MAIN, MF_BYCOMMAND | MF_ENABLED );
  616. m_pMainMenu->EnableMenuItem( IDM_VIEW_DETAIL, MF_BYCOMMAND | MF_GRAYED );
  617. break;
  618. }
  619. case MODE_BACKUP_ACTIVE:
  620. m_pToolBarDlg->EnableButton( IDM_SYSTEM_RESET, TRUE );
  621. m_pToolBarDlg->EnableButton( IDM_SYSTEM_ENABLE, TRUE );
  622. m_pMainMenu->EnableMenuItem( IDM_SYSTEM_RESET, MF_BYCOMMAND | MF_ENABLED );
  623. m_pMainMenu->EnableMenuItem( IDM_SYSTEM_ENABLE, MF_BYCOMMAND | MF_ENABLED );
  624. m_pMainMenu->EnableMenuItem( IDM_VIEW_OPTIONS, MF_BYCOMMAND | MF_ENABLED );
  625. m_pMainMenu->EnableMenuItem( IDM_SUPPORT_SOUND, MF_BYCOMMAND | MF_ENABLED );
  626. break;
  627. case MODE_BACKUP:
  628. m_pToolBarDlg->EnableButton( IDM_SYSTEM_RESET, FALSE );
  629. m_pToolBarDlg->EnableButton( IDM_SYSTEM_ENABLE, FALSE );
  630. m_pToolBarDlg->EnableButton( IDM_VIEW_MAIN, FALSE );
  631. m_pToolBarDlg->EnableButton( IDM_VIEW_DETAIL, FALSE );
  632. m_pMainMenu->EnableMenuItem( IDM_SYSTEM_RESET, MF_BYCOMMAND | MF_GRAYED );
  633. m_pMainMenu->EnableMenuItem( IDM_SYSTEM_ENABLE, MF_BYCOMMAND | MF_GRAYED );
  634. m_pMainMenu->EnableMenuItem( IDM_VIEW_MAIN, MF_BYCOMMAND | MF_GRAYED );
  635. m_pMainMenu->EnableMenuItem( IDM_VIEW_DETAIL, MF_BYCOMMAND | MF_GRAYED );
  636. m_pMainMenu->EnableMenuItem( IDM_VIEW_OPTIONS, MF_BYCOMMAND | MF_GRAYED );
  637. m_pMainMenu->EnableMenuItem( IDM_SUPPORT_SOUND, MF_BYCOMMAND | MF_GRAYED );
  638. break;
  639. }
  640. // rect.top += 50;
  641. CRect pRect[ CONTROL_COUNT ];
  642. for( int i = 0; i < CONTROL_COUNT; i++ )
  643. {
  644. pRect[i].SetRect( (int)(m_pControlRect[i].left * rect.Width()),
  645. (int)(m_pControlRect[i].top * rect.Height()),
  646. (int)(m_pControlRect[i].right * rect.Width()),
  647. (int)(m_pControlRect[i].bottom * rect.Height()) );
  648. }
  649. if( m_pToolBarDlg->GetSafeHwnd() )
  650. {
  651. m_pToolBarDlg->MoveWindow( &pRect[ CONTROL_TOOLBAR ] );
  652. m_pToolBarDlg->ShowWindow( m_pControlRect[ CONTROL_TOOLBAR ].bVisible ? SW_SHOW : SW_HIDE );
  653. m_pMainMenu->CheckMenuItem( ID_VIEW_TOOLBAR, MF_BYCOMMAND | ( m_pControlRect[CONTROL_TOOLBAR].bVisible ? MF_CHECKED : MF_UNCHECKED ) );
  654. }
  655. if( m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->GetSafeHwnd() )
  656. {
  657. m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->MoveWindow( &pRect[ CONTROL_VIDEO_NAVIGATE ] );
  658. m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->ShowWindow( m_pControlRect[ CONTROL_VIDEO_NAVIGATE ].bVisible ? SW_SHOW : SW_HIDE );
  659. m_pMainMenu->CheckMenuItem( ID_VIEW_PTZCONTROL, MF_BYCOMMAND | ( m_pControlRect[CONTROL_VIDEO_NAVIGATE].bVisible ? MF_CHECKED : MF_UNCHECKED ) );
  660. }
  661. if( m_pPropertySensorDlg->GetSafeHwnd() )
  662. {
  663. m_pPropertySensorDlg->MoveWindow( &pRect[ CONTROL_SENSOR_PROPERTY ] );
  664. m_pPropertySensorDlg->ShowWindow( m_pControlRect[ CONTROL_SENSOR_PROPERTY ].bVisible ? SW_SHOW : SW_HIDE );
  665. m_pMainMenu->CheckMenuItem( ID_VIEW_SENSORPROPERTIES, MF_BYCOMMAND | ( m_pControlRect[CONTROL_SENSOR_PROPERTY].bVisible ? MF_CHECKED : MF_UNCHECKED ) );
  666. }
  667. if( m_pTroubleListWnd->GetSafeHwnd() )
  668. {
  669. m_pTroubleListWnd->MoveWindow( &pRect[ CONTROL_TROUBLE_LIST ] );
  670. m_pTroubleListWnd->ShowWindow( m_pControlRect[ CONTROL_TROUBLE_LIST ].bVisible ? SW_SHOW : SW_HIDE );
  671. m_pMainMenu->CheckMenuItem( ID_VIEW_TROUBLES, MF_BYCOMMAND | ( m_pControlRect[CONTROL_TROUBLE_LIST].bVisible ? MF_CHECKED : MF_UNCHECKED ) );
  672. }
  673. if( m_pEventWnd->GetSafeHwnd() )
  674. {
  675. m_pEventWnd->MoveWindow( &pRect[ CONTROL_EVENT_LIST ] );
  676. m_pEventWnd->ShowWindow( m_pControlRect[ CONTROL_EVENT_LIST ].bVisible ? SW_SHOW : SW_HIDE );
  677. m_pMainMenu->CheckMenuItem( ID_VIEW_EVENTS, MF_BYCOMMAND | ( m_pControlRect[CONTROL_EVENT_LIST].bVisible ? MF_CHECKED : MF_UNCHECKED ) );
  678. }
  679. if( m_pVideoFrameWnd->GetSafeHwnd() )
  680. {
  681. m_pVideoFrameWnd->MoveWindow( &pRect[ CONTROL_VIDEO_MAIN ] );
  682. m_pVideoFrameWnd->ShowWindow( m_pControlRect[ CONTROL_VIDEO_MAIN ].bVisible ? SW_SHOW : SW_HIDE );
  683. m_pMainMenu->CheckMenuItem( ID_VIEW_VIDEO, MF_BYCOMMAND | ( m_pControlRect[CONTROL_VIDEO_MAIN].bVisible ? MF_CHECKED : MF_UNCHECKED ) );
  684. }
  685. if( m_pVideoListWnd->GetSafeHwnd() )
  686. {
  687. m_pVideoListWnd->MoveWindow( &pRect[ CONTROL_VIDEO_LIST ] );
  688. m_pVideoListWnd->ShowWindow( m_pControlRect[ CONTROL_VIDEO_LIST ].bVisible ? SW_SHOW : SW_HIDE );
  689. m_pMainMenu->CheckMenuItem( ID_VIEW_VIDEOLIST, MF_BYCOMMAND | ( m_pControlRect[CONTROL_VIDEO_LIST].bVisible ? MF_CHECKED : MF_UNCHECKED ) );
  690. }
  691. if( m_pWholeAreaWnd->GetSafeHwnd() )
  692. {
  693. m_pWholeAreaWnd->MoveWindow( &pRect[ CONTROL_WHOLE_MAP ] );
  694. m_pWholeAreaWnd->ShowWindow( m_pControlRect[ CONTROL_WHOLE_MAP ].bVisible ? SW_SHOW : SW_HIDE );
  695. m_pMainMenu->CheckMenuItem( ID_VIEW_MAP, MF_BYCOMMAND | ( m_pControlRect[CONTROL_WHOLE_MAP].bVisible ? MF_CHECKED : MF_UNCHECKED ) );
  696. }
  697. if( m_pZoomAreaWnd->GetSafeHwnd() )
  698. {
  699. m_pZoomAreaWnd->MoveWindow( &pRect[ CONTROL_ZOOM_MAP ] );
  700. m_pZoomAreaWnd->ShowWindow( m_pControlRect[ CONTROL_ZOOM_MAP ].bVisible ? SW_SHOW : SW_HIDE );
  701. m_pMainMenu->CheckMenuItem( ID_VIEW_MAGNIFIEDMAP, MF_BYCOMMAND | ( m_pControlRect[CONTROL_ZOOM_MAP].bVisible ? MF_CHECKED : MF_UNCHECKED ) );
  702. }
  703. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CChicagoDlg::Reposition"), _T("Succeeded") );
  704. return TRUE;
  705. // rect.top += m_pToolBarDlg->GetHeight();
  706. switch( nViewMode )
  707. {
  708. case VIEW_DETAIL:
  709. {
  710. CRect tmp;
  711. m_pPropertySensorDlg->GetWindowRect( &tmp );
  712. int nHeight = rect.Height() - tmp.Height();
  713. int nWidth = nHeight * 4 / 5;
  714. m_pVideoFrameWnd->MoveWindow( rect.right - nWidth, rect.top, nWidth, nHeight );
  715. rect.right -= nWidth;
  716. CRect rect0; // Main map
  717. {
  718. /* CRect tmp1, tmp2;
  719. rect0 = rect;
  720. m_pPropertySensorDlg->GetWindowRect( &tmp1 );
  721. rect0.bottom -= tmp1.Height();
  722. tmp2.SetRect( 0, 0, m_pMapData->GetMapSize().cx, m_pMapData->GetMapSize().cy );
  723. double mapScale = CalcViewRectAndScale( tmp2, &rect0 );
  724. m_pMapSite->MoveWindow( &rect0 );
  725. m_pMapSite->SetMapShiftScale( SDPOINT(0,0), mapScale );
  726. m_pMapSite->ShowWindow( SW_SHOW );
  727. */ // ClientToScreen( &rect0 );
  728. }
  729. CRect rect1; // Magnifier map
  730. {
  731. /* rect1.left = rect0.right;
  732. rect1.top = rect0.top;
  733. rect1.right = rect.right;
  734. rect1.bottom = rect0.bottom;
  735. m_pMapZoomDlg->MoveWindow( &rect1 );
  736. m_pMapZoomDlg->ShowWindow( SW_SHOW );
  737. */ }
  738. CRect rect2; // Property
  739. {
  740. CRect tmp;
  741. m_pPropertySensorDlg->GetWindowRect( &tmp );
  742. rect2.left = rect.right - tmp.Width();
  743. rect2.top = rect1.bottom;
  744. rect2.right = rect.right;
  745. rect2.bottom = rect.bottom;
  746. // m_pSensorPropertyDlg->MoveWindow( &rect2 );
  747. // m_pSensorPropertyDlg->ShowWindow( SW_HIDE );
  748. m_pPropertySensorDlg->MoveWindow( &rect2 );
  749. m_pPropertySensorDlg->ShowWindow( SW_SHOW );
  750. }
  751. // m_pVideoWnd->ShowWindow( SW_HIDE );
  752. CRect rect7; // Video
  753. if( FALSE ) //m_pVideoWnd->GetSafeHwnd() )
  754. {
  755. rect7.left = rect2.left - (rect2.bottom - rect2.top) * 4 / 3;
  756. rect7.top = rect2.top;
  757. rect7.right = rect2.left;
  758. rect7.bottom = rect2.bottom;
  759. // m_pVideoWnd->MoveWindow( &rect7 );
  760. // m_pVideoWnd->ShowWindow( SW_SHOW );
  761. // m_pVideoWnd->UpdateWindow();
  762. // m_pVideoWnd->InvalidateRect( NULL, FALSE );
  763. CRect rect3; // Trouble
  764. {
  765. rect3.left = rect.left;
  766. rect3.top = rect7.top;
  767. rect3.right = rect7.left;
  768. rect3.bottom = rect7.top + (rect7.bottom - rect7.top)/2;
  769. // m_pSensorsStateDlg->MoveWindow( &rect3 );
  770. // m_pSensorsStateDlg->ShowWindow( SW_SHOW );
  771. // m_pTroubleWnd->MoveWindow( &rect3 );
  772. // m_pTroubleWnd->ShowWindow( SW_SHOW );
  773. }
  774. CRect rect4; // Events
  775. {
  776. rect4.left = rect3.left;
  777. rect4.top = rect3.bottom;
  778. rect4.right = rect3.right;
  779. rect4.bottom = rect.bottom;
  780. m_pEventWnd->MoveWindow( &rect4 );
  781. m_pEventWnd->ShowWindow( SW_SHOW );
  782. }
  783. }
  784. else
  785. {
  786. CRect rect3; // Trouble
  787. {
  788. rect3.left = rect.left;
  789. rect3.top = rect0.bottom;
  790. rect3.right = (rect2.left - rect.left) / 2;
  791. rect3.bottom = rect.bottom;
  792. // m_pSensorsStateDlg->MoveWindow( &rect3 );
  793. // m_pSensorsStateDlg->ShowWindow( SW_SHOW );
  794. // m_pTroubleWnd->MoveWindow( &rect3 );
  795. // m_pTroubleWnd->ShowWindow( SW_SHOW );
  796. }
  797. CRect rect4; // Events
  798. {
  799. rect4.left = rect3.right;
  800. rect4.top = rect0.bottom;
  801. rect4.right = rect2.left;
  802. rect4.bottom = rect.bottom;
  803. m_pEventWnd->MoveWindow( &rect4 );
  804. m_pEventWnd->ShowWindow( SW_SHOW );
  805. }
  806. }
  807. CRect rect5; // Clock
  808. {
  809. /* rect5.left = rect0.right;
  810. rect5.top = rect.top;
  811. rect5.right = rect.right;
  812. rect5.bottom = rect.top + 110;
  813. m_pClockWnd->MoveWindow( &rect5 );
  814. m_pClockWnd->ShowWindow( SW_HIDE );
  815. */ }
  816. CRect rect6; // Logo
  817. {
  818. /* rect6.left = rect0.right + (rect.right - rect0.right - 130)/2;
  819. rect6.top = rect5.bottom + 30;
  820. rect6.right = rect6.left + 130;
  821. rect6.bottom = rect6.top + 130;
  822. m_pLogoWnd->MoveWindow( &rect6 );
  823. m_pLogoWnd->ShowWindow( SW_HIDE );
  824. */ }
  825. }
  826. break;
  827. case VIEW_MAIN:
  828. {
  829. // m_pSensorCurrent = NULL;
  830. CRect rect0; // Main map
  831. {
  832. CRect tmp1;
  833. rect0 = rect;
  834. // tmp1.SetRect( 0, 0, m_pMapData->GetMapSize().cx, m_pMapData->GetMapSize().cy );
  835. double mapScale = CalcViewRectAndScale( tmp1, &rect0 );
  836. // m_pMapSite->MoveWindow( &rect0 );
  837. // m_pMapSite->SetMapShiftScale( SDPOINT(0,0), mapScale );
  838. // m_pMapSite->ShowWindow( SW_SHOW );
  839. }
  840. // Magnifier map
  841. {
  842. // m_pMapZoomDlg->ShowWindow( SW_HIDE );
  843. }
  844. // Property
  845. {
  846. // m_pSensorPropertyDlg->ShowWindow( SW_HIDE );
  847. m_pPropertySensorDlg->ShowWindow( SW_HIDE );
  848. }
  849. CRect rect5; // Clock
  850. {
  851. // CSize as = m_pClockWnd->GetActualSize();
  852. // rect5.left = rect0.right;
  853. // rect5.top = rect.top;
  854. // rect5.right = rect.right;
  855. // rect5.bottom = rect.top + as.cy * rect5.Width() / as.cx + 6;
  856. // m_pClockWnd->MoveWindow( &rect5 );
  857. // m_pClockWnd->ShowWindow( SW_SHOW );
  858. }
  859. /*
  860. CRect rect6; // Logo
  861. {
  862. rect6.left = rect0.right + (rect.right - rect0.right - 130) / 2;
  863. rect6.right = rect6.left + 130;
  864. rect6.top = rect5.bottom;
  865. rect6.bottom = rect6.top + 130;
  866. m_pLogoWnd->MoveWindow( &rect6 );
  867. m_pLogoWnd->ShowWindow( SW_SHOW );
  868. }
  869. */
  870. CRect rect7; // Video
  871. /* if( m_pVideoWnd->GetSafeHwnd() )
  872. {
  873. rect7.left = rect0.right;
  874. rect7.top = rect5.bottom;
  875. rect7.right = rect.right;
  876. rect7.bottom = rect7.top + (rect7.right - rect7.left) * 3 / 4;
  877. m_pVideoWnd->MoveWindow( &rect7 );
  878. m_pVideoWnd->ShowWindow( SW_SHOW );
  879. m_pVideoWnd->UpdateWindow();
  880. m_pVideoWnd->InvalidateRect( NULL, FALSE );
  881. }
  882. else
  883. {
  884. rect7.left = rect0.right;
  885. rect7.top = rect5.bottom;
  886. rect7.right = rect.right;
  887. rect7.bottom = rect5.bottom;
  888. }
  889. */
  890. CRect rect3; // Trouble
  891. {
  892. rect3.left = rect0.right;
  893. rect3.top = rect7.bottom;
  894. rect3.right = rect.right;
  895. rect3.bottom = rect7.bottom + ( rect.bottom - rect7.bottom ) / 2;
  896. // m_pSensorsStateDlg->MoveWindow( &rect3 );
  897. // m_pSensorsStateDlg->ShowWindow( SW_HIDE );
  898. // m_pTroubleWnd->MoveWindow( &rect3 );
  899. // m_pTroubleWnd->ShowWindow( SW_SHOW );
  900. }
  901. CRect rect4; // Events
  902. {
  903. rect4.left = rect0.right;
  904. rect4.top = rect3.bottom;
  905. rect4.right = rect.right;
  906. rect4.bottom = rect.bottom;
  907. m_pEventWnd->MoveWindow( &rect4 );
  908. m_pEventWnd->ShowWindow( SW_SHOW );
  909. }
  910. }
  911. break;
  912. case VIEW_BACKUP:
  913. {
  914. // m_pSensorEvent = NULL;
  915. // Main map
  916. // m_pMapSite->ShowWindow( SW_HIDE );
  917. // Magnifier map
  918. // m_pMapZoomDlg->ShowWindow( SW_HIDE );
  919. // Property
  920. m_pPropertySensorDlg->ShowWindow( SW_HIDE );
  921. CRect rect0; // Clock
  922. {
  923. // CSize as = m_pClockWnd->GetActualSize();
  924. rect0.left = rect.left;
  925. rect0.top = rect.top;
  926. rect0.right = rect.right;
  927. // rect0.bottom = rect.top + as.cy * rect0.Width() / as.cx + 6;
  928. // m_pClockWnd->MoveWindow( &rect0 );
  929. // m_pClockWnd->ShowWindow( SW_SHOW );
  930. }
  931. /*
  932. CRect rect1; // Logo
  933. {
  934. rect1.left = rect.left + ( rect.Width() - 130 ) / 2;
  935. rect1.right = rect1.left + 130;
  936. rect1.top = rect0.bottom;
  937. rect1.bottom = rect1.top + 130;
  938. m_pLogoWnd->MoveWindow( &rect1 );
  939. m_pLogoWnd->ShowWindow( SW_SHOW );
  940. }
  941. */
  942. // if( m_pVideoWnd->GetSafeHwnd() )
  943. // m_pVideoWnd->ShowWindow( SW_HIDE );
  944. CRect rect2; // Trouble
  945. {
  946. rect2.left = rect.left;
  947. rect2.top = rect0.bottom;
  948. rect2.right = rect0.left;
  949. rect2.bottom = rect.bottom;
  950. // m_pTroubleWnd->MoveWindow( &rect2 );
  951. // m_pTroubleWnd->ShowWindow( SW_SHOW );
  952. }
  953. CRect rect3; // Events
  954. {
  955. rect3.left = rect0.right;
  956. rect3.top = rect0.bottom;
  957. rect3.right = rect.right;
  958. rect3.bottom = rect.bottom;
  959. m_pEventWnd->MoveWindow( &rect3 );
  960. m_pEventWnd->ShowWindow( SW_SHOW );
  961. }
  962. }
  963. break;
  964. }
  965. // log info
  966. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::Reposition" );
  967. m_nViewMode = nViewMode;
  968. return TRUE;
  969. }
  970. void CChicagoDlg::OnViewMain()
  971. {
  972. // Reposition( VIEW_MAIN );
  973. }
  974. void CChicagoDlg::OnViewAlarm()
  975. {
  976. // if( Reposition( VIEW_DETAIL ) )
  977. // {
  978. // if( !m_pSensorCurrent )
  979. // m_pSensorCurrent = m_pSensorArray->GetSensor(0);
  980. // SendMessage( WM_SENSOR_SHOW, (WPARAM)m_pSensorCurrent, (LPARAM)m_pSensorCurrent );
  981. // }
  982. }
  983. void CChicagoDlg::OnInitMenu(CMenu* pMenu)
  984. {
  985. /* int nResult;
  986. if( m_nViewMode == VIEW_DETAIL )
  987. nResult = pMenu->CheckMenuRadioItem( IDM_VIEW_MAIN, IDM_VIEW_DETAIL, IDM_VIEW_DETAIL, MF_BYCOMMAND );
  988. else
  989. nResult = pMenu->CheckMenuRadioItem( IDM_VIEW_MAIN, IDM_VIEW_DETAIL, IDM_VIEW_MAIN, MF_BYCOMMAND );
  990. if( nResult != -1 )
  991. {
  992. for( int i = 0; i < m_pSensorArray->GetSensorCount(); i++ )
  993. {
  994. switch( m_pSensorArray->GetSensor(i)->GetState() )
  995. {
  996. case CSensor::ALARM:
  997. // case CSensor::TIMEOUT:
  998. // case CSensor::POSTALARM:
  999. if( pMenu->EnableMenuItem( IDM_VIEW_MAIN, MF_BYCOMMAND | MF_GRAYED )!=0xFFFFFFFF )
  1000. goto END_PROC;
  1001. }
  1002. }
  1003. pMenu->EnableMenuItem( IDM_VIEW_MAIN, MF_BYCOMMAND | MF_ENABLED );
  1004. }
  1005. END_PROC:
  1006. */
  1007. CDialog::OnInitMenu(pMenu);
  1008. }
  1009. void CChicagoDlg::StoreEvent( EVENT &event )
  1010. {
  1011. if( m_nRunningMode != MODE_MOBILEMAP )
  1012. {
  1013. memset( &event.image, 0, sizeof(event.image) );
  1014. // place index of eventy into first sell of pImage array
  1015. if( !m_pReport->Write( event ) )
  1016. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CChicagoDlg::StoreEvent"), _T("Event store failed") );
  1017. }
  1018. }
  1019. #define GPRU_SWITCH_ADDRESS 124
  1020. void CChicagoDlg::OnTimer( UINT nIDEvent )
  1021. {
  1022. // log info
  1023. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CChicagoDlg::OnTimer", "%d start...", nIDEvent );
  1024. try
  1025. {
  1026. if( nIDEvent == 2 )
  1027. {
  1028. KillTimer( 2 ); // start timer
  1029. SetTimer( 0, 250, NULL ); // interface timer
  1030. SetTimer( 1, 50, NULL ); // fast timer
  1031. // log info
  1032. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CChicagoDlg::OnTimer", "%d done.", nIDEvent );
  1033. return;
  1034. }
  1035. // fast timer ~50 ms
  1036. if( nIDEvent == 1 )
  1037. {
  1038. m_pSensorArray->CheckCameras();
  1039. m_pVideoCapture->CheckState();
  1040. // log info
  1041. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CChicagoDlg::OnTimer", "%d done.", nIDEvent );
  1042. return;
  1043. }
  1044. m_pMaskSchedule->OnTimer();
  1045. // normal timer ~250 ms
  1046. #ifndef _DEBUG
  1047. CheckCopyright();
  1048. #endif
  1049. m_pWholeAreaWnd->UpdateInfo( m_bTimerOdd );
  1050. m_pZoomAreaWnd->UpdateInfo( m_bTimerOdd );
  1051. m_pTroubleListWnd->UpdateInfo( m_bTimerOdd );
  1052. m_pPropertySensorDlg->UpdateInfo( m_bTimerOdd );
  1053. m_pCameraNavigateDlg->UpdateInfo( m_bTimerOdd );
  1054. // m_pMapSite->SendMessage( WM_TIMER, m_bTimerOdd );
  1055. // m_pClockWnd->SendMessage( WM_TIMER, m_bTimerOdd );
  1056. // m_pMapZoomDlg->SendMessage( WM_TIMER, m_bTimerOdd );
  1057. // m_pSensorPropertyDlg->SendMessage( WM_TIMER, m_bTimerOdd );
  1058. // m_pSensorsStateDlg->SendMessage( WM_TIMER, m_bTimerOdd );
  1059. // m_pPropertySensorDlg->SendMessage( WM_TIMER, m_bTimerOdd );
  1060. // m_pTroubleWnd->SendMessage( WM_TIMER, m_bTimerOdd );
  1061. m_pEventWnd->SendMessage( WM_TIMER, m_bTimerOdd );
  1062. // m_pLogoWnd->SendMessage( WM_TIMER );
  1063. if( m_pAutorizationDlg->GetSafeHwnd() )
  1064. m_pAutorizationDlg->SendMessage( WM_TIMER );
  1065. if( m_pStatisticDlg->GetSafeHwnd() )
  1066. m_pStatisticDlg->SendMessage( WM_TIMER );
  1067. // if( m_pReportDlg->GetSafeHwnd() )
  1068. // m_pReportDlg->SendMessage( WM_TIMER );
  1069. // if( m_pTroubleDlg->GetSafeHwnd() )
  1070. // m_pTroubleDlg->SendMessage( WM_TIMER );
  1071. if( m_pGuardDlg->GetSafeHwnd() )
  1072. m_pGuardDlg->SendMessage( WM_TIMER );
  1073. if( m_pPatrolDlg->GetSafeHwnd() )
  1074. m_pPatrolDlg->SendMessage( WM_TIMER );
  1075. m_pSensorArray->CheckPatrols();
  1076. m_pSensorArray->CheckSensors();
  1077. EVENT event;
  1078. CSensor *pSensor = NULL, *pSensorLast = NULL;
  1079. BOOL bNeedBeep = FALSE;
  1080. BOOL bNeedBeepStop = FALSE;
  1081. BOOL bNeedPrintDlg = FALSE;
  1082. BOOL bNeedUpdate = FALSE;
  1083. BOOL bNeedCapture = FALSE;
  1084. while( m_pEventQueue->GetEvent( event ) )
  1085. {
  1086. BOOL bNeedStore = FALSE;
  1087. BOOL bNeedPrint = FALSE;
  1088. BOOL bNeedCapture = FALSE;
  1089. BOOL bNeedEventWnd = FALSE;
  1090. BOOL bNeedWave = FALSE;
  1091. BOOL bNeedStoreExtendedLog = FALSE;
  1092. switch( event.id )
  1093. {
  1094. case LGS_EVENT_SENSOR_LGS_POWER:
  1095. if( !event.bPowered )
  1096. bNeedBeep = TRUE;
  1097. bNeedPrint = TRUE;
  1098. bNeedStore = TRUE;
  1099. bNeedEventWnd = TRUE;
  1100. bNeedUpdate = TRUE;
  1101. break;
  1102. case LGS_EVENT_NORMAL:
  1103. bNeedUpdate = TRUE;
  1104. bNeedPrint = TRUE;
  1105. bNeedStore = TRUE;
  1106. break;
  1107. case LGS_EVENT_ALARM_SHOW:
  1108. bNeedCapture = TRUE;
  1109. case LGS_EVENT_TIMEOUT_APPEAR:
  1110. pSensor = m_pSensorArray->GetSensor( event.data16 );
  1111. if( pSensor->GetZone()->IsSoundAlarm() )
  1112. {
  1113. bNeedBeep = TRUE;
  1114. bNeedWave = TRUE;
  1115. }
  1116. // notify call center about alarm
  1117. m_pSensorArray->GetPhoneCallCenter().OnAlarm( event.data16 );
  1118. case LGS_EVENT_ALARM_HIDE:
  1119. if( pSensorLast )
  1120. {
  1121. if( pSensor->GetState() >= pSensorLast->GetState() )
  1122. pSensorLast = pSensor;
  1123. }
  1124. else pSensorLast = pSensor;
  1125. bNeedEventWnd = TRUE;
  1126. bNeedUpdate = TRUE;
  1127. bNeedPrint = TRUE;
  1128. bNeedStore = TRUE;
  1129. break;
  1130. case LGS_EVENT_ERROR:
  1131. switch( event.data8 )
  1132. {
  1133. case LGS_EVENT_ERROR_NORMAL:
  1134. bNeedStoreExtendedLog = TRUE;
  1135. break;
  1136. case LGS_EVENT_ERROR_CRITICAL:
  1137. m_pEventWnd->AddHead( event );
  1138. bNeedBeep = TRUE;
  1139. bNeedPrint = TRUE;
  1140. bNeedStore = TRUE;
  1141. m_pWholeAreaWnd->InvalidateRect( NULL );
  1142. m_pZoomAreaWnd->InvalidateRect( NULL );
  1143. break;
  1144. }
  1145. break;
  1146. case LGS_EVENT_PROGRAM_RESET:
  1147. m_pEventWnd->AddHead( event );
  1148. bNeedPrint = TRUE;
  1149. bNeedStore = TRUE;
  1150. m_pWholeAreaWnd->InvalidateRect( NULL );
  1151. m_pZoomAreaWnd->InvalidateRect( NULL );
  1152. break;
  1153. case LGS_EVENT_SENSOR_RESET_BY_CCC:
  1154. pSensor = m_pSensorArray->GetSensor( event.data16 );
  1155. pSensor->Reset();
  1156. m_pSensorArray->GetEventQueue()->PostEvent( LGS_EVENT_PROGRAM_RESET, 0, 0, 0, RGB(0xFF,0xFF,0xFF), (LPSTR)(LPCTSTR)event.pText );
  1157. break;
  1158. case LGS_EVENT_LGS_AUTO_RESET:
  1159. case LGS_EVENT_SYSTEM_REPAIR:
  1160. bNeedPrint = TRUE;
  1161. bNeedStore = TRUE;
  1162. bNeedEventWnd = TRUE;
  1163. break;
  1164. /* case LGS_EVENT_PRINTER:
  1165. m_Print.bPresent = event.data8;
  1166. bNeedEventWnd = TRUE;
  1167. break;
  1168. */ case LGS_EVENT_LINE_CUT:
  1169. bNeedEventWnd = TRUE;
  1170. bNeedPrint = TRUE;
  1171. bNeedStore = TRUE;
  1172. bNeedBeep = TRUE;
  1173. break;
  1174. case LGS_EVENT_EXTENDED_LOG:
  1175. bNeedStoreExtendedLog = TRUE;
  1176. break;
  1177. case LGS_EVENT_PATROL:
  1178. bNeedPrint = TRUE;
  1179. bNeedStore = TRUE;
  1180. bNeedUpdate = TRUE;
  1181. if( event.data8 )
  1182. bNeedBeepStop = TRUE;
  1183. else bNeedBeep = TRUE;
  1184. bNeedEventWnd = TRUE;
  1185. break;
  1186. case LGS_EVENT_MM_UPDATE:
  1187. pSensor = (CSensor*)event.data32;
  1188. switch( pSensor->GetState() )
  1189. {
  1190. case CVisual::TIMEOUT:
  1191. case CVisual::POSTALARM:
  1192. case CVisual::ALARM:
  1193. if( pSensorLast )
  1194. {
  1195. if( pSensor->GetState() >= pSensorLast->GetState() )
  1196. pSensorLast = pSensor;
  1197. }
  1198. else pSensorLast = pSensor;
  1199. if( m_nRunningMode != MODE_BACKUP )
  1200. bNeedBeep = TRUE;
  1201. break;
  1202. }
  1203. bNeedUpdate = TRUE;
  1204. break;
  1205. case LGS_EVENT_GUARD:
  1206. case LGS_EVENT_SUPER:
  1207. bNeedEventWnd = TRUE;
  1208. bNeedPrint = TRUE;
  1209. bNeedStore = TRUE;
  1210. break;
  1211. case LGS_EVENT_MM_COMMUNICATE:
  1212. switch( m_nRunningMode )
  1213. {
  1214. case MODE_HOST:
  1215. break;
  1216. case MODE_MOBILEMAP:
  1217. if( event.data8 )
  1218. {
  1219. // m_pLogoWnd->Rotate( TRUE );
  1220. bNeedBeepStop = TRUE;
  1221. // m_pTroubleWnd->Delete( TROUBLE_BACKUP, 1 );
  1222. }
  1223. else
  1224. {
  1225. // m_pLogoWnd->Rotate( FALSE );
  1226. bNeedBeep = TRUE;
  1227. // m_pTroubleWnd->Add( TROUBLE_BACKUP, 1, "MM", "No communication with host", 0xFF, 0 );
  1228. }
  1229. bNeedEventWnd = TRUE;
  1230. bNeedUpdate = TRUE;
  1231. break;
  1232. case MODE_BACKUP:
  1233. if( event.data8 )
  1234. {
  1235. // m_pLogoWnd->Rotate( TRUE );
  1236. bNeedBeepStop = TRUE;
  1237. }
  1238. else
  1239. {
  1240. m_pEventQueue->PostEvent( LGS_EVENT_GPRU_COMMAND_SEND, 0, MAKEWORD( GPRU_SWITCH_ADDRESS, 0 ), 127, 0, NULL );
  1241. for( int s = 0; s < m_pSensorArray->GetSocketCount(); s++ )
  1242. if( m_pSensorArray->GetSocket( s )->GetType() == SOCKET_SPRU )
  1243. {
  1244. m_pSensorArray->GetSocket( s )->CommandLoopStart();
  1245. break;
  1246. }
  1247. m_bWaitDisconnect = TRUE;
  1248. bNeedBeep = TRUE;
  1249. }
  1250. bNeedEventWnd = TRUE;
  1251. bNeedUpdate = TRUE;
  1252. bNeedPrint = TRUE;
  1253. break;
  1254. case MODE_BACKUP_ACTIVE:
  1255. if( event.data8 )
  1256. {
  1257. m_pEventQueue->PostEvent( LGS_EVENT_GPRU_COMMAND_SEND, 0, MAKEWORD( GPRU_SWITCH_ADDRESS, 0 ), 0, 0, NULL );
  1258. // m_pLogoWnd->Rotate( TRUE );
  1259. bNeedBeepStop = TRUE;
  1260. m_bWaitConnect = TRUE;
  1261. }
  1262. bNeedEventWnd = TRUE;
  1263. bNeedUpdate = TRUE;
  1264. bNeedPrint = TRUE;
  1265. break;
  1266. }
  1267. break;
  1268. case LGS_EVENT_SOCKET_COMMUNICATION:
  1269. if( !event.data8 )
  1270. {
  1271. CString str;
  1272. bNeedBeep = TRUE;
  1273. // switch( event.data16 )
  1274. // {
  1275. // case SOCKET_SM: m_pTroubleWnd->Add( TROUBLE_SM, 0, "ERROR SM", "Program could not create communication port for SINOPTIC MAP", 0xFF, 0 ); break;
  1276. // case SOCKET_ECS: m_pTroubleWnd->Add( TROUBLE_ECS, 0, "ERROR ECS", "Program could not create communication port for ELECTRONIC CONTROL SSYSTEM", 0xFF, 0 ); break;
  1277. // case SOCKET_BACKUP: m_pTroubleWnd->Add( TROUBLE_BACKUP, 0, "ERROR BACK UP", "Program could not create communication port for BACKUP", 0xFF, 0 ); break;
  1278. // case SOCKET_SPRU: m_pTroubleWnd->Add( TROUBLE_SPRU, 0, "ERROR LINE", "Program could not create communication port for FIELD LINE", 0xFF, 0 ); break;
  1279. // }
  1280. }
  1281. bNeedEventWnd = TRUE;
  1282. bNeedUpdate = TRUE;
  1283. bNeedPrint = TRUE;
  1284. bNeedStore = TRUE;
  1285. break;
  1286. case LGS_EVENT_GPRU_COMMAND_SEND:
  1287. if( !m_pSensorArray->PostSocketEvent( event, SOCKET_SPRU ) )
  1288. m_pEventQueue->PostEvent( LGS_EVENT_GPRU_COMMAND_RESULT, FALSE, event.data16, event.data32, RGB(0xFF,0,0), "can't perform GPRU command" );
  1289. break;
  1290. case LGS_EVENT_GPRU_COMMAND_RESULT:
  1291. if( event.data8 )
  1292. {
  1293. if( m_bWaitDisconnect )
  1294. {
  1295. if( event.data16 == MAKEWORD( GPRU_SWITCH_ADDRESS, 0 ) )
  1296. {
  1297. m_nRunningMode = MODE_BACKUP_ACTIVE;
  1298. m_pSensorArray->CommandLoop( m_nRunningMode );
  1299. for( int s = 0; s < m_pSensorArray->GetSocketCount(); s++ )
  1300. if( m_pSensorArray->GetSocket( s )->GetType() == SOCKET_BACKUP )
  1301. {
  1302. ((CSocketBackup*)m_pSensorArray->GetSocket( s ))->SetServer();
  1303. ((CSocketBackup*)m_pSensorArray->GetSocket( s ))->SetName( "Backup and mobile map server" );
  1304. break;
  1305. }
  1306. m_pEventQueue->PostEvent( LGS_EVENT_BACKUP_TO_HOST, 1,0,0, RGB(0,0xFF,0), "backup switched to host" );
  1307. // m_pTroubleWnd->Delete( TROUBLE_BACKUP, 1 );
  1308. // m_pTroubleWnd->Add( TROUBLE_BACKUP, 1, "BACK UP-> HOST", "Backup mode switched to host mode computer", RGB( 0, 0xFF, 0 ), RGB( 0, 0x7F, 0 ) );
  1309. // m_ToolBarDlg.SetModeText( "HOST" );
  1310. // Reposition( VIEW_MAIN );
  1311. bNeedBeepStop = TRUE;
  1312. bNeedUpdate = TRUE;
  1313. m_bWaitDisconnect = FALSE;
  1314. }
  1315. }
  1316. if( m_bWaitConnect )
  1317. {
  1318. if( event.data16 == MAKEWORD( GPRU_SWITCH_ADDRESS, 0 ) )
  1319. {
  1320. m_nRunningMode = MODE_BACKUP;
  1321. m_pSensorArray->CommandLoop( m_nRunningMode );
  1322. for( int s = 0; s < m_pSensorArray->GetSocketCount(); s++ )
  1323. if( m_pSensorArray->GetSocket( s )->GetType() == SOCKET_BACKUP )
  1324. {
  1325. ((CSocketBackup*)m_pSensorArray->GetSocket( s ))->SetBackup();
  1326. ((CSocketBackup*)m_pSensorArray->GetSocket( s ))->SetName( "Backup client" );
  1327. break;
  1328. }
  1329. m_pEventQueue->PostEvent( LGS_EVENT_BACKUP_TO_HOST, 0,0,0, RGB(0,0xFF,0), "host switched to backup" );
  1330. // m_pTroubleWnd->Delete( TROUBLE_BACKUP, 1 );
  1331. // m_pTroubleWnd->Add( TROUBLE_BACKUP, 1, "HOST ->BA CKUP", "Host mode computer switched to backup mode computer", RGB( 0, 0xFF, 0 ), RGB( 0, 0x7F, 0 ) );
  1332. // m_ToolBarDlg.SetModeText( "BACKUP" );
  1333. // Reposition( VIEW_BACKUP );
  1334. bNeedBeepStop = TRUE;
  1335. bNeedUpdate = TRUE;
  1336. m_bWaitConnect = FALSE;
  1337. }
  1338. }
  1339. break;
  1340. }
  1341. else
  1342. {
  1343. if( m_bWaitDisconnect && event.data16 == MAKEWORD( GPRU_SWITCH_ADDRESS, 0 ) )
  1344. {
  1345. // m_pTroubleWnd->Add( TROUBLE_BACKUP, 0, "ERROR BACK UP", "Program could not disconnect server from lines", 0xFF, 0 );
  1346. strcpy( event.pText, "can't disconnect server" );
  1347. m_bWaitDisconnect = FALSE;
  1348. }
  1349. else
  1350. if( m_bWaitConnect && event.data16 == MAKEWORD( GPRU_SWITCH_ADDRESS, 0 ) )
  1351. {
  1352. // m_pTroubleWnd->Add( TROUBLE_BACKUP, 0, "ERROR BACK UP", "Program could not connect server to lines", 0xFF, 0 );
  1353. strcpy( event.pText, "can't connect server" );
  1354. m_bWaitConnect = FALSE;
  1355. }
  1356. // else
  1357. // m_pTroubleWnd->Add( TROUBLE_GPRU_COMMAND, 0, "GPRU", "Program could not send GPRU command", 0xFF, 0 );
  1358. bNeedUpdate = TRUE;
  1359. bNeedBeep = TRUE;
  1360. }
  1361. bNeedEventWnd = TRUE;
  1362. bNeedStore = TRUE;
  1363. bNeedPrint = TRUE;
  1364. break;
  1365. case LGS_EVENT_BACKUP_TO_HOST:
  1366. bNeedEventWnd = TRUE;
  1367. bNeedStore = TRUE;
  1368. if( event.data8 ) bNeedBeep = TRUE;
  1369. else bNeedBeepStop = TRUE;
  1370. bNeedUpdate = TRUE;
  1371. bNeedPrint = TRUE;
  1372. break;
  1373. case LGS_EVENT_MANUAL_CAPTURE:
  1374. bNeedStore = TRUE;
  1375. bNeedCapture = TRUE;
  1376. break;
  1377. case LGS_EVENT_IMAGE_CAPTURE:
  1378. // display & discard bitmap
  1379. m_pTroubleListWnd->SetItemImage( event.pSensor, event.hBitmap );
  1380. break;
  1381. }
  1382. if( bNeedWave && m_bSoundEnabled )
  1383. {
  1384. /* const max = 10;
  1385. LPCTSTR ppFile[ max ];
  1386. int nCount = max;
  1387. if( pSensor->GetWaveSound( ppFile, nCount ) )
  1388. m_pAlarm->WaveStart( ppFile, nCount );
  1389. */ }
  1390. /*
  1391. if( bNeedPrint && m_Print.bPresent )
  1392. {
  1393. if( m_pEventPrinter->IsPrintFile() )
  1394. bNeedPrintDlg = TRUE;
  1395. m_pEventPrinter->PrintEvent( event );
  1396. }
  1397. */
  1398. if( bNeedStore )
  1399. {
  1400. StoreEvent( event );
  1401. if( bNeedCapture )
  1402. {
  1403. Capture( event );
  1404. }
  1405. }
  1406. if( bNeedEventWnd )
  1407. m_pEventWnd->AddHead( event );
  1408. // store all extended information
  1409. if( bNeedStoreExtendedLog || bNeedStore )
  1410. {
  1411. SYSTEMTIME cst;
  1412. FileTimeToSystemTime( (LPFILETIME)&event.time, &cst );
  1413. m_pSensorArray->StoreExtendedInfo( "%02d:%02d:%02d %02d/%02d/%02d %s", cst.wDay, cst.wMonth, cst.wYear, cst.wHour, cst.wMinute, cst.wSecond, event.pText );
  1414. }
  1415. }
  1416. // m_pReportDlg->EnablePrinter( m_Print.bPresent & !m_pEventPrinter->IsBusy() );
  1417. if( pSensorLast && !m_pSensorCurrent )
  1418. {
  1419. m_pSensorCurrent = pSensorLast;
  1420. SendMessage( WM_SENSOR_SHOW, (WPARAM)pSensorLast, (LPARAM)pSensorLast );
  1421. }
  1422. if( bNeedUpdate )
  1423. {
  1424. // if( m_pReportDlg->GetSafeHwnd() )
  1425. // m_pReportDlg->EndDialog( IDCANCEL );
  1426. SendMessage( WM_SENSOR_UPDATE, 0, 0 );
  1427. m_pSensorArray->CheckFilters();
  1428. }
  1429. if( bNeedBeepStop && !bNeedBeep )
  1430. m_pAlarm->Stop();
  1431. if( bNeedBeep && m_bSoundEnabled )
  1432. {
  1433. m_pAlarm->Start();
  1434. }
  1435. // start external alarm
  1436. if( bNeedBeep )
  1437. m_AlarmExternal.Beep( TRUE );
  1438. m_bTimerOdd = !m_bTimerOdd;
  1439. CDialog::OnTimer(nIDEvent);
  1440. /*
  1441. if( bNeedPrintDlg )
  1442. {
  1443. if( !m_Print.bDlg )
  1444. {
  1445. m_Print.bDlg = TRUE;
  1446. if( MessageBox( "Report printing is in progress, abort it?", "", MB_YESNO | MB_ICONEXCLAMATION ) == IDYES )
  1447. m_pEventPrinter->PrintFileAbort();
  1448. m_Print.bDlg = FALSE;
  1449. }
  1450. }
  1451. */
  1452. // last thing is to check command for all sensors
  1453. m_pSensorArray->CheckSensorsCommand();
  1454. // update report
  1455. m_pReport->OnTimer();
  1456. }
  1457. catch(...)
  1458. {
  1459. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CChicagoDlg::OnTimer"), _T("C++ Exception") );
  1460. }
  1461. // log info
  1462. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CChicagoDlg::OnTimer", "%d done.", nIDEvent );
  1463. }
  1464. void CChicagoDlg::OnSystemReset()
  1465. {
  1466. if( m_nRunningMode != MODE_MOBILEMAP && m_nRunningMode != MODE_BACKUP )
  1467. {
  1468. if( m_ResetDlg.DoModal()==IDOK )
  1469. {
  1470. // m_pSensorArray->Reset();
  1471. m_pAlarm->Stop();
  1472. m_bSoundEnabled = TRUE;
  1473. m_pSensorCurrent = NULL;
  1474. // Reposition( VIEW_MAIN );
  1475. m_pReport->Reset();
  1476. // notify call center about reset
  1477. m_pSensorArray->GetPhoneCallCenter().OnReset();
  1478. }
  1479. // stop external alarm
  1480. m_AlarmExternal.Beep( FALSE );
  1481. }
  1482. }
  1483. void CChicagoDlg::OnSystemEnable()
  1484. {
  1485. // if( Autorization() )
  1486. /*
  1487. if( m_nRunningMode != MODE_MOBILEMAP && m_nRunningMode != MODE_BACKUP )
  1488. {
  1489. CEnableDlg dlg( this );
  1490. dlg.SetParam( m_pSensorArray );
  1491. dlg.DoModal();
  1492. SendMessage( WM_SENSOR_UPDATE, 0, 0 );
  1493. }
  1494. */
  1495. }
  1496. LRESULT CChicagoDlg::OnWMEnableSensor(WPARAM wParam, LPARAM lParam)
  1497. {
  1498. // if( Autorization() )
  1499. if( m_nRunningMode != MODE_MOBILEMAP && m_nRunningMode != MODE_BACKUP )
  1500. {
  1501. CEnableDlg dlg( this );
  1502. dlg.SetParam( m_pSensorArray, (CSensor*)wParam );
  1503. dlg.DoModal();
  1504. SendMessage( WM_SENSOR_UPDATE, 0, 0 );
  1505. }
  1506. return 0;
  1507. }
  1508. LRESULT CChicagoDlg::OnWMEnableZone(WPARAM wParam, LPARAM lParam)
  1509. {
  1510. // if( Autorization() )
  1511. if( m_nRunningMode != MODE_MOBILEMAP && m_nRunningMode != MODE_BACKUP )
  1512. {
  1513. CEnableDlg dlg( this );
  1514. dlg.SetParam( m_pSensorArray, (CZone*)wParam );
  1515. dlg.DoModal();
  1516. SendMessage( WM_SENSOR_UPDATE, 0, 0 );
  1517. }
  1518. return 0;
  1519. }
  1520. LRESULT CChicagoDlg::OnWMEnableDTRBit(WPARAM wParam, LPARAM lParam)
  1521. {
  1522. // if( Autorization() )
  1523. if( m_nRunningMode != MODE_MOBILEMAP && m_nRunningMode != MODE_BACKUP )
  1524. {
  1525. CEnableDlg dlg( this );
  1526. dlg.SetParam( m_pSensorArray, (CSensor*)wParam, lParam );
  1527. dlg.DoModal();
  1528. SendMessage( WM_SENSOR_UPDATE, 0, 0 );
  1529. }
  1530. return 0;
  1531. }
  1532. void CChicagoDlg::OnSupportReport()
  1533. {
  1534. if( Autorization() )
  1535. m_pReport->Dlg_DoModal( GetSafeHwnd() );
  1536. }
  1537. void CChicagoDlg::OnSupportStatistic()
  1538. {
  1539. if( Autorization() )
  1540. m_pStatisticDlg->DoModal();
  1541. }
  1542. void CChicagoDlg::OnViewOptions()
  1543. {
  1544. }
  1545. void CChicagoDlg::OnSupportSound()
  1546. {
  1547. if( Autorization() )
  1548. m_pSoundDlg->DoModal();
  1549. }
  1550. void CChicagoDlg::OnSupportDatetime()
  1551. {
  1552. if( Autorization() )
  1553. {
  1554. CDateTimeDlg dtDlg( this );
  1555. dtDlg.DoModal();
  1556. }
  1557. }
  1558. void CChicagoDlg::OnSupportMute()
  1559. {
  1560. m_bSoundEnabled = FALSE;
  1561. m_pAlarm->Stop();
  1562. }
  1563. void CChicagoDlg::OnSupportGuard()
  1564. {
  1565. // switch( m_GuardDlg.DoModal( TRUE ) )
  1566. switch( m_pAutorizationDlg->DoModal( FALSE, TRUE, TRUE ) )
  1567. {
  1568. case IDRETRY:
  1569. // m_pTroubleDlg->SetTroubleText( (LPSTR)(LPCTSTR)m_pAutorizationDlg->GetErrorString() );
  1570. // m_pTroubleDlg->DoModal();
  1571. break;
  1572. case IDCANCEL:
  1573. case IDOK:
  1574. break;
  1575. }
  1576. }
  1577. LRESULT CChicagoDlg::OnWMShowTrouble(WPARAM wParam, LPARAM lParam)
  1578. {
  1579. // m_pTroubleDlg->SetTroubleText( (LPSTR)lParam );
  1580. // m_pTroubleDlg->DoModal();
  1581. return 0;
  1582. }
  1583. BOOL CChicagoDlg::PreTranslateMessage(MSG* pMsg)
  1584. {
  1585. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CChicagoDlg::PreTranslateMessage"), _T("Started...") );
  1586. switch( pMsg->message )
  1587. {
  1588. case WM_KEYDOWN:
  1589. case WM_SYSKEYDOWN:
  1590. return ::TranslateAccelerator( GetSafeHwnd(), m_hAccelerators, pMsg );
  1591. }
  1592. BOOL bResult = CDialog::PreTranslateMessage(pMsg);
  1593. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CChicagoDlg::PreTranslateMessage"), _T("Done") );
  1594. return bResult;
  1595. }
  1596. BOOL CChicagoDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  1597. {
  1598. return TRUE;//CDialog::OnHelpInfo(pHelpInfo);
  1599. }
  1600. BOOL CChicagoDlg::Autorization()
  1601. {
  1602. switch( m_pAutorizationDlg->DoModal( TRUE, FALSE, FALSE ) )
  1603. {
  1604. case IDRETRY:
  1605. // m_pTroubleDlg->SetTroubleText( (LPSTR)(LPCTSTR)m_pAutorizationDlg->GetErrorString() );
  1606. // m_pTroubleDlg->DoModal();
  1607. return FALSE;
  1608. case IDCANCEL:
  1609. return FALSE;
  1610. case IDOK:
  1611. return TRUE;
  1612. }
  1613. return FALSE;
  1614. }
  1615. LRESULT CChicagoDlg::OnWMAutorization(WPARAM wParam, LPARAM lParam)
  1616. {
  1617. return Autorization();
  1618. }
  1619. //DEL void CChicagoDlg::OnSupportPatrol()
  1620. //DEL {
  1621. //DEL m_pPatrolDlg->DoModal();
  1622. //DEL }
  1623. //DEL void CChicagoDlg::OnSupportVideoDisplay()
  1624. //DEL {
  1625. //DEL // m_pVideoWnd->DlgVideoDisplay();
  1626. //DEL }
  1627. //DEL void CChicagoDlg::OnSupportVideoSource()
  1628. //DEL {
  1629. //DEL // m_pVideoWnd->DlgVideoSource();
  1630. //DEL }
  1631. BOOL CAboutDlg::OnInitDialog()
  1632. {
  1633. CDialog::OnInitDialog();
  1634. m_BuildTime.SetWindowText( CString("Built on ") + CLgVersion::GetBuildTimeStr() );
  1635. return TRUE; // return TRUE unless you set the focus to a control
  1636. // EXCEPTION: OCX Property Pages should return FALSE
  1637. }
  1638. void CChicagoDlg::OnHelpAbout()
  1639. {
  1640. CAboutDlg dlg;
  1641. dlg.DoModal();
  1642. }
  1643. //DEL void CChicagoDlg::OnSupportCameras()
  1644. //DEL {
  1645. //DEL // m_pCameraDlg->DoModal();
  1646. //DEL }
  1647. void CChicagoDlg::Capture( EVENT& event )
  1648. {
  1649. if( event.id == LGS_EVENT_MANUAL_CAPTURE || event.target.bType == 111 )
  1650. {
  1651. if( event.pCamera )
  1652. {
  1653. m_pVideoCapture->Capture( NULL, event.pCamera, TRUE, event.image.liEventOffset, event.pan, event.tilt, event.zoom );
  1654. }
  1655. }
  1656. else
  1657. {
  1658. CSensor *pSensor = m_pSensorArray->GetSensor( event.data16 );
  1659. if( pSensor )
  1660. {
  1661. CVideoCamera *pVideoCamera = pSensor->GetVideoCamera();
  1662. if( pVideoCamera )
  1663. {
  1664. double pan, tilt, zoom, angle;
  1665. switch( pVideoCamera->GetType() )
  1666. {
  1667. case VC_FIX:
  1668. m_pVideoCapture->Capture( pSensor, pVideoCamera, FALSE, event.image.liEventOffset, 0, 0, 0 );
  1669. break;
  1670. case VC_PTZ:
  1671. switch( pSensor->GetType() )
  1672. {
  1673. case CSensor::LGS:
  1674. angle = event.target.dAngle - static_cast<CSensorLGS*>(pSensor)->GetZeroShift();
  1675. while( angle < 0.0 ) angle += 360.0;
  1676. while( angle >= 360.0 ) angle -= 360.0;
  1677. // capture video
  1678. if( pSensor->CameraTransform( event.target.bDevice ? 0 : 1, event.target.dAngle, event.target.dRange, &pan, &tilt, &zoom ) )
  1679. m_pVideoCapture->Capture( pSensor, pVideoCamera, FALSE, event.image.liEventOffset, pan, tilt, zoom );
  1680. break;
  1681. case CSensor::DC:
  1682. // zoom scale according to scale factor
  1683. event.zoom *= m_pSensorArray->GetProgramSettings().Capture.dZoomScale;
  1684. // capture video
  1685. m_pVideoCapture->Capture( pSensor, pVideoCamera, FALSE, event.image.liEventOffset, event.pan, event.tilt, event.zoom );
  1686. break;
  1687. }
  1688. break;
  1689. }
  1690. }
  1691. }
  1692. }
  1693. }
  1694. void CChicagoDlg::OnSupportInterfaceFly()
  1695. {
  1696. InterfaceEnableFly( TRUE );
  1697. }
  1698. void CChicagoDlg::OnSupportInterfaceFix()
  1699. {
  1700. InterfaceEnableFly( FALSE );
  1701. }
  1702. static void ThickFrameEnable( CWnd *pWnd, BOOL bEnable )
  1703. {
  1704. if( pWnd && pWnd->GetSafeHwnd() )
  1705. {
  1706. LONG dwStyle = ::GetWindowLong( pWnd->GetSafeHwnd(), GWL_STYLE );
  1707. if( bEnable )
  1708. ::SetWindowLong( pWnd->GetSafeHwnd(), GWL_STYLE, dwStyle | WS_THICKFRAME );
  1709. else
  1710. ::SetWindowLong( pWnd->GetSafeHwnd(), GWL_STYLE, dwStyle & ~WS_THICKFRAME );
  1711. }
  1712. }
  1713. void CChicagoDlg::InterfaceEnableFly( BOOL bEnable )
  1714. {
  1715. ThickFrameEnable( m_pWholeAreaWnd, bEnable );
  1716. ThickFrameEnable( m_pZoomAreaWnd, bEnable );
  1717. ThickFrameEnable( m_pPropertySensorDlg, bEnable );
  1718. ThickFrameEnable( m_pVideoFrameWnd, bEnable );
  1719. ThickFrameEnable( m_pVideoListWnd, bEnable );
  1720. ThickFrameEnable( m_pTroubleListWnd, bEnable );
  1721. ThickFrameEnable( m_pEventWnd, bEnable );
  1722. ThickFrameEnable( m_pToolBarDlg, bEnable );
  1723. for( int i = 0; i < CONTROL_COUNT; i++ )
  1724. ThickFrameEnable( m_pControlPanel[i], bEnable );
  1725. m_pMainMenu->CheckMenuRadioItem( IDM_SUPPORT_INTERFACE_FLY, IDM_SUPPORT_INTERFACE_FIX, bEnable ? IDM_SUPPORT_INTERFACE_FLY : IDM_SUPPORT_INTERFACE_FIX, MF_BYCOMMAND );
  1726. }
  1727. int CChicagoDlg::DoModal()
  1728. {
  1729. __try
  1730. {
  1731. return CDialog::DoModal();
  1732. }
  1733. __except(EXCEPTION_EXECUTE_HANDLER)
  1734. {
  1735. // log info
  1736. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, "CChicagoDlg::DoModal", "Exception 0x%08X", _exception_code() );
  1737. return 0;
  1738. }
  1739. }
  1740. BOOL CChicagoDlg::LoadControlDefaultSettings()
  1741. {
  1742. m_pControlRect[ CONTROL_VIDEO_MAIN ].SetRect( 0.5, 0.0, 1.0, 0.6 );
  1743. m_pControlRect[ CONTROL_VIDEO_NAVIGATE ].SetRect( 0.5, 0.6, 1.0, 0.8 );
  1744. m_pControlRect[ CONTROL_VIDEO_LIST ].SetRect( 0.5, 0.8, 1.0, 1.0 );
  1745. m_pControlRect[ CONTROL_WHOLE_MAP].SetRect( 0.0, 0.063, 0.25, 0.35 );
  1746. m_pControlRect[ CONTROL_ZOOM_MAP].SetRect( 0.25, 0.0, 0.5, 0.35 );
  1747. m_pControlRect[ CONTROL_TROUBLE_LIST].SetRect( 0.0, 0.35, 0.5, 0.8 );
  1748. m_pControlRect[ CONTROL_EVENT_LIST].SetRect( 0.0, 0.8, 0.35, 1.0 );
  1749. m_pControlRect[ CONTROL_SENSOR_PROPERTY].SetRect( 0.35, 0.8, 0.5, 1.0 );
  1750. m_pControlRect[ CONTROL_TOOLBAR].SetRect( 0.0, 0.0, 0.25, 0.063 );
  1751. m_pControlRect[ CONTROL_VIDEO_MAIN ].bVisible = TRUE;
  1752. m_pControlRect[ CONTROL_VIDEO_NAVIGATE ].bVisible = TRUE;
  1753. m_pControlRect[ CONTROL_VIDEO_LIST ].bVisible = TRUE;
  1754. m_pControlRect[ CONTROL_WHOLE_MAP].bVisible = TRUE;
  1755. m_pControlRect[ CONTROL_ZOOM_MAP].bVisible = TRUE;
  1756. m_pControlRect[ CONTROL_TROUBLE_LIST].bVisible = TRUE;
  1757. m_pControlRect[ CONTROL_EVENT_LIST].bVisible = TRUE;
  1758. m_pControlRect[ CONTROL_SENSOR_PROPERTY].bVisible = TRUE;
  1759. m_pControlRect[ CONTROL_TOOLBAR].bVisible = TRUE;
  1760. return TRUE;
  1761. }
  1762. BOOL CChicagoDlg::LoadControlSettings()
  1763. {
  1764. LoadControlDefaultSettings();
  1765. m_Settings.Load( "CONTROL_VIDEO_MAIN", &m_pControlRect[CONTROL_VIDEO_MAIN] );
  1766. m_Settings.Load( "CONTROL_VIDEO_NAVIGATE", &m_pControlRect[CONTROL_VIDEO_NAVIGATE] );
  1767. m_Settings.Load( "CONTROL_VIDEO_LIST", &m_pControlRect[CONTROL_VIDEO_LIST] );
  1768. m_Settings.Load( "CONTROL_WHOLE_MAP", &m_pControlRect[CONTROL_WHOLE_MAP] );
  1769. m_Settings.Load( "CONTROL_ZOOM_MAP", &m_pControlRect[CONTROL_ZOOM_MAP] );
  1770. m_Settings.Load( "CONTROL_TROUBLE_LIST", &m_pControlRect[CONTROL_TROUBLE_LIST] );
  1771. m_Settings.Load( "CONTROL_EVENT_LIST", &m_pControlRect[CONTROL_EVENT_LIST] );
  1772. m_Settings.Load( "CONTROL_SENSOR_PROPERTY", &m_pControlRect[CONTROL_SENSOR_PROPERTY] );
  1773. m_Settings.Load( "CONTROL_TOOLBAR", &m_pControlRect[CONTROL_TOOLBAR] );
  1774. m_Settings.Load( "CONTROL_VIDEO_MAIN_VISIBLE", &m_pControlRect[CONTROL_VIDEO_MAIN].bVisible );
  1775. m_Settings.Load( "CONTROL_VIDEO_NAVIGATE_VISIBLE", &m_pControlRect[CONTROL_VIDEO_NAVIGATE].bVisible );
  1776. m_Settings.Load( "CONTROL_VIDEO_LIST_VISIBLE", &m_pControlRect[CONTROL_VIDEO_LIST].bVisible );
  1777. m_Settings.Load( "CONTROL_WHOLE_MAP_VISIBLE", &m_pControlRect[CONTROL_WHOLE_MAP].bVisible );
  1778. m_Settings.Load( "CONTROL_ZOOM_MAP_VISIBLE", &m_pControlRect[CONTROL_ZOOM_MAP].bVisible );
  1779. m_Settings.Load( "CONTROL_TROUBLE_LIST_VISIBLE", &m_pControlRect[CONTROL_TROUBLE_LIST].bVisible );
  1780. m_Settings.Load( "CONTROL_EVENT_LIST_VISIBLE", &m_pControlRect[CONTROL_EVENT_LIST].bVisible );
  1781. m_Settings.Load( "CONTROL_SENSOR_PROPERTY_VISIBLE", &m_pControlRect[CONTROL_SENSOR_PROPERTY].bVisible );
  1782. m_Settings.Load( "CONTROL_TOOLBAR_VISIBLE", &m_pControlRect[CONTROL_TOOLBAR].bVisible );
  1783. return TRUE;
  1784. }
  1785. BOOL CChicagoDlg::SaveControlSettings()
  1786. {
  1787. CRect pRect[CONTROL_COUNT];
  1788. if( m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->GetSafeHwnd() )
  1789. {
  1790. m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->GetWindowRect( &pRect[ CONTROL_VIDEO_NAVIGATE ] );
  1791. m_pControlRect[ CONTROL_VIDEO_NAVIGATE ].bVisible = m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->IsWindowVisible();
  1792. }
  1793. if( m_pPropertySensorDlg->GetSafeHwnd() )
  1794. {
  1795. m_pPropertySensorDlg->GetWindowRect( &pRect[ CONTROL_SENSOR_PROPERTY ] );
  1796. m_pControlRect[ CONTROL_SENSOR_PROPERTY ].bVisible = m_pPropertySensorDlg->IsWindowVisible();
  1797. }
  1798. if( m_pTroubleListWnd->GetSafeHwnd() )
  1799. {
  1800. m_pTroubleListWnd->GetWindowRect( &pRect[ CONTROL_TROUBLE_LIST ] );
  1801. m_pControlRect[ CONTROL_TROUBLE_LIST ].bVisible = m_pTroubleListWnd->IsWindowVisible();
  1802. }
  1803. if( m_pEventWnd->GetSafeHwnd() )
  1804. {
  1805. m_pEventWnd->GetWindowRect( &pRect[ CONTROL_EVENT_LIST ] );
  1806. m_pControlRect[ CONTROL_EVENT_LIST ].bVisible = m_pEventWnd->IsWindowVisible();
  1807. }
  1808. if( m_pVideoFrameWnd->GetSafeHwnd() )
  1809. {
  1810. m_pVideoFrameWnd->GetWindowRect( &pRect[ CONTROL_VIDEO_MAIN ] );
  1811. m_pControlRect[ CONTROL_VIDEO_MAIN ].bVisible = m_pVideoFrameWnd->IsWindowVisible();
  1812. }
  1813. if( m_pVideoListWnd->GetSafeHwnd() )
  1814. {
  1815. m_pVideoListWnd->GetWindowRect( &pRect[ CONTROL_VIDEO_LIST ] );
  1816. m_pControlRect[ CONTROL_VIDEO_LIST ].bVisible = m_pVideoListWnd->IsWindowVisible();
  1817. }
  1818. if( m_pWholeAreaWnd->GetSafeHwnd() )
  1819. {
  1820. m_pWholeAreaWnd->GetWindowRect( &pRect[ CONTROL_WHOLE_MAP ] );
  1821. m_pControlRect[ CONTROL_WHOLE_MAP ].bVisible = m_pWholeAreaWnd->IsWindowVisible();
  1822. }
  1823. if( m_pZoomAreaWnd->GetSafeHwnd() )
  1824. {
  1825. m_pZoomAreaWnd->GetWindowRect( &pRect[ CONTROL_ZOOM_MAP ] );
  1826. m_pControlRect[ CONTROL_ZOOM_MAP ].bVisible = m_pZoomAreaWnd->IsWindowVisible();
  1827. }
  1828. if( m_pToolBarDlg->GetSafeHwnd() )
  1829. {
  1830. m_pToolBarDlg->GetWindowRect( &pRect[ CONTROL_TOOLBAR ] );
  1831. m_pControlRect[ CONTROL_TOOLBAR ].bVisible = m_pToolBarDlg->IsWindowVisible();
  1832. }
  1833. CRect rect;
  1834. GetClientRect( &rect );
  1835. double dWidth = rect.Width();
  1836. double dHeight = rect.Height();
  1837. for( int i = 0; i < CONTROL_COUNT; i++ )
  1838. {
  1839. ::MapWindowPoints( HWND_DESKTOP, GetSafeHwnd(), (LPPOINT)&pRect[i], 2 );
  1840. m_pControlRect[i].SetRect( pRect[i].left / dWidth, pRect[i].top / dHeight,
  1841. pRect[i].right / dWidth, pRect[i].bottom / dHeight );
  1842. }
  1843. m_Settings.Save( "CONTROL_VIDEO_MAIN", &m_pControlRect[CONTROL_VIDEO_MAIN] );
  1844. m_Settings.Save( "CONTROL_VIDEO_NAVIGATE", &m_pControlRect[CONTROL_VIDEO_NAVIGATE] );
  1845. m_Settings.Save( "CONTROL_VIDEO_LIST", &m_pControlRect[CONTROL_VIDEO_LIST] );
  1846. m_Settings.Save( "CONTROL_WHOLE_MAP", &m_pControlRect[CONTROL_WHOLE_MAP] );
  1847. m_Settings.Save( "CONTROL_ZOOM_MAP", &m_pControlRect[CONTROL_ZOOM_MAP] );
  1848. m_Settings.Save( "CONTROL_TROUBLE_LIST", &m_pControlRect[CONTROL_TROUBLE_LIST] );
  1849. m_Settings.Save( "CONTROL_EVENT_LIST", &m_pControlRect[CONTROL_EVENT_LIST] );
  1850. m_Settings.Save( "CONTROL_SENSOR_PROPERTY", &m_pControlRect[CONTROL_SENSOR_PROPERTY] );
  1851. m_Settings.Save( "CONTROL_TOOLBAR", &m_pControlRect[CONTROL_TOOLBAR] );
  1852. m_Settings.Save( "CONTROL_VIDEO_MAIN_VISIBLE", m_pControlRect[CONTROL_VIDEO_MAIN].bVisible );
  1853. m_Settings.Save( "CONTROL_VIDEO_NAVIGATE_VISIBLE", m_pControlRect[CONTROL_VIDEO_NAVIGATE].bVisible );
  1854. m_Settings.Save( "CONTROL_VIDEO_LIST_VISIBLE", m_pControlRect[CONTROL_VIDEO_LIST].bVisible );
  1855. m_Settings.Save( "CONTROL_WHOLE_MAP_VISIBLE", m_pControlRect[CONTROL_WHOLE_MAP].bVisible );
  1856. m_Settings.Save( "CONTROL_ZOOM_MAP_VISIBLE", m_pControlRect[CONTROL_ZOOM_MAP].bVisible );
  1857. m_Settings.Save( "CONTROL_TROUBLE_LIST_VISIBLE", m_pControlRect[CONTROL_TROUBLE_LIST].bVisible );
  1858. m_Settings.Save( "CONTROL_EVENT_LIST_VISIBLE", m_pControlRect[CONTROL_EVENT_LIST].bVisible );
  1859. m_Settings.Save( "CONTROL_SENSOR_PROPERTY_VISIBLE", m_pControlRect[CONTROL_SENSOR_PROPERTY].bVisible );
  1860. m_Settings.Save( "CONTROL_TOOLBAR_VISIBLE", m_pControlRect[CONTROL_TOOLBAR].bVisible );
  1861. return TRUE;
  1862. }
  1863. void CChicagoDlg::OnSupportLgsReset()
  1864. {
  1865. m_ResetLgsDlg.DoModal();
  1866. }
  1867. void CChicagoDlg::OnSupportInterfaceDefault()
  1868. {
  1869. if( MessageBox( _T("Load default interface?"), _T("Confirmation"), MB_YESNO | MB_ICONQUESTION ) == IDYES )
  1870. {
  1871. LoadControlDefaultSettings();
  1872. Reposition(VIEW_MAIN);
  1873. // InterfaceEnableFly( FALSE );
  1874. }
  1875. }
  1876. void CChicagoDlg::OnSupportVideoSettings()
  1877. {
  1878. CVideoSettingsDlg dlg( this );
  1879. dlg.DoModal( m_pVideoBase, m_pSensorArray );
  1880. }
  1881. void CChicagoDlg::CheckCopyright()
  1882. {
  1883. WINDOWINFO wi;
  1884. wi.cbSize = sizeof(WINDOWINFO);
  1885. ::GetWindowInfo( GetSafeHwnd(), &wi );
  1886. if( ( wi.dwStyle & WS_CAPTION ) != WS_CAPTION ||
  1887. wi.rcWindow.left != 0 || wi.rcWindow.right != ::GetSystemMetrics( SM_CXSCREEN ) ||
  1888. wi.rcWindow.top != 0 || wi.rcWindow.bottom != ::GetSystemMetrics( SM_CYSCREEN ) )
  1889. {
  1890. ::SetWindowLong( GetSafeHwnd(), GWL_STYLE, GetWindowLong( GetSafeHwnd(), GWL_STYLE ) | WS_CAPTION );
  1891. SetWindowPos( &CWnd::wndTop, 0, 0, ::GetSystemMetrics( SM_CXSCREEN ), ::GetSystemMetrics( SM_CYSCREEN ), SWP_FRAMECHANGED );
  1892. }
  1893. CString str;
  1894. GetWindowText( str );
  1895. if( str != m_pSensorArray->GetCopyright() )
  1896. SetWindowText( m_pSensorArray->GetCopyright() );
  1897. }
  1898. LRESULT CChicagoDlg::OnWMPowerBroadcast( WPARAM wParam, LPARAM lParam )
  1899. {
  1900. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnWMPowerBroadcast" );
  1901. // deny all tries to go to save mode
  1902. return BROADCAST_QUERY_DENY;
  1903. }
  1904. void CChicagoDlg::OnSupportSettings()
  1905. {
  1906. CSettingsDlg dlg;
  1907. if( dlg.DoModal( m_pSensorArray ) == IDOK )
  1908. {
  1909. m_pEventWnd->OnChangeSettings();
  1910. m_pVideoBase->OnChangeSettings();
  1911. m_AlarmExternal.OnChangeSettings( m_pSensorArray->GetProgramSettings() );
  1912. m_pReport->SetMaxStoreTime( m_pSensorArray->GetProgramSettings().nReportDays );
  1913. }
  1914. }
  1915. void CChicagoDlg::OnSupportReportSettings()
  1916. {
  1917. if( m_pReport )
  1918. m_pReport->DlgSetup_DoModal( GetSafeHwnd() );
  1919. }
  1920. void CChicagoDlg::OnSupportPhonecalllist()
  1921. {
  1922. CPhoneDlg dlg( this );
  1923. dlg.DoModal( m_pSensorArray );
  1924. }
  1925. void CChicagoDlg::OnViewEvents()
  1926. {
  1927. BOOL bShow = !m_pEventWnd->IsWindowVisible();
  1928. m_pEventWnd->ShowWindow( bShow );
  1929. m_pMainMenu->CheckMenuItem( ID_VIEW_EVENTS, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) );
  1930. }
  1931. void CChicagoDlg::OnViewMagnifiedmap()
  1932. {
  1933. BOOL bShow = !m_pZoomAreaWnd->IsWindowVisible();
  1934. m_pZoomAreaWnd->ShowWindow( bShow );
  1935. m_pMainMenu->CheckMenuItem( ID_VIEW_MAGNIFIEDMAP, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) );
  1936. }
  1937. void CChicagoDlg::OnViewMap()
  1938. {
  1939. BOOL bShow = !m_pWholeAreaWnd->IsWindowVisible();
  1940. m_pWholeAreaWnd->ShowWindow( bShow );
  1941. m_pMainMenu->CheckMenuItem( ID_VIEW_MAP, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) );
  1942. }
  1943. void CChicagoDlg::OnViewPtzcontrol()
  1944. {
  1945. BOOL bShow = !m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->IsWindowVisible();
  1946. m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->ShowWindow( bShow );
  1947. m_pMainMenu->CheckMenuItem( ID_VIEW_PTZCONTROL, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) );
  1948. }
  1949. void CChicagoDlg::OnViewSensorproperties()
  1950. {
  1951. BOOL bShow = !m_pPropertySensorDlg->IsWindowVisible();
  1952. m_pPropertySensorDlg->ShowWindow( bShow );
  1953. m_pMainMenu->CheckMenuItem( ID_VIEW_SENSORPROPERTIES, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) );
  1954. }
  1955. void CChicagoDlg::OnViewTroubles()
  1956. {
  1957. BOOL bShow = !m_pTroubleListWnd->IsWindowVisible();
  1958. m_pTroubleListWnd->ShowWindow( bShow );
  1959. m_pMainMenu->CheckMenuItem( ID_VIEW_TROUBLES, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) );
  1960. }
  1961. void CChicagoDlg::OnViewVideo()
  1962. {
  1963. BOOL bShow = !m_pVideoFrameWnd->IsWindowVisible();
  1964. m_pVideoFrameWnd->ShowWindow( bShow );
  1965. m_pMainMenu->CheckMenuItem( ID_VIEW_VIDEO, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) );
  1966. }
  1967. void CChicagoDlg::OnViewVideolist()
  1968. {
  1969. BOOL bShow = !m_pVideoListWnd->IsWindowVisible();
  1970. m_pVideoListWnd->ShowWindow( bShow );
  1971. m_pMainMenu->CheckMenuItem( ID_VIEW_VIDEOLIST, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) );
  1972. }
  1973. void CChicagoDlg::OnViewToolbar()
  1974. {
  1975. BOOL bShow = !m_pToolBarDlg->IsWindowVisible();
  1976. m_pToolBarDlg->ShowWindow( bShow );
  1977. m_pMainMenu->CheckMenuItem( ID_VIEW_TOOLBAR, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) );
  1978. }
  1979. void CChicagoDlg::OnSupportLgsHzSchedule()
  1980. {
  1981. CLgMaskScheduleLgsArray array;
  1982. for( INT i = 0; i < m_pSensorArray->GetSensorCount(); i++ )
  1983. {
  1984. CSensor *pSensor = m_pSensorArray->GetSensor(i);
  1985. if( pSensor->GetType() != CVisual::LGS )
  1986. continue;
  1987. CLgMaskScheduleLgs lgs;
  1988. lgs.dwId = i;
  1989. _tcscpy( lgs.pName, pSensor->GetName() );
  1990. array.Add( lgs );
  1991. }
  1992. CLgMaskScheduleDlg dlg;
  1993. dlg.DoModal( m_pMaskSchedule, &array, GetSafeHwnd() );
  1994. m_pMaskSchedule->Save();
  1995. }
  1996. void CChicagoDlg::SwitchMask( INT nLgsId, INT nMask, BOOL bOn )
  1997. {
  1998. CSensorLGS *pSensor = (CSensorLGS*)m_pSensorArray->GetSensor( nLgsId );
  1999. if( !pSensor )
  2000. return;
  2001. pSensor->SwitchHZ( nMask, bOn );
  2002. }
  2003. void CChicagoDlg::OnSystemRepair()
  2004. {
  2005. if( MessageBox( _T("System will be ineffective for about 1 minute. Are you sure to make full system reset?"), _T("Warning"), MB_YESNO | MB_ICONEXCLAMATION ) != IDYES )
  2006. return;
  2007. // post event
  2008. m_pSensorArray->GetEventQueue()->PostEvent( LGS_EVENT_SYSTEM_REPAIR, 0, 0, 0, RGB(0xFF,0xFF,0xFF), (LPSTR)(LPCTSTR)_T("Full system repair") );
  2009. // initiate full system repair process
  2010. m_pSensorArray->FullSystemRepair();
  2011. // show dialog panel
  2012. CRepairDlg dlg( this );
  2013. if( dlg.DoModal() != IDOK )
  2014. return;
  2015. // issue system stop
  2016. OnCancel();
  2017. // notify main app class that should be made restart
  2018. CChicagoApp *pApplication = static_cast<CChicagoApp*>( AfxGetApp() );
  2019. if( !pApplication )
  2020. {
  2021. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CChicagoDlg::OnSystemRepair"), _T("Can't get application") );
  2022. return;
  2023. }
  2024. pApplication->SetRestart();
  2025. }