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.
2275 lines
74 KiB
2275 lines
74 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: SensorArray.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of SensorArray.cpp
|
|
//----------------------------------------------------------------------------
|
|
// SensorArray.cpp: implementation of the CSensorArray class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "stdafx.h"
|
|
//#include "Chicago.h"
|
|
#include "SensorArray.h"
|
|
#include "SensorLGS.h"
|
|
#include "SensorSPRU.h"
|
|
#include "SocketSPRU.h"
|
|
//#include "SocketMMServer.h"
|
|
//#include "SocketMMClient.h"
|
|
#include "SocketSM.h"
|
|
#include "SocketECS.h"
|
|
#include "SocketBackup.h"
|
|
#include "SocketMD.h"
|
|
#include "SocketLGS.h"
|
|
#include "SocketVM.h"
|
|
//#include "SocketPTZ.h"
|
|
#include "SocketPTZm.h"
|
|
#include "DeviceLGSm.h"
|
|
#include "DeviceLGSs.h"
|
|
//#include "DevicePTZs.h"
|
|
#include "DevicePTZm.h"
|
|
#include "DeviceRabbit.h"
|
|
#include "CameraPTZ.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
#include "SensorDC.h"
|
|
#include "SensorCLD.h"
|
|
#include "DeviceCLD.h"
|
|
#include "SocketRS232DI.h"
|
|
#include "SocketMigvanPTZ.h"
|
|
#include "DeviceMigvanPTZ.h"
|
|
#include "DevicePCI1762.h"
|
|
#include "DeviceCameraMic1300.h"
|
|
#include "DeviceCameraHebron.h"
|
|
#include "SocketCameraMic1300.h"
|
|
#include "SocketCCC.h"
|
|
#include "..\Chicago\DeviceCameraTKS576.h"
|
|
#include "..\Chicago\SocketCameraTKS576.h"
|
|
#include "..\DLIB\SocketCameraPhilipsG3AD.h"
|
|
#include "..\DLIB\DeviceCameraPhilipsG3AD.h"
|
|
#include "..\DLIB\SocketCameraAmericanDynamics.h"
|
|
#include "..\DLIB\DeviceCameraAmericanDynamics.h"
|
|
#include "SocketCameraPelco.h"
|
|
#include "DeviceCameraPelco.h"
|
|
#include "..\DLIB\SocketCameraVicon.h"
|
|
#include "..\DLIB\DeviceCameraVicon.h"
|
|
#include "..\..\LgLib\MFC\LgBitCodeFile.h"
|
|
|
|
#include "ObjectFactory.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
CSensorArray::CSensorArray()
|
|
{
|
|
memset( m_nLastDemoSampleTime, 0, sizeof(m_nLastDemoSampleTime) );
|
|
m_bDebugMode = FALSE;
|
|
|
|
m_nSensor = 0;
|
|
m_ppSensor = NULL;
|
|
m_hEventWnd = NULL;
|
|
|
|
m_nZonesCount = 0;
|
|
m_ppZones = NULL;
|
|
|
|
m_nSocket = 0;
|
|
m_ppSocket = NULL;
|
|
|
|
m_nSensor = 0;
|
|
m_ppSensor = NULL;
|
|
|
|
m_nBitmapsCount = 0;
|
|
m_pBitmaps = NULL;
|
|
|
|
m_nGuardsCount = 0;
|
|
m_pGuards = NULL;
|
|
|
|
m_nSupersCount = 0;
|
|
m_pSupers = NULL;
|
|
|
|
m_pConditions = NULL;
|
|
m_nConditionsCount = 0;
|
|
|
|
m_pFilters = NULL;
|
|
m_nFiltersCount = 0;
|
|
|
|
m_pCommands = NULL;
|
|
m_nCommandsCount = 0;
|
|
|
|
// m_pPatrols = NULL;
|
|
// m_nPatrolsCount = 0;
|
|
m_ppVideoCamera = NULL;
|
|
m_nVideoCamera = 0;
|
|
|
|
m_ppVideoMatrix = NULL;
|
|
m_nVideoMatrix = 0;
|
|
|
|
m_ppDirectInput = NULL;
|
|
m_nDirectInput = 0;
|
|
|
|
m_ppDirectOutput = NULL;
|
|
m_nDirectOutput = 0;
|
|
|
|
m_ppDevice = NULL;
|
|
m_nDevice = 0;
|
|
|
|
m_ppVideoCaptureDevice = NULL;
|
|
m_nVideoCaptureDevice = 0;
|
|
|
|
m_nBG = 0;
|
|
m_pBG = NULL;
|
|
|
|
m_nIrisDayHour = 7;
|
|
m_nIrisDayMinute = 0;
|
|
m_nIrisNightHour = 19;
|
|
m_nIrisNightMinute = 0;
|
|
|
|
m_dIrisDayValue = 0.4;
|
|
m_dIrisNightValue = 1.0;
|
|
|
|
m_bIrisNeedSwitchDay = TRUE;
|
|
m_bIrisNeedSwitchNight = TRUE;
|
|
|
|
m_pSettings = NULL;
|
|
|
|
m_bDemoMode = FALSE;
|
|
|
|
LOGFONT lf =
|
|
{
|
|
-16, -8/2, 0, 0, FW_NORMAL, 0UL, 0UL, 0UL,
|
|
OEM_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
|
DEFAULT_QUALITY, DEFAULT_PITCH, _T("Courier New")
|
|
};
|
|
|
|
m_ProgramSettings.LogFontReport = m_ProgramSettings.LogFontVideo = lf;
|
|
m_ProgramSettings.ColorVideo = RGB(255,0,0);
|
|
m_ProgramSettings.Capture.dZoomScale = 1.0;
|
|
|
|
m_bBackgroundDirty = FALSE;
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CSensorArray::CSensorArray") );
|
|
}
|
|
|
|
CSensorArray::~CSensorArray()
|
|
{
|
|
if( m_ppSocket )
|
|
{
|
|
for( int i = 0; i < m_nSocket; i++ )
|
|
delete m_ppSocket[i];
|
|
free( m_ppSocket );
|
|
}
|
|
|
|
if( m_ppSensor )
|
|
{
|
|
for( int i = 0; i < m_nSensor; i++ )
|
|
delete m_ppSensor[i];
|
|
free( m_ppSensor );
|
|
m_nSensor = 0;
|
|
m_ppSensor = NULL;
|
|
}
|
|
|
|
if( m_ppZones )
|
|
{
|
|
for( int i = 0; i < m_nZonesCount; i++ )
|
|
delete m_ppZones[i];
|
|
delete [] m_ppZones;
|
|
}
|
|
|
|
if( m_pBitmaps )
|
|
{
|
|
for( int i = 0; i < m_nBitmapsCount; i++ )
|
|
::DeleteObject( m_pBitmaps[i].Detach() );
|
|
delete [] m_pBitmaps;
|
|
}
|
|
|
|
if( m_pGuards )
|
|
{
|
|
delete [] m_pGuards;
|
|
}
|
|
|
|
if( m_pSupers )
|
|
{
|
|
delete [] m_pSupers;
|
|
}
|
|
|
|
if( m_pConditions )
|
|
{
|
|
delete [] m_pConditions;
|
|
}
|
|
|
|
if( m_pFilters )
|
|
{
|
|
delete [] m_pFilters;
|
|
}
|
|
|
|
if( m_pCommands )
|
|
{
|
|
delete [] m_pCommands;
|
|
}
|
|
|
|
if( m_ppVideoCaptureDevice )
|
|
{
|
|
for( int i = 0; i < m_nVideoCaptureDevice; i++ )
|
|
delete m_ppVideoCaptureDevice[i];
|
|
free( m_ppVideoCaptureDevice );
|
|
}
|
|
|
|
if( m_ppVideoMatrix )
|
|
{
|
|
for( int i = 0; i < m_nVideoMatrix; i++ )
|
|
delete m_ppVideoMatrix[i];
|
|
delete [] m_ppVideoMatrix;
|
|
}
|
|
|
|
if( m_ppVideoCamera )
|
|
{
|
|
for( int i = 0; i < m_nVideoCamera; i++ )
|
|
delete m_ppVideoCamera[i];
|
|
free( m_ppVideoCamera );
|
|
}
|
|
|
|
if( m_ppDirectInput )
|
|
{
|
|
for( int i = 0; i < m_nDirectInput; i++ )
|
|
delete m_ppDirectInput[i];
|
|
free( m_ppDirectInput );
|
|
}
|
|
|
|
if( m_ppDirectOutput )
|
|
{
|
|
for( int i = 0; i < m_nDirectOutput; i++ )
|
|
delete m_ppDirectOutput[i];
|
|
free( m_ppDirectOutput );
|
|
}
|
|
|
|
if( m_ppDevice )
|
|
{
|
|
for( int i = 0; i < m_nDevice; i++ )
|
|
delete m_ppDevice[i];
|
|
free( m_ppDevice );
|
|
}
|
|
|
|
if( m_pBG )
|
|
{
|
|
delete [] m_pBG;
|
|
}
|
|
|
|
UpdateSettings();
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CSensorArray::~CSensorArray") );
|
|
}
|
|
|
|
CSensor* CSensorArray::GetSensor( SDPOINT& p )
|
|
{
|
|
double dMin = DBL_MAX;
|
|
INT nMin = -1;
|
|
for( INT i = 0; i < m_nSensor; i++ )
|
|
{
|
|
SDPOINT sp = m_ppSensor[i]->GetPosition();
|
|
double d = sqrt( pow( sp.x - p.x, 2 ) + pow( sp.y - p.y, 2 ) );
|
|
if( d < dMin )
|
|
{
|
|
dMin = d;
|
|
nMin = i;
|
|
}
|
|
}
|
|
if( nMin != -1 )
|
|
return m_ppSensor[nMin];
|
|
|
|
return NULL;
|
|
}
|
|
|
|
CSensor* CSensorArray::GetSensor( CLgDRect& drect )
|
|
{
|
|
for( INT i = 0; i < m_nSensor; i++ )
|
|
{
|
|
SDPOINT sp = m_ppSensor[i]->GetPosition();
|
|
if( sp.x >= drect.left && sp.x <= drect.right &&
|
|
sp.y >= drect.top && sp.y <= drect.bottom )
|
|
{
|
|
return m_ppSensor[i];
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
CZone* CSensorArray::GetZone(SDPOINT &p)
|
|
{
|
|
double dMin = DBL_MAX;
|
|
INT nMin = -1;
|
|
for( INT i = 0; i < m_nZonesCount; i++ )
|
|
{
|
|
SDPOINT sp = m_ppZones[i]->GetPosition();
|
|
double d = sqrt( pow( sp.x - p.x, 2 ) + pow( sp.y - p.y, 2 ) );
|
|
if( d < dMin )
|
|
{
|
|
dMin = d;
|
|
nMin = i;
|
|
}
|
|
}
|
|
if( nMin != -1 )
|
|
return m_ppZones[nMin];
|
|
|
|
return NULL;
|
|
}
|
|
/*
|
|
void CSensorArray::Paint( CDC *pDC, CRect& viewRect, CSize& mapSize, SDPOINT& mapShift, double mapScale, BOOL bInverse, BOOL bBigSize )
|
|
{
|
|
for( INT i = 0; i < m_nSensor; i++ )
|
|
m_ppSensor[i]->Paint( pDC, viewRect, mapSize, mapShift, mapScale, bInverse, bBigSize );
|
|
for( INT z = 0; z < m_nZonesCount; z++ )
|
|
m_ppZones[z]->Paint( pDC, viewRect, mapSize, mapShift, mapScale, bInverse, bBigSize );
|
|
}
|
|
*/
|
|
using namespace OFNS;
|
|
|
|
static void GetSocketConnectionList( CSensorArray::CVoidList &list, OFNS::COFPin *pPin )
|
|
{
|
|
if( !pPin )
|
|
return;
|
|
|
|
CObjectFactory *pOF = pPin->GetOF();
|
|
for( int i = 0; i < pPin->m_nDeviceCount; i++ )
|
|
{
|
|
COFDevice *pTempl = pOF->DeviceGet( pPin->m_pDevice[i].nIndex, pPin->m_pDevice[i].nType );
|
|
switch( pPin->m_nPinType )
|
|
{
|
|
case PT_SOCKET_MD:
|
|
case PT_SOCKET_PTZ:
|
|
case PT_SOCKET_VM:
|
|
case PT_SOCKET_LGS:
|
|
case PT_SOCKET_MIC1300:
|
|
case PT_SOCKET_TKS576:
|
|
case PT_SOCKET_PG3AD:
|
|
case PT_SOCKET_VICON:
|
|
case PT_SOCKET_PELCO:
|
|
case PT_SOCKET_AMERICAN_DYNAMIS:
|
|
if( !list.Find( pTempl->m_pDevice ) )
|
|
{
|
|
list.AddTail( pTempl->m_pDevice );
|
|
GetSocketConnectionList( list, pTempl->GetPin( pPin->m_pDevice[i].nPin ) );
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//#define STI_SETUP
|
|
|
|
BOOL CSensorArray::SaveTransform( CSensor *pSensor )
|
|
{
|
|
try
|
|
{
|
|
using namespace OFNS;
|
|
OFNS::CObjectFactory OF;
|
|
|
|
CLgBitCodeFile ofFile( 9 );
|
|
if( ofFile.Open( m_CurrentFileName, CFile::modeRead ) )
|
|
{
|
|
CArchive ofAr( &ofFile, CArchive::load );
|
|
OF.Serialize( ofAr );
|
|
}
|
|
else return FALSE;
|
|
ofFile.Close();
|
|
|
|
COFDeviceLGS *pTempl = (COFDeviceLGS*)OF.DeviceGet( pSensor->m_nTemplateIndex, pSensor->m_nTemplateType );
|
|
if( pTempl )
|
|
{
|
|
pTempl->m_Transform[0].m_dX = pSensor->GetTransform(0)->GetParameters()[0];
|
|
pTempl->m_Transform[0].m_dY = pSensor->GetTransform(0)->GetParameters()[1];
|
|
pTempl->m_Transform[0].m_dZ = pSensor->GetTransform(0)->GetParameters()[2];
|
|
pTempl->m_Transform[0].m_dPsi = pSensor->GetTransform(0)->GetParameters()[3];
|
|
pTempl->m_Transform[0].m_dTheta = pSensor->GetTransform(0)->GetParameters()[4];
|
|
pTempl->m_Transform[0].m_dPhi = pSensor->GetTransform(0)->GetParameters()[5];
|
|
|
|
pTempl->m_Transform[1].m_dX = pSensor->GetTransform(1)->GetParameters()[0];
|
|
pTempl->m_Transform[1].m_dY = pSensor->GetTransform(1)->GetParameters()[1];
|
|
pTempl->m_Transform[1].m_dZ = pSensor->GetTransform(1)->GetParameters()[2];
|
|
pTempl->m_Transform[1].m_dPsi = pSensor->GetTransform(1)->GetParameters()[3];
|
|
pTempl->m_Transform[1].m_dTheta = pSensor->GetTransform(1)->GetParameters()[4];
|
|
pTempl->m_Transform[1].m_dPhi = pSensor->GetTransform(1)->GetParameters()[5];
|
|
}
|
|
|
|
if( ofFile.Open( m_CurrentFileName, CFile::modeWrite ) )
|
|
{
|
|
CArchive ofAr( &ofFile, CArchive::store );
|
|
OF.Serialize( ofAr );
|
|
}
|
|
else return FALSE;
|
|
ofFile.Close();
|
|
}
|
|
catch( CFileException *e )
|
|
{
|
|
e->ReportError();
|
|
}
|
|
catch( CArchiveException *e )
|
|
{
|
|
e->ReportError();
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CSensorArray::SaveCalibrationName( CSensor *pSensor )
|
|
{
|
|
try
|
|
{
|
|
using namespace OFNS;
|
|
OFNS::CObjectFactory OF;
|
|
|
|
CLgBitCodeFile ofFile( 9 );
|
|
if( ofFile.Open( m_CurrentFileName, CFile::modeRead ) )
|
|
{
|
|
CArchive ofAr( &ofFile, CArchive::load );
|
|
OF.Serialize( ofAr );
|
|
}
|
|
else return FALSE;
|
|
ofFile.Close();
|
|
|
|
COFDeviceLGS *pTempl = (COFDeviceLGS*)OF.DeviceGet( pSensor->m_nTemplateIndex, pSensor->m_nTemplateType );
|
|
if( pTempl )
|
|
pTempl->m_arrCalibrationName = pSensor->GetCalibrationNameArray();
|
|
|
|
if( ofFile.Open( m_CurrentFileName, CFile::modeWrite ) )
|
|
{
|
|
CArchive ofAr( &ofFile, CArchive::store );
|
|
OF.Serialize( ofAr );
|
|
}
|
|
else return FALSE;
|
|
ofFile.Close();
|
|
}
|
|
catch( CFileException *e )
|
|
{
|
|
e->ReportError();
|
|
}
|
|
catch( CArchiveException *e )
|
|
{
|
|
e->ReportError();
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CSensorArray::Load( LPCTSTR pFileName, int nRunningMode, CSettings *pSettings, BOOL bDemo )
|
|
{
|
|
BOOL bResult = FALSE;
|
|
|
|
m_CurrentFileName = pFileName;
|
|
|
|
__try
|
|
{
|
|
bResult = Load_( pFileName, nRunningMode, pSettings, bDemo );
|
|
}
|
|
__except( EXCEPTION_EXECUTE_HANDLER )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CSensorArray::Load"), _T("Exception 0x%08X"), _exception_code() );
|
|
bResult = FALSE;
|
|
}
|
|
|
|
return bResult;
|
|
}
|
|
|
|
BOOL CSensorArray::Load_( LPCTSTR pFileName, int nRunningMode, CSettings *pSettings, BOOL bDemo )
|
|
{
|
|
m_bDemoMode = bDemo;
|
|
|
|
m_pSettings = pSettings;
|
|
if( m_pSettings )
|
|
{
|
|
m_pSettings->Load( _T("IRIS_DAY_HOUR"), &m_nIrisDayHour );
|
|
m_pSettings->Load( _T("IRIS_DAY_MINUTE"), &m_nIrisDayMinute );
|
|
m_pSettings->Load( _T("IRIS_DAY_VALUE"), &m_dIrisDayValue );
|
|
m_pSettings->Load( _T("IRIS_NIGHT_HOUR"), &m_nIrisNightHour );
|
|
m_pSettings->Load( _T("IRIS_NIGHT_MINUTE"), &m_nIrisNightMinute );
|
|
m_pSettings->Load( _T("IRIS_NIGHT_VALUE"), &m_dIrisNightValue );
|
|
m_pSettings->Load( _T("SETTINGS"), &m_ProgramSettings, sizeof(m_ProgramSettings) );
|
|
}
|
|
|
|
#ifndef STI_SETUP
|
|
try
|
|
{
|
|
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CSensorArray::Load"), _T("Started") );
|
|
|
|
using namespace OFNS;
|
|
CLgBitCodeFile ofFile( pFileName, CFile::modeRead, 9 );
|
|
CArchive ofAr( &ofFile, CArchive::load );
|
|
{
|
|
OFNS::CObjectFactory OF;
|
|
OF.Serialize( ofAr );
|
|
|
|
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CSensorArray::Load"), _T("OF.Serialize passed") );
|
|
|
|
// store settings
|
|
m_SetupSettings = OF.GetSettings();
|
|
|
|
// m_Background.Load = OF.FileGroupGetTemp( OF.m_FileNameBG );
|
|
|
|
m_Background.Load( OF.m_FileNameBG, OF.FileGroupGet(), OF.GetMeterScale() );
|
|
|
|
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CSensorArray::Load"), _T("m_Background.Load passed") );
|
|
|
|
m_nBG = OF.TemplateGetCount();
|
|
if( m_nBG )
|
|
{
|
|
m_pBG = new CLgMemoryDC[ m_nBG ];
|
|
for( int i = 0; i < m_nBG; i++ )
|
|
{
|
|
// HBITMAP hBmp = (HBITMAP)::LoadImage( NULL, OF.FileGroupGetTemp( OF.TemplateGet(i)->GetBG() ), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE );
|
|
HBITMAP hBmp = (HBITMAP)OF.FileGroupGet()->LoadImage( OF.TemplateGet(i)->GetBG(), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE );
|
|
m_pBG[ i ].Create( hBmp, FALSE );
|
|
}
|
|
}
|
|
|
|
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CSensorArray::Load"), _T("Template loating passed") );
|
|
|
|
// basic device creating
|
|
for( int nType = OFNS::DT_FIRST; nType < OFNS::DT_COUNT; nType++ )
|
|
{
|
|
int nIndex;
|
|
switch( OF.m_pDevice[ nType ].nType )
|
|
{
|
|
case OFNS::DT_MIGVAN_VM8X4:
|
|
m_ppDevice = (CDevice**)realloc( m_ppDevice, sizeof(CDevice*) * ( m_nDevice + OF.m_pDevice[ nType ].nCount ) );
|
|
m_ppVideoMatrix = (CVideoMatrix**)realloc( m_ppVideoMatrix, sizeof(CVideoMatrix*) * ( m_nVideoMatrix + OF.m_pDevice[ nType ].nCount ) );
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDeviceMigvanVM8x4* pTempl = static_cast<COFDeviceMigvanVM8x4*>( OF.m_pDevice[ nType ].ppDevice[ nIndex ] );
|
|
// hardware imagination
|
|
m_ppDevice[ m_nDevice + nIndex ] = new CDeviceVMs;
|
|
CDeviceVMs *pDevice = static_cast<CDeviceVMs*>(m_ppDevice[ m_nDevice + nIndex ]);
|
|
pDevice->SetAutoInit( pTempl->m_bAuto );
|
|
pDevice->SetHardwareID( pTempl->m_pHardwareID );
|
|
// logical imagination
|
|
m_ppVideoMatrix[ m_nVideoMatrix + nIndex ] = new CVideoMatrix;
|
|
m_ppVideoMatrix[ m_nVideoMatrix + nIndex ]->ConnectToDevice( pDevice );
|
|
|
|
pTempl->m_pDevice = pDevice;
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoMatrix[ m_nVideoMatrix + nIndex ];
|
|
}
|
|
m_nDevice += OF.m_pDevice[ nType ].nCount;
|
|
m_nVideoMatrix += OF.m_pDevice[ nType ].nCount;
|
|
break;
|
|
case OFNS::DT_RABBIT_CAMERA:
|
|
m_ppVideoCamera = (CVideoCamera**)realloc( m_ppVideoCamera, sizeof(CVideoCamera*) * ( m_nVideoCamera + OF.m_pDevice[ nType ].nCount ) );
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDeviceRabbitCamera* pTempl = static_cast<COFDeviceRabbitCamera*>( OF.m_pDevice[ nType ].ppDevice[ nIndex ] );
|
|
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCamera[ m_nVideoCamera + nIndex ] = new CVideoCameraPTZ;
|
|
CVideoCameraPTZ *pVideoCamera = static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[ m_nVideoCamera + nIndex ]);
|
|
pVideoCamera->SetName( &pTempl->GetName() );
|
|
pVideoCamera->SetSensorArray( this );
|
|
}
|
|
m_nVideoCamera += OF.m_pDevice[ nType ].nCount;
|
|
break;
|
|
case OFNS::DT_CAMERA_LGS:
|
|
m_ppVideoCamera = (CVideoCamera**)realloc( m_ppVideoCamera, sizeof(CVideoCamera*) * ( m_nVideoCamera + OF.m_pDevice[ nType ].nCount ) );
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDeviceCameraLGS* pTempl = static_cast<COFDeviceCameraLGS*>(OF.m_pDevice[ nType ].ppDevice[ nIndex ]);
|
|
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCamera[ m_nVideoCamera + nIndex ] = new CVideoCameraPTZ;
|
|
CVideoCameraPTZ *pVideoCamera = static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[ m_nVideoCamera + nIndex ]);
|
|
pVideoCamera->SetName( &pTempl->GetName() );
|
|
pVideoCamera->SetSensorArray( this );
|
|
pVideoCamera->SetRangeZoom( pTempl->m_dZoomTable );
|
|
}
|
|
m_nVideoCamera += OF.m_pDevice[ nType ].nCount;
|
|
break;
|
|
case OFNS::DT_CAMERA:
|
|
m_ppVideoCamera = (CVideoCamera**)realloc( m_ppVideoCamera, sizeof(CVideoCamera*) * ( m_nVideoCamera + OF.m_pDevice[ nType ].nCount ) );
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDeviceCamera* pTempl = static_cast<COFDeviceCamera*>(OF.m_pDevice[ nType ].ppDevice[ nIndex ]);
|
|
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCamera[ m_nVideoCamera + nIndex ] = new CVideoCamera;
|
|
CVideoCamera *pVideoCamera = static_cast<CVideoCamera*>(m_ppVideoCamera[ m_nVideoCamera + nIndex ]);
|
|
pVideoCamera->SetName( &pTempl->GetName() );
|
|
pVideoCamera->SetSensorArray( this );
|
|
}
|
|
m_nVideoCamera += OF.m_pDevice[ nType ].nCount;
|
|
break;
|
|
case OFNS::DT_RABBIT:
|
|
m_ppDevice = (CDevice**)realloc( m_ppDevice, sizeof(CDevice*) * ( m_nDevice + OF.m_pDevice[ nType ].nCount ) );
|
|
m_ppVideoMatrix = (CVideoMatrix**)realloc( m_ppVideoMatrix, sizeof(CVideoMatrix*) * ( m_nVideoMatrix + OF.m_pDevice[ nType ].nCount * 2 ) );
|
|
m_ppDirectInput = (CDirectInput**)realloc( m_ppDirectInput, sizeof(CDirectInput*) * ( m_nDirectInput + OF.m_pDevice[ nType ].nCount * CDeviceRabbit::DI_INPUT_COUNT ) );
|
|
m_ppDirectOutput = (CDirectOutput**)realloc( m_ppDirectOutput, sizeof(CDirectOutput*) * ( m_nDirectOutput + OF.m_pDevice[ nType ].nCount * CDeviceRabbit::DO_OUTPUT_COUNT ) );
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDeviceRabbit* pTempl = static_cast<COFDeviceRabbit*>(OF.m_pDevice[ nType ].ppDevice[ nIndex ]);
|
|
// hardware imagination
|
|
m_ppDevice[ m_nDevice + nIndex ] = new CDeviceRabbit;
|
|
CDeviceRabbit *pDevice = static_cast<CDeviceRabbit*>(m_ppDevice[ m_nDevice + nIndex ]);
|
|
// pDevice->SetAddress( pTempl->m_nAddress );
|
|
// logical imagination
|
|
for( int k = 0; k < 2; k++ )
|
|
{
|
|
int n = m_nVideoMatrix + nIndex * 2 + k;
|
|
m_ppVideoMatrix[ n ] = new CVideoMatrix;
|
|
m_ppVideoMatrix[ n ]->ConnectToDevice( pDevice->GetDeviceVM(k) );
|
|
|
|
pTempl->m_pVideoDevice[k] = m_ppVideoMatrix[ n ];
|
|
}
|
|
|
|
for( k = 0; k < CDeviceRabbit::DI_INPUT_COUNT; k++ )
|
|
{
|
|
int n = m_nDirectInput + nIndex * CDeviceRabbit::DI_INPUT_COUNT + k;
|
|
// ???????? pDevice->SetNC( k, pTempl->GetPin()>m_pDryContact[k].bNC );
|
|
|
|
m_ppDirectInput[ n ] = new CDirectInput;
|
|
m_ppDirectInput[ n ]->ConnectToDevice( pDevice, k, 0 );
|
|
|
|
pTempl->m_pDI[k] = m_ppDirectInput[ n ];
|
|
}
|
|
|
|
for( k = 0; k < CDeviceRabbit::DO_OUTPUT_COUNT; k++ )
|
|
{
|
|
int n = m_nDirectOutput + nIndex * CDeviceRabbit::DO_OUTPUT_COUNT + k;
|
|
m_ppDirectOutput[ n ] = new CDirectOutput;
|
|
m_ppDirectOutput[ n ]->ConnectToDevice( pDevice, k, 0 );
|
|
|
|
pTempl->m_pDO[k] = m_ppDirectOutput[ n ];
|
|
}
|
|
|
|
pTempl->m_pDevice = pDevice;
|
|
}
|
|
m_nDevice += OF.m_pDevice[ nType ].nCount;
|
|
m_nVideoMatrix += OF.m_pDevice[ nType ].nCount * 2;
|
|
m_nDirectInput += OF.m_pDevice[ nType ].nCount * CDeviceRabbit::DI_INPUT_COUNT;
|
|
m_nDirectOutput += OF.m_pDevice[ nType ].nCount * CDeviceRabbit::DO_OUTPUT_COUNT;
|
|
break;
|
|
case OFNS::DT_LGS:
|
|
m_ppDevice = (CDevice**)realloc( m_ppDevice, sizeof(CDevice*) * ( m_nDevice + OF.m_pDevice[ nType ].nCount ) );
|
|
m_ppSensor = (CSensor**)realloc( m_ppSensor, sizeof(CSensor*) * ( m_nSensor + OF.m_pDevice[ nType ].nCount ) );
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDeviceLGS* pTempl = static_cast<COFDeviceLGS*>(OF.m_pDevice[ nType ].ppDevice[ nIndex ]);
|
|
// CDevice *pDevice;
|
|
CSensorLGS *pSensorLGS;
|
|
CDeviceLGSm *pDeviceLGSm;
|
|
CDeviceLGSs *pDeviceLGSs;
|
|
|
|
int n = m_nSensor + nIndex;
|
|
|
|
switch( pTempl->m_nSubType )
|
|
{
|
|
case COFDeviceLGS::ST_MULTI:
|
|
pDeviceLGSm = new CDeviceLGSm;
|
|
pTempl->m_pDevice = m_ppDevice[ m_nDevice + nIndex ] = pDeviceLGSm;
|
|
// pDevice = m_ppDevice[ m_nDevice + nIndex ];
|
|
pDeviceLGSm->CLgNetDeviceLGS::SetAddress( pTempl->m_nAddress );
|
|
|
|
m_ppSensor[n] = new CSensorLGS;
|
|
pSensorLGS = static_cast<CSensorLGS*>(m_ppSensor[n]);
|
|
pSensorLGS->ConnectToDevice( pDeviceLGSm );
|
|
break;
|
|
|
|
case COFDeviceLGS::ST_SINGLE:
|
|
pDeviceLGSs = new CDeviceLGSs;
|
|
pTempl->m_pDevice = m_ppDevice[ m_nDevice + nIndex ] = pDeviceLGSs;
|
|
|
|
m_ppSensor[n] = new CSensorLGS;
|
|
pSensorLGS = static_cast<CSensorLGS*>(m_ppSensor[n]);
|
|
pSensorLGS->ConnectToDevice( pDeviceLGSs );
|
|
break;
|
|
}
|
|
|
|
pSensorLGS->SetDebugMode( m_bDebugMode );
|
|
pSensorLGS->SetRange( pTempl->m_dRange );
|
|
pSensorLGS->SetBorderLGS( pTempl->GetBorderLGS() );
|
|
// pSensorLGS->SetHiddenZoneList( pTempl->GetHiddenZoneList() );
|
|
pSensorLGS->SetCommonZero( pTempl->GetCommonZero() );
|
|
pSensorLGS->SetPosition( SDPOINT( pTempl->m_Pos.x / OF.GetMapSize()->cx,
|
|
pTempl->m_Pos.y / OF.GetMapSize()->cy) );
|
|
pSensorLGS->Enable( TRUE );
|
|
pSensorLGS->SetAddress( 0 );
|
|
pSensorLGS->SetArrayIndex( n );
|
|
pSensorLGS->SetSocket( 2 );
|
|
pSensorLGS->SetZoneIndex( 0 ); // need to changed
|
|
pSensorLGS->SetSensorArray( this );
|
|
pSensorLGS->SetState( CSensor::UNKNOWN );
|
|
pSensorLGS->SetName( pTempl->GetName() );
|
|
pSensorLGS->SetPatrol( FALSE );
|
|
|
|
// for update in calibration program
|
|
pSensorLGS->m_nTemplateType = nType;
|
|
pSensorLGS->m_nTemplateIndex = nIndex;
|
|
|
|
CTransform *ppTransform[2];
|
|
for( int i = 0; i < 2; i++ )
|
|
{
|
|
ppTransform[i] = new CTransform();
|
|
ppTransform[i]->Prepare( pTempl->m_Transform[i].m_dX, pTempl->m_Transform[i].m_dY, pTempl->m_Transform[i].m_dZ,
|
|
pTempl->m_Transform[i].m_dPsi, pTempl->m_Transform[i].m_dTheta, pTempl->m_Transform[i].m_dPhi );
|
|
}
|
|
pSensorLGS->SetTransform( pTempl->m_bRemoteCamera, pTempl->m_dPanShift, pTempl->m_dTiltTable, ppTransform[0], ppTransform[1] );
|
|
|
|
pSensorLGS->SetAddressCCC( pTempl->m_nAddressCCC );
|
|
pSensorLGS->SetImageCount( pTempl->m_nImageCount );
|
|
|
|
pSensorLGS->GetCalibrationNameArray() = pTempl->m_arrCalibrationName;
|
|
|
|
pTempl->m_pSensor = pSensorLGS;
|
|
}
|
|
m_nDevice += OF.m_pDevice[ nType ].nCount;
|
|
m_nSensor += OF.m_pDevice[ nType ].nCount;
|
|
break;
|
|
|
|
case OFNS::DT_CLD:
|
|
m_ppDevice = (CDevice**)realloc( m_ppDevice, sizeof(CDevice*) * ( m_nDevice + OF.m_pDevice[ nType ].nCount ) );
|
|
m_ppSensor = (CSensor**)realloc( m_ppSensor, sizeof(CSensor*) * ( m_nSensor + OF.m_pDevice[ nType ].nCount ) );
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDeviceCLD* pTempl = static_cast<COFDeviceCLD*>(OF.m_pDevice[ nType ].ppDevice[ nIndex ]);
|
|
CDevice *pDevice;
|
|
CSensorCLD *pSensorCLD;
|
|
|
|
int n = m_nSensor + nIndex;
|
|
|
|
pTempl->m_pDevice = m_ppDevice[ m_nDevice + nIndex ] = new CDeviceCLD;
|
|
pDevice = m_ppDevice[ m_nDevice + nIndex ];
|
|
static_cast<CDeviceCLD*>(pDevice)->CLgNetDeviceCLD::SetAddress( pTempl->m_nAddress );
|
|
|
|
m_ppSensor[n] = new CSensorCLD;
|
|
pSensorCLD = static_cast<CSensorCLD*>(m_ppSensor[n]);
|
|
pSensorCLD->ConnectToDevice( static_cast<CDeviceCLD*>(pDevice) );
|
|
// ((CDeviceCLD*)pDevice)->SetSensorCLD( pSensorCLD );
|
|
|
|
// pSensorCLD->SetDebugMode( m_bDebugMode );
|
|
pSensorCLD->SetRange( pTempl->m_dRange );
|
|
pSensorCLD->SetCommonZero( pTempl->GetCommonZero() );
|
|
pSensorCLD->SetPosition( SDPOINT( pTempl->m_Pos.x / OF.GetMapSize()->cx,
|
|
pTempl->m_Pos.y / OF.GetMapSize()->cy) );
|
|
pSensorCLD->Enable( TRUE );
|
|
pSensorCLD->SetAddress( 0 );
|
|
pSensorCLD->SetArrayIndex( n );
|
|
pSensorCLD->SetSocket( 2 );
|
|
pSensorCLD->SetZoneIndex( 0 ); // need to changed
|
|
pSensorCLD->SetSensorArray( this );
|
|
pSensorCLD->SetState( CSensor::UNKNOWN );
|
|
pSensorCLD->SetName( pTempl->GetName() );
|
|
pSensorCLD->SetPatrol( FALSE );
|
|
|
|
pSensorCLD->SetImageCount( pTempl->m_nImageCount );
|
|
pSensorCLD->SetAddressCCC( pTempl->m_nAddressCCC );
|
|
|
|
pTempl->m_pSensor = pSensorCLD;
|
|
}
|
|
m_nDevice += OF.m_pDevice[ nType ].nCount;
|
|
m_nSensor += OF.m_pDevice[ nType ].nCount;
|
|
break;
|
|
/* +++ +++ +++
|
|
case OFNS::DT_MIGVAN_CAMERA:
|
|
m_ppDevice = (CDevice**)realloc( m_ppDevice, sizeof(CDevice*) * ( m_nDevice + OF.m_pDevice[ nType ].nCount ) );
|
|
m_ppVideoCamera = (CVideoCamera**)realloc( m_ppVideoCamera, sizeof(CVideoCamera*) * ( m_nVideoCamera + OF.m_pDevice[ nType ].nCount ) );
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDeviceMigvanCameraPTZ* pTempl = (COFDeviceMigvanCameraPTZ*)OF.m_pDevice[ nType ].ppDevice[ nIndex ];
|
|
|
|
pTempl->m_pDevice = m_ppDevice[ m_nDevice + nIndex ] = new CDeviceMigvanPTZ;
|
|
CDeviceMigvanPTZ *pDevice = (CDeviceMigvanPTZ*)m_ppDevice[ m_nDevice + nIndex ];
|
|
pDevice->SetAutoInit( pTempl->m_bAuto );
|
|
pDevice->SetHardwareID( pTempl->m_pHardwareID );
|
|
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCamera[ m_nVideoCamera + nIndex ] = new CVideoCameraPTZ;
|
|
CVideoCameraPTZ *pVideoCamera = (CVideoCameraPTZ*)m_ppVideoCamera[ m_nVideoCamera + nIndex ];
|
|
pVideoCamera->SetSensorArray( this );
|
|
pVideoCamera->ConnectToDevice( pDevice );
|
|
pVideoCamera->SetName( &pTempl->GetName() );
|
|
}
|
|
m_nDevice += OF.m_pDevice[ nType ].nCount;
|
|
m_nVideoCamera += OF.m_pDevice[ nType ].nCount;
|
|
break;
|
|
*/
|
|
case OFNS::DT_CAMERA_PTZ:
|
|
m_ppDevice = (CDevice**)realloc( m_ppDevice, sizeof(CDevice*) * ( m_nDevice + OF.m_pDevice[ nType ].nCount ) );
|
|
m_ppVideoCamera = (CVideoCamera**)realloc( m_ppVideoCamera, sizeof(CVideoCamera*) * ( m_nVideoCamera + OF.m_pDevice[ nType ].nCount ) );
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDeviceCameraPTZ* pTempl = static_cast<COFDeviceCameraPTZ*>(OF.m_pDevice[ nType ].ppDevice[ nIndex ]);
|
|
|
|
switch( pTempl->GetSubType() )
|
|
{
|
|
case COFDeviceCameraPTZ::PTZST_MIGVAN_878:
|
|
case COFDeviceCameraPTZ::PTZST_MIGVAN_KD6Z:
|
|
{
|
|
pTempl->m_pDevice = m_ppDevice[ m_nDevice + nIndex ] = new CDeviceMigvanPTZ;
|
|
CDeviceMigvanPTZ *pDevice = static_cast<CDeviceMigvanPTZ*>(m_ppDevice[ m_nDevice + nIndex ]);
|
|
pDevice->SetAutoInit( pTempl->m_uData.migvan.bAuto );
|
|
pDevice->SetHardwareID( pTempl->m_uData.migvan.pHardwareID );
|
|
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCamera[ m_nVideoCamera + nIndex ] = new CVideoCameraPTZ;
|
|
CVideoCameraPTZ *pVideoCamera = static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[ m_nVideoCamera + nIndex ]);
|
|
pVideoCamera->SetSensorArray( this );
|
|
pVideoCamera->ConnectToDevice( pDevice );
|
|
pVideoCamera->SetName( &pTempl->GetName() );
|
|
pVideoCamera->SetRangeZoom( pTempl->m_dZoomTable );
|
|
|
|
if( bDemo )
|
|
pVideoCamera->PostReady();
|
|
}
|
|
break;
|
|
case COFDeviceCameraPTZ::PTZST_MIC_1_300:
|
|
{
|
|
pTempl->m_pDevice = m_ppDevice[ m_nDevice + nIndex ] = new CDeviceCameraMic1300;
|
|
CDeviceCameraMic1300 *pDevice = static_cast<CDeviceCameraMic1300*>(m_ppDevice[ m_nDevice + nIndex ]);
|
|
pDevice->SetAddress( pTempl->m_uData.mic1300.bAddress );
|
|
// pDevice->SetAutoInit( pTempl->m_uData.migvan.bAuto );
|
|
// pDevice->SetHardwareID( pTempl->m_uData.migvan.pHardwareID );
|
|
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCamera[ m_nVideoCamera + nIndex ] = new CVideoCameraPTZ;
|
|
CVideoCameraPTZ *pVideoCamera = static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[ m_nVideoCamera + nIndex ]);
|
|
pVideoCamera->SetSensorArray( this );
|
|
pVideoCamera->ConnectToDevice( pDevice );
|
|
pVideoCamera->SetName( &pTempl->GetName() );
|
|
pVideoCamera->SetRangeZoom( pTempl->m_dZoomTable );
|
|
|
|
if( bDemo )
|
|
pVideoCamera->PostReady();
|
|
}
|
|
break;
|
|
case COFDeviceCameraPTZ::PTZST_TK_S576:
|
|
{
|
|
pTempl->m_pDevice = m_ppDevice[ m_nDevice + nIndex ] = new CDeviceCameraTKS576;
|
|
CDeviceCameraTKS576 *pDevice = static_cast<CDeviceCameraTKS576*>(m_ppDevice[ m_nDevice + nIndex ]);
|
|
pDevice->SetAddress( pTempl->m_uData.tks576.bAddress );
|
|
// pDevice->SetAutoInit( pTempl->m_uData.migvan.bAuto );
|
|
// pDevice->SetHardwareID( pTempl->m_uData.migvan.pHardwareID );
|
|
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCamera[ m_nVideoCamera + nIndex ] = new CVideoCameraPTZ;
|
|
CVideoCameraPTZ *pVideoCamera = static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[ m_nVideoCamera + nIndex ]);
|
|
pVideoCamera->SetSensorArray( this );
|
|
pVideoCamera->ConnectToDevice( pDevice );
|
|
pVideoCamera->SetName( &pTempl->GetName() );
|
|
pVideoCamera->SetRangeZoom( pTempl->m_dZoomTable );
|
|
|
|
if( bDemo )
|
|
pVideoCamera->PostReady();
|
|
}
|
|
break;
|
|
case COFDeviceCameraPTZ::PTZST_PG3AD_NEW:
|
|
case COFDeviceCameraPTZ::PTZST_PG3AD_OLD:
|
|
{
|
|
pTempl->m_pDevice = m_ppDevice[ m_nDevice + nIndex ] = new CDeviceCameraPhilipsG3AD;
|
|
CDeviceCameraPhilipsG3AD *pDevice = static_cast<CDeviceCameraPhilipsG3AD*>(m_ppDevice[ m_nDevice + nIndex ]);
|
|
pDevice->SetAddress( pTempl->m_uData.pg3ad.bAddress );
|
|
|
|
if( pTempl->GetSubType() == COFDeviceCameraPTZ::PTZST_PG3AD_OLD )
|
|
pDevice->SetOldType();
|
|
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCamera[ m_nVideoCamera + nIndex ] = new CVideoCameraPTZ;
|
|
CVideoCameraPTZ *pVideoCamera = static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[ m_nVideoCamera + nIndex ]);
|
|
pVideoCamera->SetSensorArray( this );
|
|
pVideoCamera->ConnectToDevice( pDevice );
|
|
pVideoCamera->SetName( &pTempl->GetName() );
|
|
pVideoCamera->SetRangeZoom( pTempl->m_dZoomTable );
|
|
|
|
if( bDemo )
|
|
pVideoCamera->PostReady();
|
|
}
|
|
break;
|
|
case COFDeviceCameraPTZ::PTZST_AMERICAN_DYNAMICS:
|
|
{
|
|
pTempl->m_pDevice = m_ppDevice[ m_nDevice + nIndex ] = new CDeviceCameraAmericanDynamics;
|
|
CDeviceCameraAmericanDynamics *pDevice = static_cast<CDeviceCameraAmericanDynamics*>(m_ppDevice[ m_nDevice + nIndex ]);
|
|
pDevice->SetAddress( pTempl->m_uData.american_dynamics.bAddress );
|
|
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCamera[ m_nVideoCamera + nIndex ] = new CVideoCameraPTZ;
|
|
CVideoCameraPTZ *pVideoCamera = static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[ m_nVideoCamera + nIndex ]);
|
|
pVideoCamera->SetSensorArray( this );
|
|
pVideoCamera->ConnectToDevice( pDevice );
|
|
pVideoCamera->SetName( &pTempl->GetName() );
|
|
pVideoCamera->SetRangeZoom( pTempl->m_dZoomTable );
|
|
|
|
if( bDemo )
|
|
pVideoCamera->PostReady();
|
|
}
|
|
break;
|
|
case COFDeviceCameraPTZ::PTZST_PELCO:
|
|
{
|
|
pTempl->m_pDevice = m_ppDevice[ m_nDevice + nIndex ] = new CDeviceCameraPelco;
|
|
CDeviceCameraPelco *pDevice = static_cast<CDeviceCameraPelco*>(m_ppDevice[ m_nDevice + nIndex ]);
|
|
pDevice->SetAddress( pTempl->m_uData.pelco.bAddress );
|
|
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCamera[ m_nVideoCamera + nIndex ] = new CVideoCameraPTZ;
|
|
CVideoCameraPTZ *pVideoCamera = static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[ m_nVideoCamera + nIndex ]);
|
|
pVideoCamera->SetSensorArray( this );
|
|
pVideoCamera->ConnectToDevice( pDevice );
|
|
pVideoCamera->SetName( &pTempl->GetName() );
|
|
pVideoCamera->SetRangeZoom( pTempl->m_dZoomTable );
|
|
|
|
if( bDemo )
|
|
pVideoCamera->PostReady();
|
|
}
|
|
break;
|
|
case COFDeviceCameraPTZ::PTZST_VICON:
|
|
{
|
|
pTempl->m_pDevice = m_ppDevice[ m_nDevice + nIndex ] = new CDeviceCameraVicon;
|
|
CDeviceCameraVicon *pDevice = static_cast<CDeviceCameraVicon*>(m_ppDevice[ m_nDevice + nIndex ]);
|
|
pDevice->SetAddress( pTempl->m_uData.vicon.bAddress );
|
|
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCamera[ m_nVideoCamera + nIndex ] = new CVideoCameraPTZ;
|
|
CVideoCameraPTZ *pVideoCamera = static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[ m_nVideoCamera + nIndex ]);
|
|
pVideoCamera->SetSensorArray( this );
|
|
pVideoCamera->ConnectToDevice( pDevice );
|
|
pVideoCamera->SetName( &pTempl->GetName() );
|
|
pVideoCamera->SetRangeZoom( pTempl->m_dZoomTable );
|
|
|
|
if( bDemo )
|
|
pVideoCamera->PostReady();
|
|
}
|
|
break;
|
|
case COFDeviceCameraPTZ::PTZST_HEBRON:
|
|
{
|
|
pTempl->m_pDevice = m_ppDevice[ m_nDevice + nIndex ] = new CDeviceCameraHebron;
|
|
CDeviceCameraHebron *pDevice = static_cast<CDeviceCameraHebron*>(m_ppDevice[ m_nDevice + nIndex ]);
|
|
pDevice->SetAddress( pTempl->m_uData.hebron.bAddress );
|
|
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCamera[ m_nVideoCamera + nIndex ] = new CVideoCameraPTZ;
|
|
CVideoCameraPTZ *pVideoCamera = static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[ m_nVideoCamera + nIndex ]);
|
|
pVideoCamera->SetSensorArray( this );
|
|
pVideoCamera->ConnectToDevice( pDevice );
|
|
pVideoCamera->SetName( &pTempl->GetName() );
|
|
pVideoCamera->SetRangeZoom( pTempl->m_dZoomTable );
|
|
|
|
if( bDemo )
|
|
pVideoCamera->PostReady();
|
|
}
|
|
break;
|
|
case COFDeviceCameraPTZ::PTZST_3_TRACK:
|
|
{
|
|
pTempl->m_pDevice = m_ppDevice[ m_nDevice + nIndex ] = new CDeviceCameraHebron;
|
|
CDeviceCameraHebron *pDevice = static_cast<CDeviceCameraHebron*>(m_ppDevice[ m_nDevice + nIndex ]);
|
|
pDevice->SetAddress( pTempl->m_uData.tri_track.bAddress );
|
|
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCamera[ m_nVideoCamera + nIndex ] = new CVideoCameraPTZ;
|
|
CVideoCameraPTZ *pVideoCamera = static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[ m_nVideoCamera + nIndex ]);
|
|
pVideoCamera->SetSensorArray( this );
|
|
pVideoCamera->ConnectToDevice( pDevice );
|
|
pVideoCamera->SetName( &pTempl->GetName() );
|
|
pVideoCamera->SetRangeZoom( pTempl->m_dZoomTable );
|
|
pVideoCamera->SetDoplerParams( pTempl->m_uData.tri_track.nAngle, pTempl->m_uData.tri_track.dwTimeout );
|
|
|
|
if( bDemo )
|
|
pVideoCamera->PostReady();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
m_nDevice += OF.m_pDevice[ nType ].nCount;
|
|
m_nVideoCamera += OF.m_pDevice[ nType ].nCount;
|
|
break;
|
|
case OFNS::DT_SOCKET:
|
|
m_ppSocket = (CSocket**)realloc( m_ppSocket, sizeof(CSocket*) * ( m_nSocket + OF.m_pDevice[ nType ].nCount ) );
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDeviceSocket* pTempl = static_cast<COFDeviceSocket*>(OF.m_pDevice[ nType ].ppDevice[ nIndex ]);
|
|
CSocketMD *pSocketMD;
|
|
CSocketMigvanPTZ *pSocketPTZ;
|
|
CSocketCameraMic1300 *pSocketMic1300;
|
|
CSocketCameraTKS576 *pSocketTKS576;
|
|
CSocketCameraPhilipsG3AD *pSocketPG3AD;
|
|
CSocketCameraAmericanDynamics *pAmericanDynamics;
|
|
CSocketCameraPelco *pSocketPelco;
|
|
CSocketCameraVicon *pSocketVicon;
|
|
CSocketVM *pSocketVM;
|
|
CSocketLGS *pSocketLGS;
|
|
CSocketCCC *pSocketCCC;
|
|
CSocketRS232DI *pSocketDI;
|
|
// int k;
|
|
pTempl->m_pDevice = NULL;
|
|
switch( pTempl->m_nSubType )
|
|
{
|
|
case COFDeviceSocket::ST_MD:
|
|
pTempl->m_pSocket = m_ppSocket[ m_nSocket + nIndex ] = new CSocketMD;
|
|
pSocketMD = static_cast<CSocketMD*>(m_ppSocket[ m_nSocket + nIndex ]);
|
|
pSocketMD->Create( this, pTempl->m_Port, atoi( pTempl->m_BaudRate ), pTempl->m_bSpyMode );
|
|
pSocketMD->SetName( pTempl->m_Port + CString( _T("(MultiDrop)") ) );
|
|
break;
|
|
case COFDeviceSocket::ST_PTZ:
|
|
pTempl->m_pSocket = m_ppSocket[ m_nSocket + nIndex ] = new CSocketMigvanPTZ;
|
|
pSocketPTZ = static_cast<CSocketMigvanPTZ*>(m_ppSocket[ m_nSocket + nIndex ]);
|
|
pSocketPTZ->Create( this, pTempl->m_Port );
|
|
pSocketPTZ->SetName( pTempl->m_Port + CString( _T("(Migvan PTZ)") ) );
|
|
break;
|
|
case COFDeviceSocket::ST_MIC1300:
|
|
pTempl->m_pSocket = m_ppSocket[ m_nSocket + nIndex ] = new CSocketCameraMic1300;
|
|
pSocketMic1300 = static_cast<CSocketCameraMic1300*>(m_ppSocket[ m_nSocket + nIndex ]);
|
|
pSocketMic1300->Create( this, pTempl->m_Port );
|
|
pSocketMic1300->SetName( pTempl->m_Port + CString( _T("(MIC1-300 PTZ)") ) );
|
|
break;
|
|
case COFDeviceSocket::ST_TKS576:
|
|
pTempl->m_pSocket = m_ppSocket[ m_nSocket + nIndex ] = new CSocketCameraTKS576;
|
|
pSocketTKS576 = static_cast<CSocketCameraTKS576*>(m_ppSocket[ m_nSocket + nIndex ]);
|
|
pSocketTKS576->Create( this, pTempl->m_Port );
|
|
pSocketTKS576->SetName( pTempl->m_Port + CString( _T("(JVC TK-S576 PTZ)") ) );
|
|
break;
|
|
case COFDeviceSocket::ST_PG3AD:
|
|
pTempl->m_pSocket = m_ppSocket[ m_nSocket + nIndex ] = new CSocketCameraPhilipsG3AD;
|
|
pSocketPG3AD = static_cast<CSocketCameraPhilipsG3AD*>(m_ppSocket[ m_nSocket + nIndex ]);
|
|
pSocketPG3AD->Create( this, pTempl->m_Port );
|
|
pSocketPG3AD->SetName( pTempl->m_Port + CString( _T("(Philips G3 AutoDome PTZ)") ) );
|
|
break;
|
|
case COFDeviceSocket::ST_AMERICAN_DYNAMICS:
|
|
pTempl->m_pSocket = m_ppSocket[ m_nSocket + nIndex ] = new CSocketCameraAmericanDynamics;
|
|
pAmericanDynamics = static_cast<CSocketCameraAmericanDynamics*>(m_ppSocket[ m_nSocket + nIndex ]);
|
|
pAmericanDynamics->Create( this, pTempl->m_Port );
|
|
pAmericanDynamics->SetName( pTempl->m_Port + CString( _T("(American Dynamics PTZ)") ) );
|
|
break;
|
|
case COFDeviceSocket::ST_PELCO:
|
|
pTempl->m_pSocket = m_ppSocket[ m_nSocket + nIndex ] = new CSocketCameraPelco;
|
|
pSocketPelco = static_cast<CSocketCameraPelco*>(m_ppSocket[ m_nSocket + nIndex ]);
|
|
pSocketPelco->Create( this, pTempl->m_Port );
|
|
pSocketPelco->SetName( pTempl->m_Port + CString( _T("(Pelco PTZ)") ) );
|
|
break;
|
|
case COFDeviceSocket::ST_VICON:
|
|
pTempl->m_pSocket = m_ppSocket[ m_nSocket + nIndex ] = new CSocketCameraVicon;
|
|
pSocketVicon = static_cast<CSocketCameraVicon*>(m_ppSocket[ m_nSocket + nIndex ]);
|
|
pSocketVicon->Create( this, pTempl->m_Port );
|
|
pSocketVicon->SetName( pTempl->m_Port + CString( _T("(Vicon S2000 PTZ)") ) );
|
|
break;
|
|
case COFDeviceSocket::ST_LGS:
|
|
pTempl->m_pSocket = m_ppSocket[ m_nSocket + nIndex ] = new CSocketLGS;
|
|
pSocketLGS = static_cast<CSocketLGS*>(m_ppSocket[ m_nSocket + nIndex ]);
|
|
pSocketLGS->Create( this, pTempl->m_Port );
|
|
pSocketLGS->SetName( pTempl->m_Port + CString( _T("(Single LGS)") ) );
|
|
break;
|
|
case COFDeviceSocket::ST_VM:
|
|
pTempl->m_pSocket = m_ppSocket[ m_nSocket + nIndex ] = new CSocketVM;
|
|
pSocketVM = static_cast<CSocketVM*>(m_ppSocket[ m_nSocket + nIndex ]);
|
|
pSocketVM->Create( this, pTempl->m_Port );
|
|
pSocketVM->SetName( pTempl->m_Port + CString( _T("(Migvan VM)") ) );
|
|
break;
|
|
case COFDeviceSocket::ST_CCC:
|
|
pTempl->m_pSocket = m_ppSocket[ m_nSocket + nIndex ] = new CSocketCCC;
|
|
pSocketCCC = static_cast<CSocketCCC*>(m_ppSocket[ m_nSocket + nIndex ]);
|
|
pSocketCCC->Create( this, pTempl->m_Port );
|
|
pSocketCCC->SetName( pTempl->m_Port + CString( _T("(CCC)") ) );
|
|
break;
|
|
case COFDeviceSocket::ST_DI:
|
|
pTempl->m_pSocket = m_ppSocket[ m_nSocket + nIndex ] = new CSocketRS232DI;
|
|
pSocketDI = static_cast<CSocketRS232DI*>(m_ppSocket[ m_nSocket + nIndex ]);
|
|
pSocketDI->Create( this, pTempl->m_Port, pTempl->m_bSelfTest, pTempl->m_nSelfTest );
|
|
pSocketDI->SetName( pTempl->m_Port + CString( _T("(RS232 D/C)") ) );
|
|
pTempl->m_pDevice = (CDevice*)pSocketDI;
|
|
break;
|
|
}
|
|
}
|
|
m_nSocket += OF.m_pDevice[ nType ].nCount;
|
|
break;
|
|
|
|
case OFNS::DT_PCI_1762:
|
|
m_ppDevice = (CDevice**)realloc( m_ppDevice, sizeof(CDevice*) * ( m_nDevice + OF.m_pDevice[ nType ].nCount ) );
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDevicePCI1762* pTempl = static_cast<COFDevicePCI1762*>(OF.m_pDevice[ nType ].ppDevice[ nIndex ]);
|
|
// hardware imagination
|
|
m_ppDevice[ m_nDevice + nIndex ] = new CDevicePCI1762;
|
|
CDevicePCI1762 *pDevice = static_cast<CDevicePCI1762*>(m_ppDevice[ m_nDevice + nIndex ]);
|
|
pDevice->Create( 0 );
|
|
pTempl->m_pDevice = pDevice;
|
|
}
|
|
m_nDevice += OF.m_pDevice[ nType ].nCount;
|
|
break;
|
|
|
|
case OFNS::DT_VIDEO_IN:
|
|
m_ppVideoCaptureDevice = (CVideoCaptureDevice**)realloc( m_ppVideoCaptureDevice, sizeof(CVideoCaptureDevice*) * ( m_nVideoCaptureDevice + OF.m_pDevice[ nType ].nCount ) );
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDeviceVideoIn* pTempl = static_cast<COFDeviceVideoIn*>(OF.m_pDevice[ nType ].ppDevice[ nIndex ]);
|
|
pTempl->m_pVideoDevice[0] = m_ppVideoCaptureDevice[ m_nVideoCaptureDevice + nIndex ] = new CVideoCaptureDevice;
|
|
CVideoCaptureDevice *pVideoCaptureDevice = m_ppVideoCaptureDevice[ m_nVideoCaptureDevice + nIndex ];
|
|
pVideoCaptureDevice->SetIOCount( 4, 0 );
|
|
pVideoCaptureDevice->SetVideoDeviceID( pTempl->m_nSubType );
|
|
pVideoCaptureDevice->SetVideoStandard( pTempl->m_nStandard );
|
|
}
|
|
m_nVideoCaptureDevice += OF.m_pDevice[ nType ].nCount;
|
|
break;
|
|
|
|
case OFNS::DT_DRY_CONTACTS:
|
|
m_ppSensor = (CSensor**)realloc( m_ppSensor, sizeof(CSensor*) * ( m_nSensor + OF.m_pDevice[ nType ].nCount ) );
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDeviceDryContacts * pTempl = static_cast<COFDeviceDryContacts*>(OF.m_pDevice[ nType ].ppDevice[ nIndex ]);
|
|
|
|
CSensorDC *pSensorDC;
|
|
|
|
m_ppSensor[ m_nSensor + nIndex ] = pSensorDC = new CSensorDC;
|
|
|
|
pSensorDC->SetPosition( SDPOINT( pTempl->m_Pos.x / OF.GetMapSize()->cx,
|
|
pTempl->m_Pos.y / OF.GetMapSize()->cy) );
|
|
pSensorDC->Enable( TRUE );
|
|
pSensorDC->SetArrayIndex( m_nSensor + nIndex );
|
|
pSensorDC->SetSocket( 2 );
|
|
pSensorDC->SetZoneIndex( 0 ); // need to changed
|
|
pSensorDC->SetSensorArray( this );
|
|
pSensorDC->SetState( CSensor::UNKNOWN );
|
|
pSensorDC->SetName( pTempl->GetName() );
|
|
pSensorDC->SetPatrol( FALSE );
|
|
pSensorDC->SetPTZ( pTempl->m_Pan, pTempl->m_Tilt, pTempl->m_Zoom / 100.0 );
|
|
|
|
// for background
|
|
COFTemplateDC *pTDC = OF.TemplateGet( pTempl->m_nTemplate );
|
|
pSensorDC->SetBG( &m_pBG[ pTempl->m_nTemplate ] );
|
|
for( int i = 0; i < pTDC->BitGetCount(); i++ )
|
|
pSensorDC->AddBitPos( pTDC->BitGet( i )->GetPos() );
|
|
|
|
// for update in calibration program
|
|
pSensorDC->m_nTemplateType = nType;
|
|
pSensorDC->m_nTemplateIndex = nIndex;
|
|
|
|
CTransform *ppTransform[2];
|
|
for( i = 0; i < 2; i++ )
|
|
{
|
|
ppTransform[i] = new CTransform();
|
|
ppTransform[i]->Prepare( pTempl->m_Transform[i].m_dX, pTempl->m_Transform[i].m_dY, pTempl->m_Transform[i].m_dZ,
|
|
pTempl->m_Transform[i].m_dPsi, pTempl->m_Transform[i].m_dTheta, pTempl->m_Transform[i].m_dPhi );
|
|
}
|
|
pSensorDC->SetTransform( pTempl->m_bRemoteCamera, pTempl->m_dPanShift, pTempl->m_dTiltTable, ppTransform[0], ppTransform[1] );
|
|
|
|
pSensorDC->SetAddressCCC( pTempl->m_nAddressCCC );
|
|
pSensorDC->SetImageCount( pTempl->m_nImageCount );
|
|
|
|
// small trick
|
|
pTempl->m_pSensor = pSensorDC;
|
|
}
|
|
m_nSensor += OF.m_pDevice[ nType ].nCount;
|
|
break;
|
|
}
|
|
}
|
|
|
|
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CSensorArray::Load"), _T("Device loading passed") );
|
|
|
|
// logical connections layer creating
|
|
for( nType = OFNS::DT_FIRST; nType < OFNS::DT_COUNT; nType++ )
|
|
{
|
|
int nIndex;
|
|
switch( OF.m_pDevice[ nType ].nType )
|
|
{
|
|
case OFNS::DT_SOCKET: // perform sockets connection
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDeviceSocket* pTempl = static_cast<COFDeviceSocket*>(OF.m_pDevice[ nType ].ppDevice[ nIndex ]);
|
|
CSocketMD *pSocketMD;
|
|
CSocketMigvanPTZ *pSocketPTZ;
|
|
CSocketCameraMic1300 *pSocketMic1300;
|
|
CSocketCameraTKS576 *pSocketTKS576;
|
|
CSocketCameraPhilipsG3AD *pSocketPG3AD;
|
|
CSocketCameraAmericanDynamics *pSocketAmericanDynamics;
|
|
CSocketCameraPelco *pSocketPelco;
|
|
CSocketCameraVicon *pSocketVicon;
|
|
CSocketVM *pSocketVM;
|
|
CSocketLGS *pSocketLGS;
|
|
CVoidList list;
|
|
GetSocketConnectionList( list, pTempl->GetPin(0) );
|
|
POSITION pos = list.GetHeadPosition();
|
|
switch( pTempl->m_nSubType )
|
|
{
|
|
case COFDeviceSocket::ST_MD:
|
|
pSocketMD = static_cast<CSocketMD*>(pTempl->m_pSocket);
|
|
while( pos )
|
|
{
|
|
CDevice *pDevice = static_cast<CDevice*>(list.GetNext( pos ));
|
|
if( pDevice )
|
|
{
|
|
pDevice->SetSocket( pSocketMD );
|
|
switch( pDevice->GetDeviceType() )
|
|
{
|
|
case OFNS::DT_LGS: pSocketMD->CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Link( static_cast<CDeviceLGSm*>(pDevice) ); break;
|
|
case OFNS::DT_CLD: pSocketMD->CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Link( static_cast<CDeviceCLD*>(pDevice) ); break;
|
|
case OFNS::DT_CAMERA_PTZ: pSocketMD->CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Link( static_cast<CDeviceCameraHebron*>(pDevice) ); break;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case COFDeviceSocket::ST_PTZ:
|
|
pSocketPTZ = static_cast<CSocketMigvanPTZ*>(pTempl->m_pSocket);
|
|
while( pos )
|
|
{
|
|
CDeviceMigvanPTZ *pDevice = static_cast<CDeviceMigvanPTZ*>(list.GetNext( pos ));
|
|
if( pDevice )
|
|
{
|
|
pDevice->SetSocket( pSocketPTZ );
|
|
pSocketPTZ->CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Link( pDevice );
|
|
pDevice->InitDevice();
|
|
}
|
|
}
|
|
break;
|
|
case COFDeviceSocket::ST_MIC1300:
|
|
pSocketMic1300 = static_cast<CSocketCameraMic1300*>(pTempl->m_pSocket);
|
|
while( pos )
|
|
{
|
|
CDeviceCameraMic1300 *pDevice = static_cast<CDeviceCameraMic1300*>(list.GetNext( pos ));
|
|
if( pDevice )
|
|
{
|
|
pDevice->SetSocket( pSocketMic1300 );
|
|
pSocketMic1300->CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Link( pDevice );
|
|
// pDevice->InitDevice();
|
|
}
|
|
}
|
|
break;
|
|
case COFDeviceSocket::ST_TKS576:
|
|
pSocketTKS576 = static_cast<CSocketCameraTKS576*>(pTempl->m_pSocket);
|
|
while( pos )
|
|
{
|
|
CDeviceCameraTKS576 *pDevice = static_cast<CDeviceCameraTKS576*>(list.GetNext( pos ));
|
|
if( pDevice )
|
|
{
|
|
pDevice->SetSocket( pSocketTKS576 );
|
|
pSocketTKS576->CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Link( pDevice );
|
|
// pDevice->InitDevice();
|
|
}
|
|
}
|
|
break;
|
|
case COFDeviceSocket::ST_PG3AD:
|
|
pSocketPG3AD = (CSocketCameraPhilipsG3AD*)pTempl->m_pSocket;
|
|
while( pos )
|
|
{
|
|
CDeviceCameraPhilipsG3AD *pDevice = static_cast<CDeviceCameraPhilipsG3AD*>(list.GetNext( pos ));
|
|
if( pDevice )
|
|
{
|
|
pDevice->SetSocket( pSocketPG3AD );
|
|
pSocketPG3AD->CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Link( pDevice );
|
|
// pDevice->InitDevice();
|
|
}
|
|
}
|
|
break;
|
|
case COFDeviceSocket::ST_AMERICAN_DYNAMICS:
|
|
pSocketAmericanDynamics = (CSocketCameraAmericanDynamics*)pTempl->m_pSocket;
|
|
while( pos )
|
|
{
|
|
CDeviceCameraAmericanDynamics *pDevice = static_cast<CDeviceCameraAmericanDynamics*>(list.GetNext( pos ));
|
|
if( pDevice )
|
|
{
|
|
pDevice->SetSocket( pSocketAmericanDynamics );
|
|
pSocketAmericanDynamics->CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Link( pDevice );
|
|
// pDevice->InitDevice();
|
|
}
|
|
}
|
|
break;
|
|
case COFDeviceSocket::ST_PELCO:
|
|
pSocketPelco = (CSocketCameraPelco*)pTempl->m_pSocket;
|
|
while( pos )
|
|
{
|
|
CDeviceCameraPelco *pDevice = static_cast<CDeviceCameraPelco*>(list.GetNext( pos ));
|
|
if( pDevice )
|
|
{
|
|
pDevice->SetSocket( pSocketPelco );
|
|
pSocketPelco->CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Link( pDevice );
|
|
// pDevice->InitDevice();
|
|
}
|
|
}
|
|
break;
|
|
case COFDeviceSocket::ST_VICON:
|
|
pSocketVicon = (CSocketCameraVicon*)pTempl->m_pSocket;
|
|
while( pos )
|
|
{
|
|
CDeviceCameraVicon *pDevice = static_cast<CDeviceCameraVicon*>(list.GetNext( pos ));
|
|
if( pDevice )
|
|
{
|
|
pDevice->SetSocket( pSocketVicon );
|
|
pSocketVicon->CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Link( pDevice );
|
|
// pDevice->InitDevice();
|
|
}
|
|
}
|
|
break;
|
|
case COFDeviceSocket::ST_LGS:
|
|
pSocketLGS = (CSocketLGS*)pTempl->m_pSocket;
|
|
while( pos )
|
|
{
|
|
CDeviceLGSs *pDevice = static_cast<CDeviceLGSs*>(list.GetNext( pos ));
|
|
if( pDevice )
|
|
pSocketLGS->DeviceAttach( pDevice );
|
|
}
|
|
break;
|
|
case COFDeviceSocket::ST_VM:
|
|
pSocketVM = static_cast<CSocketVM*>(pTempl->m_pSocket);
|
|
while( pos )
|
|
{
|
|
CDeviceVMs *pDevice = static_cast<CDeviceVMs*>(list.GetNext( pos ));
|
|
if( pDevice )
|
|
pSocketVM->DeviceAttach( pDevice );
|
|
}
|
|
break;
|
|
case COFDeviceSocket::ST_DI:
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
for( nIndex = 0; nIndex < OF.m_pDevice[ nType ].nCount; nIndex++ )
|
|
{
|
|
COFDevice* pTempl1 = static_cast<COFDevice*>(OF.m_pDevice[ nType ].ppDevice[ nIndex ]);
|
|
for( int nPin1 = 0; nPin1 < pTempl1->GetPinCount(); nPin1++ )
|
|
{
|
|
COFPin *pPin1 = pTempl1->GetPin(nPin1);
|
|
for( int nPin2 = 0; nPin2 < pPin1->m_nDeviceCount; nPin2++ )
|
|
{
|
|
COFDevice* pTempl2 = static_cast<COFDevice*>(OF.DeviceGet( pPin1->m_pDevice[ nPin2 ].nIndex, pPin1->m_pDevice[ nPin2 ].nType ));
|
|
COFPin *pPin2 = pTempl2->GetPin( pPin1->m_pDevice[ nPin2 ].nPin );
|
|
switch( pPin1->GetType() )
|
|
{
|
|
case PT_VIDEO_IN:
|
|
{
|
|
CVideoPin *pP1, *pP2;
|
|
|
|
if( pTempl1->GetType() == DT_RABBIT )
|
|
{
|
|
if( pPin1->m_nSubIndex > 1 ) pP1 = pTempl1->m_pVideoDevice[0]->GetInput( pPin1->m_nSubIndex-2 );
|
|
else pP1 = pTempl1->m_pVideoDevice[1]->GetInput( pPin1->m_nSubIndex );
|
|
}
|
|
else pP1 = pTempl1->m_pVideoDevice[0]->GetInput( pPin1->m_nSubIndex );
|
|
|
|
if( pTempl2->GetType() == DT_RABBIT )
|
|
{
|
|
if( pPin2->m_nSubIndex > 0 ) pP1 = pTempl2->m_pVideoDevice[0]->GetOutput( pPin2->m_nSubIndex-1 );
|
|
else pP2 = pTempl2->m_pVideoDevice[1]->GetOutput( pPin2->m_nSubIndex );
|
|
}
|
|
else pP2 = pTempl2->m_pVideoDevice[0]->GetOutput( pPin2->m_nSubIndex );
|
|
|
|
// connect video pins
|
|
pP2->Connect( pP1 );
|
|
}
|
|
break;
|
|
|
|
case PT_VIDEO_OUT: // actualy already connected in previous CASE block
|
|
break;
|
|
|
|
case PT_RABBIT_CAMERA:
|
|
{
|
|
CDeviceRabbit *pDevice = static_cast<CDeviceRabbit*>(pTempl1->m_pDevice);
|
|
CVideoCameraPTZ *pCamera = static_cast<CVideoCameraPTZ*>(pTempl2->m_pVideoDevice[0]);
|
|
pCamera->ConnectToDevice( pDevice );
|
|
}
|
|
break;
|
|
|
|
case PT_CAMERA_LGS:
|
|
{
|
|
CDeviceLGSm *pDevice = static_cast<CDeviceLGSm*>(pTempl2->m_pDevice);
|
|
CVideoCameraPTZ *pCamera = static_cast<CVideoCameraPTZ*>(pTempl1->m_pVideoDevice[0]);
|
|
pCamera->ConnectToDevice( pDevice );
|
|
}
|
|
break;
|
|
|
|
case PT_CAMERA_RABBIT: // actualy already connected in previous block
|
|
break;
|
|
|
|
case PT_SENSOR_CAMERA:
|
|
if( !pPin1->IsFree() )
|
|
{
|
|
pTempl1->m_pSensor->SetVideoCamera( static_cast<CVideoCamera*>(pTempl2->m_pVideoDevice[0]) );
|
|
|
|
if( static_cast<CVideoCamera*>(pTempl2->m_pVideoDevice[0])->GetType() == VC_PTZ )
|
|
static_cast<CVideoCameraPTZ*>(pTempl2->m_pVideoDevice[0])->SetSensor( pTempl1->m_pSensor );
|
|
}
|
|
break;
|
|
|
|
case PT_CAMERA_SENSOR: // actualy already connected in previous block
|
|
break;
|
|
|
|
case PT_SOCKET_MD:
|
|
case PT_SOCKET_PTZ:
|
|
case PT_SOCKET_VM:
|
|
case PT_SOCKET_LGS:
|
|
case PT_SOCKET_MIC1300:
|
|
case PT_SOCKET_TKS576:
|
|
case PT_SOCKET_PG3AD:
|
|
case PT_SOCKET_PELCO:
|
|
case PT_SOCKET_AMERICAN_DYNAMIS:
|
|
break;
|
|
|
|
case PT_INPUT_SENSOR:
|
|
{
|
|
CDirectInputSet *pSensorInputSet = NULL;
|
|
CDirectInputSet *pCommandInputSet = NULL;
|
|
switch( pTempl1->m_pSensor->GetType() )
|
|
{
|
|
case CVisual::DC: pSensorInputSet = &static_cast<CSensorDC*>(pTempl1->m_pSensor)->GetSensorInputSet();
|
|
case CVisual::LGS:
|
|
case CVisual::CLD: pCommandInputSet = &pTempl1->m_pSensor->GetCommandInputSet(); break;
|
|
}
|
|
|
|
CDirectInputSet *pInputSet = NULL;
|
|
switch( pPin1->GetSubType() )
|
|
{
|
|
case PST_SENSOR: pInputSet = pSensorInputSet; ASSERT( pInputSet ); break;
|
|
case PST_COMMAND: pInputSet = pCommandInputSet; ASSERT( pInputSet ); break;
|
|
default: ASSERT( NULL ); break;
|
|
}
|
|
|
|
if( !pInputSet )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CSensorArray::Load"), _T("DirectInputSet equal NULL") );
|
|
else
|
|
{
|
|
CDeviceDI *pDeviceDI = NULL;
|
|
|
|
switch( pTempl2->m_pDevice->GetDeviceType() )
|
|
{
|
|
case OFNS::DT_PCI_1762: pDeviceDI = static_cast<CDeviceDI*>( static_cast<CDevicePCI1762*>(pTempl2->m_pDevice) ); break;
|
|
case OFNS::DT_SOCKET: pDeviceDI = static_cast<CSocketRS232DI*>(pTempl2->m_pDevice)->GetDeviceDI(); break;
|
|
}
|
|
|
|
if( !pDeviceDI )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CSensorArray::Load"), _T("DeviceDI equal NULL") );
|
|
else
|
|
{
|
|
pInputSet->ConnectToDevice( pDeviceDI, pPin2->m_nSubIndex, pPin1->m_nSubIndex );
|
|
pDeviceDI->SetNC( pPin2->m_nSubIndex, pPin2->GetParam() );
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case PT_SENSOR_INPUT:
|
|
break;
|
|
|
|
case PT_EVENT_OUTPUT:
|
|
{
|
|
CDirectOutputSet *pEventOutputSet = &pTempl1->m_pSensor->GetEventOutputSet();
|
|
|
|
if( !pEventOutputSet )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CSensorArray::Load"), _T("DirectOutputSet equal NULL") );
|
|
else
|
|
{
|
|
CDeviceDO *pDeviceDO = NULL;
|
|
|
|
switch( pTempl2->m_pDevice->GetDeviceType() )
|
|
{
|
|
case DT_PCI_1762: pDeviceDO = static_cast<CDeviceDO*>( static_cast<CDevicePCI1762*>(pTempl2->m_pDevice) ); break;
|
|
case DT_SOCKET: pDeviceDO = static_cast<CSocketRS232DI*>( pTempl2->m_pSocket )->GetDeviceDO(); break;
|
|
}
|
|
|
|
if( !pDeviceDO )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CSensorArray::Load"), _T("DeviceDO equal NULL") );
|
|
else
|
|
{
|
|
pEventOutputSet->ConnectToDevice( pDeviceDO, pPin2->m_nSubIndex, pPin1->m_nSubIndex );
|
|
// pDeviceDO->SetNC( pPin2->m_nSubIndex, pPin2->GetParam() );
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case PT_OUTPUT_EVENT:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CSensorArray::Load"), _T("Locical connections passed") );
|
|
|
|
OF.GetProtectedString( m_Copyright );
|
|
|
|
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CSensorArray::Load"), _T("OF.GetProtectedString passed") );
|
|
}
|
|
|
|
m_nZonesCount = 1;
|
|
m_ppZones = new CZone*[ m_nZonesCount ];
|
|
for( int i = 0; i < m_nZonesCount; i++ )
|
|
{
|
|
m_ppZones[i] = new CZone;
|
|
m_ppZones[i]->SetName( CString( _T("ZONE") ) );
|
|
m_ppZones[i]->Create( this, i );
|
|
m_ppZones[i]->SetState( CSensor::UNKNOWN );
|
|
|
|
SDPOINT p(0.0,0.0);
|
|
for( int j = 0; j < m_ppZones[i]->GetCount(); j++ )
|
|
{
|
|
p.x += m_ppZones[i]->GetSensor( j )->GetPosition().x;
|
|
p.y += m_ppZones[i]->GetSensor( j )->GetPosition().y;
|
|
}
|
|
|
|
p.x /= m_ppZones[i]->GetCount();
|
|
p.y /= m_ppZones[i]->GetCount();
|
|
|
|
m_ppZones[i]->SetPosition( p );
|
|
}
|
|
|
|
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CSensorArray::Load"), _T("Zones creating passed") );
|
|
|
|
m_Options.bNeedAutorization = FALSE;
|
|
m_Options.nZoomFactor = 25;
|
|
|
|
m_PhoneCallCenter.Create( this );
|
|
|
|
UpdateSettings();
|
|
|
|
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CSensorArray::Load"), _T("m_PhoneCallCenter.Create passed") );
|
|
}
|
|
|
|
catch( CFileException *e )
|
|
{
|
|
e->ReportError();
|
|
}
|
|
catch( CArchiveException *e )
|
|
{
|
|
e->ReportError();
|
|
}
|
|
|
|
#endif
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CSensorArray::Load"), _T("Succeeded") );
|
|
|
|
return TRUE;
|
|
}
|
|
/*
|
|
void CSensorArray::SensorUpdate(CSensor *pSensor)
|
|
{
|
|
if( m_hEventWnd )
|
|
{
|
|
PostMessage( m_hEventWnd, WM_SENSOR_UPDATE, (WPARAM)0, (LPARAM)pSensor );
|
|
}
|
|
}
|
|
|
|
void CSensorArray::SensorEvent(int nIndex, DWORD data)
|
|
{
|
|
if( m_pEventWnd )
|
|
{
|
|
// m_pEventWnd->PostMessage( WM_SENSOR_EVENT, (WPARAM)nIndex, (LPARAM)data );
|
|
EVENT event;
|
|
event.dwID = LGS_EVENT_SENSOR;
|
|
event.dwData1 = nIndex;
|
|
event.dwData2 = data;
|
|
m_pEventQueue->PostEvent( event );
|
|
}
|
|
}
|
|
*/
|
|
void CSensorArray::CommandLoop( int nRunningMode )
|
|
{
|
|
for( int i = 0; i < m_nSocket; i++ )
|
|
{
|
|
switch( nRunningMode )
|
|
{
|
|
case MODE_HOST:
|
|
switch( m_ppSocket[i]->GetType() )
|
|
{
|
|
// case SOCKET_SPRU:
|
|
// case SOCKET_SM:
|
|
// case SOCKET_ECS:
|
|
// case SOCKET_BACKUP:
|
|
case SOCKET_MD:
|
|
case SOCKET_LGS:
|
|
case SOCKET_PTZ:
|
|
case SOCKET_RS232DI:
|
|
case SOCKET_CCC:
|
|
// case SOCKET_VM:
|
|
m_ppSocket[i]->CommandLoopStart();
|
|
break;
|
|
}
|
|
break;
|
|
case MODE_BACKUP:
|
|
switch( m_ppSocket[i]->GetType() )
|
|
{
|
|
case SOCKET_BACKUP:
|
|
m_ppSocket[i]->CommandLoopStart();
|
|
break;
|
|
case SOCKET_SPRU:
|
|
case SOCKET_SM:
|
|
case SOCKET_ECS:
|
|
case SOCKET_MD:
|
|
case SOCKET_VM:
|
|
m_ppSocket[i]->CommandLoopStop();
|
|
break;
|
|
}
|
|
break;
|
|
case MODE_BACKUP_ACTIVE:
|
|
switch( m_ppSocket[i]->GetType() )
|
|
{
|
|
case SOCKET_SPRU:
|
|
case SOCKET_SM:
|
|
case SOCKET_ECS:
|
|
case SOCKET_BACKUP:
|
|
case SOCKET_MD:
|
|
case SOCKET_VM:
|
|
m_ppSocket[i]->CommandLoopStart();
|
|
break;
|
|
}
|
|
break;
|
|
case MODE_MOBILEMAP:
|
|
switch( m_ppSocket[i]->GetType() )
|
|
{
|
|
case SOCKET_BACKUP:
|
|
m_ppSocket[i]->CommandLoopStart();
|
|
break;
|
|
case SOCKET_SPRU:
|
|
case SOCKET_SM:
|
|
case SOCKET_ECS:
|
|
case SOCKET_MD:
|
|
case SOCKET_VM:
|
|
m_ppSocket[i]->CommandLoopStop();
|
|
break;
|
|
}
|
|
break;
|
|
case MODE_STOP:
|
|
m_ppSocket[i]->CommandLoopStop();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
/*
|
|
void CSensorArray::SocketEvent(int nIndex, DWORD data)
|
|
{
|
|
if( m_pEventWnd )
|
|
{
|
|
// m_pEventWnd->PostMessage( WM_SOCKET_EVENT, (WPARAM)nIndex, (LPARAM)data );
|
|
EVENT event;
|
|
event.dwID = LGS_EVENT_SOCKET;
|
|
event.dwData1 = nIndex;
|
|
event.dwData2 = data;
|
|
m_pEventQueue->PostEvent( event );
|
|
}
|
|
}
|
|
*/
|
|
void CSensorArray::SetEventQueue(CEventQueue *pEventQueue)
|
|
{
|
|
m_pEventQueue = pEventQueue;
|
|
}
|
|
|
|
void CSensorArray::Reset( CSensor *pSensor )
|
|
{
|
|
if( pSensor )
|
|
{
|
|
pSensor->Reset();
|
|
}
|
|
else
|
|
{
|
|
for( int i = 0; i < m_nZonesCount; i++ )
|
|
m_ppZones[i]->Reset();
|
|
|
|
for( i = 0; i < m_nVideoCamera; i++ )
|
|
{
|
|
if( m_ppVideoCamera[i]->GetType() == VC_PTZ )
|
|
static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[i])->CmdReset();
|
|
}
|
|
}
|
|
}
|
|
|
|
BOOL CSensorArray::PostSocketEvent( EVENT &event, INT nType )
|
|
{
|
|
BOOL bSuccess = FALSE;
|
|
for( int i = 0; i < m_nSocket; i++ )
|
|
if( m_ppSocket[i]->GetType() == nType )
|
|
bSuccess = m_ppSocket[i]->PostEvent( event );
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CSensorArray::CheckGuard( LPSTR pGuard )
|
|
{
|
|
if( m_nGuardsCount )
|
|
{
|
|
for( int g = 0; g < m_nGuardsCount; g++ )
|
|
if( !stricmp( m_pGuards[ g ].pName, pGuard ) )
|
|
return TRUE;
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CSensorArray::CheckSuper( LPSTR pSuper )
|
|
{
|
|
if( m_nSupersCount )
|
|
{
|
|
for( int s = 0; s < m_nSupersCount; s++ )
|
|
if( !stricmp( m_pSupers[ s ].pName, pSuper ) )
|
|
return TRUE;
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CSensorArray::CheckSuperPassword( LPSTR pSuper, LPSTR pPassword )
|
|
{
|
|
if( m_nSupersCount )
|
|
{
|
|
for( int s = 0; s < m_nSupersCount; s++ )
|
|
if( !stricmp( m_pSupers[ s ].pName, pSuper ) )
|
|
{
|
|
if( !stricmp( m_pSupers[ s ].pPassword, pPassword ) )
|
|
return TRUE;
|
|
break;
|
|
}
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|
|
BOOL CSensorArray::CheckFilters()
|
|
{
|
|
for( int f = 0; f < m_nFiltersCount; f++ )
|
|
{
|
|
IOFILTER *pFilter = m_pFilters + f;
|
|
|
|
BOOL bResult = TRUE;
|
|
for( int c = 0; c < pFilter->ff.nInputCount; c++ )
|
|
{
|
|
FILE_CONDITION *pCondition = m_pConditions + pFilter->ff.inputs[c];
|
|
|
|
CSensorSPRU *pSensor = static_cast<CSensorSPRU*>(GetSensor( pCondition->nSensor ));
|
|
|
|
INT nState = pSensor->GetState();
|
|
|
|
INT nBitMask = pSensor->GetBitMask();
|
|
|
|
INT nBitState = pSensor->GetBitState() & nBitMask;
|
|
INT nBitAlarm = pSensor->GetBitAlarm() & nBitMask;
|
|
INT nBitEnable = pSensor->GetBitEnable() & nBitMask;
|
|
|
|
BOOL bCondition = FALSE;
|
|
|
|
if( pCondition->nState & FILE_UNKNOWN )
|
|
{
|
|
if( nState== CVisual::UNKNOWN )
|
|
bCondition = TRUE;
|
|
}
|
|
if( pCondition->nState & FILE_SS_NORMAL )
|
|
{
|
|
if( nState==CVisual::NORMAL )
|
|
bCondition = TRUE;
|
|
}
|
|
if( pCondition->nState & FILE_SS_TIMEOUT )
|
|
{
|
|
if( nState==CVisual::TIMEOUT )
|
|
bCondition = TRUE;
|
|
}
|
|
|
|
if( pCondition->bAll )
|
|
{
|
|
if( pCondition->nState & FILE_SS_DISABLE )
|
|
{
|
|
if( ( nBitEnable & pCondition->nBitMask) == pCondition->nBitMask )
|
|
bCondition = TRUE;
|
|
}
|
|
if( pCondition->nState & FILE_SS_POSTALARM )
|
|
{
|
|
if( ( nBitAlarm & pCondition->nBitMask ) == pCondition->nBitMask )
|
|
bCondition = TRUE;
|
|
}
|
|
if( pCondition->nState & FILE_SS_ALARM )
|
|
{
|
|
if( ( nBitState & pCondition->nBitMask ) == pCondition->nBitMask )
|
|
bCondition = TRUE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if( pCondition->nState & FILE_SS_DISABLE )
|
|
{
|
|
if( nBitEnable & pCondition->nBitMask )
|
|
bCondition = TRUE;
|
|
}
|
|
if( pCondition->nState & FILE_SS_POSTALARM )
|
|
{
|
|
if( nBitAlarm & pCondition->nBitMask )
|
|
bCondition = TRUE;
|
|
}
|
|
if( pCondition->nState & FILE_SS_ALARM )
|
|
{
|
|
if( nBitState & pCondition->nBitMask )
|
|
bCondition = TRUE;
|
|
}
|
|
}
|
|
|
|
if( !bCondition )
|
|
{
|
|
bResult = FALSE;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if( bResult )
|
|
{
|
|
if( pFilter->bNeedPerform )
|
|
{
|
|
EVENT event;
|
|
event.id = LGS_EVENT_GPRU_COMMAND_SEND;
|
|
event.color = 0;
|
|
strcpy( event.pText, "" );
|
|
SYSTEMTIME st;
|
|
::GetLocalTime( &st );
|
|
::SystemTimeToFileTime( &st, (LPFILETIME)&event.time );
|
|
event.data8 = 0;
|
|
for( int c = 0; c < pFilter->ff.nCommandCount; c++ )
|
|
{
|
|
FILE_COMMAND *pCommand = m_pCommands + pFilter->ff.commands[c];
|
|
event.data16 = MAKEWORD( pCommand->nAddress, pCommand->nLine );
|
|
event.data32 = ( ( pCommand->nCommand >> 8 ) & 0xFF ) |
|
|
( ( pCommand->nCommand >> 16 ) & 0xFF00 );
|
|
PostSocketEvent( event, SOCKET_SPRU );
|
|
event.data16 = MAKEWORD( pCommand->nAddress+1, pCommand->nLine );
|
|
event.data32 = ( pCommand->nCommand & 0xFF ) |
|
|
( ( pCommand->nCommand >> 8 ) & 0xFF00 );
|
|
PostSocketEvent( event, SOCKET_SPRU );
|
|
}
|
|
pFilter->bNeedPerform = FALSE;
|
|
}
|
|
}
|
|
else pFilter->bNeedPerform = TRUE;
|
|
}
|
|
/*
|
|
EVENT event;
|
|
event.event = LGS_EVENT_GPRU_COMMAND_SEND;
|
|
event.color = 0;
|
|
strcpy( event.pText, "" );
|
|
SYSTEMTIME st;
|
|
::GetLocalTime( &st );
|
|
event.data8 = 0;
|
|
event.data16 = MAKEWORD( 0, 0 );
|
|
event.data32 = 0;
|
|
SystemTimeToFileTime( &st, (LPFILETIME)&event.time );
|
|
PostSocketEvent( event, SOCKET_SPRU );
|
|
*/
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CSensorArray::CheckPatrols()
|
|
{
|
|
/*
|
|
DWORD dwCT = ::GetTickCount();
|
|
for( int i = 0; i < m_nPatrolsCount; i++ )
|
|
{
|
|
if( m_pPatrols[i].bActive )
|
|
{
|
|
if( dwCT >= m_pPatrols[i].maxTime )
|
|
{
|
|
m_pEventQueue->PostEvent( LGS_EVENT_PATROL, FALSE, m_pPatrols[i].nActive, 0, RGB(0xFF,0,0), "patrol time expaired" );
|
|
m_pPatrols[i].bActive = FALSE;
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
m_Patrol.CheckTime();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CSensorArray::CheckSensors()
|
|
{
|
|
for( int i = 0; i < m_nSensor; i++ )
|
|
{
|
|
switch( m_ppSensor[i]->GetType() )
|
|
{
|
|
case CSensor::DC:
|
|
static_cast<CSensorDC*>(m_ppSensor[i])->CheckState();
|
|
break;
|
|
case CSensor::LGS:
|
|
static_cast<CSensorLGS*>(m_ppSensor[i])->CheckState();
|
|
break;
|
|
case CSensor::CLD:
|
|
static_cast<CSensorCLD*>(m_ppSensor[i])->CheckState();
|
|
break;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CSensorArray::CheckSensorsCommand()
|
|
{
|
|
for( int i = 0; i < m_nSensor; i++ )
|
|
{
|
|
switch( m_ppSensor[i]->GetType() )
|
|
{
|
|
case CSensor::DC:
|
|
static_cast<CSensorDC*>(m_ppSensor[i])->CheckCommand();
|
|
break;
|
|
case CSensor::LGS:
|
|
static_cast<CSensorLGS*>(m_ppSensor[i])->CheckCommand();
|
|
break;
|
|
case CSensor::CLD:
|
|
static_cast<CSensorCLD*>(m_ppSensor[i])->CheckCommand();
|
|
break;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CSensorArray::CheckCameras()
|
|
{
|
|
for( int i = 0; i < m_nVideoCamera; i++ )
|
|
m_ppVideoCamera[i]->CheckState();
|
|
|
|
SYSTEMTIME st;
|
|
::GetLocalTime( &st );
|
|
|
|
int cTime = st.wHour * 60 + st.wMinute;
|
|
int dTime = m_nIrisDayHour * 60 + m_nIrisDayMinute;
|
|
int nTime = m_nIrisNightHour * 60 + m_nIrisNightMinute;
|
|
|
|
if( cTime >= dTime && cTime < nTime )
|
|
{
|
|
if( m_bIrisNeedSwitchDay )
|
|
{
|
|
for( int i = 0; i < m_nVideoCamera; i++ )
|
|
{
|
|
if( m_ppVideoCamera[i]->GetType() == VC_PTZ )
|
|
{
|
|
static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[i])->SetIrisDay( TRUE );
|
|
}
|
|
}
|
|
|
|
m_bIrisNeedSwitchDay = FALSE;
|
|
m_bIrisNeedSwitchNight = TRUE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if( m_bIrisNeedSwitchNight )
|
|
{
|
|
for( int i = 0; i < m_nVideoCamera; i++ )
|
|
{
|
|
if( m_ppVideoCamera[i]->GetType() == VC_PTZ )
|
|
{
|
|
static_cast<CVideoCameraPTZ*>(m_ppVideoCamera[i])->SetIrisDay( FALSE );
|
|
}
|
|
}
|
|
|
|
m_bIrisNeedSwitchNight = FALSE;
|
|
m_bIrisNeedSwitchDay = TRUE;
|
|
}
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CSensorArray::GetIrisTime( int& nDayHour, int& nDayMinute, double &dDayValue, int& nNightHour, int& nNightMinute, double &dNightValue )
|
|
{
|
|
nDayHour = m_nIrisDayHour;
|
|
nDayMinute = m_nIrisDayMinute;
|
|
nNightHour = m_nIrisNightHour;
|
|
nNightMinute = m_nIrisNightMinute;
|
|
dDayValue = m_dIrisDayValue;
|
|
dNightValue = m_dIrisNightValue;
|
|
}
|
|
|
|
void CSensorArray::SetIrisTime( int nDayHour, int nDayMinute, double dDayValue, int nNightHour, int nNightMinute, double dNightValue )
|
|
{
|
|
m_nIrisDayHour = nDayHour;
|
|
m_nIrisDayMinute = nDayMinute;
|
|
m_nIrisNightHour = nNightHour;
|
|
m_nIrisNightMinute = nNightMinute;
|
|
m_dIrisDayValue = dDayValue;
|
|
m_dIrisNightValue = dNightValue;
|
|
}
|
|
|
|
void CSensorArray::UpdateDemo( INT nVideoInput, double SampleTime )
|
|
{
|
|
INT nDevice = 0;
|
|
for( INT i = 0; i < m_nDevice; i++ )
|
|
{
|
|
if( m_ppDevice[i]->GetSocket()->GetType() == SOCKET_MD )
|
|
{
|
|
// if current LGS relative to current video
|
|
if( nDevice++ == nVideoInput )
|
|
{
|
|
INT nSampleTime = (INT)SampleTime;
|
|
|
|
const double _PI_ = 2 * asin(1.0);
|
|
|
|
if( nSampleTime == 0 )
|
|
m_nLastDemoSampleTime[nVideoInput] = 0;
|
|
|
|
switch( nVideoInput )
|
|
{
|
|
case 0:
|
|
if( nSampleTime >= 42 && m_nLastDemoSampleTime[nVideoInput] < nSampleTime )
|
|
{
|
|
m_nLastDemoSampleTime[nVideoInput] = nSampleTime;
|
|
|
|
double x = -75 + nSampleTime;
|
|
double y = -20 * cos( 3.1415 / 2.0 * x / 100 );
|
|
|
|
double r = sqrt( x * x + y * y );
|
|
double a = (INT)(atan2((double)-y , (double)x) * 180.0 / _PI_);
|
|
if(a < 0.0 ) a += 360.0;
|
|
|
|
EVENT event;
|
|
event.id = LGS_EVENT_DEMO;
|
|
event.pDemoDevice = m_ppDevice[i];
|
|
event.dDemoRange = r / 100.0;
|
|
event.dDemoAngle = a;
|
|
PostSocketEvent( event, SOCKET_MD );
|
|
}
|
|
break;
|
|
case 1:
|
|
if( nSampleTime >= 20 && m_nLastDemoSampleTime[nVideoInput] < nSampleTime )
|
|
{
|
|
m_nLastDemoSampleTime[nVideoInput] = nSampleTime;
|
|
|
|
double x = 60-nSampleTime;
|
|
double y = -20 * cos( 3.1415 / 2.0 * x / 100 );
|
|
double r = sqrt( x * x + y * y );
|
|
double a = (INT)(atan2((double)-y , (double)x) * 180.0 / _PI_);
|
|
if(a < 0.0 ) a += 360.0;
|
|
|
|
EVENT event;
|
|
event.id = LGS_EVENT_DEMO;
|
|
event.pDemoDevice = m_ppDevice[i];
|
|
event.dDemoRange = r / 100.0;
|
|
event.dDemoAngle = a;
|
|
PostSocketEvent( event, SOCKET_MD );
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
BOOL CSensorArray::StoreExtendedInfo( LPCTSTR pFormat, ... )
|
|
{
|
|
const INT MAX_EXTENDED_TEXT_LINE = 100;
|
|
const INT MAX_EXTENDED_TEXT_LINE_COUNT = 1000000;
|
|
|
|
// open file
|
|
CFile file;
|
|
if( !file.Open( "ISSC_EX.LOG", CFile::modeCreate | CFile::modeNoTruncate | CFile::modeReadWrite ) )
|
|
return FALSE;
|
|
|
|
// place header
|
|
DWORD dwPos = 0;
|
|
if( file.Read( &dwPos, sizeof(dwPos) ) != sizeof(dwPos) )
|
|
{
|
|
try
|
|
{
|
|
file.Write( &dwPos, sizeof(dwPos) );
|
|
}
|
|
catch( CFileException* )
|
|
{
|
|
file.Close();
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
// goto position
|
|
file.Seek( dwPos + sizeof(dwPos), SEEK_SET );
|
|
|
|
// write information
|
|
try
|
|
{
|
|
TCHAR pBuffer[MAX_EXTENDED_TEXT_LINE];
|
|
memset( pBuffer, ' ', MAX_EXTENDED_TEXT_LINE );
|
|
pBuffer[MAX_EXTENDED_TEXT_LINE-2] = '\r';
|
|
pBuffer[MAX_EXTENDED_TEXT_LINE-1] = '\n';
|
|
|
|
// prepare string
|
|
va_list pMarker;
|
|
va_start( pMarker, pFormat );
|
|
INT nCount = _vsntprintf( pBuffer, MAX_EXTENDED_TEXT_LINE, pFormat, pMarker );
|
|
// substitute terminating 0 with ' ';
|
|
if( nCount >= 0 ) pBuffer[ nCount ] = ' ';
|
|
va_end( pMarker );
|
|
|
|
// write to file
|
|
file.Write( pBuffer, MAX_EXTENDED_TEXT_LINE );
|
|
}
|
|
catch( CFileException* )
|
|
{
|
|
file.Close();
|
|
return FALSE;
|
|
}
|
|
|
|
// calculate position
|
|
dwPos = (dwPos + MAX_EXTENDED_TEXT_LINE) % (MAX_EXTENDED_TEXT_LINE * MAX_EXTENDED_TEXT_LINE_COUNT);
|
|
|
|
// goto position
|
|
file.Seek( 0, SEEK_SET );
|
|
|
|
// write information
|
|
try
|
|
{
|
|
file.Write( &dwPos, sizeof(dwPos) );
|
|
}
|
|
catch( CFileException* )
|
|
{
|
|
file.Close();
|
|
return FALSE;
|
|
}
|
|
|
|
file.Close();
|
|
return TRUE;
|
|
}
|
|
*/
|
|
|
|
BOOL CSensorArray::StoreExtendedInfo( LPCTSTR pFormat, ... )
|
|
{
|
|
return TRUE;
|
|
|
|
const DWORD MAX_EXTENDED_FILE_SIZE = 10000000UL; // 10 Mb
|
|
|
|
LPCTSTR pFileName = _T("ISSC_EX_0.LOG");
|
|
LPCTSTR pFileName2 = _T("ISSC_EX_1.LOG");
|
|
|
|
// get file size
|
|
WIN32_FILE_ATTRIBUTE_DATA FileAttributeData;
|
|
memset( &FileAttributeData, 0, sizeof(FileAttributeData) );
|
|
if( !::GetFileAttributesEx( pFileName, GetFileExInfoStandard, &FileAttributeData ) )
|
|
{
|
|
DWORD dwError = ::GetLastError();
|
|
switch( dwError )
|
|
{
|
|
case ERROR_FILE_NOT_FOUND:
|
|
break;
|
|
|
|
default:
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CSensorArray::StoreExtendedInfo"), _T("GetFileAttributesEx failed with 0x%08X"), dwError );
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
// check file size
|
|
if( FileAttributeData.nFileSizeLow > MAX_EXTENDED_FILE_SIZE )
|
|
{
|
|
// copy contens to new file
|
|
if( !::MoveFileEx( pFileName, pFileName2, MOVEFILE_REPLACE_EXISTING ) )
|
|
{
|
|
DWORD dwError = GetLastError();
|
|
switch( dwError )
|
|
{
|
|
case ERROR_CALL_NOT_IMPLEMENTED:
|
|
if( ::DeleteFile( pFileName2 ) )
|
|
{
|
|
dwError = GetLastError();
|
|
switch( dwError )
|
|
{
|
|
case ERROR_FILE_NOT_FOUND:
|
|
break;
|
|
default:
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CSensorArray::StoreExtendedInfo"), _T("DeleteFile failed with 0x%08X"), dwError );
|
|
return FALSE;
|
|
}
|
|
}
|
|
if( !::MoveFile( pFileName, pFileName2 ) )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CSensorArray::StoreExtendedInfo"), _T("MoveFile failed with 0x%08X"), GetLastError() );
|
|
return FALSE;
|
|
}
|
|
break;
|
|
|
|
default:
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CSensorArray::StoreExtendedInfo"), _T("MoveFileEx failed with 0x%08X"), dwError );
|
|
return FALSE;
|
|
}
|
|
}
|
|
}
|
|
|
|
FILE *pFile = _tfopen( pFileName, _T("a+") );
|
|
if( !pFile )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CSensorArray::StoreExtendedInfo"), _T("_tfopen filed with 0x%08X"), GetLastError() );
|
|
return FALSE;
|
|
}
|
|
|
|
// prepare string
|
|
TCHAR pBuffer[MAX_PATH];
|
|
va_list pMarker;
|
|
va_start( pMarker, pFormat );
|
|
INT nCount = _vsntprintf( pBuffer, MAX_PATH, pFormat, pMarker );
|
|
// update counter if size was exeeded
|
|
if( nCount < 0 ) nCount = MAX_PATH;
|
|
va_end( pMarker );
|
|
|
|
// write data
|
|
fwrite( pBuffer, 1, nCount, pFile );
|
|
|
|
TCHAR pLR[] = _T("\r\n");
|
|
fwrite( pLR, 1, sizeof(TCHAR) * 2, pFile );
|
|
|
|
// close file
|
|
fclose( pFile );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CSensorArray::DrawBackground( CDC *pDC, CRect *pRect )
|
|
{
|
|
m_Background.Draw( pDC, pRect );
|
|
|
|
double dMeterToPixelScale = pRect->Width() / m_Background.GetMeterScale();
|
|
|
|
for( INT i = 0; i < m_nSensor; i++ )
|
|
{
|
|
CSensor *pSensor = GetSensor(i);
|
|
|
|
CPoint center( (INT)( pSensor->GetPosition().x * pRect->Width() ),
|
|
(INT)( pSensor->GetPosition().y * pRect->Height() ) );
|
|
|
|
pSensor->OnDrawBackground( pDC, center, dMeterToPixelScale );
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CSensorArray::UpdateSettings()
|
|
{
|
|
if( !m_pSettings )
|
|
return;
|
|
|
|
m_pSettings->Save( _T("IRIS_DAY_HOUR"), m_nIrisDayHour );
|
|
m_pSettings->Save( _T("IRIS_DAY_MINUTE"), m_nIrisDayMinute );
|
|
m_pSettings->Save( _T("IRIS_DAY_VALUE"), m_dIrisDayValue );
|
|
m_pSettings->Save( _T("IRIS_NIGHT_HOUR"), m_nIrisNightHour );
|
|
m_pSettings->Save( _T("IRIS_NIGHT_MINUTE"), m_nIrisNightMinute );
|
|
m_pSettings->Save( _T("IRIS_NIGHT_VALUE"), m_dIrisNightValue );
|
|
m_pSettings->Save( _T("SETTINGS"), &m_ProgramSettings, sizeof(m_ProgramSettings) );
|
|
|
|
for( int i = 0; i < m_nSensor; i++ )
|
|
{
|
|
CSensor *pSensor = m_ppSensor[i];
|
|
|
|
switch( pSensor->GetType() )
|
|
{
|
|
case CVisual::LGS:
|
|
static_cast<CSensorLGS*>(pSensor)->SetAutoReset( m_ProgramSettings.AutoResetLGS.bEnable, m_ProgramSettings.AutoResetLGS.nTime );
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
void CSensorArray::SetBackgroundDirty( BOOL bDirty )
|
|
{
|
|
m_bBackgroundDirty = bDirty;
|
|
}
|
|
|
|
BOOL CSensorArray::IsBackgroundDirty()
|
|
{
|
|
return m_bBackgroundDirty;
|
|
}
|
|
|
|
BOOL CSensorArray::FullSystemRepair()
|
|
{
|
|
for( INT i = 0; i < GetSensorCount(); i++ )
|
|
{
|
|
CSensor *pSensor = GetSensor(i);
|
|
|
|
ASSERT( pSensor );
|
|
|
|
switch( pSensor->GetType() )
|
|
{
|
|
case CVisual::CLD: static_cast<CSensorCLD*>(pSensor)->Reset(); break;
|
|
case CVisual::LGS: static_cast<CSensorLGS*>(pSensor)->CmdReset( TRUE ); break;
|
|
case CVisual::DC: break;
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
}
|