##// END OF EJS Templates
Bug 914 Masque erroné en cas de bande polluée partiellement ......
paul -
r344:547f7fbdb0d0 R3++ draft
parent child
Show More
@@ -94,7 +94,7 unsigned int check_update_info_hk_thr_mo
94 94 void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value );
95 95 void set_hk_lfr_sc_rw_f_flags( void );
96 96 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC );
97 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float kcoeff );
97 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float sy_lfr_rw_k );
98 98 void build_sy_lfr_rw_mask( unsigned int channel );
99 99 void build_sy_lfr_rw_masks();
100 100 void merge_fbins_masks( void );
@@ -1080,7 +1080,7 void getReactionWheelsFrequencies( ccsds
1080 1080
1081 1081 }
1082 1082
1083 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float kcoeff )
1083 void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float sy_lfr_rw_k )
1084 1084 {
1085 1085 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
1086 1086 *
@@ -1100,6 +1100,7 void setFBinMask(unsigned char *fbins_ma
1100 1100 float fi;
1101 1101 float deltaBelow;
1102 1102 float deltaAbove;
1103 float freqToFilterOut;
1103 1104 int binBelow;
1104 1105 int binAbove;
1105 1106 int closestBin;
@@ -1107,79 +1108,99 void setFBinMask(unsigned char *fbins_ma
1107 1108 int selectedByte;
1108 1109 int bin;
1109 1110 int binToRemove[NB_BINS_TO_REMOVE];
1110 int i;
1111 int k;
1112 bool filteringSet;
1111 1113
1112 1114 closestBin = 0;
1113 1115 whichByte = 0;
1114 1116 bin = 0;
1117 filteringSet = false;
1115 1118
1116 for (i = 0; i < NB_BINS_TO_REMOVE; i++)
1119 for (k = 0; k < NB_BINS_TO_REMOVE; k++)
1117 1120 {
1118 binToRemove[i] = -1;
1121 binToRemove[k] = -1;
1119 1122 }
1120 1123
1121 1124 if (!isnan(rw_f))
1122 1125 {
1123
1124 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
1125 f_RW_min = rw_f - ( (filterPar.sy_lfr_sc_rw_delta_f * kcoeff) / DELTAF_DIV);
1126 f_RW_MAX = rw_f + ( (filterPar.sy_lfr_sc_rw_delta_f * kcoeff) / DELTAF_DIV);
1126 // compute the frequency range to filter [ rw_f - delta_f; rw_f + delta_f ]
1127 f_RW_min = rw_f - ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k);
1128 f_RW_MAX = rw_f + ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k);
1127 1129
1128 // compute the index of the frequency bin immediately below rw_f
1129 binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) );
1130 deltaBelow = rw_f - binBelow * deltaFreq;
1130 freqToFilterOut = f_RW_min;
1131 while ( filteringSet == false )
1132 {
1133 // compute the index of the frequency bin immediately below rw_f
1134 binBelow = (int) ( floor( ((double) freqToFilterOut) / ((double) deltaFreq)) );
1135 deltaBelow = freqToFilterOut - binBelow * deltaFreq;
1131 1136
1132 // compute the index of the frequency bin immediately above rw_f
1133 binAbove = (int) ( ceil( ((double) rw_f) / ((double) deltaFreq)) );
1134 deltaAbove = binAbove * deltaFreq - rw_f;
1137 // compute the index of the frequency bin immediately above rw_f
1138 binAbove = (int) ( ceil( ((double) freqToFilterOut) / ((double) deltaFreq)) );
1139 deltaAbove = binAbove * deltaFreq - freqToFilterOut;
1135 1140
1136 // search the closest bin
1137 if (deltaAbove > deltaBelow)
1138 {
1139 closestBin = binBelow;
1140 }
1141 else
1142 {
1143 closestBin = binAbove;
1144 }
1141 // search the closest bin
1142 if (deltaAbove > deltaBelow)
1143 {
1144 closestBin = binBelow;
1145 }
1146 else
1147 {
1148 closestBin = binAbove;
1149 }
1145 1150
1146 // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285]
1147 fi = closestBin * deltaFreq;
1148 fi_min = fi - (deltaFreq * FI_INTERVAL_COEFF);
1149 fi_MAX = fi + (deltaFreq * FI_INTERVAL_COEFF);
1151 // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285]
1152 fi = closestBin * deltaFreq;
1153 fi_min = fi - (deltaFreq * FI_INTERVAL_COEFF);
1154 fi_MAX = fi + (deltaFreq * FI_INTERVAL_COEFF);
1155
1156 //**************************************************************************************
1157 // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra
1158 // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum
1159 //**************************************************************************************
1150 1160
1151 //**************************************************************************************
1152 // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra
1153 // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum
1154 //**************************************************************************************
1161 // 1. IF freqToFilterOut is included in [ fi_min; fi_MAX ]
1162 // => remove f_(i), f_(i-1) and f_(i+1)
1163 if ( ( freqToFilterOut > fi_min ) && ( freqToFilterOut < fi_MAX ) )
1164 {
1165 binToRemove[0] = (closestBin - 1) - 1;
1166 binToRemove[1] = (closestBin) - 1;
1167 binToRemove[2] = (closestBin + 1) - 1;
1168 }
1169 // 2. ELSE
1170 // => remove the two f_(i) which are around f_RW
1171 else
1172 {
1173 binToRemove[0] = (binBelow) - 1;
1174 binToRemove[1] = (binAbove) - 1;
1175 binToRemove[2] = (-1);
1176 }
1155 1177
1156 // 1. IF [ f_RW_min, f_RW_MAX] is included in [ fi_min; fi_MAX ]
1157 // => remove f_(i), f_(i-1) and f_(i+1)
1158 if ( ( f_RW_min > fi_min ) && ( f_RW_MAX < fi_MAX ) )
1159 {
1160 binToRemove[0] = (closestBin - 1) - 1;
1161 binToRemove[1] = (closestBin) - 1;
1162 binToRemove[2] = (closestBin + 1) - 1;
1163 }
1164 // 2. ELSE
1165 // => remove the two f_(i) which are around f_RW
1166 else
1167 {
1168 binToRemove[0] = (binBelow) - 1;
1169 binToRemove[1] = (binAbove) - 1;
1170 binToRemove[2] = (-1);
1171 }
1178 for (k = 0; k < NB_BINS_TO_REMOVE; k++)
1179 {
1180 bin = binToRemove[k];
1181 if ( (bin >= BIN_MIN) && (bin <= BIN_MAX) )
1182 {
1183 whichByte = (bin >> SHIFT_3_BITS); // division by 8
1184 selectedByte = ( 1 << (bin - (whichByte * BITS_PER_BYTE)) );
1185 fbins_mask[BYTES_PER_MASK - 1 - whichByte] =
1186 fbins_mask[BYTES_PER_MASK - 1 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1187
1188 }
1189 }
1172 1190
1173 for (i = 0; i < NB_BINS_TO_REMOVE; i++)
1174 {
1175 bin = binToRemove[i];
1176 if ( (bin >= BIN_MIN) && (bin <= BIN_MAX) )
1191 // update freqToFilterOut
1192 if ( freqToFilterOut == f_RW_MAX )
1193 {
1194 filteringSet = true; // end of the loop
1195 }
1196 else
1177 1197 {
1198 freqToFilterOut = freqToFilterOut + deltaFreq;
1199 }
1178 1200
1179 whichByte = (bin >> SHIFT_3_BITS); // division by 8
1180 selectedByte = ( 1 << (bin - (whichByte * BITS_PER_BYTE)) );
1181 fbins_mask[BYTES_PER_MASK - 1 - whichByte] =
1182 fbins_mask[BYTES_PER_MASK - 1 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1201 if ( freqToFilterOut > f_RW_MAX)
1202 {
1203 freqToFilterOut = f_RW_MAX;
1183 1204 }
1184 1205 }
1185 1206 }
General Comments 0
You need to be logged in to leave comments. Login now