//---------------------------------------------------------------------------- // Laser Guard Ltd. // Copyright © 2000-2002. All Rights Reserved. // Version 1.0 01/01/2000 // Last modification: 12/11/2003 // PROJECT: // SUBSYSTEM: // FILE: ChicagoDlg.cpp // AUTHOR: Sergey Chizhevskiy // OVERVIEW // ~~~~~~~~ // Source file of ChicagoDlg.cpp //---------------------------------------------------------------------------- // ChicagoDlg.cpp : implementation file // #include "stdafx.h" #include "Chicago.h" #include "ChicagoDlg.h" #include "..\DLIB\AuxLib.h" #include "..\DLIB\EventQueue.h" #include "..\DLIB\SocketBackup.h" #include "..\..\LgLib\Version.h" #include "..\..\LgLib\MaskSchedule\LgMaskScheduleDlg.h" #include "..\DLIB\ObjectFactory.h" #include "EnableDlg.h" #include "StatisticDlg.h" #include "ViewOptionsDlg.h" #include "ProgramModeDlg.h" #include "DateTimeDlg.h" #include "VideoSettingsDlg.h" #include "SetupDlg.h" #include "SettingsDlg.h" #include "PhoneDlg.h" #include "RepairDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; CStatic m_BuildTime; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(CAboutDlg) virtual BOOL OnInitDialog(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) DDX_Control(pDX, IDC_STATIC_BUILD_TIME, m_BuildTime); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CChicagoDlg dialog CChicagoDlg::CChicagoDlg(CWnd* pParent /*=NULL*/) : CDialog(CChicagoDlg::IDD, pParent) { //{{AFX_DATA_INIT(CChicagoDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); // m_pSensorEvent = NULL; m_pAutorizationDlg = NULL; // ::ZeroMemory( &m_Print, sizeof(m_Print) ); // m_ScaleFactor = 1; m_pSensorCurrent = NULL; m_bStarted = FALSE; m_bWaitDisconnect = FALSE; m_bWaitConnect = FALSE; // m_Print.bDlg = FALSE; m_nViewMode = VIEW_NONE; m_bSoundEnabled = TRUE; m_pVideoFrameWnd = NULL; m_pVideoFrameWnd = NULL; m_pVideoBase = NULL; m_pVideoListWnd = NULL; m_pWholeAreaWnd = NULL; m_pZoomAreaWnd = NULL; m_pTroubleListWnd = NULL; m_pCameraNavigateDlg = NULL; for( int i = 0; i < CONTROL_COUNT; i++ ) { m_pControlPanel[ i ] = NULL; } m_bDebugMode = FALSE; m_pVideoWnd = NULL; m_pReport = NULL; LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CChicagoDlg::CChicagoDlg") ); } void CChicagoDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CChicagoDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CChicagoDlg, CDialog) //{{AFX_MSG_MAP(CChicagoDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_WM_NCLBUTTONDOWN() ON_WM_NCLBUTTONDBLCLK() ON_COMMAND(IDM_VIEW_MAIN, OnViewMain) ON_COMMAND(IDM_VIEW_DETAIL, OnViewAlarm) ON_WM_INITMENU() ON_WM_TIMER() ON_COMMAND(IDM_SYSTEM_RESET, OnSystemReset) ON_COMMAND(IDM_SYSTEM_ENABLE, OnSystemEnable) ON_COMMAND( IDM_SUPPORT_REPORT, OnSupportReport ) ON_COMMAND(IDM_SUPPORT_STATISTIC, OnSupportStatistic) ON_COMMAND(IDM_VIEW_OPTIONS, OnViewOptions) ON_COMMAND(IDM_SUPPORT_SOUND, OnSupportSound) ON_COMMAND(IDM_SUPPORT_DATETIME, OnSupportDatetime) ON_COMMAND(IDM_SUPPORT_MUTE, OnSupportMute) ON_COMMAND(IDM_SUPPORT_GUARD, OnSupportGuard) ON_WM_HELPINFO() ON_COMMAND(IDM_HELP_ABOUT, OnHelpAbout) ON_COMMAND(IDM_SUPPORT_INTERFACE_FLY, OnSupportInterfaceFly) ON_COMMAND(IDM_SUPPORT_INTERFACE_FIX, OnSupportInterfaceFix) ON_COMMAND(IDM_SUPPORT_LGS_RESET, OnSupportLgsReset) ON_COMMAND(IDM_SUPPORT_INTERFACE_DEFAULT, OnSupportInterfaceDefault) ON_COMMAND(IDM_SUPPORT_VIDEO_SETTINGS, OnSupportVideoSettings) ON_COMMAND(ID_SUPPORT_SETTINGS, OnSupportSettings) ON_COMMAND(ID_SUPPORT_REPORTSETTINGS, OnSupportReportSettings) ON_COMMAND(ID_SUPPORT_PHONECALLLIST, OnSupportPhonecalllist) ON_COMMAND(ID_VIEW_EVENTS, OnViewEvents) ON_COMMAND(ID_VIEW_MAGNIFIEDMAP, OnViewMagnifiedmap) ON_COMMAND(ID_VIEW_MAP, OnViewMap) ON_COMMAND(ID_VIEW_PTZCONTROL, OnViewPtzcontrol) ON_COMMAND(ID_VIEW_SENSORPROPERTIES, OnViewSensorproperties) ON_COMMAND(ID_VIEW_TROUBLES, OnViewTroubles) ON_COMMAND(ID_VIEW_VIDEO, OnViewVideo) ON_COMMAND(ID_VIEW_VIDEOLIST, OnViewVideolist) ON_COMMAND(ID_VIEW_TOOLBAR, OnViewToolbar) ON_WM_DESTROY() ON_MESSAGE( WM_SENSOR_SHOW, OnWMSensorShow ) ON_MESSAGE( WM_SENSOR_UPDATE, OnWMSensorUpdate ) ON_MESSAGE( WM_ENABLE_SENSOR, OnWMEnableSensor ) ON_MESSAGE( WM_ENABLE_ZONE, OnWMEnableZone ) ON_MESSAGE( WM_ENABLE_DTRBIT, OnWMEnableDTRBit ) // ON_MESSAGE( WM_PRINT_FILE, OnWMPrintFile ) ON_MESSAGE( WM_SHOW_TROUBLE, OnWMShowTrouble ) ON_MESSAGE( WM_AUTORIZATION, OnWMAutorization ) ON_MESSAGE( WM_AUTORIZATION, OnWMAutorization ) ON_MESSAGE( WM_POWERBROADCAST, OnWMPowerBroadcast ) ON_COMMAND(IDM_SYSTEM_EXIT, OnCancel) ON_COMMAND(ID_SUPPORT_LGSHZSCHEDULE, OnSupportLgsHzSchedule) ON_COMMAND(IDM_SYSTEM_REPAIR, OnSystemRepair) //}}AFX_MSG_MAP END_MESSAGE_MAP() BOOL CChicagoDlg::OnInitDialog() { CDialog::OnInitDialog(); CWinApp *pApp = AfxGetApp(); ASSERT( pApp ); LPCTSTR pCmdLine = pApp->m_lpCmdLine; m_bDebugMode = (_tcsstr( pCmdLine, _T("DEBUG") ) != NULL) || (_tcsstr( pCmdLine, _T("debug") ) != NULL); m_bDemoMode = (_tcsstr( pCmdLine, _T("DEMO") ) != NULL) || (_tcsstr( pCmdLine, _T("demo") ) != NULL); // select best program mode DEVMODE DevMode, DevModeBest; memset( &DevMode, 0, sizeof(DevMode) ); DevMode.dmSize = sizeof(DevMode); DevMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; DevModeBest = DevMode; if( ::EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &DevModeBest ) ) { BOOL bBestModePresent = FALSE; switch( DevModeBest.dmBitsPerPel ) { case 8: case 15: case 16: case 32: bBestModePresent = TRUE; break; } if( !bBestModePresent ) { BOOL bBestModeFound = FALSE; for( INT nDisplayMode = 0; ; nDisplayMode++ ) { if( !::EnumDisplaySettings( NULL, nDisplayMode, &DevMode ) ) break; switch( DevMode.dmBitsPerPel ) { case 8: case 15: case 16: case 32: if( ( DevModeBest.dmBitsPerPel < DevMode.dmBitsPerPel || DevModeBest.dmDisplayFrequency < DevMode.dmDisplayFrequency ) && DevModeBest.dmPelsWidth == DevMode.dmPelsWidth && DevModeBest.dmPelsHeight == DevMode.dmPelsHeight ) { DevModeBest = DevMode; bBestModeFound = TRUE; } break; } 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 ); } if( bBestModeFound ) ::ChangeDisplaySettings( &DevModeBest, 0 ); } } SetIcon(m_hIcon, TRUE); SetIcon(m_hIcon, FALSE); srand( ::GetTickCount() ); CString strSetupFileName = _T("setup.lgs"); if( m_bDebugMode ) { CSetupDlg SetupDlg; if( SetupDlg.DoModal() != IDOK ) { EndDialog( IDOK ); return TRUE; } strSetupFileName = SetupDlg.GetSetupName(); } m_hAccelerators = ::LoadAccelerators( AfxGetInstanceHandle(), (LPCTSTR)IDR_ACCELERATORS ); m_TaskSwitch.Lock(); m_Settings.Create( _T("LaserGuard\\ISSC") ); LoadControlSettings(); m_nRunningMode = MODE_HOST; m_pMainMenu = new CMenu; //+++ switch( m_nRunningMode ) { case MODE_HOST: m_pMainMenu->LoadMenu( IDR_MENU_HOST ); SetMenu( m_pMainMenu ); break; case MODE_MOBILEMAP: m_pMainMenu->LoadMenu( IDR_MENU_MOBILEMAP ); SetWindowLong( GetSafeHwnd(), GWL_STYLE, GetWindowLong( GetSafeHwnd(), GWL_STYLE ) ^ WS_CAPTION ); break; case MODE_BACKUP: m_pMainMenu->LoadMenu( IDR_MENU_HOST ); SetMenu( m_pMainMenu ); break; } LOGFONT lf; lf.lfHeight = -10; lf.lfWidth = 0; lf.lfEscapement = 0; lf.lfOrientation = 0; lf.lfWeight = 1000; lf.lfItalic = FALSE; lf.lfUnderline = FALSE; lf.lfStrikeOut = FALSE; lf.lfCharSet = OEM_CHARSET; lf.lfOutPrecision = OUT_DEFAULT_PRECIS; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; lf.lfQuality = DEFAULT_QUALITY; lf.lfPitchAndFamily = FIXED_PITCH|FF_MODERN; strcpy( lf.lfFaceName, "Courier" ); m_pFont = new CFont(); m_pFont->CreateFontIndirect( &lf ); SetFont( m_pFont ); m_pAlarm = new CLgAlarm(); m_pAlarm->Create( _T("ISSC.wav") ); #ifdef _DEBUG m_pAlarm->Enable( TRUE ); #else m_pAlarm->Enable( TRUE ); #endif m_pEventQueue = new CEventQueue(); m_pSensorArray = new CSensorArray(); m_pSensorArray->SetEventQueue( m_pEventQueue ); m_pSensorArray->SetEventWnd( GetSafeHwnd() ); m_pSensorArray->SetDebugMode( m_bDebugMode ); if( !m_pSensorArray->Load( strSetupFileName, m_nRunningMode, &m_Settings, m_bDemoMode ) ) { MessageBox( "Error loading configuration" ); CDialog::OnCancel(); return FALSE; } m_pReport = new CReport(); m_pReport->SetSensorArray( m_pSensorArray ); m_pReport->Create( _T("\\REPORT"), m_pSensorArray->GetProgramSettings().nReportDays ); // create external alarm m_AlarmExternal.Create( m_pSensorArray->GetProgramSettings() ); CRect rectClient; GetClientRect( &rectClient ); m_pPropertySensorDlg = new CPropertySensorFrameWnd(); m_pPropertySensorDlg->Create( this, 0,0, 1,1 ); m_pEventWnd = new CEventWnd(); m_pEventWnd->SetSensorArray( m_pSensorArray ); m_pEventWnd->Create( NULL, NULL, WS_CHILD, rectClient, this, 0UL ); m_ResetDlg.SetSensorArray( m_pSensorArray ); m_ResetLgsDlg.SetSensorArray( m_pSensorArray ); m_pStatisticDlg = new CStatisticDlg( this ); m_pStatisticDlg->SetSensorArray( m_pSensorArray ); m_pPatrolDlg = new CPatrolDlg; /*+++*/ m_pPatrolDlg->SetSensorArray( m_pSensorArray ); m_pToolBarDlg = new CToolBarDlg; /*+++*/ m_pToolBarDlg->Create( IDD_TOOLBAR_DLG, this, m_pMainMenu ); switch( m_nRunningMode ) { case MODE_HOST: m_pToolBarDlg->SetModeText( "HOST" ); break; case MODE_MOBILEMAP: m_pToolBarDlg->SetModeText( "" ); break; case MODE_BACKUP: m_pToolBarDlg->SetModeText( "BACKUP" ); break; } m_pSoundDlg = new CSoundDlg; /*+++*/ m_pSoundDlg->SetSensorArray( m_pSensorArray ); m_pGuardDlg = new CGuardDlg; /*+++*/ m_pGuardDlg->SetSensorArray( m_pSensorArray ); m_pVideoCapture = new CVideoCapture(); m_pVideoCapture->SetSensorArray( m_pSensorArray ); m_pVideoCapture->SetReport( m_pReport ); m_pAutorizationDlg = new CAutorizationDlg( this ); m_pAutorizationDlg->SetSensorArray( m_pSensorArray ); m_pAutorizationDlg->Enable( m_pSensorArray->GetOptions().bNeedAutorization ); m_pVideoBase = new CVideoBase; m_pVideoBase->SetSensorArray( m_pSensorArray ); if( !m_pVideoBase->Create( this, &m_Settings ) ) MessageBox( "Not enough video capturing boards for this configuration.\nProgram will work incorrectly!" ); m_pVideoFrameWnd = new CVideoFrameWnd; m_pVideoFrameWnd->Create( this, 0, 0, 120, 120 ); m_pVideoListWnd = new CVideoListWnd; m_pVideoListWnd->Create( this, -100, -100, 10, 10 ); // attach video windows to main window and to list window for( int i = 0; i < m_pVideoBase->GetVideoWndCount(); i++ ) { if( i == 0 ) m_pVideoFrameWnd->SetVideoWnd( m_pVideoBase->GetVideoWnd(i) ); else m_pVideoListWnd->Add( m_pVideoBase->GetVideoWnd(i) ); } m_pWholeAreaWnd = new CWholeAreaWnd(); m_pWholeAreaWnd->Create( this, m_pSensorArray->GetBackground(), 0,0,10,10 ); m_pWholeAreaWnd->ShowWindow( SW_SHOW ); m_pZoomAreaWnd = new CLgUIMapZoomWnd(); m_pZoomAreaWnd->Create( this, m_pSensorArray->GetBackground(), 0,0,10,10 ); m_pZoomAreaWnd->SetScale( 3 ); m_pZoomAreaWnd->ShowWindow( SW_SHOW ); m_pZoomAreaWnd->CLgLinkS::Link( m_pWholeAreaWnd ); { // register objects in map for( INT i = 0; i < m_pSensorArray->GetSensorCount(); i++ ) m_pZoomAreaWnd->Link( m_pSensorArray->GetSensor(i) ); } m_pTroubleListWnd = new CTroubleListWnd(); m_pTroubleListWnd->Create( this, 0, 0, 10, 10, m_pSensorArray->GetBackground() ); m_pTroubleListWnd->SetSensorArray( m_pSensorArray ); m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ] = new CPanelWnd(); m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->Create( this, 0, 0, 10, 10 ); m_pCameraNavigateDlg = new CCameraNavigateDlg(); m_pCameraNavigateDlg->Create( m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ], 0, 0, 10, 10 ); m_pCameraNavigateDlg->SetVideoBase( m_pVideoBase ); m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->PlaceChildCenter( m_pCameraNavigateDlg ); m_pCameraNavigateDlg->SetFocus(); m_pCameraNavigateDlg->SetSensorArray( m_pSensorArray ); m_pCameraNavigateDlg->SetVideoSource( (CVideoCaptureWnd*)m_pVideoFrameWnd->GetVideoWnd() ); m_pVideoBase->SetVideoFrameWnd( m_pVideoFrameWnd ); m_pVideoBase->SetVideoListWnd( m_pVideoListWnd ); m_pVideoBase->SetCameraNavigateDlg( m_pCameraNavigateDlg ); m_pVideoBase->Initialize(); SetWindowPos( &CWnd::wndTop, 0, 0, GetSystemMetrics( SM_CXSCREEN ), GetSystemMetrics( SM_CYSCREEN ), 0 ); Reposition(VIEW_MAIN); OnSupportInterfaceFix(); m_pMaskSchedule = new CMaskSchedule(); m_pMaskSchedule->Create( this ); m_bTimerOdd = FALSE; SetTimer( 2, 2000, NULL ); // start timer m_pSensorArray->CommandLoop( m_nRunningMode ); m_bStarted = TRUE; // draw copyright CheckCopyright(); // log info LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnInitDialog", "Done successefully" ); return FALSE; } void CChicagoDlg::OnSysCommand(UINT nID, LPARAM lParam) { /* if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else */ { CDialog::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CChicagoDlg::OnPaint() { LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CChicagoDlg::OnPaint"), _T("Started...") ); if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CChicagoDlg::OnPaint"), _T("Done") ); } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CChicagoDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } LRESULT CChicagoDlg::OnWMSensorShow( WPARAM wParam, LPARAM lParam ) { LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnWMSensorShow", "begin..." ); CSensor *pSensor = (CSensor*)wParam; if( pSensor ) { m_pPropertySensorDlg->SetSensor( pSensor ); if( m_pWholeAreaWnd->SetActiveObject( pSensor ) ) // if( m_pWholeAreaWnd->SetActiveSensor( pSensor ) ) { CLgDPoint dp( pSensor->GetPosition().x, pSensor->GetPosition().y ); m_pZoomAreaWnd->SetCenter( &dp ); } // sould be rewritten for multiplexors !!!! CVideoCamera *pCamera = pSensor->GetVideoCamera(); if( pCamera ) { CVideoCaptureSource *pVideoCaptureSource = pCamera->GetVideoCaptureSource(); if( pVideoCaptureSource ) { m_pVideoBase->SetControlledVideo( (CVideoCaptureWnd*)pVideoCaptureSource ); } else LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnWMSensorShow", "camera %p has no video capture source", pCamera ); } else LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnWMSensorShow", "sensor %p has no connected camera", pSensor ); } LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnWMSensorShow", "end" ); return 0UL; } LRESULT CChicagoDlg::OnWMSensorUpdate( WPARAM wParam, LPARAM lParam ) { // m_pMapSite->SendMessage( WM_SENSOR_UPDATE, wParam, lParam ); // m_pMapZoomDlg->SendMessage( WM_SENSOR_UPDATE, wParam, lParam ); // m_pSensorPropertyDlg->UpdateSensor(); // m_pTroubleWnd->Update(); return 0UL; } void CChicagoDlg::OnNcLButtonDown(UINT nHitTest, CPoint point) { #ifndef _DEBUG if( nHitTest != HTCAPTION ) #endif CDialog::OnNcLButtonDown(nHitTest, point); #ifndef _DEBUG else SetFocus(); #endif } void CChicagoDlg::OnNcLButtonDblClk(UINT nHitTest, CPoint point) { #ifndef _DEBUG if( nHitTest != HTCAPTION ) #endif CDialog::OnNcLButtonDblClk(nHitTest, point); #ifndef _DEBUG else SetFocus(); #endif } void CChicagoDlg::OnCancel() { try { BOOL bAutorized = TRUE; if( m_bStarted && m_nRunningMode != MODE_MOBILEMAP ) bAutorized = Autorization(); if( bAutorized ) { /* if( m_Print.bPresent ) if( m_pEventPrinter->IsBusy() || m_pEventPrinter->IsPrintFile() ) { if( MessageBox( "Cancel print?", NULL, MB_YESNO | MB_ICONEXCLAMATION ) != IDYES ) return; } */ #ifndef _DEBUG ::SystemParametersInfo ( SPI_SCREENSAVERRUNNING, 0, NULL, 0 ); #endif KillTimer( 0 ); KillTimer( 1 ); SaveControlSettings(); m_pAutorizationDlg->DestroyWindow(); m_pPropertySensorDlg->DestroyWindow(); m_pEventWnd->DestroyWindow(); m_ResetDlg.DestroyWindow(); m_pToolBarDlg->DestroyWindow(); m_pCameraNavigateDlg->DestroyWindow(); m_pZoomAreaWnd->DestroyWindow(); m_pWholeAreaWnd->DestroyWindow(); m_pTroubleListWnd->DestroyWindow(); m_pVideoListWnd->DestroyWindow(); m_pControlPanel[CONTROL_VIDEO_NAVIGATE]->DestroyWindow(); m_pVideoFrameWnd->DestroyWindow(); // log info LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnCancel", "All controls destroyed" ); m_pSensorArray->CommandLoop( MODE_STOP ); // Sleep( 1000 ); delete m_pVideoCapture; delete m_pStatisticDlg; // delete m_pEventPrinter; delete m_pEventQueue; delete m_pAlarm; delete m_pFont; delete m_pMainMenu; delete m_pPatrolDlg; // delete m_pTroubleDlg; // delete m_pReportDlg; delete m_pSoundDlg; delete m_pGuardDlg; delete m_pAutorizationDlg; delete m_pCameraNavigateDlg; delete m_pPropertySensorDlg; delete m_pEventWnd; delete m_pToolBarDlg; delete m_pZoomAreaWnd; delete m_pWholeAreaWnd; delete m_pTroubleListWnd; delete m_pVideoListWnd; delete m_pControlPanel[CONTROL_VIDEO_NAVIGATE]; delete m_pVideoFrameWnd; m_pVideoBase->Destroy(); // if( !m_bDemoMode ) delete m_pVideoBase; delete [] m_pVideoWnd; delete m_pReport; delete m_pMaskSchedule; delete m_pSensorArray; // destroy external alarm m_AlarmExternal.Destroy(); // log info LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnCancel", "All operational objects deleted" ); CDialog::OnCancel(); // log info LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnCancel", "Report storage engine deleted" ); } } catch(...) { LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnCancel", "exception" ); } } using namespace OFNS; BOOL CChicagoDlg::Reposition( INT nViewMode ) { if( m_nRunningMode == MODE_BACKUP && nViewMode != VIEW_BACKUP ) return FALSE; LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CChicagoDlg::Reposition"), _T("Started...") ); // if( m_nViewMode == nViewMode ) // return FALSE; CRect rect; GetClientRect( &rect ); switch( m_nRunningMode ) { case MODE_MOBILEMAP: case MODE_HOST: switch( nViewMode ) { case VIEW_MAIN: m_pToolBarDlg->EnableButton( IDM_VIEW_MAIN, FALSE ); m_pToolBarDlg->EnableButton( IDM_VIEW_DETAIL, TRUE ); m_pMainMenu->EnableMenuItem( IDM_VIEW_MAIN, MF_BYCOMMAND | MF_GRAYED ); m_pMainMenu->EnableMenuItem( IDM_VIEW_DETAIL, MF_BYCOMMAND | MF_ENABLED ); break; case VIEW_DETAIL: m_pToolBarDlg->EnableButton( IDM_VIEW_MAIN, TRUE ); m_pToolBarDlg->EnableButton( IDM_VIEW_DETAIL, FALSE ); m_pMainMenu->EnableMenuItem( IDM_VIEW_MAIN, MF_BYCOMMAND | MF_ENABLED ); m_pMainMenu->EnableMenuItem( IDM_VIEW_DETAIL, MF_BYCOMMAND | MF_GRAYED ); break; } case MODE_BACKUP_ACTIVE: m_pToolBarDlg->EnableButton( IDM_SYSTEM_RESET, TRUE ); m_pToolBarDlg->EnableButton( IDM_SYSTEM_ENABLE, TRUE ); m_pMainMenu->EnableMenuItem( IDM_SYSTEM_RESET, MF_BYCOMMAND | MF_ENABLED ); m_pMainMenu->EnableMenuItem( IDM_SYSTEM_ENABLE, MF_BYCOMMAND | MF_ENABLED ); m_pMainMenu->EnableMenuItem( IDM_VIEW_OPTIONS, MF_BYCOMMAND | MF_ENABLED ); m_pMainMenu->EnableMenuItem( IDM_SUPPORT_SOUND, MF_BYCOMMAND | MF_ENABLED ); break; case MODE_BACKUP: m_pToolBarDlg->EnableButton( IDM_SYSTEM_RESET, FALSE ); m_pToolBarDlg->EnableButton( IDM_SYSTEM_ENABLE, FALSE ); m_pToolBarDlg->EnableButton( IDM_VIEW_MAIN, FALSE ); m_pToolBarDlg->EnableButton( IDM_VIEW_DETAIL, FALSE ); m_pMainMenu->EnableMenuItem( IDM_SYSTEM_RESET, MF_BYCOMMAND | MF_GRAYED ); m_pMainMenu->EnableMenuItem( IDM_SYSTEM_ENABLE, MF_BYCOMMAND | MF_GRAYED ); m_pMainMenu->EnableMenuItem( IDM_VIEW_MAIN, MF_BYCOMMAND | MF_GRAYED ); m_pMainMenu->EnableMenuItem( IDM_VIEW_DETAIL, MF_BYCOMMAND | MF_GRAYED ); m_pMainMenu->EnableMenuItem( IDM_VIEW_OPTIONS, MF_BYCOMMAND | MF_GRAYED ); m_pMainMenu->EnableMenuItem( IDM_SUPPORT_SOUND, MF_BYCOMMAND | MF_GRAYED ); break; } // rect.top += 50; CRect pRect[ CONTROL_COUNT ]; for( int i = 0; i < CONTROL_COUNT; i++ ) { pRect[i].SetRect( (int)(m_pControlRect[i].left * rect.Width()), (int)(m_pControlRect[i].top * rect.Height()), (int)(m_pControlRect[i].right * rect.Width()), (int)(m_pControlRect[i].bottom * rect.Height()) ); } if( m_pToolBarDlg->GetSafeHwnd() ) { m_pToolBarDlg->MoveWindow( &pRect[ CONTROL_TOOLBAR ] ); m_pToolBarDlg->ShowWindow( m_pControlRect[ CONTROL_TOOLBAR ].bVisible ? SW_SHOW : SW_HIDE ); m_pMainMenu->CheckMenuItem( ID_VIEW_TOOLBAR, MF_BYCOMMAND | ( m_pControlRect[CONTROL_TOOLBAR].bVisible ? MF_CHECKED : MF_UNCHECKED ) ); } if( m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->GetSafeHwnd() ) { m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->MoveWindow( &pRect[ CONTROL_VIDEO_NAVIGATE ] ); m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->ShowWindow( m_pControlRect[ CONTROL_VIDEO_NAVIGATE ].bVisible ? SW_SHOW : SW_HIDE ); m_pMainMenu->CheckMenuItem( ID_VIEW_PTZCONTROL, MF_BYCOMMAND | ( m_pControlRect[CONTROL_VIDEO_NAVIGATE].bVisible ? MF_CHECKED : MF_UNCHECKED ) ); } if( m_pPropertySensorDlg->GetSafeHwnd() ) { m_pPropertySensorDlg->MoveWindow( &pRect[ CONTROL_SENSOR_PROPERTY ] ); m_pPropertySensorDlg->ShowWindow( m_pControlRect[ CONTROL_SENSOR_PROPERTY ].bVisible ? SW_SHOW : SW_HIDE ); m_pMainMenu->CheckMenuItem( ID_VIEW_SENSORPROPERTIES, MF_BYCOMMAND | ( m_pControlRect[CONTROL_SENSOR_PROPERTY].bVisible ? MF_CHECKED : MF_UNCHECKED ) ); } if( m_pTroubleListWnd->GetSafeHwnd() ) { m_pTroubleListWnd->MoveWindow( &pRect[ CONTROL_TROUBLE_LIST ] ); m_pTroubleListWnd->ShowWindow( m_pControlRect[ CONTROL_TROUBLE_LIST ].bVisible ? SW_SHOW : SW_HIDE ); m_pMainMenu->CheckMenuItem( ID_VIEW_TROUBLES, MF_BYCOMMAND | ( m_pControlRect[CONTROL_TROUBLE_LIST].bVisible ? MF_CHECKED : MF_UNCHECKED ) ); } if( m_pEventWnd->GetSafeHwnd() ) { m_pEventWnd->MoveWindow( &pRect[ CONTROL_EVENT_LIST ] ); m_pEventWnd->ShowWindow( m_pControlRect[ CONTROL_EVENT_LIST ].bVisible ? SW_SHOW : SW_HIDE ); m_pMainMenu->CheckMenuItem( ID_VIEW_EVENTS, MF_BYCOMMAND | ( m_pControlRect[CONTROL_EVENT_LIST].bVisible ? MF_CHECKED : MF_UNCHECKED ) ); } if( m_pVideoFrameWnd->GetSafeHwnd() ) { m_pVideoFrameWnd->MoveWindow( &pRect[ CONTROL_VIDEO_MAIN ] ); m_pVideoFrameWnd->ShowWindow( m_pControlRect[ CONTROL_VIDEO_MAIN ].bVisible ? SW_SHOW : SW_HIDE ); m_pMainMenu->CheckMenuItem( ID_VIEW_VIDEO, MF_BYCOMMAND | ( m_pControlRect[CONTROL_VIDEO_MAIN].bVisible ? MF_CHECKED : MF_UNCHECKED ) ); } if( m_pVideoListWnd->GetSafeHwnd() ) { m_pVideoListWnd->MoveWindow( &pRect[ CONTROL_VIDEO_LIST ] ); m_pVideoListWnd->ShowWindow( m_pControlRect[ CONTROL_VIDEO_LIST ].bVisible ? SW_SHOW : SW_HIDE ); m_pMainMenu->CheckMenuItem( ID_VIEW_VIDEOLIST, MF_BYCOMMAND | ( m_pControlRect[CONTROL_VIDEO_LIST].bVisible ? MF_CHECKED : MF_UNCHECKED ) ); } if( m_pWholeAreaWnd->GetSafeHwnd() ) { m_pWholeAreaWnd->MoveWindow( &pRect[ CONTROL_WHOLE_MAP ] ); m_pWholeAreaWnd->ShowWindow( m_pControlRect[ CONTROL_WHOLE_MAP ].bVisible ? SW_SHOW : SW_HIDE ); m_pMainMenu->CheckMenuItem( ID_VIEW_MAP, MF_BYCOMMAND | ( m_pControlRect[CONTROL_WHOLE_MAP].bVisible ? MF_CHECKED : MF_UNCHECKED ) ); } if( m_pZoomAreaWnd->GetSafeHwnd() ) { m_pZoomAreaWnd->MoveWindow( &pRect[ CONTROL_ZOOM_MAP ] ); m_pZoomAreaWnd->ShowWindow( m_pControlRect[ CONTROL_ZOOM_MAP ].bVisible ? SW_SHOW : SW_HIDE ); m_pMainMenu->CheckMenuItem( ID_VIEW_MAGNIFIEDMAP, MF_BYCOMMAND | ( m_pControlRect[CONTROL_ZOOM_MAP].bVisible ? MF_CHECKED : MF_UNCHECKED ) ); } LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CChicagoDlg::Reposition"), _T("Succeeded") ); return TRUE; // rect.top += m_pToolBarDlg->GetHeight(); switch( nViewMode ) { case VIEW_DETAIL: { CRect tmp; m_pPropertySensorDlg->GetWindowRect( &tmp ); int nHeight = rect.Height() - tmp.Height(); int nWidth = nHeight * 4 / 5; m_pVideoFrameWnd->MoveWindow( rect.right - nWidth, rect.top, nWidth, nHeight ); rect.right -= nWidth; CRect rect0; // Main map { /* CRect tmp1, tmp2; rect0 = rect; m_pPropertySensorDlg->GetWindowRect( &tmp1 ); rect0.bottom -= tmp1.Height(); tmp2.SetRect( 0, 0, m_pMapData->GetMapSize().cx, m_pMapData->GetMapSize().cy ); double mapScale = CalcViewRectAndScale( tmp2, &rect0 ); m_pMapSite->MoveWindow( &rect0 ); m_pMapSite->SetMapShiftScale( SDPOINT(0,0), mapScale ); m_pMapSite->ShowWindow( SW_SHOW ); */ // ClientToScreen( &rect0 ); } CRect rect1; // Magnifier map { /* rect1.left = rect0.right; rect1.top = rect0.top; rect1.right = rect.right; rect1.bottom = rect0.bottom; m_pMapZoomDlg->MoveWindow( &rect1 ); m_pMapZoomDlg->ShowWindow( SW_SHOW ); */ } CRect rect2; // Property { CRect tmp; m_pPropertySensorDlg->GetWindowRect( &tmp ); rect2.left = rect.right - tmp.Width(); rect2.top = rect1.bottom; rect2.right = rect.right; rect2.bottom = rect.bottom; // m_pSensorPropertyDlg->MoveWindow( &rect2 ); // m_pSensorPropertyDlg->ShowWindow( SW_HIDE ); m_pPropertySensorDlg->MoveWindow( &rect2 ); m_pPropertySensorDlg->ShowWindow( SW_SHOW ); } // m_pVideoWnd->ShowWindow( SW_HIDE ); CRect rect7; // Video if( FALSE ) //m_pVideoWnd->GetSafeHwnd() ) { rect7.left = rect2.left - (rect2.bottom - rect2.top) * 4 / 3; rect7.top = rect2.top; rect7.right = rect2.left; rect7.bottom = rect2.bottom; // m_pVideoWnd->MoveWindow( &rect7 ); // m_pVideoWnd->ShowWindow( SW_SHOW ); // m_pVideoWnd->UpdateWindow(); // m_pVideoWnd->InvalidateRect( NULL, FALSE ); CRect rect3; // Trouble { rect3.left = rect.left; rect3.top = rect7.top; rect3.right = rect7.left; rect3.bottom = rect7.top + (rect7.bottom - rect7.top)/2; // m_pSensorsStateDlg->MoveWindow( &rect3 ); // m_pSensorsStateDlg->ShowWindow( SW_SHOW ); // m_pTroubleWnd->MoveWindow( &rect3 ); // m_pTroubleWnd->ShowWindow( SW_SHOW ); } CRect rect4; // Events { rect4.left = rect3.left; rect4.top = rect3.bottom; rect4.right = rect3.right; rect4.bottom = rect.bottom; m_pEventWnd->MoveWindow( &rect4 ); m_pEventWnd->ShowWindow( SW_SHOW ); } } else { CRect rect3; // Trouble { rect3.left = rect.left; rect3.top = rect0.bottom; rect3.right = (rect2.left - rect.left) / 2; rect3.bottom = rect.bottom; // m_pSensorsStateDlg->MoveWindow( &rect3 ); // m_pSensorsStateDlg->ShowWindow( SW_SHOW ); // m_pTroubleWnd->MoveWindow( &rect3 ); // m_pTroubleWnd->ShowWindow( SW_SHOW ); } CRect rect4; // Events { rect4.left = rect3.right; rect4.top = rect0.bottom; rect4.right = rect2.left; rect4.bottom = rect.bottom; m_pEventWnd->MoveWindow( &rect4 ); m_pEventWnd->ShowWindow( SW_SHOW ); } } CRect rect5; // Clock { /* rect5.left = rect0.right; rect5.top = rect.top; rect5.right = rect.right; rect5.bottom = rect.top + 110; m_pClockWnd->MoveWindow( &rect5 ); m_pClockWnd->ShowWindow( SW_HIDE ); */ } CRect rect6; // Logo { /* rect6.left = rect0.right + (rect.right - rect0.right - 130)/2; rect6.top = rect5.bottom + 30; rect6.right = rect6.left + 130; rect6.bottom = rect6.top + 130; m_pLogoWnd->MoveWindow( &rect6 ); m_pLogoWnd->ShowWindow( SW_HIDE ); */ } } break; case VIEW_MAIN: { // m_pSensorCurrent = NULL; CRect rect0; // Main map { CRect tmp1; rect0 = rect; // tmp1.SetRect( 0, 0, m_pMapData->GetMapSize().cx, m_pMapData->GetMapSize().cy ); double mapScale = CalcViewRectAndScale( tmp1, &rect0 ); // m_pMapSite->MoveWindow( &rect0 ); // m_pMapSite->SetMapShiftScale( SDPOINT(0,0), mapScale ); // m_pMapSite->ShowWindow( SW_SHOW ); } // Magnifier map { // m_pMapZoomDlg->ShowWindow( SW_HIDE ); } // Property { // m_pSensorPropertyDlg->ShowWindow( SW_HIDE ); m_pPropertySensorDlg->ShowWindow( SW_HIDE ); } CRect rect5; // Clock { // CSize as = m_pClockWnd->GetActualSize(); // rect5.left = rect0.right; // rect5.top = rect.top; // rect5.right = rect.right; // rect5.bottom = rect.top + as.cy * rect5.Width() / as.cx + 6; // m_pClockWnd->MoveWindow( &rect5 ); // m_pClockWnd->ShowWindow( SW_SHOW ); } /* CRect rect6; // Logo { rect6.left = rect0.right + (rect.right - rect0.right - 130) / 2; rect6.right = rect6.left + 130; rect6.top = rect5.bottom; rect6.bottom = rect6.top + 130; m_pLogoWnd->MoveWindow( &rect6 ); m_pLogoWnd->ShowWindow( SW_SHOW ); } */ CRect rect7; // Video /* if( m_pVideoWnd->GetSafeHwnd() ) { rect7.left = rect0.right; rect7.top = rect5.bottom; rect7.right = rect.right; rect7.bottom = rect7.top + (rect7.right - rect7.left) * 3 / 4; m_pVideoWnd->MoveWindow( &rect7 ); m_pVideoWnd->ShowWindow( SW_SHOW ); m_pVideoWnd->UpdateWindow(); m_pVideoWnd->InvalidateRect( NULL, FALSE ); } else { rect7.left = rect0.right; rect7.top = rect5.bottom; rect7.right = rect.right; rect7.bottom = rect5.bottom; } */ CRect rect3; // Trouble { rect3.left = rect0.right; rect3.top = rect7.bottom; rect3.right = rect.right; rect3.bottom = rect7.bottom + ( rect.bottom - rect7.bottom ) / 2; // m_pSensorsStateDlg->MoveWindow( &rect3 ); // m_pSensorsStateDlg->ShowWindow( SW_HIDE ); // m_pTroubleWnd->MoveWindow( &rect3 ); // m_pTroubleWnd->ShowWindow( SW_SHOW ); } CRect rect4; // Events { rect4.left = rect0.right; rect4.top = rect3.bottom; rect4.right = rect.right; rect4.bottom = rect.bottom; m_pEventWnd->MoveWindow( &rect4 ); m_pEventWnd->ShowWindow( SW_SHOW ); } } break; case VIEW_BACKUP: { // m_pSensorEvent = NULL; // Main map // m_pMapSite->ShowWindow( SW_HIDE ); // Magnifier map // m_pMapZoomDlg->ShowWindow( SW_HIDE ); // Property m_pPropertySensorDlg->ShowWindow( SW_HIDE ); CRect rect0; // Clock { // CSize as = m_pClockWnd->GetActualSize(); rect0.left = rect.left; rect0.top = rect.top; rect0.right = rect.right; // rect0.bottom = rect.top + as.cy * rect0.Width() / as.cx + 6; // m_pClockWnd->MoveWindow( &rect0 ); // m_pClockWnd->ShowWindow( SW_SHOW ); } /* CRect rect1; // Logo { rect1.left = rect.left + ( rect.Width() - 130 ) / 2; rect1.right = rect1.left + 130; rect1.top = rect0.bottom; rect1.bottom = rect1.top + 130; m_pLogoWnd->MoveWindow( &rect1 ); m_pLogoWnd->ShowWindow( SW_SHOW ); } */ // if( m_pVideoWnd->GetSafeHwnd() ) // m_pVideoWnd->ShowWindow( SW_HIDE ); CRect rect2; // Trouble { rect2.left = rect.left; rect2.top = rect0.bottom; rect2.right = rect0.left; rect2.bottom = rect.bottom; // m_pTroubleWnd->MoveWindow( &rect2 ); // m_pTroubleWnd->ShowWindow( SW_SHOW ); } CRect rect3; // Events { rect3.left = rect0.right; rect3.top = rect0.bottom; rect3.right = rect.right; rect3.bottom = rect.bottom; m_pEventWnd->MoveWindow( &rect3 ); m_pEventWnd->ShowWindow( SW_SHOW ); } } break; } // log info LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::Reposition" ); m_nViewMode = nViewMode; return TRUE; } void CChicagoDlg::OnViewMain() { // Reposition( VIEW_MAIN ); } void CChicagoDlg::OnViewAlarm() { // if( Reposition( VIEW_DETAIL ) ) // { // if( !m_pSensorCurrent ) // m_pSensorCurrent = m_pSensorArray->GetSensor(0); // SendMessage( WM_SENSOR_SHOW, (WPARAM)m_pSensorCurrent, (LPARAM)m_pSensorCurrent ); // } } void CChicagoDlg::OnInitMenu(CMenu* pMenu) { /* int nResult; if( m_nViewMode == VIEW_DETAIL ) nResult = pMenu->CheckMenuRadioItem( IDM_VIEW_MAIN, IDM_VIEW_DETAIL, IDM_VIEW_DETAIL, MF_BYCOMMAND ); else nResult = pMenu->CheckMenuRadioItem( IDM_VIEW_MAIN, IDM_VIEW_DETAIL, IDM_VIEW_MAIN, MF_BYCOMMAND ); if( nResult != -1 ) { for( int i = 0; i < m_pSensorArray->GetSensorCount(); i++ ) { switch( m_pSensorArray->GetSensor(i)->GetState() ) { case CSensor::ALARM: // case CSensor::TIMEOUT: // case CSensor::POSTALARM: if( pMenu->EnableMenuItem( IDM_VIEW_MAIN, MF_BYCOMMAND | MF_GRAYED )!=0xFFFFFFFF ) goto END_PROC; } } pMenu->EnableMenuItem( IDM_VIEW_MAIN, MF_BYCOMMAND | MF_ENABLED ); } END_PROC: */ CDialog::OnInitMenu(pMenu); } void CChicagoDlg::StoreEvent( EVENT &event ) { if( m_nRunningMode != MODE_MOBILEMAP ) { memset( &event.image, 0, sizeof(event.image) ); // place index of eventy into first sell of pImage array if( !m_pReport->Write( event ) ) LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CChicagoDlg::StoreEvent"), _T("Event store failed") ); } } #define GPRU_SWITCH_ADDRESS 124 void CChicagoDlg::OnTimer( UINT nIDEvent ) { // log info LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CChicagoDlg::OnTimer", "%d start...", nIDEvent ); try { if( nIDEvent == 2 ) { KillTimer( 2 ); // start timer SetTimer( 0, 250, NULL ); // interface timer SetTimer( 1, 50, NULL ); // fast timer // log info LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CChicagoDlg::OnTimer", "%d done.", nIDEvent ); return; } // fast timer ~50 ms if( nIDEvent == 1 ) { m_pSensorArray->CheckCameras(); m_pVideoCapture->CheckState(); // log info LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CChicagoDlg::OnTimer", "%d done.", nIDEvent ); return; } m_pMaskSchedule->OnTimer(); // normal timer ~250 ms #ifndef _DEBUG CheckCopyright(); #endif m_pWholeAreaWnd->UpdateInfo( m_bTimerOdd ); m_pZoomAreaWnd->UpdateInfo( m_bTimerOdd ); m_pTroubleListWnd->UpdateInfo( m_bTimerOdd ); m_pPropertySensorDlg->UpdateInfo( m_bTimerOdd ); m_pCameraNavigateDlg->UpdateInfo( m_bTimerOdd ); // m_pMapSite->SendMessage( WM_TIMER, m_bTimerOdd ); // m_pClockWnd->SendMessage( WM_TIMER, m_bTimerOdd ); // m_pMapZoomDlg->SendMessage( WM_TIMER, m_bTimerOdd ); // m_pSensorPropertyDlg->SendMessage( WM_TIMER, m_bTimerOdd ); // m_pSensorsStateDlg->SendMessage( WM_TIMER, m_bTimerOdd ); // m_pPropertySensorDlg->SendMessage( WM_TIMER, m_bTimerOdd ); // m_pTroubleWnd->SendMessage( WM_TIMER, m_bTimerOdd ); m_pEventWnd->SendMessage( WM_TIMER, m_bTimerOdd ); // m_pLogoWnd->SendMessage( WM_TIMER ); if( m_pAutorizationDlg->GetSafeHwnd() ) m_pAutorizationDlg->SendMessage( WM_TIMER ); if( m_pStatisticDlg->GetSafeHwnd() ) m_pStatisticDlg->SendMessage( WM_TIMER ); // if( m_pReportDlg->GetSafeHwnd() ) // m_pReportDlg->SendMessage( WM_TIMER ); // if( m_pTroubleDlg->GetSafeHwnd() ) // m_pTroubleDlg->SendMessage( WM_TIMER ); if( m_pGuardDlg->GetSafeHwnd() ) m_pGuardDlg->SendMessage( WM_TIMER ); if( m_pPatrolDlg->GetSafeHwnd() ) m_pPatrolDlg->SendMessage( WM_TIMER ); m_pSensorArray->CheckPatrols(); m_pSensorArray->CheckSensors(); EVENT event; CSensor *pSensor = NULL, *pSensorLast = NULL; BOOL bNeedBeep = FALSE; BOOL bNeedBeepStop = FALSE; BOOL bNeedPrintDlg = FALSE; BOOL bNeedUpdate = FALSE; BOOL bNeedCapture = FALSE; while( m_pEventQueue->GetEvent( event ) ) { BOOL bNeedStore = FALSE; BOOL bNeedPrint = FALSE; BOOL bNeedCapture = FALSE; BOOL bNeedEventWnd = FALSE; BOOL bNeedWave = FALSE; BOOL bNeedStoreExtendedLog = FALSE; switch( event.id ) { case LGS_EVENT_SENSOR_LGS_POWER: if( !event.bPowered ) bNeedBeep = TRUE; bNeedPrint = TRUE; bNeedStore = TRUE; bNeedEventWnd = TRUE; bNeedUpdate = TRUE; break; case LGS_EVENT_NORMAL: bNeedUpdate = TRUE; bNeedPrint = TRUE; bNeedStore = TRUE; break; case LGS_EVENT_ALARM_SHOW: bNeedCapture = TRUE; case LGS_EVENT_TIMEOUT_APPEAR: pSensor = m_pSensorArray->GetSensor( event.data16 ); if( pSensor->GetZone()->IsSoundAlarm() ) { bNeedBeep = TRUE; bNeedWave = TRUE; } // notify call center about alarm m_pSensorArray->GetPhoneCallCenter().OnAlarm( event.data16 ); case LGS_EVENT_ALARM_HIDE: if( pSensorLast ) { if( pSensor->GetState() >= pSensorLast->GetState() ) pSensorLast = pSensor; } else pSensorLast = pSensor; bNeedEventWnd = TRUE; bNeedUpdate = TRUE; bNeedPrint = TRUE; bNeedStore = TRUE; break; case LGS_EVENT_ERROR: switch( event.data8 ) { case LGS_EVENT_ERROR_NORMAL: bNeedStoreExtendedLog = TRUE; break; case LGS_EVENT_ERROR_CRITICAL: m_pEventWnd->AddHead( event ); bNeedBeep = TRUE; bNeedPrint = TRUE; bNeedStore = TRUE; m_pWholeAreaWnd->InvalidateRect( NULL ); m_pZoomAreaWnd->InvalidateRect( NULL ); break; } break; case LGS_EVENT_PROGRAM_RESET: m_pEventWnd->AddHead( event ); bNeedPrint = TRUE; bNeedStore = TRUE; m_pWholeAreaWnd->InvalidateRect( NULL ); m_pZoomAreaWnd->InvalidateRect( NULL ); break; case LGS_EVENT_SENSOR_RESET_BY_CCC: pSensor = m_pSensorArray->GetSensor( event.data16 ); pSensor->Reset(); m_pSensorArray->GetEventQueue()->PostEvent( LGS_EVENT_PROGRAM_RESET, 0, 0, 0, RGB(0xFF,0xFF,0xFF), (LPSTR)(LPCTSTR)event.pText ); break; case LGS_EVENT_LGS_AUTO_RESET: case LGS_EVENT_SYSTEM_REPAIR: bNeedPrint = TRUE; bNeedStore = TRUE; bNeedEventWnd = TRUE; break; /* case LGS_EVENT_PRINTER: m_Print.bPresent = event.data8; bNeedEventWnd = TRUE; break; */ case LGS_EVENT_LINE_CUT: bNeedEventWnd = TRUE; bNeedPrint = TRUE; bNeedStore = TRUE; bNeedBeep = TRUE; break; case LGS_EVENT_EXTENDED_LOG: bNeedStoreExtendedLog = TRUE; break; case LGS_EVENT_PATROL: bNeedPrint = TRUE; bNeedStore = TRUE; bNeedUpdate = TRUE; if( event.data8 ) bNeedBeepStop = TRUE; else bNeedBeep = TRUE; bNeedEventWnd = TRUE; break; case LGS_EVENT_MM_UPDATE: pSensor = (CSensor*)event.data32; switch( pSensor->GetState() ) { case CVisual::TIMEOUT: case CVisual::POSTALARM: case CVisual::ALARM: if( pSensorLast ) { if( pSensor->GetState() >= pSensorLast->GetState() ) pSensorLast = pSensor; } else pSensorLast = pSensor; if( m_nRunningMode != MODE_BACKUP ) bNeedBeep = TRUE; break; } bNeedUpdate = TRUE; break; case LGS_EVENT_GUARD: case LGS_EVENT_SUPER: bNeedEventWnd = TRUE; bNeedPrint = TRUE; bNeedStore = TRUE; break; case LGS_EVENT_MM_COMMUNICATE: switch( m_nRunningMode ) { case MODE_HOST: break; case MODE_MOBILEMAP: if( event.data8 ) { // m_pLogoWnd->Rotate( TRUE ); bNeedBeepStop = TRUE; // m_pTroubleWnd->Delete( TROUBLE_BACKUP, 1 ); } else { // m_pLogoWnd->Rotate( FALSE ); bNeedBeep = TRUE; // m_pTroubleWnd->Add( TROUBLE_BACKUP, 1, "MM", "No communication with host", 0xFF, 0 ); } bNeedEventWnd = TRUE; bNeedUpdate = TRUE; break; case MODE_BACKUP: if( event.data8 ) { // m_pLogoWnd->Rotate( TRUE ); bNeedBeepStop = TRUE; } else { m_pEventQueue->PostEvent( LGS_EVENT_GPRU_COMMAND_SEND, 0, MAKEWORD( GPRU_SWITCH_ADDRESS, 0 ), 127, 0, NULL ); for( int s = 0; s < m_pSensorArray->GetSocketCount(); s++ ) if( m_pSensorArray->GetSocket( s )->GetType() == SOCKET_SPRU ) { m_pSensorArray->GetSocket( s )->CommandLoopStart(); break; } m_bWaitDisconnect = TRUE; bNeedBeep = TRUE; } bNeedEventWnd = TRUE; bNeedUpdate = TRUE; bNeedPrint = TRUE; break; case MODE_BACKUP_ACTIVE: if( event.data8 ) { m_pEventQueue->PostEvent( LGS_EVENT_GPRU_COMMAND_SEND, 0, MAKEWORD( GPRU_SWITCH_ADDRESS, 0 ), 0, 0, NULL ); // m_pLogoWnd->Rotate( TRUE ); bNeedBeepStop = TRUE; m_bWaitConnect = TRUE; } bNeedEventWnd = TRUE; bNeedUpdate = TRUE; bNeedPrint = TRUE; break; } break; case LGS_EVENT_SOCKET_COMMUNICATION: if( !event.data8 ) { CString str; bNeedBeep = TRUE; // switch( event.data16 ) // { // case SOCKET_SM: m_pTroubleWnd->Add( TROUBLE_SM, 0, "ERROR SM", "Program could not create communication port for SINOPTIC MAP", 0xFF, 0 ); break; // case SOCKET_ECS: m_pTroubleWnd->Add( TROUBLE_ECS, 0, "ERROR ECS", "Program could not create communication port for ELECTRONIC CONTROL SSYSTEM", 0xFF, 0 ); break; // case SOCKET_BACKUP: m_pTroubleWnd->Add( TROUBLE_BACKUP, 0, "ERROR BACK UP", "Program could not create communication port for BACKUP", 0xFF, 0 ); break; // case SOCKET_SPRU: m_pTroubleWnd->Add( TROUBLE_SPRU, 0, "ERROR LINE", "Program could not create communication port for FIELD LINE", 0xFF, 0 ); break; // } } bNeedEventWnd = TRUE; bNeedUpdate = TRUE; bNeedPrint = TRUE; bNeedStore = TRUE; break; case LGS_EVENT_GPRU_COMMAND_SEND: if( !m_pSensorArray->PostSocketEvent( event, SOCKET_SPRU ) ) m_pEventQueue->PostEvent( LGS_EVENT_GPRU_COMMAND_RESULT, FALSE, event.data16, event.data32, RGB(0xFF,0,0), "can't perform GPRU command" ); break; case LGS_EVENT_GPRU_COMMAND_RESULT: if( event.data8 ) { if( m_bWaitDisconnect ) { if( event.data16 == MAKEWORD( GPRU_SWITCH_ADDRESS, 0 ) ) { m_nRunningMode = MODE_BACKUP_ACTIVE; m_pSensorArray->CommandLoop( m_nRunningMode ); for( int s = 0; s < m_pSensorArray->GetSocketCount(); s++ ) if( m_pSensorArray->GetSocket( s )->GetType() == SOCKET_BACKUP ) { ((CSocketBackup*)m_pSensorArray->GetSocket( s ))->SetServer(); ((CSocketBackup*)m_pSensorArray->GetSocket( s ))->SetName( "Backup and mobile map server" ); break; } m_pEventQueue->PostEvent( LGS_EVENT_BACKUP_TO_HOST, 1,0,0, RGB(0,0xFF,0), "backup switched to host" ); // m_pTroubleWnd->Delete( TROUBLE_BACKUP, 1 ); // m_pTroubleWnd->Add( TROUBLE_BACKUP, 1, "BACK UP-> HOST", "Backup mode switched to host mode computer", RGB( 0, 0xFF, 0 ), RGB( 0, 0x7F, 0 ) ); // m_ToolBarDlg.SetModeText( "HOST" ); // Reposition( VIEW_MAIN ); bNeedBeepStop = TRUE; bNeedUpdate = TRUE; m_bWaitDisconnect = FALSE; } } if( m_bWaitConnect ) { if( event.data16 == MAKEWORD( GPRU_SWITCH_ADDRESS, 0 ) ) { m_nRunningMode = MODE_BACKUP; m_pSensorArray->CommandLoop( m_nRunningMode ); for( int s = 0; s < m_pSensorArray->GetSocketCount(); s++ ) if( m_pSensorArray->GetSocket( s )->GetType() == SOCKET_BACKUP ) { ((CSocketBackup*)m_pSensorArray->GetSocket( s ))->SetBackup(); ((CSocketBackup*)m_pSensorArray->GetSocket( s ))->SetName( "Backup client" ); break; } m_pEventQueue->PostEvent( LGS_EVENT_BACKUP_TO_HOST, 0,0,0, RGB(0,0xFF,0), "host switched to backup" ); // m_pTroubleWnd->Delete( TROUBLE_BACKUP, 1 ); // 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 ) ); // m_ToolBarDlg.SetModeText( "BACKUP" ); // Reposition( VIEW_BACKUP ); bNeedBeepStop = TRUE; bNeedUpdate = TRUE; m_bWaitConnect = FALSE; } } break; } else { if( m_bWaitDisconnect && event.data16 == MAKEWORD( GPRU_SWITCH_ADDRESS, 0 ) ) { // m_pTroubleWnd->Add( TROUBLE_BACKUP, 0, "ERROR BACK UP", "Program could not disconnect server from lines", 0xFF, 0 ); strcpy( event.pText, "can't disconnect server" ); m_bWaitDisconnect = FALSE; } else if( m_bWaitConnect && event.data16 == MAKEWORD( GPRU_SWITCH_ADDRESS, 0 ) ) { // m_pTroubleWnd->Add( TROUBLE_BACKUP, 0, "ERROR BACK UP", "Program could not connect server to lines", 0xFF, 0 ); strcpy( event.pText, "can't connect server" ); m_bWaitConnect = FALSE; } // else // m_pTroubleWnd->Add( TROUBLE_GPRU_COMMAND, 0, "GPRU", "Program could not send GPRU command", 0xFF, 0 ); bNeedUpdate = TRUE; bNeedBeep = TRUE; } bNeedEventWnd = TRUE; bNeedStore = TRUE; bNeedPrint = TRUE; break; case LGS_EVENT_BACKUP_TO_HOST: bNeedEventWnd = TRUE; bNeedStore = TRUE; if( event.data8 ) bNeedBeep = TRUE; else bNeedBeepStop = TRUE; bNeedUpdate = TRUE; bNeedPrint = TRUE; break; case LGS_EVENT_MANUAL_CAPTURE: bNeedStore = TRUE; bNeedCapture = TRUE; break; case LGS_EVENT_IMAGE_CAPTURE: // display & discard bitmap m_pTroubleListWnd->SetItemImage( event.pSensor, event.hBitmap ); break; } if( bNeedWave && m_bSoundEnabled ) { /* const max = 10; LPCTSTR ppFile[ max ]; int nCount = max; if( pSensor->GetWaveSound( ppFile, nCount ) ) m_pAlarm->WaveStart( ppFile, nCount ); */ } /* if( bNeedPrint && m_Print.bPresent ) { if( m_pEventPrinter->IsPrintFile() ) bNeedPrintDlg = TRUE; m_pEventPrinter->PrintEvent( event ); } */ if( bNeedStore ) { StoreEvent( event ); if( bNeedCapture ) { Capture( event ); } } if( bNeedEventWnd ) m_pEventWnd->AddHead( event ); // store all extended information if( bNeedStoreExtendedLog || bNeedStore ) { SYSTEMTIME cst; FileTimeToSystemTime( (LPFILETIME)&event.time, &cst ); m_pSensorArray->StoreExtendedInfo( "%02d:%02d:%02d %02d/%02d/%02d %s", cst.wDay, cst.wMonth, cst.wYear, cst.wHour, cst.wMinute, cst.wSecond, event.pText ); } } // m_pReportDlg->EnablePrinter( m_Print.bPresent & !m_pEventPrinter->IsBusy() ); if( pSensorLast && !m_pSensorCurrent ) { m_pSensorCurrent = pSensorLast; SendMessage( WM_SENSOR_SHOW, (WPARAM)pSensorLast, (LPARAM)pSensorLast ); } if( bNeedUpdate ) { // if( m_pReportDlg->GetSafeHwnd() ) // m_pReportDlg->EndDialog( IDCANCEL ); SendMessage( WM_SENSOR_UPDATE, 0, 0 ); m_pSensorArray->CheckFilters(); } if( bNeedBeepStop && !bNeedBeep ) m_pAlarm->Stop(); if( bNeedBeep && m_bSoundEnabled ) { m_pAlarm->Start(); } // start external alarm if( bNeedBeep ) m_AlarmExternal.Beep( TRUE ); m_bTimerOdd = !m_bTimerOdd; CDialog::OnTimer(nIDEvent); /* if( bNeedPrintDlg ) { if( !m_Print.bDlg ) { m_Print.bDlg = TRUE; if( MessageBox( "Report printing is in progress, abort it?", "", MB_YESNO | MB_ICONEXCLAMATION ) == IDYES ) m_pEventPrinter->PrintFileAbort(); m_Print.bDlg = FALSE; } } */ // last thing is to check command for all sensors m_pSensorArray->CheckSensorsCommand(); // update report m_pReport->OnTimer(); } catch(...) { LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CChicagoDlg::OnTimer"), _T("C++ Exception") ); } // log info LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CChicagoDlg::OnTimer", "%d done.", nIDEvent ); } void CChicagoDlg::OnSystemReset() { if( m_nRunningMode != MODE_MOBILEMAP && m_nRunningMode != MODE_BACKUP ) { if( m_ResetDlg.DoModal()==IDOK ) { // m_pSensorArray->Reset(); m_pAlarm->Stop(); m_bSoundEnabled = TRUE; m_pSensorCurrent = NULL; // Reposition( VIEW_MAIN ); m_pReport->Reset(); // notify call center about reset m_pSensorArray->GetPhoneCallCenter().OnReset(); } // stop external alarm m_AlarmExternal.Beep( FALSE ); } } void CChicagoDlg::OnSystemEnable() { // if( Autorization() ) /* if( m_nRunningMode != MODE_MOBILEMAP && m_nRunningMode != MODE_BACKUP ) { CEnableDlg dlg( this ); dlg.SetParam( m_pSensorArray ); dlg.DoModal(); SendMessage( WM_SENSOR_UPDATE, 0, 0 ); } */ } LRESULT CChicagoDlg::OnWMEnableSensor(WPARAM wParam, LPARAM lParam) { // if( Autorization() ) if( m_nRunningMode != MODE_MOBILEMAP && m_nRunningMode != MODE_BACKUP ) { CEnableDlg dlg( this ); dlg.SetParam( m_pSensorArray, (CSensor*)wParam ); dlg.DoModal(); SendMessage( WM_SENSOR_UPDATE, 0, 0 ); } return 0; } LRESULT CChicagoDlg::OnWMEnableZone(WPARAM wParam, LPARAM lParam) { // if( Autorization() ) if( m_nRunningMode != MODE_MOBILEMAP && m_nRunningMode != MODE_BACKUP ) { CEnableDlg dlg( this ); dlg.SetParam( m_pSensorArray, (CZone*)wParam ); dlg.DoModal(); SendMessage( WM_SENSOR_UPDATE, 0, 0 ); } return 0; } LRESULT CChicagoDlg::OnWMEnableDTRBit(WPARAM wParam, LPARAM lParam) { // if( Autorization() ) if( m_nRunningMode != MODE_MOBILEMAP && m_nRunningMode != MODE_BACKUP ) { CEnableDlg dlg( this ); dlg.SetParam( m_pSensorArray, (CSensor*)wParam, lParam ); dlg.DoModal(); SendMessage( WM_SENSOR_UPDATE, 0, 0 ); } return 0; } void CChicagoDlg::OnSupportReport() { if( Autorization() ) m_pReport->Dlg_DoModal( GetSafeHwnd() ); } void CChicagoDlg::OnSupportStatistic() { if( Autorization() ) m_pStatisticDlg->DoModal(); } void CChicagoDlg::OnViewOptions() { } void CChicagoDlg::OnSupportSound() { if( Autorization() ) m_pSoundDlg->DoModal(); } void CChicagoDlg::OnSupportDatetime() { if( Autorization() ) { CDateTimeDlg dtDlg( this ); dtDlg.DoModal(); } } void CChicagoDlg::OnSupportMute() { m_bSoundEnabled = FALSE; m_pAlarm->Stop(); } void CChicagoDlg::OnSupportGuard() { // switch( m_GuardDlg.DoModal( TRUE ) ) switch( m_pAutorizationDlg->DoModal( FALSE, TRUE, TRUE ) ) { case IDRETRY: // m_pTroubleDlg->SetTroubleText( (LPSTR)(LPCTSTR)m_pAutorizationDlg->GetErrorString() ); // m_pTroubleDlg->DoModal(); break; case IDCANCEL: case IDOK: break; } } LRESULT CChicagoDlg::OnWMShowTrouble(WPARAM wParam, LPARAM lParam) { // m_pTroubleDlg->SetTroubleText( (LPSTR)lParam ); // m_pTroubleDlg->DoModal(); return 0; } BOOL CChicagoDlg::PreTranslateMessage(MSG* pMsg) { LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CChicagoDlg::PreTranslateMessage"), _T("Started...") ); switch( pMsg->message ) { case WM_KEYDOWN: case WM_SYSKEYDOWN: return ::TranslateAccelerator( GetSafeHwnd(), m_hAccelerators, pMsg ); } BOOL bResult = CDialog::PreTranslateMessage(pMsg); LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CChicagoDlg::PreTranslateMessage"), _T("Done") ); return bResult; } BOOL CChicagoDlg::OnHelpInfo(HELPINFO* pHelpInfo) { return TRUE;//CDialog::OnHelpInfo(pHelpInfo); } BOOL CChicagoDlg::Autorization() { switch( m_pAutorizationDlg->DoModal( TRUE, FALSE, FALSE ) ) { case IDRETRY: // m_pTroubleDlg->SetTroubleText( (LPSTR)(LPCTSTR)m_pAutorizationDlg->GetErrorString() ); // m_pTroubleDlg->DoModal(); return FALSE; case IDCANCEL: return FALSE; case IDOK: return TRUE; } return FALSE; } LRESULT CChicagoDlg::OnWMAutorization(WPARAM wParam, LPARAM lParam) { return Autorization(); } //DEL void CChicagoDlg::OnSupportPatrol() //DEL { //DEL m_pPatrolDlg->DoModal(); //DEL } //DEL void CChicagoDlg::OnSupportVideoDisplay() //DEL { //DEL // m_pVideoWnd->DlgVideoDisplay(); //DEL } //DEL void CChicagoDlg::OnSupportVideoSource() //DEL { //DEL // m_pVideoWnd->DlgVideoSource(); //DEL } BOOL CAboutDlg::OnInitDialog() { CDialog::OnInitDialog(); m_BuildTime.SetWindowText( CString("Built on ") + CLgVersion::GetBuildTimeStr() ); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CChicagoDlg::OnHelpAbout() { CAboutDlg dlg; dlg.DoModal(); } //DEL void CChicagoDlg::OnSupportCameras() //DEL { //DEL // m_pCameraDlg->DoModal(); //DEL } void CChicagoDlg::Capture( EVENT& event ) { if( event.id == LGS_EVENT_MANUAL_CAPTURE || event.target.bType == 111 ) { if( event.pCamera ) { m_pVideoCapture->Capture( NULL, event.pCamera, TRUE, event.image.liEventOffset, event.pan, event.tilt, event.zoom ); } } else { CSensor *pSensor = m_pSensorArray->GetSensor( event.data16 ); if( pSensor ) { CVideoCamera *pVideoCamera = pSensor->GetVideoCamera(); if( pVideoCamera ) { double pan, tilt, zoom, angle; switch( pVideoCamera->GetType() ) { case VC_FIX: m_pVideoCapture->Capture( pSensor, pVideoCamera, FALSE, event.image.liEventOffset, 0, 0, 0 ); break; case VC_PTZ: switch( pSensor->GetType() ) { case CSensor::LGS: angle = event.target.dAngle - static_cast(pSensor)->GetZeroShift(); while( angle < 0.0 ) angle += 360.0; while( angle >= 360.0 ) angle -= 360.0; // capture video if( pSensor->CameraTransform( event.target.bDevice ? 0 : 1, event.target.dAngle, event.target.dRange, &pan, &tilt, &zoom ) ) m_pVideoCapture->Capture( pSensor, pVideoCamera, FALSE, event.image.liEventOffset, pan, tilt, zoom ); break; case CSensor::DC: // zoom scale according to scale factor event.zoom *= m_pSensorArray->GetProgramSettings().Capture.dZoomScale; // capture video m_pVideoCapture->Capture( pSensor, pVideoCamera, FALSE, event.image.liEventOffset, event.pan, event.tilt, event.zoom ); break; } break; } } } } } void CChicagoDlg::OnSupportInterfaceFly() { InterfaceEnableFly( TRUE ); } void CChicagoDlg::OnSupportInterfaceFix() { InterfaceEnableFly( FALSE ); } static void ThickFrameEnable( CWnd *pWnd, BOOL bEnable ) { if( pWnd && pWnd->GetSafeHwnd() ) { LONG dwStyle = ::GetWindowLong( pWnd->GetSafeHwnd(), GWL_STYLE ); if( bEnable ) ::SetWindowLong( pWnd->GetSafeHwnd(), GWL_STYLE, dwStyle | WS_THICKFRAME ); else ::SetWindowLong( pWnd->GetSafeHwnd(), GWL_STYLE, dwStyle & ~WS_THICKFRAME ); } } void CChicagoDlg::InterfaceEnableFly( BOOL bEnable ) { ThickFrameEnable( m_pWholeAreaWnd, bEnable ); ThickFrameEnable( m_pZoomAreaWnd, bEnable ); ThickFrameEnable( m_pPropertySensorDlg, bEnable ); ThickFrameEnable( m_pVideoFrameWnd, bEnable ); ThickFrameEnable( m_pVideoListWnd, bEnable ); ThickFrameEnable( m_pTroubleListWnd, bEnable ); ThickFrameEnable( m_pEventWnd, bEnable ); ThickFrameEnable( m_pToolBarDlg, bEnable ); for( int i = 0; i < CONTROL_COUNT; i++ ) ThickFrameEnable( m_pControlPanel[i], bEnable ); m_pMainMenu->CheckMenuRadioItem( IDM_SUPPORT_INTERFACE_FLY, IDM_SUPPORT_INTERFACE_FIX, bEnable ? IDM_SUPPORT_INTERFACE_FLY : IDM_SUPPORT_INTERFACE_FIX, MF_BYCOMMAND ); } int CChicagoDlg::DoModal() { __try { return CDialog::DoModal(); } __except(EXCEPTION_EXECUTE_HANDLER) { // log info LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, "CChicagoDlg::DoModal", "Exception 0x%08X", _exception_code() ); return 0; } } BOOL CChicagoDlg::LoadControlDefaultSettings() { m_pControlRect[ CONTROL_VIDEO_MAIN ].SetRect( 0.5, 0.0, 1.0, 0.6 ); m_pControlRect[ CONTROL_VIDEO_NAVIGATE ].SetRect( 0.5, 0.6, 1.0, 0.8 ); m_pControlRect[ CONTROL_VIDEO_LIST ].SetRect( 0.5, 0.8, 1.0, 1.0 ); m_pControlRect[ CONTROL_WHOLE_MAP].SetRect( 0.0, 0.063, 0.25, 0.35 ); m_pControlRect[ CONTROL_ZOOM_MAP].SetRect( 0.25, 0.0, 0.5, 0.35 ); m_pControlRect[ CONTROL_TROUBLE_LIST].SetRect( 0.0, 0.35, 0.5, 0.8 ); m_pControlRect[ CONTROL_EVENT_LIST].SetRect( 0.0, 0.8, 0.35, 1.0 ); m_pControlRect[ CONTROL_SENSOR_PROPERTY].SetRect( 0.35, 0.8, 0.5, 1.0 ); m_pControlRect[ CONTROL_TOOLBAR].SetRect( 0.0, 0.0, 0.25, 0.063 ); m_pControlRect[ CONTROL_VIDEO_MAIN ].bVisible = TRUE; m_pControlRect[ CONTROL_VIDEO_NAVIGATE ].bVisible = TRUE; m_pControlRect[ CONTROL_VIDEO_LIST ].bVisible = TRUE; m_pControlRect[ CONTROL_WHOLE_MAP].bVisible = TRUE; m_pControlRect[ CONTROL_ZOOM_MAP].bVisible = TRUE; m_pControlRect[ CONTROL_TROUBLE_LIST].bVisible = TRUE; m_pControlRect[ CONTROL_EVENT_LIST].bVisible = TRUE; m_pControlRect[ CONTROL_SENSOR_PROPERTY].bVisible = TRUE; m_pControlRect[ CONTROL_TOOLBAR].bVisible = TRUE; return TRUE; } BOOL CChicagoDlg::LoadControlSettings() { LoadControlDefaultSettings(); m_Settings.Load( "CONTROL_VIDEO_MAIN", &m_pControlRect[CONTROL_VIDEO_MAIN] ); m_Settings.Load( "CONTROL_VIDEO_NAVIGATE", &m_pControlRect[CONTROL_VIDEO_NAVIGATE] ); m_Settings.Load( "CONTROL_VIDEO_LIST", &m_pControlRect[CONTROL_VIDEO_LIST] ); m_Settings.Load( "CONTROL_WHOLE_MAP", &m_pControlRect[CONTROL_WHOLE_MAP] ); m_Settings.Load( "CONTROL_ZOOM_MAP", &m_pControlRect[CONTROL_ZOOM_MAP] ); m_Settings.Load( "CONTROL_TROUBLE_LIST", &m_pControlRect[CONTROL_TROUBLE_LIST] ); m_Settings.Load( "CONTROL_EVENT_LIST", &m_pControlRect[CONTROL_EVENT_LIST] ); m_Settings.Load( "CONTROL_SENSOR_PROPERTY", &m_pControlRect[CONTROL_SENSOR_PROPERTY] ); m_Settings.Load( "CONTROL_TOOLBAR", &m_pControlRect[CONTROL_TOOLBAR] ); m_Settings.Load( "CONTROL_VIDEO_MAIN_VISIBLE", &m_pControlRect[CONTROL_VIDEO_MAIN].bVisible ); m_Settings.Load( "CONTROL_VIDEO_NAVIGATE_VISIBLE", &m_pControlRect[CONTROL_VIDEO_NAVIGATE].bVisible ); m_Settings.Load( "CONTROL_VIDEO_LIST_VISIBLE", &m_pControlRect[CONTROL_VIDEO_LIST].bVisible ); m_Settings.Load( "CONTROL_WHOLE_MAP_VISIBLE", &m_pControlRect[CONTROL_WHOLE_MAP].bVisible ); m_Settings.Load( "CONTROL_ZOOM_MAP_VISIBLE", &m_pControlRect[CONTROL_ZOOM_MAP].bVisible ); m_Settings.Load( "CONTROL_TROUBLE_LIST_VISIBLE", &m_pControlRect[CONTROL_TROUBLE_LIST].bVisible ); m_Settings.Load( "CONTROL_EVENT_LIST_VISIBLE", &m_pControlRect[CONTROL_EVENT_LIST].bVisible ); m_Settings.Load( "CONTROL_SENSOR_PROPERTY_VISIBLE", &m_pControlRect[CONTROL_SENSOR_PROPERTY].bVisible ); m_Settings.Load( "CONTROL_TOOLBAR_VISIBLE", &m_pControlRect[CONTROL_TOOLBAR].bVisible ); return TRUE; } BOOL CChicagoDlg::SaveControlSettings() { CRect pRect[CONTROL_COUNT]; if( m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->GetSafeHwnd() ) { m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->GetWindowRect( &pRect[ CONTROL_VIDEO_NAVIGATE ] ); m_pControlRect[ CONTROL_VIDEO_NAVIGATE ].bVisible = m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->IsWindowVisible(); } if( m_pPropertySensorDlg->GetSafeHwnd() ) { m_pPropertySensorDlg->GetWindowRect( &pRect[ CONTROL_SENSOR_PROPERTY ] ); m_pControlRect[ CONTROL_SENSOR_PROPERTY ].bVisible = m_pPropertySensorDlg->IsWindowVisible(); } if( m_pTroubleListWnd->GetSafeHwnd() ) { m_pTroubleListWnd->GetWindowRect( &pRect[ CONTROL_TROUBLE_LIST ] ); m_pControlRect[ CONTROL_TROUBLE_LIST ].bVisible = m_pTroubleListWnd->IsWindowVisible(); } if( m_pEventWnd->GetSafeHwnd() ) { m_pEventWnd->GetWindowRect( &pRect[ CONTROL_EVENT_LIST ] ); m_pControlRect[ CONTROL_EVENT_LIST ].bVisible = m_pEventWnd->IsWindowVisible(); } if( m_pVideoFrameWnd->GetSafeHwnd() ) { m_pVideoFrameWnd->GetWindowRect( &pRect[ CONTROL_VIDEO_MAIN ] ); m_pControlRect[ CONTROL_VIDEO_MAIN ].bVisible = m_pVideoFrameWnd->IsWindowVisible(); } if( m_pVideoListWnd->GetSafeHwnd() ) { m_pVideoListWnd->GetWindowRect( &pRect[ CONTROL_VIDEO_LIST ] ); m_pControlRect[ CONTROL_VIDEO_LIST ].bVisible = m_pVideoListWnd->IsWindowVisible(); } if( m_pWholeAreaWnd->GetSafeHwnd() ) { m_pWholeAreaWnd->GetWindowRect( &pRect[ CONTROL_WHOLE_MAP ] ); m_pControlRect[ CONTROL_WHOLE_MAP ].bVisible = m_pWholeAreaWnd->IsWindowVisible(); } if( m_pZoomAreaWnd->GetSafeHwnd() ) { m_pZoomAreaWnd->GetWindowRect( &pRect[ CONTROL_ZOOM_MAP ] ); m_pControlRect[ CONTROL_ZOOM_MAP ].bVisible = m_pZoomAreaWnd->IsWindowVisible(); } if( m_pToolBarDlg->GetSafeHwnd() ) { m_pToolBarDlg->GetWindowRect( &pRect[ CONTROL_TOOLBAR ] ); m_pControlRect[ CONTROL_TOOLBAR ].bVisible = m_pToolBarDlg->IsWindowVisible(); } CRect rect; GetClientRect( &rect ); double dWidth = rect.Width(); double dHeight = rect.Height(); for( int i = 0; i < CONTROL_COUNT; i++ ) { ::MapWindowPoints( HWND_DESKTOP, GetSafeHwnd(), (LPPOINT)&pRect[i], 2 ); m_pControlRect[i].SetRect( pRect[i].left / dWidth, pRect[i].top / dHeight, pRect[i].right / dWidth, pRect[i].bottom / dHeight ); } m_Settings.Save( "CONTROL_VIDEO_MAIN", &m_pControlRect[CONTROL_VIDEO_MAIN] ); m_Settings.Save( "CONTROL_VIDEO_NAVIGATE", &m_pControlRect[CONTROL_VIDEO_NAVIGATE] ); m_Settings.Save( "CONTROL_VIDEO_LIST", &m_pControlRect[CONTROL_VIDEO_LIST] ); m_Settings.Save( "CONTROL_WHOLE_MAP", &m_pControlRect[CONTROL_WHOLE_MAP] ); m_Settings.Save( "CONTROL_ZOOM_MAP", &m_pControlRect[CONTROL_ZOOM_MAP] ); m_Settings.Save( "CONTROL_TROUBLE_LIST", &m_pControlRect[CONTROL_TROUBLE_LIST] ); m_Settings.Save( "CONTROL_EVENT_LIST", &m_pControlRect[CONTROL_EVENT_LIST] ); m_Settings.Save( "CONTROL_SENSOR_PROPERTY", &m_pControlRect[CONTROL_SENSOR_PROPERTY] ); m_Settings.Save( "CONTROL_TOOLBAR", &m_pControlRect[CONTROL_TOOLBAR] ); m_Settings.Save( "CONTROL_VIDEO_MAIN_VISIBLE", m_pControlRect[CONTROL_VIDEO_MAIN].bVisible ); m_Settings.Save( "CONTROL_VIDEO_NAVIGATE_VISIBLE", m_pControlRect[CONTROL_VIDEO_NAVIGATE].bVisible ); m_Settings.Save( "CONTROL_VIDEO_LIST_VISIBLE", m_pControlRect[CONTROL_VIDEO_LIST].bVisible ); m_Settings.Save( "CONTROL_WHOLE_MAP_VISIBLE", m_pControlRect[CONTROL_WHOLE_MAP].bVisible ); m_Settings.Save( "CONTROL_ZOOM_MAP_VISIBLE", m_pControlRect[CONTROL_ZOOM_MAP].bVisible ); m_Settings.Save( "CONTROL_TROUBLE_LIST_VISIBLE", m_pControlRect[CONTROL_TROUBLE_LIST].bVisible ); m_Settings.Save( "CONTROL_EVENT_LIST_VISIBLE", m_pControlRect[CONTROL_EVENT_LIST].bVisible ); m_Settings.Save( "CONTROL_SENSOR_PROPERTY_VISIBLE", m_pControlRect[CONTROL_SENSOR_PROPERTY].bVisible ); m_Settings.Save( "CONTROL_TOOLBAR_VISIBLE", m_pControlRect[CONTROL_TOOLBAR].bVisible ); return TRUE; } void CChicagoDlg::OnSupportLgsReset() { m_ResetLgsDlg.DoModal(); } void CChicagoDlg::OnSupportInterfaceDefault() { if( MessageBox( _T("Load default interface?"), _T("Confirmation"), MB_YESNO | MB_ICONQUESTION ) == IDYES ) { LoadControlDefaultSettings(); Reposition(VIEW_MAIN); // InterfaceEnableFly( FALSE ); } } void CChicagoDlg::OnSupportVideoSettings() { CVideoSettingsDlg dlg( this ); dlg.DoModal( m_pVideoBase, m_pSensorArray ); } void CChicagoDlg::CheckCopyright() { WINDOWINFO wi; wi.cbSize = sizeof(WINDOWINFO); ::GetWindowInfo( GetSafeHwnd(), &wi ); if( ( wi.dwStyle & WS_CAPTION ) != WS_CAPTION || wi.rcWindow.left != 0 || wi.rcWindow.right != ::GetSystemMetrics( SM_CXSCREEN ) || wi.rcWindow.top != 0 || wi.rcWindow.bottom != ::GetSystemMetrics( SM_CYSCREEN ) ) { ::SetWindowLong( GetSafeHwnd(), GWL_STYLE, GetWindowLong( GetSafeHwnd(), GWL_STYLE ) | WS_CAPTION ); SetWindowPos( &CWnd::wndTop, 0, 0, ::GetSystemMetrics( SM_CXSCREEN ), ::GetSystemMetrics( SM_CYSCREEN ), SWP_FRAMECHANGED ); } CString str; GetWindowText( str ); if( str != m_pSensorArray->GetCopyright() ) SetWindowText( m_pSensorArray->GetCopyright() ); } LRESULT CChicagoDlg::OnWMPowerBroadcast( WPARAM wParam, LPARAM lParam ) { LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CChicagoDlg::OnWMPowerBroadcast" ); // deny all tries to go to save mode return BROADCAST_QUERY_DENY; } void CChicagoDlg::OnSupportSettings() { CSettingsDlg dlg; if( dlg.DoModal( m_pSensorArray ) == IDOK ) { m_pEventWnd->OnChangeSettings(); m_pVideoBase->OnChangeSettings(); m_AlarmExternal.OnChangeSettings( m_pSensorArray->GetProgramSettings() ); m_pReport->SetMaxStoreTime( m_pSensorArray->GetProgramSettings().nReportDays ); } } void CChicagoDlg::OnSupportReportSettings() { if( m_pReport ) m_pReport->DlgSetup_DoModal( GetSafeHwnd() ); } void CChicagoDlg::OnSupportPhonecalllist() { CPhoneDlg dlg( this ); dlg.DoModal( m_pSensorArray ); } void CChicagoDlg::OnViewEvents() { BOOL bShow = !m_pEventWnd->IsWindowVisible(); m_pEventWnd->ShowWindow( bShow ); m_pMainMenu->CheckMenuItem( ID_VIEW_EVENTS, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) ); } void CChicagoDlg::OnViewMagnifiedmap() { BOOL bShow = !m_pZoomAreaWnd->IsWindowVisible(); m_pZoomAreaWnd->ShowWindow( bShow ); m_pMainMenu->CheckMenuItem( ID_VIEW_MAGNIFIEDMAP, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) ); } void CChicagoDlg::OnViewMap() { BOOL bShow = !m_pWholeAreaWnd->IsWindowVisible(); m_pWholeAreaWnd->ShowWindow( bShow ); m_pMainMenu->CheckMenuItem( ID_VIEW_MAP, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) ); } void CChicagoDlg::OnViewPtzcontrol() { BOOL bShow = !m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->IsWindowVisible(); m_pControlPanel[ CONTROL_VIDEO_NAVIGATE ]->ShowWindow( bShow ); m_pMainMenu->CheckMenuItem( ID_VIEW_PTZCONTROL, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) ); } void CChicagoDlg::OnViewSensorproperties() { BOOL bShow = !m_pPropertySensorDlg->IsWindowVisible(); m_pPropertySensorDlg->ShowWindow( bShow ); m_pMainMenu->CheckMenuItem( ID_VIEW_SENSORPROPERTIES, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) ); } void CChicagoDlg::OnViewTroubles() { BOOL bShow = !m_pTroubleListWnd->IsWindowVisible(); m_pTroubleListWnd->ShowWindow( bShow ); m_pMainMenu->CheckMenuItem( ID_VIEW_TROUBLES, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) ); } void CChicagoDlg::OnViewVideo() { BOOL bShow = !m_pVideoFrameWnd->IsWindowVisible(); m_pVideoFrameWnd->ShowWindow( bShow ); m_pMainMenu->CheckMenuItem( ID_VIEW_VIDEO, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) ); } void CChicagoDlg::OnViewVideolist() { BOOL bShow = !m_pVideoListWnd->IsWindowVisible(); m_pVideoListWnd->ShowWindow( bShow ); m_pMainMenu->CheckMenuItem( ID_VIEW_VIDEOLIST, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) ); } void CChicagoDlg::OnViewToolbar() { BOOL bShow = !m_pToolBarDlg->IsWindowVisible(); m_pToolBarDlg->ShowWindow( bShow ); m_pMainMenu->CheckMenuItem( ID_VIEW_TOOLBAR, MF_BYCOMMAND | ( bShow ? MF_CHECKED : MF_UNCHECKED ) ); } void CChicagoDlg::OnSupportLgsHzSchedule() { CLgMaskScheduleLgsArray array; for( INT i = 0; i < m_pSensorArray->GetSensorCount(); i++ ) { CSensor *pSensor = m_pSensorArray->GetSensor(i); if( pSensor->GetType() != CVisual::LGS ) continue; CLgMaskScheduleLgs lgs; lgs.dwId = i; _tcscpy( lgs.pName, pSensor->GetName() ); array.Add( lgs ); } CLgMaskScheduleDlg dlg; dlg.DoModal( m_pMaskSchedule, &array, GetSafeHwnd() ); m_pMaskSchedule->Save(); } void CChicagoDlg::SwitchMask( INT nLgsId, INT nMask, BOOL bOn ) { CSensorLGS *pSensor = (CSensorLGS*)m_pSensorArray->GetSensor( nLgsId ); if( !pSensor ) return; pSensor->SwitchHZ( nMask, bOn ); } void CChicagoDlg::OnSystemRepair() { 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 ) return; // post event m_pSensorArray->GetEventQueue()->PostEvent( LGS_EVENT_SYSTEM_REPAIR, 0, 0, 0, RGB(0xFF,0xFF,0xFF), (LPSTR)(LPCTSTR)_T("Full system repair") ); // initiate full system repair process m_pSensorArray->FullSystemRepair(); // show dialog panel CRepairDlg dlg( this ); if( dlg.DoModal() != IDOK ) return; // issue system stop OnCancel(); // notify main app class that should be made restart CChicagoApp *pApplication = static_cast( AfxGetApp() ); if( !pApplication ) { LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CChicagoDlg::OnSystemRepair"), _T("Can't get application") ); return; } pApplication->SetRestart(); }