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.
651 lines
18 KiB
651 lines
18 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: DeviceLGSm.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of DeviceLGSm.cpp
|
|
//----------------------------------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "SocketMD.h"
|
|
#include "SensorLGS.h"
|
|
#include "DeviceLGSm.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
#include "SensorArray.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
CDeviceLGSm::CDeviceLGSm()
|
|
{
|
|
m_pThisValid = this;
|
|
|
|
m_bEnable = FALSE;
|
|
|
|
m_bDemoOperationMode = TRUE;
|
|
|
|
m_MessageDispatcher.CLgLinkP<CLgNetObject,CLgNetObject,CLgNetObjectChild>::Link( static_cast<CLgNetDeviceLGS*>(this) );
|
|
|
|
SetDeviceType( DT_LGS );
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceLGSm::CDeviceLGSm") );
|
|
}
|
|
|
|
CDeviceLGSm::~CDeviceLGSm()
|
|
{
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceLGSm::~CDeviceLGSm") );
|
|
}
|
|
|
|
BOOL CDeviceLGSm::LGS_PostReset()
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
BOOL bResult = CDeviceLGS::LGS_PostReset();
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
|
|
return bResult;
|
|
}
|
|
|
|
BOOL CDeviceLGSm::LGS_PostRestart()
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
BOOL bResult = CDeviceLGS::LGS_PostRestart();
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
|
|
return bResult;
|
|
}
|
|
|
|
BOOL CDeviceLGSm::LGS_PostEnable( BOOL bEnable )
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
BOOL bResult = CDeviceLGS::LGS_PostEnable( bEnable );
|
|
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
|
|
return bResult;
|
|
}
|
|
|
|
void CDeviceLGSm::PTZ_PostSetPTZ( double pan, double tilt, double zoom )
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
CDevicePTZ::PTZ_PostSetPTZ( pan, tilt, zoom );
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
}
|
|
void CDeviceLGSm::PTZ_PostGetPTZ()
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
CDevicePTZ::PTZ_PostGetPTZ();
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
}
|
|
void CDeviceLGSm::PTZ_PostPan( double speed, int nDir )
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
CDevicePTZ::PTZ_PostPan( speed, nDir );
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
}
|
|
void CDeviceLGSm::PTZ_PostTilt( double speed, int nDir )
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
CDevicePTZ::PTZ_PostTilt( speed, nDir );
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
}
|
|
void CDeviceLGSm::PTZ_PostZoom( double speed, int nDir )
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
CDevicePTZ::PTZ_PostZoom( speed, nDir );
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
}
|
|
void CDeviceLGSm::PTZ_PostIris( double value )
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
CDevicePTZ::PTZ_PostIris( value );
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
}
|
|
void CDeviceLGSm::PTZ_PostWiper( BOOL bOn )
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
CDevicePTZ::PTZ_PostWiper( bOn );
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
}
|
|
|
|
BOOL CDeviceLGSm::LGS_PostGetHiddenZones()
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
BOOL bResult = CDeviceLGS::LGS_PostGetHiddenZones();
|
|
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
|
|
return bResult;
|
|
}
|
|
|
|
BOOL CDeviceLGSm::LGS_PostSetHiddenZones( CLgDeviceLGS::LGS_HZ_ARRAY& HzArray )
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
BOOL bResult = CDeviceLGS::LGS_PostSetHiddenZones( HzArray );
|
|
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
|
|
return bResult;
|
|
}
|
|
|
|
BOOL CDeviceLGSm::LGS_PostGetCalibrationTable( INT nDevice )
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
BOOL bResult = CDeviceLGS::LGS_PostGetCalibrationTable( nDevice );
|
|
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
|
|
return bResult;
|
|
}
|
|
|
|
|
|
BOOL CDeviceLGSm::LGS_PostSetCalibrationTable( CLgDeviceLGS::LGS_CALIBRATION_TABLE& cTable )
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
BOOL bResult = CDeviceLGS::LGS_PostSetCalibrationTable( cTable );
|
|
|
|
if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
|
|
|
|
return bResult;
|
|
}
|
|
|
|
BOOL CDeviceLGSm::DeviceProc( CLgNetSocket *pSocket, CProtocol *pProtocol )
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
BOOL bResult = TRUE;
|
|
|
|
__try
|
|
{
|
|
bResult = DeviceProc_( pSocket, pProtocol );
|
|
}
|
|
__except( EXCEPTION_EXECUTE_HANDLER )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProc"), _T("Exception 0x%08X"), _exception_code() );
|
|
}
|
|
|
|
return bResult;
|
|
}
|
|
|
|
BOOL CDeviceLGSm::DeviceProc_( CLgNetSocket *pSocket, CProtocol *pProtocol )
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
if( DeviceProcDemo_() )
|
|
return TRUE;
|
|
|
|
////////////////////////////////// to do normal work ///////////////////////////////////////////////////
|
|
|
|
// call actual DeviceProc
|
|
BOOL bTransaction = CLgNetDeviceLGS::DeviceProc( static_cast<CLgNetSocketMD*>(static_cast<CSocketMD*>(GetSocket())), pProtocol );
|
|
|
|
__try
|
|
{
|
|
DeviceProcLGS_();
|
|
}
|
|
__except( EXCEPTION_EXECUTE_HANDLER )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProc"), _T("DeviceProcLGS_ rises exception 0x%08X"), _exception_code() );
|
|
}
|
|
|
|
__try
|
|
{
|
|
DeviceProcPTZ_();
|
|
}
|
|
__except( EXCEPTION_EXECUTE_HANDLER )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProc"), _T("DeviceProcPTZ_ rises exception 0x%08X"), _exception_code() );
|
|
}
|
|
|
|
__try
|
|
{
|
|
DeviceProcDispatcher_();
|
|
}
|
|
__except( EXCEPTION_EXECUTE_HANDLER )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProc"), _T("DeviceProcDispatcher_ rises exception 0x%08X"), _exception_code() );
|
|
}
|
|
|
|
// test
|
|
// GetSocket()->GetSensorArray()->GetEventQueue()->PostEvent( LGS_EVENT_ERROR, 0, 0, (DWORD)m_pSensor, RGB( 0xFF, 0, 0 ), "test" );
|
|
// m_pSensor->PostTarget( TT_MASTER, rand()%360, rand() % 100 );
|
|
return bTransaction;
|
|
}
|
|
|
|
BOOL CDeviceLGSm::DeviceProcDemo_()
|
|
{
|
|
// check for demo mode
|
|
BOOL bDemo = FALSE;
|
|
if( CDevice::GetSocket() )
|
|
{
|
|
CSensorArray *pSensorArray = CDevice::GetSocket()->GetSensorArray();
|
|
if( pSensorArray )
|
|
bDemo = pSensorArray->IsDemo();
|
|
}
|
|
|
|
// if demo mode to do emulation
|
|
if( !bDemo )
|
|
return FALSE;
|
|
|
|
// "process" camera commands
|
|
PTZEVENT event_ptz;
|
|
while( CDevicePTZ::m_Queue.Pop( event_ptz ) )
|
|
{
|
|
switch( event_ptz.id )
|
|
{
|
|
case PTZC_INIT:
|
|
case PTZC_GET_PTZ:
|
|
CDevicePTZ::SetPTZ( 0, 0, 0 );
|
|
break;
|
|
case PTZC_SET_PTZ:
|
|
CDevicePTZ::SetPTZ( event_ptz.ptz.pan, event_ptz.ptz.tilt, event_ptz.ptz.zoom );
|
|
break;
|
|
case PTZC_RESET:
|
|
case PTZC_PAN:
|
|
case PTZC_TILT:
|
|
case PTZC_ZOOM:
|
|
case PTZC_IRIS:
|
|
case PTZC_WIPER:
|
|
break;
|
|
}
|
|
}
|
|
|
|
// process LGS commands
|
|
LGSEVENT event;
|
|
while( CDeviceLGS::m_Queue.Pop( event ) )
|
|
{
|
|
CLgDeviceLGS::LGS_CALIBRATION_TABLE table;
|
|
|
|
switch( event.id )
|
|
{
|
|
case LGSC_RESET:
|
|
case LGSC_RESTART:
|
|
case LGSC_ENABLE:
|
|
break;
|
|
case LGSC_GET_HZ:
|
|
m_pSensor->PostGetCalibrationTable( table );
|
|
break;
|
|
case LGSC_SET_HZ:
|
|
m_pSensor->PostSetCalibrationTable( table );
|
|
break;
|
|
}
|
|
}
|
|
|
|
// process socket events
|
|
EVENT se;
|
|
if( GetSocket()->GetEventQueue()->GetEvent( se ) )
|
|
{
|
|
if( se.pDemoDevice == this )
|
|
m_pSensor->PostTarget( 0, LGS::TT_NORMAL, se.dDemoAngle, se.dDemoRange );
|
|
}
|
|
|
|
// emulate oprational mode
|
|
if( m_bDemoOperationMode )
|
|
{
|
|
m_bDemoOperationMode = FALSE;
|
|
m_pSensor->PostOperationMode( LGS_OM_DETECTION );
|
|
}
|
|
|
|
// to prevent processor overheating :-)
|
|
Sleep(10);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDeviceLGSm::DeviceProcLGS_()
|
|
{
|
|
CLgNetMessageLGS msg;
|
|
msg.SetSenderID( m_MessageDispatcher.GetID() );
|
|
msg.SetDistinationID( CLgNetDeviceLGS::GetID() );
|
|
|
|
// process LGS commands
|
|
LGSEVENT event_lgs;
|
|
while( CDeviceLGS::m_Queue.Pop( event_lgs ) )
|
|
{
|
|
switch( event_lgs.id )
|
|
{
|
|
case LGSC_RESET:
|
|
msg.BuildCmdReset();
|
|
m_MessageDispatcher.SendMessageToChild( msg );
|
|
|
|
// log info
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received LGSC_RESET" );
|
|
break;
|
|
|
|
case LGSC_RESTART:
|
|
msg.BuildCmdRestart();
|
|
m_MessageDispatcher.SendMessageToChild( msg );
|
|
|
|
// log info
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received LGSC_RESTART" );
|
|
break;
|
|
|
|
case LGSC_GET_HZ:
|
|
msg.BuildCmdGetHzData( FALSE );
|
|
m_MessageDispatcher.SendMessageToChild( msg );
|
|
break;
|
|
|
|
case LGSC_SET_HZ:
|
|
msg.BuildCmdSetHzData( event_lgs.HzArray );
|
|
m_MessageDispatcher.SendMessageToChild( msg );
|
|
break;
|
|
|
|
case LGSC_GET_CT:
|
|
msg.BuildCmdGetCalibrationTable( event_lgs.CtTable.nDevice );
|
|
m_MessageDispatcher.SendMessageToChild( msg );
|
|
break;
|
|
|
|
case LGSC_SET_CT:
|
|
msg.BuildCmdSetCalibrationTable( event_lgs.CtTable );
|
|
m_MessageDispatcher.SendMessageToChild( msg );
|
|
break;
|
|
|
|
case LGSC_ENABLE:
|
|
// m_bEnable = event_lgs.bEnable;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDeviceLGSm::DeviceProcPTZ_()
|
|
{
|
|
CLgNetMessageLGS msg;
|
|
msg.SetSenderID( m_MessageDispatcher.GetID() );
|
|
msg.SetDistinationID( CLgNetDeviceLGS::GetID() );
|
|
|
|
// process PTZ commands
|
|
PTZEVENT event_ptz;
|
|
while( CDevicePTZ::m_Queue.Pop( event_ptz ) )
|
|
{
|
|
switch( event_ptz.id )
|
|
{
|
|
case PTZC_GET_PTZ:
|
|
msg.BuildCmdGetPTZ();
|
|
m_MessageDispatcher.SendMessageToChild( msg );
|
|
break;
|
|
case PTZC_SET_PTZ:
|
|
msg.BuildCmdSetPTZ( event_ptz.ptz.pan, event_ptz.ptz.tilt, event_ptz.ptz.zoom * 100.0 );
|
|
m_MessageDispatcher.SendMessageToChild( msg );
|
|
break;
|
|
case PTZC_PAN:
|
|
msg.BuildCmdMovePan( event_ptz.move.nDir == PAN_RIGHT, ( event_ptz.move.nDir == PAN_STOP ) ? 0 : event_ptz.move.speed * 100 );
|
|
m_MessageDispatcher.SendMessageToChild( msg );
|
|
break;
|
|
case PTZC_TILT:
|
|
msg.BuildCmdMoveTilt( event_ptz.move.nDir == TILT_UP, ( event_ptz.move.nDir == TILT_STOP ) ? 0 : event_ptz.move.speed * 100 );
|
|
m_MessageDispatcher.SendMessageToChild( msg );
|
|
break;
|
|
case PTZC_ZOOM:
|
|
msg.BuildCmdMoveZoom( event_ptz.move.nDir == ZOOM_TELE, ( event_ptz.move.nDir == ZOOM_STOP ) ? 0 : event_ptz.move.speed * 100 );
|
|
m_MessageDispatcher.SendMessageToChild( msg );
|
|
break;
|
|
case PTZC_IRIS:
|
|
msg.BuildCmdSetIris( event_ptz.iris.value * 100 );
|
|
m_MessageDispatcher.SendMessageToChild( msg );
|
|
break;
|
|
case PTZC_WIPER:
|
|
msg.BuildCmdWiper( event_ptz.wiper.on );
|
|
m_MessageDispatcher.SendMessageToChild( msg );
|
|
break;
|
|
default:
|
|
CDevicePTZ::SetReady();
|
|
break;
|
|
|
|
case PTZC_INIT:
|
|
CDevicePTZ::SetReady();
|
|
// log info
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received PTZC_INIT" );
|
|
break;
|
|
|
|
case PTZC_RESET:
|
|
CDevicePTZ::SetReady();
|
|
// log info
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received PTZC_RESET" );
|
|
break;
|
|
}
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDeviceLGSm::DeviceProcDispatcher_()
|
|
{
|
|
try
|
|
{
|
|
CLgNetDeviceLGS::LGS_TARGET target;
|
|
CLgDevicePTZ::PTZ_POSITION position;
|
|
CLgDeviceLGS::LGS_ERROR error;
|
|
CLgDeviceLGS::LGS_HZ_ARRAY HzArray;
|
|
CLgDeviceLGS::LGS_CALIBRATION_TABLE cTable;
|
|
CLgDeviceLGS::LGS_OPERATION_MODE eMode;
|
|
BOOL bPowered;
|
|
BOOL dConnected;
|
|
INT nProgress;
|
|
|
|
CLgNetMessageLGS msg;
|
|
|
|
// read messages
|
|
while( m_MessageDispatcher.PopMessage( msg ) )
|
|
{
|
|
|
|
BYTE bCommand;
|
|
|
|
|
|
try
|
|
{
|
|
if( !msg.GetCommand(&bCommand) )
|
|
continue;
|
|
}
|
|
catch(...)
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception during GetCommand") );
|
|
}
|
|
|
|
switch( bCommand )
|
|
{
|
|
case CLgDeviceLGS::EVT_ERROR:
|
|
try
|
|
{
|
|
if( msg.GetEvtError( &error ) )
|
|
{
|
|
if( error.eErrorLevel == LGS_ERROR_LEVEL_CRITICAL )
|
|
{
|
|
TCHAR pErrorText[MAX_PATH];
|
|
_sntprintf( pErrorText, MAX_PATH, _T("%s technical event type <%d>"), (LPCTSTR)m_pSensor->GetName(), error.eErrorID );
|
|
pErrorText[MAX_PATH-1] = 0;
|
|
GetSocket()->GetSensorArray()->GetEventQueue()->PostEvent( LGS_EVENT_ERROR, LGS_EVENT_ERROR_CRITICAL, 0, (DWORD)m_pSensor, RGB( 0xFF, 0, 0 ), (LPSTR)(LPCTSTR)pErrorText );
|
|
}
|
|
else
|
|
GetSocket()->GetSensorArray()->GetEventQueue()->PostEvent( LGS_EVENT_ERROR, LGS_EVENT_ERROR_NORMAL, 0, (DWORD)m_pSensor, RGB( 0xFF, 0, 0 ), (LPSTR)(LPCTSTR)error.pErrorText );
|
|
}
|
|
}
|
|
catch(...)
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception during EVT_ERROR") );
|
|
}
|
|
break;
|
|
case CLgDeviceLGS::EVT_TARGET:
|
|
try
|
|
{
|
|
if( msg.GetTarget( &target ) )
|
|
{
|
|
switch( target.bType )
|
|
{
|
|
case LGS::TT_FLIP:
|
|
case LGS::TT_CAMERA:
|
|
break;
|
|
case LGS::TT_BLIND:
|
|
m_pSensor->PostTarget( target.bDevice, LGS::TT_BLIND, target.dAngle, 0 );
|
|
break;
|
|
default:
|
|
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "%d %d", target.bDevice, target.bType );
|
|
|
|
switch( target.bDevice )
|
|
{
|
|
case 0: m_pSensor->PostTarget( 0, target.bType, target.dAngle, target.dRange ); break;
|
|
case 1: m_pSensor->PostTarget( 1, target.bType, target.dAngle, target.dRange ); break;
|
|
default:
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_WARNING, this, "CDeviceLGSm::DeviceProc", "received CLgNetMessageLGS::EVT_TARGET with unknown type %d", target.bType );
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch(...)
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception during EVT_TARGET") );
|
|
}
|
|
break;
|
|
case CLgDeviceLGS::EVT_RESET:
|
|
m_pSensor->PostReset();
|
|
// log info
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received CLgNetMessageLGS::EVT_RESET" );
|
|
break;
|
|
case CLgDeviceLGS::EVT_RESTART:
|
|
m_pSensor->PostReset();
|
|
// log info
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received CLgNetMessageLGS::EVT_RESTART" );
|
|
break;
|
|
case CLgDeviceLGS::EVT_FULL_RESET:
|
|
m_pSensor->PostReset();
|
|
// log info
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received CLgNetMessageLGS::EVT_FULL_RESET" );
|
|
break;
|
|
case CLgDeviceLGS::EVT_QUIT:
|
|
m_pSensor->PostReset();
|
|
break;
|
|
case CLgDeviceLGS::EVT_VOLTAGE:
|
|
if( msg.GetEvtVoltage( &bPowered ) )
|
|
m_pSensor->PostPower( bPowered );
|
|
break;
|
|
case CLgDeviceLGS::EVT_CONNECTION:
|
|
try
|
|
{
|
|
if( msg.GetEvtConnection( &dConnected ) )
|
|
m_pSensor->PostConnection( dConnected );
|
|
}
|
|
catch(...)
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception during EVT_CONNECTION") );
|
|
}
|
|
break;
|
|
case CLgDeviceLGS::EVT_OPERATION_MODE:
|
|
|
|
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("CLgDeviceLGS::EVT_OPERATION_MODE") );
|
|
|
|
try
|
|
{
|
|
if( msg.GetEvtOperationMode( &eMode ) )
|
|
m_pSensor->PostOperationMode( eMode );
|
|
}
|
|
catch(...)
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception during EVT_OPERATION_MODE") );
|
|
}
|
|
break;
|
|
case CLgDeviceLGS::EVT_GET_HZ_DATA:
|
|
if( msg.GetEvtGetHzData( HzArray ) )
|
|
m_pSensor->PostGetHiddenZones( HzArray );
|
|
break;
|
|
case CLgDeviceLGS::EVT_GET_HZ_DATA_PROGRESS:
|
|
if( msg.GetEvtGetHzDataProgress( &nProgress ) )
|
|
m_pSensor->PostGetHiddenZonesProgress( nProgress );
|
|
break;
|
|
case CLgDeviceLGS::EVT_SET_HZ_DATA:
|
|
if( msg.GetEvtSetHzData( HzArray ) )
|
|
m_pSensor->PostSetHiddenZones( HzArray );
|
|
break;
|
|
case CLgDeviceLGS::EVT_SET_HZ_DATA_PROGRESS:
|
|
if( msg.GetEvtSetHzDataProgress( &nProgress ) )
|
|
m_pSensor->PostSetHiddenZonesProgress( nProgress );
|
|
break;
|
|
|
|
case CLgDeviceLGS::EVT_GET_CALIBRATION_TABLE:
|
|
if( msg.GetEvtGetCalibrationTable( cTable ) )
|
|
m_pSensor->PostGetCalibrationTable( cTable );
|
|
break;
|
|
case CLgDeviceLGS::EVT_GET_CALIBRATION_TABLE_PROGRESS:
|
|
if( msg.GetEvtGetCalibrationTableProgress( &nProgress ) )
|
|
m_pSensor->PostGetCalibrationTableProgress( nProgress );
|
|
break;
|
|
case CLgDeviceLGS::EVT_SET_CALIBRATION_TABLE:
|
|
try
|
|
{
|
|
if( msg.GetEvtSetCalibrationTable( cTable ) )
|
|
m_pSensor->PostSetCalibrationTable( cTable );
|
|
}
|
|
catch(...)
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception during EVT_SET_CALIBRATION_TABLE") );
|
|
}
|
|
break;
|
|
case CLgDeviceLGS::EVT_SET_CALIBRATION_TABLE_PROGRESS:
|
|
if( msg.GetEvtSetCalibrationTableProgress( &nProgress ) )
|
|
m_pSensor->PostSetCalibrationTableProgress( nProgress );
|
|
break;
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
case CLgDeviceLGS::EVT_GET_PTZ:
|
|
if( msg.GetPTZ( &position ) )
|
|
CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
|
|
break;
|
|
case CLgDeviceLGS::EVT_SET_PTZ:
|
|
if( msg.GetPTZ( &position ) )
|
|
CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
|
|
break;
|
|
case CLgDeviceLGS::EVT_MOVE_PAN:
|
|
case CLgDeviceLGS::EVT_MOVE_TILT:
|
|
case CLgDeviceLGS::EVT_MOVE_ZOOM:
|
|
case CLgDeviceLGS::EVT_SET_IRIS:
|
|
case CLgDeviceLGS::EVT_WIPER:
|
|
case CLgDeviceLGS::EVT_COMMAND_ERROR:
|
|
CDevicePTZ::SetReady();
|
|
break;
|
|
default:
|
|
// log info
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received unknown message %d", bCommand );
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch(...)
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception") );
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void CDeviceLGSm::SetSpyMode( BOOL bSpyMode )
|
|
{
|
|
ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
|
|
|
|
// call base class
|
|
CLgNetDeviceLGS::SetSpyMode( bSpyMode );
|
|
|
|
if( m_pSensor )
|
|
m_pSensor->SetSpyMode( bSpyMode );
|
|
}
|