//---------------------------------------------------------------------------- // Laser Guard Ltd. // Copyright © 2000-2002. All Rights Reserved. // Version 1.0 01/01/2000 // Last modification: 08/10/2003 // PROJECT: // SUBSYSTEM: // FILE: LgNetDevicePTZFlir.cpp // AUTHOR: Sergey Chizhevskiy // OVERVIEW // ~~~~~~~~ // Source file of LgNetDevicePTZFlir.cpp //---------------------------------------------------------------------------- #include "stdafx.h" #include "LgNetDevicePTZFlir.h" CLgNetDevicePTZFlir::CLgNetDevicePTZFlir() { LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CLgNetDevicePTZFlir::CLgNetDevicePTZFlir") ); } CLgNetDevicePTZFlir::~CLgNetDevicePTZFlir() { // nessesary to do it, because "vtable" will be cleared before // parent's destructor will be called CLgLinkSP::Unlink(); LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CLgNetDevicePTZFlir::~CLgNetDevicePTZFlir") ); } void CLgNetDevicePTZFlir::OnEvtGetPTZ( PTZ_DEGREE dPan, PTZ_DEGREE dTilt, PTZ_PERCENT dZoom ) { m_OutMsg.BuildEvtGetPTZ( dPan, dTilt, dZoom ); SendMessageToParent( m_OutMsg ); } void CLgNetDevicePTZFlir::OnEvtSetPTZ( PTZ_DEGREE dPan, PTZ_DEGREE dTilt, PTZ_PERCENT dZoom ) { m_OutMsg.BuildEvtSetPTZ( dPan, dTilt, dZoom ); SendMessageToParent( m_OutMsg ); } void CLgNetDevicePTZFlir::OnEvtMoveTilt( BOOL bUp, PTZ_PERCENT dSpeed ) { m_OutMsg.BuildEvtMoveTilt( bUp, dSpeed ); SendMessageToParent( m_OutMsg ); } void CLgNetDevicePTZFlir::OnEvtMovePan( BOOL bRight, PTZ_PERCENT dSpeed ) { m_OutMsg.BuildEvtMovePan( bRight, dSpeed ); SendMessageToParent( m_OutMsg ); } void CLgNetDevicePTZFlir::OnEvtMoveZoom( BOOL bTele, PTZ_PERCENT dSpeed ) { m_OutMsg.BuildEvtMoveZoom( bTele, dSpeed ); SendMessageToParent( m_OutMsg ); } void CLgNetDevicePTZFlir::OnEvtMoveFocus( BOOL bFar, PTZ_PERCENT dSpeed ) { m_OutMsg.BuildEvtMoveFocus( bFar, dSpeed ); SendMessageToParent( m_OutMsg ); } void CLgNetDevicePTZFlir::OnEvtSetIris( PTZ_PERCENT dIris ) { m_OutMsg.BuildEvtSetIris( dIris ); SendMessageToParent( m_OutMsg ); } void CLgNetDevicePTZFlir::OnEvtSetFocus( PTZ_PERCENT dFocus ) { m_OutMsg.BuildEvtSetFocus( dFocus ); SendMessageToParent( m_OutMsg ); } void CLgNetDevicePTZFlir::OnEvtGetFocus( PTZ_PERCENT dFocus ) { m_OutMsg.BuildEvtGetFocus( dFocus ); SendMessageToParent( m_OutMsg ); } void CLgNetDevicePTZFlir::OnEvtWiper( BOOL bOn ) { m_OutMsg.BuildEvtWiper( bOn ); SendMessageToParent( m_OutMsg ); } void CLgNetDevicePTZFlir::OnEvtInit() { m_OutMsg.BuildEvtInit(); SendMessageToParent( m_OutMsg ); } void CLgNetDevicePTZFlir::OnEvtCommandError( INT nCommand, LPCTSTR pFormat, ... ) { va_list marker; va_start( marker, pFormat ); m_OutMsg.BuildEvtCommandError( nCommand, pFormat, marker ); va_end( marker ); CLgNetObject::SendMessageToParent( m_OutMsg ); LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, "CLgNetDevicePTZFlir::OnEvtCommandError" ); } BOOL CLgNetDevicePTZFlir::DeviceProc( CLgNetSocket *pSocket, CProtocol *pProtocol ) { // cast to related protocol CProtocolPTZFlir *pProtocolPTZ = (CProtocolPTZFlir*) pProtocol; // check input command if( CLgDevicePTZFlir::IsReadyForCmd() && CLgNetObject::PopMessage( m_InMsg ) ) { m_OutMsg.SetDistinationID( m_InMsg.GetSenderID() ); m_OutMsg.SetSenderID( GetID() ); // depend on command BYTE bCommand; if( m_InMsg.GetCommand( &bCommand ) ) { PTZ_POSITION pos; PTZ_PAN pan; PTZ_TILT tilt; PTZ_ZOOM zoom; PTZ_PERCENT iris; PTZ_PERCENT focus; switch( bCommand ) { case CLgDevicePTZFlir::CMD_GET_PTZ: CmdGetPTZ(); break; case CLgDevicePTZFlir::CMD_SET_PTZ: if( m_InMsg.GetPTZ( &pos ) ) CmdSetPTZ( pos.dPan, pos.dTilt, pos.dZoom ); break; case CLgDevicePTZFlir::CMD_MOVE_TILT: if( m_InMsg.GetTilt( &tilt ) ) CmdMoveTilt( tilt.bUp, tilt.dSpeed ); break; case CLgDevicePTZFlir::CMD_MOVE_PAN: if( m_InMsg.GetPan( &pan ) ) CmdMovePan( pan.bRight, pan.dSpeed ); break; case CLgDevicePTZFlir::CMD_MOVE_ZOOM: if( m_InMsg.GetZoom( &zoom ) ) CmdMoveZoom( zoom.bTele, zoom.dSpeed ); break; case CLgDevicePTZFlir::CMD_SET_IRIS: //if( m_InMsg.GetIris( &iris ) ) // CmdSetIris( iris ); break; case CLgDevicePTZFlir::CMD_SET_FOCUS: //if( m_InMsg.GetFocus( &focus ) ) // CmdSetFocus( focus ); break; case CLgDevicePTZFlir::CMD_GET_FOCUS: //CmdGetFocus(); break; default: OnEvtCommandError( -1, _T("UNKNOWN COMMAND") ); break; } } } // write command LONG lTimeout = 0L; BOOL bRead = WriteProc( pProtocolPTZ, &lTimeout ); // read responce if nessessary if( bRead ) bRead = ReadProc( pProtocolPTZ, lTimeout, TRUE ); else { bRead = TRUE; ::Sleep( lTimeout ); } return bRead; }