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.
122 lines
3.0 KiB
122 lines
3.0 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: LgNetSocketMigvanPTZ.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of LgNetSocketMigvanPTZ.cpp
|
|
//----------------------------------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "..\Version.h"
|
|
#include "LgNetSocketMigvanPTZ.h"
|
|
#include "LgNetDeviceMigvanPTZ.h"
|
|
|
|
CLgNetSocketMigvanPTZ::CLgNetSocketMigvanPTZ()
|
|
{
|
|
// clear address array
|
|
memset( m_pAddressArray, 0, sizeof(m_pAddressArray) );
|
|
}
|
|
|
|
CLgNetSocketMigvanPTZ::~CLgNetSocketMigvanPTZ()
|
|
{
|
|
Destroy();
|
|
|
|
// unlink all linked devices
|
|
CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Unlink();
|
|
}
|
|
|
|
BOOL CLgNetSocketMigvanPTZ::Create( LPCTSTR pCommPort, BOOL bDemo )
|
|
{
|
|
Destroy();
|
|
|
|
if( !bDemo )
|
|
{
|
|
if( !m_Connection.Create( pCommPort, 4800, 8, NOPARITY, ONESTOPBIT, 1024, 1024 ) )
|
|
return FALSE;
|
|
|
|
if( !m_Protocol.Create( &m_Connection ) )
|
|
return FALSE;
|
|
}
|
|
|
|
if( !CLgNetSocket::Create( &m_Protocol ) )
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CLgNetSocketMigvanPTZ::Destroy()
|
|
{
|
|
CLgNetSocket::Destroy();
|
|
m_Protocol.Destroy();
|
|
m_Connection.Destroy();
|
|
}
|
|
|
|
BOOL CLgNetSocketMigvanPTZ::Link( CLgLink<CLgNetSocketDevice,CLgNetSocket>* pLink )
|
|
{
|
|
for( INT i = MIN_ADDRESS; i <= MAX_ADDRESS; i++ )
|
|
{
|
|
if( m_pAddressArray[i] == FALSE )
|
|
{
|
|
// try to attach device
|
|
if( CLgNetSocket::Link( pLink ) )
|
|
{
|
|
// assign address to device
|
|
static_cast<CLgNetDeviceMigvanPTZ*>(pLink->GetThis())->SetAddress( i );
|
|
// mark address as unavailible for assignment
|
|
m_pAddressArray[i] = TRUE;
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CLgNetSocketMigvanPTZ::Unlink( CLgLink<CLgNetSocketDevice,CLgNetSocket>* pLink )
|
|
{
|
|
// if( !CLgNetSocket::CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Unlink( pLink ) )
|
|
// return FALSE;
|
|
if( !CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Unlink( pLink ) )
|
|
return FALSE;
|
|
|
|
// mark address as free for assignment
|
|
m_pAddressArray[ static_cast<CLgNetDeviceMigvanPTZ*>( pLink->GetThis() )->GetAddress() ] = FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
/*
|
|
BOOL CLgNetSocketMigvanPTZ::AttachDevice( CLgNetSocketDevice* pDevice )
|
|
{
|
|
for( INT i = MIN_ADDRESS; i <= MAX_ADDRESS; i++ )
|
|
{
|
|
if( m_pAddressArray[i] == FALSE )
|
|
{
|
|
// try to attach device
|
|
if( CLgNetSocket::AttachDevice( pDevice ) )
|
|
{
|
|
// assign address to device
|
|
((CLgNetDeviceMigvanPTZ*)pDevice)->SetAddress( i );
|
|
// mark address as unavailible for assignment
|
|
m_pAddressArray[i] = TRUE;
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CLgNetSocketMigvanPTZ::DetachDevice( CLgNetSocketDevice* pDevice )
|
|
{
|
|
if( !CLgNetSocket::DetachDevice( pDevice ) )
|
|
return FALSE;
|
|
|
|
// mark address as free for assignment
|
|
m_pAddressArray[ ((CLgNetDeviceMigvanPTZ*)pDevice)->GetAddress() ] = FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
*/
|