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.
216 lines
5.9 KiB
216 lines
5.9 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 13/04/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: LgNetDevicePTZ.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of LgNetDevicePTZ.cpp
|
|
//----------------------------------------------------------------------------
|
|
|
|
#include "stdafx.h"
|
|
#include "..\Version.h"
|
|
#include "LgNetDevicePTZ.h"
|
|
#include "LgNetSocketPTZ.h"
|
|
|
|
CLgNetDevicePTZ::CLgNetDevicePTZ()
|
|
{
|
|
}
|
|
|
|
CLgNetDevicePTZ::~CLgNetDevicePTZ()
|
|
{
|
|
// nessesary to do it, because "vtable" will be cleared before
|
|
// parent's destructor will be called
|
|
CLgNetSocketDevice::DetachSocket();
|
|
}
|
|
|
|
BOOL CLgNetDevicePTZ::DeviceProc( CLgNetSocket *pSocket, CProtocol *pProtocol )
|
|
{
|
|
// cast to related socket type
|
|
CLgNetSocketPTZ *pSocketPTZ = (CLgNetSocketPTZ*)pSocket;
|
|
CLgDevicePTZ *pDevicePTZ = NULL;
|
|
switch( pSocketPTZ->GetType() )
|
|
{
|
|
case CLgNetSocketPTZ::NET_SOCKET_PTZ_PG3AD: pDevicePTZ = (CLgDevicePTZ*)(CLgDevicePTZPG3AD*)this; break;
|
|
case CLgNetSocketPTZ::NET_SOCKET_PTZ_TKS576: pDevicePTZ = (CLgDevicePTZ*)(CLgDevicePTZTKS576*)this; break;
|
|
case CLgNetSocketPTZ::NET_SOCKET_PTZ_MIGVAN: pDevicePTZ = (CLgDevicePTZ*)(CLgDevicePTZMigvan*)this; break;
|
|
case CLgNetSocketPTZ::NET_SOCKET_PTZ_MIC1300: pDevicePTZ = (CLgDevicePTZ*)(CLgDevicePTZMic1300*)this; break;
|
|
}
|
|
|
|
// check input command
|
|
if( pDevicePTZ->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_SERIAL_NUMBER sn;
|
|
PTZ_PERCENT iris;
|
|
PTZ_PERCENT focus;
|
|
BYTE address;
|
|
switch( bCommand )
|
|
{
|
|
// common messages
|
|
case CLgNetMessagePTZ::CMD_GET_POSITION:
|
|
pDevicePTZ->CmdGetPosition();
|
|
break;
|
|
case CLgNetMessagePTZ::CMD_GOTO_POSITION:
|
|
if( m_InMsg.GetPosition( &pos ) )
|
|
pDevicePTZ->CmdGotoPosition( pos.dPan, pos.dTilt, pos.dZoom );
|
|
break;
|
|
case CLgNetMessagePTZ::CMD_TILT:
|
|
if( m_InMsg.GetTilt( &tilt ) )
|
|
pDevicePTZ->CmdTilt( tilt.bUp, tilt.dSpeed );
|
|
break;
|
|
case CLgNetMessagePTZ::CMD_PAN:
|
|
if( m_InMsg.GetPan( &pan ) )
|
|
pDevicePTZ->CmdPan( pan.bRight, pan.dSpeed );
|
|
break;
|
|
case CLgNetMessagePTZ::CMD_ZOOM:
|
|
if( m_InMsg.GetZoom( &zoom ) )
|
|
pDevicePTZ->CmdZoom( zoom.bTele, zoom.dSpeed );
|
|
break;
|
|
case CLgNetMessagePTZ::CMD_IRIS:
|
|
if( m_InMsg.GetIris( &iris ) )
|
|
pDevicePTZ->CmdIris( iris );
|
|
break;
|
|
case CLgNetMessagePTZ::CMD_FOCUS:
|
|
if( m_InMsg.GetFocus( &focus ) )
|
|
pDevicePTZ->CmdFocus( focus );
|
|
break;
|
|
|
|
// migvan messages
|
|
case CLgNetMessagePTZ::CMD_GET_SERIAL_NUMBER:
|
|
CmdGetSerialNumber();
|
|
break;
|
|
case CLgNetMessagePTZ::CMD_AUTO_INIT:
|
|
CmdAutoInit();
|
|
break;
|
|
case CLgNetMessagePTZ::CMD_WARM_BOOT:
|
|
CmdWarmBoot();
|
|
break;
|
|
case CLgNetMessagePTZ::CMD_SET_ADDRESS:
|
|
if( m_InMsg.GetSerialNumber( &sn ) )
|
|
CLgDevicePTZMigvan::CmdSetAddress( sn.pSerialNumber, sn.bAddress );
|
|
break;
|
|
|
|
// mic1300
|
|
case CLgNetMessagePTZ::CMD_INIT:
|
|
CLgDevicePTZMic1300::CmdInit();
|
|
break;
|
|
case CLgNetMessagePTZ::CMD_SET_ADDRESS:
|
|
if( m_InMsg.GetAddress( &address ) )
|
|
CLgDevicePTZMic1300::CmdSetAddress( address );
|
|
break;
|
|
|
|
// tks576
|
|
case CLgNetMessagePTZ::CMD_INIT:
|
|
CLgDevicePTZTKS576::CmdInit();
|
|
break;
|
|
|
|
// common
|
|
default:
|
|
OnEvtCommandError( -1, _T("UNKNOWN COMMAND") );
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// write command
|
|
LONG lTimeout = 0L;
|
|
BOOL bRead = pDevicePTZ->WriteProc( pProtocol, &lTimeout );
|
|
|
|
// read responce if nessessary
|
|
if( bRead )
|
|
bRead = pDevicePTZ->ReadProc( pProtocol, lTimeout, TRUE );
|
|
else
|
|
{
|
|
bRead = TRUE;
|
|
::Sleep( lTimeout );
|
|
}
|
|
|
|
return bRead;
|
|
}
|
|
|
|
void CLgNetDevicePTZ::OnEvtGetPosition( PTZ_DEGREE dPan, PTZ_DEGREE dTilt, PTZ_PERCENT dZoom )
|
|
{
|
|
m_OutMsg.BuildEvtGetPosition( dPan, dTilt, dZoom );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZ::OnEvtGotoPosition( PTZ_DEGREE dPan, PTZ_DEGREE dTilt, PTZ_PERCENT dZoom )
|
|
{
|
|
m_OutMsg.BuildEvtGotoPosition( dPan, dTilt, dZoom );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZ::OnEvtTilt( BOOL bUp, PTZ_PERCENT dSpeed )
|
|
{
|
|
m_OutMsg.BuildEvtTilt( bUp, dSpeed );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZ::OnEvtPan( BOOL bRight, PTZ_PERCENT dSpeed )
|
|
{
|
|
m_OutMsg.BuildEvtPan( bRight, dSpeed );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZ::OnEvtZoom( BOOL bTele, PTZ_PERCENT dSpeed )
|
|
{
|
|
m_OutMsg.BuildEvtZoom( bTele, dSpeed );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZ::OnEvtIris( PTZ_PERCENT dIris )
|
|
{
|
|
m_OutMsg.BuildEvtIris( dIris );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZ::OnEvtFocus( PTZ_PERCENT dFocus )
|
|
{
|
|
m_OutMsg.BuildEvtFocus( dFocus );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZ::OnEvtAutoInit( PBYTE pSerialNumber, BYTE bAddress )
|
|
{
|
|
m_InMsg.BuildEvtAutoInit( pSerialNumber, bAddress );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZ::OnEvtWarmBoot()
|
|
{
|
|
m_InMsg.BuildEvtWarmBoot();
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZ::OnEvtGetSerialNumber( PBYTE pSerialNumber )
|
|
{
|
|
m_InMsg.BuildEvtGetSerialNumber( pSerialNumber );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZ::OnEvtSetAddress( BYTE bAddress, PBYTE pSerialNumber )
|
|
{
|
|
m_InMsg.BuildEvtSetAddress( bAddress, pSerialNumber );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|
|
|
|
void CLgNetDevicePTZ::OnEvtWiper( BOOL bOn )
|
|
{
|
|
m_OutMsg.BuildEvtWiper( bOn );
|
|
SendMessageToParent( m_OutMsg );
|
|
}
|