//---------------------------------------------------------------------------- // Laser Guard Ltd. // Copyright © 2000-2002. All Rights Reserved. // Version 1.0 01/01/2000 // Last modification: 08/10/2003 // PROJECT: // SUBSYSTEM: // FILE: cnesher.cpp // AUTHOR: Sergey Chizhevskiy // OVERVIEW // ~~~~~~~~ // Source file of ctks576.cpp //---------------------------------------------------------------------------- #include "stdafx.h" #include "cnesher.h" #ifdef EMBEDDED_CAMERA_NESHER #include "..\lglib\comm\pnesher.cpp" #include "..\lglib\device\dnesher.cpp" CCameraNesherPTZ::CCameraNesherPTZ() { m_pComm = NULL; m_pCamera = NULL; } CCameraNesherPTZ::~CCameraNesherPTZ() { Destroy(); } BOOL CCameraNesherPTZ::Create( CCamera *pCamera, CComm485* pComm, CComm485::PORTS nPort, LGS::PCAMERA_PARAMETERS pParameters, SWITCHER_SETTINGS *pSwitcher ) { // destroy old incarnation :) Destroy(); m_pComm = pComm; m_pCamera = pCamera; if( !m_pComm->Create( nPort, 19200L, 8, CComm485::_NOPARITY ) ) return FALSE; if( !m_Protocol.Create( m_pComm ) ) return FALSE; SetProtocol( &m_Protocol ); m_pTable[0] = pSwitcher->pTable[0]; m_pTable[1] = pSwitcher->pTable[1]; m_pTable[2] = pSwitcher->pTable[2]; m_nTimeoutCommand = pSwitcher->nReplyTimeout; m_nTimeoutAfterCommand = pSwitcher->nCommandTimeout; m_nTimeoutEnterSwitch = pSwitcher->nAutoEnterTimeout * 1000L; // convert to ms m_nTimeoutInterSwitch = pSwitcher->nAutoSwitchTimeout * 1000L; // convert to ms m_nSwitchMode = pSwitcher->nAutoMode; return TRUE; } void CCameraNesherPTZ::Destroy() { m_Protocol.Destroy(); if( m_pComm ) { m_pComm->Destroy(); m_pComm = NULL; } } BOOL CCameraNesherPTZ::CmdSetPTZ( PTZ_DEGREE dPan, PTZ_DEGREE dTilt, PTZ_PERCENT dZoom ) { if ( dPan > m_pTable[2] ) dPan = (LGS_MIRROR_ANGLE_OF_VIEW * 4 / 4 - LGS_MIRROR_ANGLE_OF_VIEW / 8); else if ( dPan > m_pTable[1] ) dPan = (LGS_MIRROR_ANGLE_OF_VIEW * 3 / 4 - LGS_MIRROR_ANGLE_OF_VIEW / 8); else if ( dPan > m_pTable[0] ) dPan = (LGS_MIRROR_ANGLE_OF_VIEW * 2 / 4 - LGS_MIRROR_ANGLE_OF_VIEW / 8); else dPan = (LGS_MIRROR_ANGLE_OF_VIEW * 1 / 4 - LGS_MIRROR_ANGLE_OF_VIEW / 8); return CLgDevicePTZNesher::CmdSetPTZ( dPan, dTilt, dZoom ); } #endif // EMBEDDED_CAMERA_NESHER