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.
 
 
 
 
 

168 lines
4.6 KiB

//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright © 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: DeviceCameraPhilipsG3AD.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of DeviceCameraPhilipsG3AD.cpp
//----------------------------------------------------------------------------
#include "stdafx.h"
#include "DeviceCameraPelco.h"
#include "SensorArray.h"
#include "..\..\LgLib\Version.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
CDeviceCameraPelco::CDeviceCameraPelco()
{
// static DWORD nID = 0;
// SetID( nID++ );
// m_MessageDispatcher.SetID( nID++ );
m_MessageDispatcher.CLgLinkP<CLgNetObject,CLgNetObject,CLgNetObjectChild>::Link( this );
SetDeviceType( DT_CAMERA_PTZ );
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceCameraPelco::CDeviceCameraPelco") );
}
CDeviceCameraPelco::~CDeviceCameraPelco()
{
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceCameraPelco::~CDeviceCameraPelco") );
}
BOOL CDeviceCameraPelco::DeviceProc( CLgNetSocket *pSocket, CProtocol *pProtocol )
{
// check for demo mode
BOOL bDemo = FALSE;
if( CDevice::GetSocket() )
{
CSensorArray *pSensorArray = CDevice::GetSocket()->GetSensorArray();
if( pSensorArray )
bDemo = pSensorArray->IsDemo();
}
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceCameraPelco::DeviceProc", "%d start...", 0 );
LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CDeviceCameraPelco::DeviceProc", "%d start...", 0 );
// if demo mode to do emulation
if( bDemo )
{
// "process" commands
PTZEVENT event;
while( m_Queue.Pop( event ) )
{
switch( event.id )
{
case PTZC_INIT:
case PTZC_GET_PTZ:
CDevicePTZ::SetPTZ( 0, 0, 0 );
break;
case PTZC_SET_PTZ:
CDevicePTZ::SetPTZ( event.ptz.pan, event.ptz.tilt, event.ptz.zoom );
break;
case PTZC_RESET:
case PTZC_PAN:
case PTZC_TILT:
case PTZC_ZOOM:
case PTZC_IRIS:
break;
}
}
// to prevent processor overheating
Sleep( 10 );
return TRUE;
}
// to do normal processing
// call actual DeviceProc
CLgNetDevicePTZPelco::DeviceProc( (CSocketCameraPelco*)pSocket, pProtocol );
CLgNetMessagePTZ msg;
msg.SetSenderID( m_MessageDispatcher.GetID() );
msg.SetDistinationID( GetID() );
// process commands
PTZEVENT event;
while( m_Queue.Pop( event ) )
{
switch( event.id )
{
/* case PTZC_INIT:
msg.BuildCmdInit();
m_MessageDispatcher.SendMessageToChild( msg );
break;
*/ case PTZC_GET_PTZ:
msg.BuildCmdGetPTZ();
m_MessageDispatcher.SendMessageToChild( msg );
break;
case PTZC_RESET:
// msg.BuildCmdWarmBoot();
// m_MessageDispatcher.SendMessageToChild( msg );
break;
case PTZC_SET_PTZ:
msg.BuildCmdSetPTZ( event.ptz.pan, event.ptz.tilt, event.ptz.zoom * 100.0 );
m_MessageDispatcher.SendMessageToChild( msg );
break;
case PTZC_PAN:
msg.BuildCmdMovePan( event.move.nDir == PAN_RIGHT, ( event.move.nDir == PAN_STOP ) ? 0 : event.move.speed * 100 );
m_MessageDispatcher.SendMessageToChild( msg );
break;
case PTZC_TILT:
msg.BuildCmdMoveTilt( event.move.nDir == TILT_UP, ( event.move.nDir == TILT_STOP ) ? 0 : event.move.speed * 100 );
m_MessageDispatcher.SendMessageToChild( msg );
break;
case PTZC_ZOOM:
msg.BuildCmdMoveZoom( event.move.nDir == ZOOM_TELE, ( event.move.nDir == ZOOM_STOP ) ? 0 : event.move.speed * 100 );
m_MessageDispatcher.SendMessageToChild( msg );
break;
case PTZC_IRIS:
msg.BuildCmdSetIris( event.iris.value * 100 );
m_MessageDispatcher.SendMessageToChild( msg );
break;
default:
break;
}
}
// read messages
while( m_MessageDispatcher.PopMessage( msg ) )
{
BYTE bCommand;
if( msg.GetCommand(&bCommand) )
{
CLgDevicePTZ::PTZ_POSITION position;
switch( bCommand )
{
case CLgDevicePTZ::EVT_GET_PTZ:
if( msg.GetPTZ( &position ) )
CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
break;
case CLgDevicePTZ::EVT_SET_PTZ:
if( msg.GetPTZ( &position ) )
CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
break;
case CLgDevicePTZ::EVT_MOVE_PAN:
case CLgDevicePTZ::EVT_MOVE_TILT:
case CLgDevicePTZ::EVT_MOVE_ZOOM:
case CLgDevicePTZ::EVT_SET_IRIS:
case CLgDevicePTZ::EVT_COMMAND_ERROR:
default:
CDevicePTZ::SetReady();
break;
}
}
}
return TRUE;
}