|
|
|
@ -8,7 +8,7 @@ |
|
|
|
#define LGS_MAX_DETECTOR_RANGE 2047
|
|
|
|
|
|
|
|
|
|
|
|
#define DEBUG_EXTRA
|
|
|
|
//#define DEBUG_EXTRA
|
|
|
|
|
|
|
|
#undef LOG
|
|
|
|
#undef LOG_ERROR
|
|
|
|
@ -1393,8 +1393,8 @@ void device2DSensor::save_detection(){ |
|
|
|
if( !setWidthTable( pTBL ) ) { |
|
|
|
LOG_ERROR("Fall Back to Disconnected!"); |
|
|
|
setWM( LRF_WM_CONNECTION ); |
|
|
|
} else transactionWaitResult(); |
|
|
|
free( pTBL->pTable ); |
|
|
|
} else //transactionWaitResult();
|
|
|
|
startWaitDeviceOnline( LRF_WM_SAVE_DETECTION, LRF_WS_STAGE_6 ); |
|
|
|
free( pTBL ); |
|
|
|
} else transactionSetResult( TRANSACTION_RESULT_OK ); |
|
|
|
break; |
|
|
|
@ -1407,7 +1407,8 @@ void device2DSensor::save_detection(){ |
|
|
|
if (!setParameters( tData, true, m_nActiveDetectionProfile)) { |
|
|
|
LOG_ERROR("Fall Back to Disconnected!"); |
|
|
|
setWM( LRF_WM_CONNECTION ); |
|
|
|
} else transactionWaitResult(); |
|
|
|
} else //transactionWaitResult();
|
|
|
|
startWaitDeviceOnline( LRF_WM_SAVE_DETECTION, LRF_WS_STAGE_7 ); |
|
|
|
free( tData ); |
|
|
|
} else transactionSetResult( TRANSACTION_RESULT_OK ); |
|
|
|
break; |
|
|
|
@ -1421,7 +1422,8 @@ void device2DSensor::save_detection(){ |
|
|
|
if (!setParameters( tData, false, m_nActiveDetectionProfile)) { |
|
|
|
LOG_ERROR("Fall Back to Disconnected!"); |
|
|
|
setWM( LRF_WM_CONNECTION ); |
|
|
|
} else transactionWaitResult(); |
|
|
|
} else //transactionWaitResult();
|
|
|
|
startWaitDeviceOnline( LRF_WM_SAVE_DETECTION, LRF_WS_STAGE_8 ); |
|
|
|
free( tData ); |
|
|
|
} else transactionSetResult( TRANSACTION_RESULT_OK ); |
|
|
|
} else transactionSetResult( TRANSACTION_RESULT_OK ); |
|
|
|
@ -1446,6 +1448,37 @@ void device2DSensor::save_detection(){ |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
void device2DSensor::wait_device(){ |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Wait Device Online"); |
|
|
|
#endif
|
|
|
|
if( initWModeFunction( LRF_WM_WAIT_ONLINE_SPECIAL ) ) updateDataStatus( ARGUS_DS_BUSY ); |
|
|
|
switch( getPPStatus() ){ |
|
|
|
case STG_PUSH:{ |
|
|
|
switch( getStage() ) { |
|
|
|
case LRF_WS_INIT:{ |
|
|
|
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER; |
|
|
|
if( !getState() ) { |
|
|
|
LOG_ERROR("Fall Back to Disconnected!"); |
|
|
|
setWM( LRF_WM_CONNECTION ); |
|
|
|
} else transactionWaitResult(); |
|
|
|
break; |
|
|
|
}; |
|
|
|
case LRF_WS_STAGE_1:{ |
|
|
|
setWM( m_SP_WM ); |
|
|
|
setWM( m_SP_WM ); |
|
|
|
setStage( m_SP_STAGE ); |
|
|
|
break; |
|
|
|
}; |
|
|
|
default: setStage( LRF_WS_INIT ); break; |
|
|
|
}; |
|
|
|
break; |
|
|
|
}; |
|
|
|
case STG_WAIT: waitStateFunction(); break; |
|
|
|
case STG_POOL: poolStateFunction(); break; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
void device2DSensor::save_masks(){ |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("SAVE MASKS"); |
|
|
|
@ -2308,35 +2341,11 @@ WIDTH_TABLE * device2DSensor::prepareWidthTable(){ |
|
|
|
rVal->nCount = WIDTH_TABLE_SIZE; |
|
|
|
for ( int i=0; i<WIDTH_TABLE_SIZE; i++ ) rVal->pTable[i] = 100; // Init Default Values
|
|
|
|
DBC_WIDTH_TABLE *tDATA = m_pDBC->getLRFWidthTable( m_sLRF_DATA.id ); |
|
|
|
if( tDATA ){ |
|
|
|
if( tDATA->count ){ |
|
|
|
uint8_t cIDX = 0; |
|
|
|
float cK = 1.0f; |
|
|
|
const float cPV = 100.0f / WIDTH_TABLE_SIZE; |
|
|
|
// Check if WT works from the beginning of the detection range
|
|
|
|
if( tDATA->wt_records[cIDX].rangePercent == 0 ){ |
|
|
|
rVal->pTable[0] = tDATA->wt_records[cIDX].widthPercent; |
|
|
|
} else { |
|
|
|
cK = ( tDATA->wt_records[cIDX].widthPercent - rVal->pTable[0] ) / tDATA->wt_records[cIDX].rangePercent; |
|
|
|
}; |
|
|
|
for ( int i=1; i < WIDTH_TABLE_SIZE; i++ ) { |
|
|
|
// If greater then current point -> go to the next one
|
|
|
|
if ( cPV*i > tDATA->wt_records[cIDX].rangePercent ) { |
|
|
|
cIDX++; |
|
|
|
if( cIDX < tDATA->count ) { |
|
|
|
cK = (tDATA->wt_records[cIDX].widthPercent - tDATA->wt_records[cIDX-1].widthPercent ) / |
|
|
|
( tDATA->wt_records[cIDX].rangePercent - tDATA->wt_records[cIDX-1].rangePercent ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
// Calc next WT record
|
|
|
|
rVal->pTable[i] = (uint16_t)( rVal->pTable[i] + cPV * cK ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
if (tDATA) if ( tDATA->count == WIDTH_TABLE_SIZE ) for (int i = 0; i < WIDTH_TABLE_SIZE; i++) rVal->pTable[i] = tDATA->wt_records[i].widthPercent; |
|
|
|
#ifdef DEBUG
|
|
|
|
char tB[128]; |
|
|
|
for ( int i=0; i<WIDTH_TABLE_SIZE; i++ ){ |
|
|
|
sprintf( tB, "WT[%d] = %d%%", rVal->pTable[i] ); |
|
|
|
sprintf( tB, "WT[%d] = %d%%", i, rVal->pTable[i] ); |
|
|
|
LOG( tB ); |
|
|
|
}; |
|
|
|
#endif
|
|
|
|
|