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.
176 lines
4.9 KiB
176 lines
4.9 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: LgNetDevicePTZNesher.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of LgNetDevicePTZNesher.cpp
|
|
//----------------------------------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "LgNetDevicePTZNesher.h"
|
|
|
|
CLgNetDevicePTZNesher::CLgNetDevicePTZNesher()
|
|
{
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CLgNetDevicePTZNesher::CLgNetDevicePTZNesher") );
|
|
}
|
|
|
|
CLgNetDevicePTZNesher::~CLgNetDevicePTZNesher()
|
|
{
|
|
// nessesary to do it, because "vtable" will be cleared before
|
|
// parent's destructor will be called
|
|
CLgLinkSP<CLgNetSocketDevice,CLgNetSocket>::Unlink();
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CLgNetDevicePTZNesher::~CLgNetDevicePTZNesher") );
|
|
}
|
|
|
|
void CLgNetDevicePTZNesher::OnEvtGetPTZ( PTZ_DEGREE dPan, PTZ_DEGREE dTilt, PTZ_PERCENT dZoom )
|
|
{
|
|
m_OutMsg.BuildEvtGetPTZ( dPan, dTilt, dZoom );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZNesher::OnEvtSetPTZ( PTZ_DEGREE dPan, PTZ_DEGREE dTilt, PTZ_PERCENT dZoom )
|
|
{
|
|
m_OutMsg.BuildEvtSetPTZ( dPan, dTilt, dZoom );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZNesher::OnEvtMoveTilt( BOOL bUp, PTZ_PERCENT dSpeed )
|
|
{
|
|
m_OutMsg.BuildEvtMoveTilt( bUp, dSpeed );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZNesher::OnEvtMovePan( BOOL bRight, PTZ_PERCENT dSpeed )
|
|
{
|
|
m_OutMsg.BuildEvtMovePan( bRight, dSpeed );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZNesher::OnEvtMoveZoom( BOOL bTele, PTZ_PERCENT dSpeed )
|
|
{
|
|
m_OutMsg.BuildEvtMoveZoom( bTele, dSpeed );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZNesher::OnEvtMoveFocus( BOOL bFar, PTZ_PERCENT dSpeed )
|
|
{
|
|
m_OutMsg.BuildEvtMoveFocus( bFar, dSpeed );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZNesher::OnEvtSetIris( PTZ_PERCENT dIris )
|
|
{
|
|
m_OutMsg.BuildEvtSetIris( dIris );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZNesher::OnEvtSetFocus( PTZ_PERCENT dFocus )
|
|
{
|
|
m_OutMsg.BuildEvtSetFocus( dFocus );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZNesher::OnEvtGetFocus( PTZ_PERCENT dFocus )
|
|
{
|
|
m_OutMsg.BuildEvtGetFocus( dFocus );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZNesher::OnEvtWiper( BOOL bOn )
|
|
{
|
|
m_OutMsg.BuildEvtWiper( bOn );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZNesher::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, "CLgNetDevicePTZNesher::OnEvtCommandError" );
|
|
}
|
|
|
|
BOOL CLgNetDevicePTZNesher::DeviceProc( CLgNetSocket *pSocket, CProtocol *pProtocol )
|
|
{
|
|
// cast to related protocol
|
|
// CProtocolPTZNesher *pProtocolPTZ = (CProtocolPTZNesher*) pProtocol;
|
|
|
|
// check input command
|
|
if( CLgDevicePTZNesher::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 CLgDevicePTZNesher::CMD_GET_PTZ:
|
|
CmdGetPTZ();
|
|
break;
|
|
case CLgDevicePTZNesher::CMD_SET_PTZ:
|
|
if( m_InMsg.GetPTZ( &pos ) )
|
|
CmdSetPTZ( pos.dPan, pos.dTilt, pos.dZoom );
|
|
break;
|
|
case CLgDevicePTZNesher::CMD_MOVE_TILT:
|
|
if( m_InMsg.GetTilt( &tilt ) )
|
|
CmdMoveTilt( tilt.bUp, tilt.dSpeed );
|
|
break;
|
|
case CLgDevicePTZNesher::CMD_MOVE_PAN:
|
|
if( m_InMsg.GetPan( &pan ) )
|
|
CmdMovePan( pan.bRight, pan.dSpeed );
|
|
break;
|
|
case CLgDevicePTZNesher::CMD_MOVE_ZOOM:
|
|
if( m_InMsg.GetZoom( &zoom ) )
|
|
CmdMoveZoom( zoom.bTele, zoom.dSpeed );
|
|
break;
|
|
case CLgDevicePTZNesher::CMD_SET_IRIS:
|
|
if( m_InMsg.GetIris( &iris ) )
|
|
CmdSetIris( iris );
|
|
break;
|
|
case CLgDevicePTZNesher::CMD_SET_FOCUS:
|
|
if( m_InMsg.GetFocus( &focus ) )
|
|
CmdSetFocus( focus );
|
|
break;
|
|
case CLgDevicePTZNesher::CMD_GET_FOCUS:
|
|
CmdGetFocus();
|
|
break;
|
|
default:
|
|
OnEvtCommandError( -1, _T("UNKNOWN COMMAND") );
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// write command
|
|
LONG lTimeout = 0L;
|
|
BOOL bRead = WriteProc( /*pProtocolPTZ*/NULL, &lTimeout );
|
|
|
|
// read responce if nessessary
|
|
if( bRead )
|
|
bRead = ReadProc( NULL/*pProtocolPTZ*/, lTimeout, TRUE );
|
|
else
|
|
{
|
|
bRead = TRUE;
|
|
::Sleep( lTimeout );
|
|
}
|
|
|
|
return bRead;
|
|
}
|