# HG changeset patch # User paul # Date 2017-03-17 15:18:58 # Node ID 6155c628c2519654420c929bda43c08dce749d52 # Parent 06a7ca24f3e74cfd91bd845b3b3e99c34cc3f53c 3.2.0.5 PAS filtering updated for testing diff --git a/.hgsubstate b/.hgsubstate --- a/.hgsubstate +++ b/.hgsubstate @@ -1,2 +1,2 @@ 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters -5dfc0745a617f0b14b9b4c6d6c12d01f1fb9a801 header/lfr_common_headers +26659466eb11170e587645c796142ac8a7fd0add header/lfr_common_headers diff --git a/header/processing/fsw_processing.h b/header/processing/fsw_processing.h --- a/header/processing/fsw_processing.h +++ b/header/processing/fsw_processing.h @@ -176,6 +176,8 @@ static inline void ASM_compress_reorgani static inline void ASM_convert(volatile float *input_matrix, char *output_matrix); +unsigned char isPolluted( u_int64_t t0, u_int64_t t1, u_int64_t tbad0, u_int64_t tbad1 ); + unsigned char acquisitionTimeIsValid(unsigned int coarseTime, unsigned int fineTime, unsigned char channel); void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, @@ -208,7 +210,7 @@ void SM_average( float *averaged_spec_ma sum = INIT_FLOAT; for ( k = 0; k < NB_SM_BEFORE_AVF0_F1; k++ ) { - if (incomingSMIsValid[k] == 1) + if (incomingSMIsValid[k] == MATRIX_IS_NOT_POLLUTED) { sum = sum + ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] ; } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,7 +64,7 @@ option(FSW_debug_tch "?" OFF) set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE) set(SW_VERSION_N2 "2" CACHE STRING "Choose N2 FSW Version." FORCE) set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE) -set(SW_VERSION_N4 "3" CACHE STRING "Choose N4 FSW Version." FORCE) +set(SW_VERSION_N4 "5" CACHE STRING "Choose N4 FSW Version." FORCE) if(FSW_verbose) add_definitions(-DPRINT_MESSAGES_ON_CONSOLE) diff --git a/src/fsw_globals.c b/src/fsw_globals.c --- a/src/fsw_globals.c +++ b/src/fsw_globals.c @@ -94,5 +94,3 @@ rw_f_t rw_f; filterPar_t filterPar = {0}; fbins_masks_t fbins_masks = {0}; -unsigned int acquisitionDurations[NB_ACQUISITION_DURATION] -= {ACQUISITION_DURATION_F0, ACQUISITION_DURATION_F1, ACQUISITION_DURATION_F2}; diff --git a/src/processing/avf2_prc2.c b/src/processing/avf2_prc2.c --- a/src/processing/avf2_prc2.c +++ b/src/processing/avf2_prc2.c @@ -278,7 +278,7 @@ void SM_average_f2( float *averaged_spec sum = ( (int *) (ring_node->buffer_address) ) [ i ]; if ( (nbAverageNormF2 == 0) ) // average initialization { - if (keepMatrix == 1) // keep the matrix and add it to the average + if (keepMatrix == MATRIX_IS_NOT_POLLUTED) // keep the matrix and add it to the average { averaged_spec_mat_f2[ i ] = sum; } @@ -291,7 +291,7 @@ void SM_average_f2( float *averaged_spec } else { - if (keepMatrix == 1) // keep the matrix and add it to the average + if (keepMatrix == MATRIX_IS_NOT_POLLUTED) // keep the matrix and add it to the average { averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum ); } diff --git a/src/processing/fsw_processing.c b/src/processing/fsw_processing.c --- a/src/processing/fsw_processing.c +++ b/src/processing/fsw_processing.c @@ -718,82 +718,95 @@ int getFBinMask( int index, unsigned cha return fbin; } +unsigned char isPolluted( u_int64_t t0, u_int64_t t1, u_int64_t tbad0, u_int64_t tbad1 ) +{ + unsigned char polluted; + + polluted = MATRIX_IS_NOT_POLLUTED; + + if ( ((tbad0 < t0) && (t0 < tbad1)) // t0 is inside the polluted range + || ((tbad0 < t1) && (t1 < tbad1)) // t1 is inside the polluted range + || ((t0 < tbad0) && (tbad1 < t1)) // the polluted range is inside the signal range + || ((tbad0 < t0) && (t1 < tbad1))) // the signal range is inside the polluted range + { + polluted = MATRIX_IS_POLLUTED; + } + + return polluted; +} + unsigned char acquisitionTimeIsValid( unsigned int coarseTime, unsigned int fineTime, unsigned char channel) { - u_int64_t acquisitionTStart; - u_int64_t acquisitionTStop; - u_int64_t timecodeReference; + u_int64_t t0; + u_int64_t t1; + u_int64_t tc; + u_int64_t tbad0; + u_int64_t tbad1; + + u_int64_t modulusInFineTime; u_int64_t offsetInFineTime; u_int64_t shiftInFineTime; - u_int64_t tBadInFineTime; - u_int64_t perturbationTStart; - u_int64_t perturbationTStop; + u_int64_t tbadInFineTime; + + u_int64_t timecodeReference; + unsigned char pasFilteringIsEnabled; unsigned char ret; pasFilteringIsEnabled = (filterPar.spare_sy_lfr_pas_filter_enabled & 1); // [0000 0001] - ret = 1; + ret = MATRIX_IS_NOT_POLLUTED; + + // compute the acquitionTime range + modulusInFineTime = ((u_int64_t) filterPar.sy_lfr_pas_filter_modulus) * CONST_65536; + offsetInFineTime = ((u_int64_t) filterPar.sy_lfr_pas_filter_offset) * CONST_65536; + shiftInFineTime = ((u_int64_t) filterPar.sy_lfr_pas_filter_shift) * CONST_65536; + tbadInFineTime = ((u_int64_t) filterPar.sy_lfr_pas_filter_tbad) * CONST_65536; // compute acquisition time from caoarseTime and fineTime - acquisitionTStart = ( ((u_int64_t)coarseTime) << SHIFT_2_BYTES ) - + (u_int64_t) fineTime; + t0 = ( ((u_int64_t)coarseTime) << SHIFT_2_BYTES ) + (u_int64_t) fineTime; switch(channel) { case CHANNELF0: - acquisitionTStop = acquisitionTStart + ACQUISITION_DURATION_F0; + t1 = t0 + ACQUISITION_DURATION_F0; + tc = t0 + HALF_ACQUISITION_DURATION_F0; break; case CHANNELF1: - acquisitionTStop = acquisitionTStart + ACQUISITION_DURATION_F1; + t1 = t0 + ACQUISITION_DURATION_F1; + tc = t0 + HALF_ACQUISITION_DURATION_F1; break; case CHANNELF2: - acquisitionTStop = acquisitionTStart + ACQUISITION_DURATION_F2; + t1 = t0 + ACQUISITION_DURATION_F2; + tc = t0 + HALF_ACQUISITION_DURATION_F2; break; } - // compute the timecode reference - timecodeReference = (u_int64_t) ( (floor( ((double) coarseTime) / ((double) filterPar.sy_lfr_pas_filter_modulus) ) - * ((double) filterPar.sy_lfr_pas_filter_modulus)) * CONST_65536 ); - - // compute the acquitionTime range - offsetInFineTime = ((double) filterPar.sy_lfr_pas_filter_offset) * CONST_65536; - shiftInFineTime = ((double) filterPar.sy_lfr_pas_filter_shift) * CONST_65536; - tBadInFineTime = ((double) filterPar.sy_lfr_pas_filter_tbad) * CONST_65536; - - perturbationTStart = - timecodeReference - + offsetInFineTime - + shiftInFineTime; + // INTERSECTION TEST #1 + timecodeReference = (tc - (tc % modulusInFineTime)) - modulusInFineTime ; + tbad0 = timecodeReference + offsetInFineTime + shiftInFineTime; + tbad1 = timecodeReference + offsetInFineTime + shiftInFineTime + tbadInFineTime; + ret = isPolluted( t0, t1, tbad0, tbad1 ); - perturbationTStop = - timecodeReference - + offsetInFineTime - + shiftInFineTime - + tBadInFineTime; - - if ( (acquisitionTStart >= perturbationTStart) - && (acquisitionTStart <= perturbationTStop) - && (pasFilteringIsEnabled == 1) ) + // INTERSECTION TEST #2 + timecodeReference = (tc - (tc % modulusInFineTime)) ; + tbad0 = timecodeReference + offsetInFineTime + shiftInFineTime; + tbad1 = timecodeReference + offsetInFineTime + shiftInFineTime + tbadInFineTime; + if (ret == MATRIX_IS_NOT_POLLUTED) { - ret = 0; // the acquisition time is INSIDE the range, the matrix shall be ignored - } - else - { - ret = 1; // the acquisition time is OUTSIDE the range, the matrix can be used for the averaging + ret = isPolluted( t0, t1, tbad0, tbad1 ); } - // the last sample of the data used to compute the matrix shall not be INSIDE the range, test it now, it depends on the channel - if (ret == 1) + // INTERSECTION TEST #3 + timecodeReference = (tc - (tc % modulusInFineTime)) + modulusInFineTime ; + tbad0 = timecodeReference + offsetInFineTime + shiftInFineTime; + tbad1 = timecodeReference + offsetInFineTime + shiftInFineTime + tbadInFineTime; + if (ret == MATRIX_IS_NOT_POLLUTED) { - if ( (acquisitionTStop >= perturbationTStart) - && (acquisitionTStop <= perturbationTStop) - && (pasFilteringIsEnabled == 1) ) - { - ret = 0; // the acquisition time is INSIDE the range, the matrix shall be ignored - } - else - { - ret = 1; // the acquisition time is OUTSIDE the range, the matrix can be used for the averaging - } + ret = isPolluted( t0, t1, tbad0, tbad1 ); + } + + if (pasFilteringIsEnabled == 0) + { + ret = MATRIX_IS_NOT_POLLUTED; } return ret;