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.
|
|
//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright � 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: DeviceCameraMic1300.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of DeviceCameraMic1300.cpp
//----------------------------------------------------------------------------
#include "stdafx.h"
#include "DeviceCameraMic1300.h"
#include "..\..\LgLib\Net\LgNetDeviceMic1300PTZ.h"
#include "..\..\LgLib\Net\LgNetSocketMic1300PTZ.h"
#include "..\..\LgLib\Version.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;#define new DEBUG_NEW
#endif
CDeviceCameraMic1300::CDeviceCameraMic1300(){// m_bEnable = FALSE;
// 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("CDeviceCameraMic1300::CDeviceCameraMic1300") );}
CDeviceCameraMic1300::~CDeviceCameraMic1300(){ LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceCameraMic1300::~CDeviceCameraMic1300") );}
BOOL CDeviceCameraMic1300::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(); } // 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: case PTZC_WIPER: break; } }
// to prevent processor overheating
Sleep( 10 );
return TRUE; }
// to do normal processing
// call actual DeviceProc
CLgNetDeviceMic1300PTZ::DeviceProc( (CSocketCameraMic1300*)pSocket, pProtocol );
CLgNetMessageMic1300PTZ 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; case PTZC_WIPER: msg.BuildCmdWiper( event.wiper.on ); 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 CLgDevicePTZMic1300::EVT_GET_PTZ: if( msg.GetPTZ( &position ) ) CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 ); break; case CLgDevicePTZMic1300::EVT_SET_PTZ: if( msg.GetPTZ( &position ) ) CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 ); break; case CLgDevicePTZMic1300::EVT_MOVE_PAN: case CLgDevicePTZMic1300::EVT_MOVE_TILT: case CLgDevicePTZMic1300::EVT_MOVE_ZOOM: case CLgDevicePTZMic1300::EVT_SET_IRIS: case CLgDevicePTZMic1300::EVT_WIPER: case CLgDevicePTZMic1300::EVT_COMMAND_ERROR: default: CDevicePTZ::SetReady(); break; } } }
return TRUE;}
|