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.
194 lines
4.8 KiB
194 lines
4.8 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: LgUISiteEngine.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of LgUISiteEngine.cpp
|
|
//----------------------------------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "LgUISiteEngine.h"
|
|
#include "LgUISiteCamera.h"
|
|
#include "LgUISiteSensorLGS.h"
|
|
#include "LgUISiteSensorWnd.h"
|
|
#include "LgUISiteTroubleWnd.h"
|
|
#include "LgUISiteTroubleListWnd.h"
|
|
#include "LgUISiteClock.h"
|
|
#include "..\UICamera\LgUICameraEngine.h"
|
|
#include "..\UICamera\LgUICameraVideoWnd.h"
|
|
#include "..\UIMap\LgUIMapEngine.h"
|
|
#include "..\UIMap\LgUIMapWholeWnd.h"
|
|
|
|
CLgUISiteEngine::CLgUISiteEngine()
|
|
{
|
|
}
|
|
|
|
CLgUISiteEngine::~CLgUISiteEngine()
|
|
{
|
|
DestroyAllObject();
|
|
}
|
|
|
|
BOOL CLgUISiteEngine::OnActivateSensor( CLgUISiteSensor* pSensor )
|
|
{
|
|
if( !pSensor )
|
|
return FALSE;
|
|
|
|
CLgUISiteSensorWnd *pSensorWnd = *this;
|
|
if( !pSensorWnd )
|
|
return FALSE;
|
|
|
|
// set new sensor for sensor property wnd
|
|
if( !pSensorWnd->Link( pSensor ) )
|
|
return FALSE;
|
|
|
|
// try to activate camera connected to the sensor
|
|
OnActivateVideoCamera( pSensor->GetVideoCamera() );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CLgUISiteEngine::OnActivateVideoCamera( CLgUISiteCamera* pCamera )
|
|
{
|
|
if( !pCamera )
|
|
return FALSE;
|
|
|
|
CLgUICameraEngine *pVideoCameraEngine = *this;
|
|
if( !pVideoCameraEngine )
|
|
return FALSE;
|
|
|
|
// try to activate video camera
|
|
if( !pCamera->CameraActivate( TRUE ) )
|
|
return FALSE;
|
|
|
|
// set it as active camera for video camera engine
|
|
return pVideoCameraEngine->SetActiveCamera( pCamera );
|
|
}
|
|
|
|
BOOL CLgUISiteEngine::OnHalCreate( HAL_OBJECT_ID objID, CLgHALCamera* pRouterCamera )
|
|
{
|
|
// check map engine existance
|
|
CLgUIMapEngine *pMapEngine = *this;
|
|
if( !pMapEngine )
|
|
return FALSE;
|
|
|
|
// check camera engine existance
|
|
CLgUICameraEngine *pCameraEngine = *this;
|
|
if( !pCameraEngine )
|
|
return FALSE;
|
|
|
|
// check site clock existance
|
|
CLgUISiteClock *pSiteClock = *this;
|
|
if( !pSiteClock )
|
|
return FALSE;
|
|
|
|
CLgUISiteCamera *pCamera = new CLgUISiteCamera( objID );
|
|
if( !pCamera )
|
|
return FALSE;
|
|
|
|
// Link within site engine
|
|
CLgLink<CLgUISiteEngine,CLgUISiteCamera>::Link( pCamera );
|
|
|
|
// perform router linking
|
|
if( !pCamera->CLgHALObject::Link( pRouterCamera ) )
|
|
return FALSE;
|
|
|
|
// Link within map engine
|
|
CLgUIMapWholeWnd *pMapWholeWnd = pMapEngine->GetWholeWnd();
|
|
if( pMapWholeWnd )
|
|
{
|
|
if( !pMapWholeWnd->Link( pCamera ) )
|
|
return FALSE;
|
|
}
|
|
|
|
// Link within camera engine
|
|
if( !pCameraEngine->CLgLink<CLgUICameraEngine,CLgUICamera>::Link( pCamera ) )
|
|
return FALSE;
|
|
|
|
// Link within site clock
|
|
if( !pSiteClock->CLgLink<CLgUISiteClock,CLgUISiteCamera>::Link( pCamera ) )
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CLgUISiteEngine::OnHalCreate( HAL_OBJECT_ID objID, CLgHALSensor* pRouterSensor )
|
|
{
|
|
// check map engine existance
|
|
CLgUIMapEngine *pMapEngine = *this;
|
|
if( !pMapEngine )
|
|
return FALSE;
|
|
|
|
CLgUISiteSensorLGS *pSensor = new CLgUISiteSensorLGS( objID );
|
|
if( !pSensor )
|
|
return FALSE;
|
|
|
|
// Link within site engine
|
|
CLgLink<CLgUISiteEngine,CLgUISiteSensor>::Link( pSensor );
|
|
|
|
// perform router linking
|
|
if( !pSensor->CLgHALObject::Link( pRouterSensor ) )
|
|
return FALSE;
|
|
|
|
// Link within map engine
|
|
CLgUIMapWholeWnd *pMapWholeWnd = pMapEngine->GetWholeWnd();
|
|
if( pMapWholeWnd )
|
|
{
|
|
if( !pMapWholeWnd->Link( pSensor ) )
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CLgUISiteEngine::DestroyAllObject()
|
|
{
|
|
CLgArray< CLgLink<CLgUISiteSensor,CLgUISiteEngine>* >& arrSensor = *this;
|
|
CLgArray< CLgLink<CLgUISiteCamera,CLgUISiteEngine>* >& arrCamera = *this;
|
|
|
|
// delete all dynamic objects
|
|
while( arrCamera.GetCount() ) delete *arrCamera[0];
|
|
while( arrSensor.GetCount() ) delete *arrSensor[0];
|
|
}
|
|
|
|
BOOL CLgUISiteEngine::OnHalLink( HAL_OBJECT_ID cameraID, HAL_OBJECT_ID sensorID )
|
|
{
|
|
CLgUISiteCamera *pCamera = NULL;
|
|
|
|
CLgArray< CLgLink<CLgUISiteCamera,CLgUISiteEngine>* >& arrCamera = *this;
|
|
for( INT i = 0; i < arrCamera.GetCount(); i++ )
|
|
{
|
|
CLgUISiteCamera *pTempCamera = *arrCamera[i];
|
|
ASSERT( pTempCamera );
|
|
if( pTempCamera->GetHALID() == cameraID )
|
|
{
|
|
pCamera = pTempCamera;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if( !pCamera )
|
|
return FALSE;
|
|
|
|
CLgUISiteSensor *pSensor = NULL;
|
|
CLgArray< CLgLink<CLgUISiteSensor,CLgUISiteEngine>* >& arrSensor = *this;
|
|
for( i = 0; i < arrSensor.GetCount(); i++ )
|
|
{
|
|
CLgUISiteSensor *pTempSensor = *arrSensor[i];
|
|
ASSERT( pTempSensor );
|
|
if( pTempSensor->GetHALID() == sensorID )
|
|
{
|
|
pSensor = pTempSensor;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if( !pSensor )
|
|
return FALSE;
|
|
|
|
return pCamera->CLgLink<CLgUISiteCamera,CLgUISiteSensor>::Link( pSensor );
|
|
}
|