Old fashion design for PC-104
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.
|
|
//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright � 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: filters_.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of filters_.cpp
//----------------------------------------------------------------------------
#include "stdafx.h"
#include "Filters.h"
/////////////////////////////////////////////////////
// FILTER "UNRELIABLE POINTS DETECTION BY SUN BIT" //
/////////////////////////////////////////////////////
CFilterSun::CFilterSun(){ m_lpSunData = NULL; m_pTracker = NULL; Reset();}
CFilterSun::~CFilterSun(){ Destroy();}
BOOL CFilterSun::Create( CTracker *pTracker ){ Destroy();
m_pTracker = pTracker;
// allocate data for sun bit checking
m_lpSunData = (LPSUN_DATA)farmalloc( sizeof( SUN_DATA ) * LGS_MAX_DETECTOR_ANGLES ); if( !m_lpSunData ) return FALSE;
return TRUE;}
void CFilterSun::Destroy(){ // release array with sun data
if( m_lpSunData ) { farfree( m_lpSunData ); m_lpSunData = NULL; }
m_pTracker = NULL;}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FILTER "BLIND DETECTION BY MEDIUM RANGE"
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CFilterMediumRange::CFilterMediumRange(){ m_pTracker = NULL; Reset();}
CFilterMediumRange::~CFilterMediumRange(){ Destroy();}
BOOL CFilterMediumRange::Create( CTracker *pTracker ){ Reset(); // store pointer for future use
m_pTracker = pTracker; return TRUE;}
void CFilterMediumRange::Destroy(){ m_pTracker = NULL;}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FILTER "PD CONDITION DETECTION BY UNSTABLE RANGES"
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CFilterPD::CFilterPD(){ m_ppSAF[0] = NULL; m_ppSAF[1] = NULL; m_lpPD = NULL; m_lpPDEX = NULL; m_pTracker = NULL;
Reset();}
CFilterPD::~CFilterPD(){ Destroy();}
BOOL CFilterPD::Create( CTracker *pTracker ){ // allocate memory for SAF
for( INT i = 0; i < 2; i++ ) { if( !m_ppSAF[i] ) { m_ppSAF[i] = (LPSAF)farmalloc( sizeof(SAF) * LGS_MAX_DETECTOR_ANGLES ); if( !m_ppSAF[i] ) return FALSE; } }
// allocate memory for PD points
if( !m_lpPD ) { m_lpPD = (LPPD)farmalloc( sizeof(PD) * LGS_MAX_DETECTOR_ANGLES ); if( !m_lpPD ) return FALSE; }
// allocate memory for PDEX points
if( !m_lpPDEX ) { m_lpPDEX = (LPPDEX)farmalloc( sizeof(PDEX) * LGS_MAX_DETECTOR_ANGLES ); if( !m_lpPDEX ) return FALSE; }
m_pTracker = pTracker;
// reset filter
Reset();
return TRUE;}
void CFilterPD::Destroy(){ // free memory of SAF
for( INT i = 0; i < 2; i++ ) { if( m_ppSAF[i] ) { farfree( m_ppSAF[i] ); m_ppSAF[i] = NULL; } }
// free memory of PD points
if( m_lpPD ) { farfree( m_lpPD ); m_lpPD = NULL; }
// free memory of PDEX points
if( m_lpPDEX ) { farfree( m_lpPDEX ); m_lpPDEX = NULL; }}
////////////////////////////////////////////////////////
// FILTER "WIDTH" //
////////////////////////////////////////////////////////
CFilterWidth::CFilterWidth(){ memset( m_pTable, 0, sizeof( m_pTable ) );}
CFilterWidth::~CFilterWidth(){
}
BOOL CFilterWidth::Create( CTracker *pTracker, LPCTSTR pFileName ){ pTracker;
// place initial values
for( INT i = 0; i < LGS::WIDTH_TABLE_SIZE; i++ ) m_pTable[i] = 128;
// read coefficients
FILE *pFile = pFileName ? fopen( pFileName, "rt" ) : NULL; if( pFile ) { INT nTableIndex = 0;
CHAR pLine[MAX_PATH]; while( fgets( pLine, MAX_PATH, pFile ) && nTableIndex < LGS::WIDTH_TABLE_SIZE ) { // find first numbers
PCHAR pTemp = strtok( pLine, " ,;\t\n\r" ); // pass full string
while( pTemp && nTableIndex < LGS::WIDTH_TABLE_SIZE ) { // update from percent to 128
m_pTable[ nTableIndex++ ] = atol( pTemp ) * 128L / 100;
// skip delimiters
pTemp = strtok( NULL, " ,;\t\n\r" ); } }
fclose( pFile ); }
return TRUE;}
void CFilterWidth::Destroy(){
}
////////////////////////////////////////////////////////
// FILTER "CALIBRATION" //
////////////////////////////////////////////////////////
CFilterCalibration::CFilterCalibration(){ m_lpA2DRange = NULL; m_nA2DRangeCount = 0; m_lpLookupTable = NULL;}
CFilterCalibration::~CFilterCalibration(){ Destroy();}
BOOL CFilterCalibration::Create( LPCTSTR pFileName ){ m_lpLookupTable = (LPINT)farmalloc( LGS_MAX_DETECTOR_RANGE_POINTS * sizeof(INT) ); if( !m_lpLookupTable ) return FALSE;
for( INT i = 0; i < LGS_MAX_DETECTOR_RANGE_POINTS; i++ ) m_lpLookupTable[i] = i;
return Load( pFileName );}
void CFilterCalibration::Destroy(){ if( m_lpA2DRange ) { farfree( m_lpA2DRange ); m_lpA2DRange = NULL; }
if( m_lpLookupTable ) { farfree( m_lpLookupTable ); m_lpLookupTable = NULL; }
m_nA2DRangeCount = 0;}
|