##// END OF EJS Templates
PAS filtering implemented
paul -
r289:a907a62ed869 R3_plus draft
parent child
Show More
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 dad8371a5549f3395f975fddc33098b05fd829f4 header/lfr_common_headers
2 2450d4935652a4d0370245cc7fc60a4c51e6fc9b header/lfr_common_headers
@@ -10,7 +10,7 TEMPLATE = app
10 # debug_tch
10 # debug_tch
11 # lpp_dpu_destid /!\ REMOVE BEFORE DELIVERY TO LESIA /!\
11 # lpp_dpu_destid /!\ REMOVE BEFORE DELIVERY TO LESIA /!\
12 # debug_watchdog
12 # debug_watchdog
13 CONFIG += console verbose lpp_dpu_destid
13 CONFIG += console verbose lpp_dpu_destid cpu_usage_report
14 CONFIG -= qt
14 CONFIG -= qt
15
15
16 include(./sparc.pri)
16 include(./sparc.pri)
@@ -80,6 +80,8 typedef struct asm_msg
80 unsigned int fineTimeNORM;
80 unsigned int fineTimeNORM;
81 unsigned int coarseTimeSBM;
81 unsigned int coarseTimeSBM;
82 unsigned int fineTimeSBM;
82 unsigned int fineTimeSBM;
83 unsigned int numberOfSMInASMNORM;
84 unsigned int numberOfSMInASMSBM;
83 } asm_msg;
85 } asm_msg;
84
86
85 extern unsigned char thisIsAnASMRestart;
87 extern unsigned char thisIsAnASMRestart;
@@ -87,6 +89,7 extern unsigned char thisIsAnASMRestart;
87 extern volatile int sm_f0[ ];
89 extern volatile int sm_f0[ ];
88 extern volatile int sm_f1[ ];
90 extern volatile int sm_f1[ ];
89 extern volatile int sm_f2[ ];
91 extern volatile int sm_f2[ ];
92 extern unsigned int acquisitionDurations[];
90
93
91 // parameters
94 // parameters
92 extern struct param_local_str param_local;
95 extern struct param_local_str param_local;
@@ -145,12 +148,7 extern rtems_status_code get_message_que
145 static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
148 static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
146 ring_node *ring_node_tab[],
149 ring_node *ring_node_tab[],
147 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
150 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
148 asm_msg *msgForMATR );
151 asm_msg *msgForMATR , unsigned char channel);
149
150 static inline void SM_average_debug(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
151 ring_node *ring_node_tab[],
152 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
153 asm_msg *msgForMATR );
154
152
155 void ASM_patch( float *inputASM, float *outputASM );
153 void ASM_patch( float *inputASM, float *outputASM );
156
154
@@ -165,24 +163,52 static inline void ASM_compress_reorgani
165
163
166 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
164 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
167
165
166 unsigned char acquisitionTimeIsValid(unsigned int coarseTime, unsigned int fineTime, unsigned char channel);
167
168 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
168 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
169 ring_node *ring_node_tab[],
169 ring_node *ring_node_tab[],
170 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
170 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
171 asm_msg *msgForMATR )
171 asm_msg *msgForMATR, unsigned char channel )
172 {
172 {
173 float sum;
173 float sum;
174 unsigned int i;
174 unsigned int i;
175 unsigned int k;
176 unsigned char incomingSMIsValid[8];
177 unsigned int numberOfValidSM;
178 unsigned char isValid;
175
179
180 //**************
181 // PAS FILTERING
182 // check acquisitionTime of the incoming data
183 numberOfValidSM = 0;
184 for (k=0; k<8; k++)
185 {
186 isValid = acquisitionTimeIsValid( ring_node_tab[k]->coarseTime, ring_node_tab[k]->fineTime, channel );
187 incomingSMIsValid[k] = isValid;
188 numberOfValidSM = numberOfValidSM + isValid;
189 }
190
191 //************************
192 // AVERAGE SPECTRAL MATRIX
176 for(i=0; i<TOTAL_SIZE_SM; i++)
193 for(i=0; i<TOTAL_SIZE_SM; i++)
177 {
194 {
178 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
195 // sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
179 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
196 // + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
180 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
197 // + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
181 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
198 // + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
182 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
199 // + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
183 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
200 // + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
184 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
201 // + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
185 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
202 // + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
203
204 sum = ( (incomingSMIsValid[0] == 1) ? ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] : 0.0 )
205 + ( (incomingSMIsValid[1] == 1) ? ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] : 0.0 )
206 + ( (incomingSMIsValid[2] == 1) ? ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] : 0.0 )
207 + ( (incomingSMIsValid[3] == 1) ? ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] : 0.0 )
208 + ( (incomingSMIsValid[4] == 1) ? ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] : 0.0 )
209 + ( (incomingSMIsValid[5] == 1) ? ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] : 0.0 )
210 + ( (incomingSMIsValid[6] == 1) ? ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] : 0.0 )
211 + ( (incomingSMIsValid[7] == 1) ? ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ] : 0.0 );
186
212
187 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
213 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
188 {
214 {
@@ -214,25 +240,28 void SM_average( float *averaged_spec_ma
214 // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
240 // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
215 }
241 }
216 }
242 }
217 }
218
243
219 void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
244 //*******************
220 ring_node *ring_node_tab[],
245 // UPDATE SM COUNTERS
221 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
246 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
222 asm_msg *msgForMATR )
247 {
223 {
248 msgForMATR->numberOfSMInASMNORM = numberOfValidSM;
224 float sum;
249 msgForMATR->numberOfSMInASMSBM = numberOfValidSM;
225 unsigned int i;
250 }
226
251 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
227 for(i=0; i<TOTAL_SIZE_SM; i++)
228 {
252 {
229 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ];
253 msgForMATR->numberOfSMInASMNORM = msgForMATR->numberOfSMInASMNORM + numberOfValidSM;
230 averaged_spec_mat_NORM[ i ] = sum;
254 msgForMATR->numberOfSMInASMSBM = msgForMATR->numberOfSMInASMSBM + numberOfValidSM;
231 averaged_spec_mat_SBM[ i ] = sum;
255 }
232 msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime;
256 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
233 msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime;
257 {
234 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
258 msgForMATR->numberOfSMInASMNORM = msgForMATR->numberOfSMInASMNORM + numberOfValidSM;
235 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
259 msgForMATR->numberOfSMInASMSBM = numberOfValidSM;
260 }
261 else
262 {
263 msgForMATR->numberOfSMInASMNORM = numberOfValidSM;
264 msgForMATR->numberOfSMInASMSBM = msgForMATR->numberOfSMInASMSBM + numberOfValidSM;
236 }
265 }
237 }
266 }
238
267
@@ -255,7 +284,7 void ASM_reorganize_and_divide( float *a
255 asmComponent * NB_BINS_PER_SM
284 asmComponent * NB_BINS_PER_SM
256 + frequencyBin;
285 + frequencyBin;
257 averaged_spec_mat_reorganized[offsetASMReorganized ] =
286 averaged_spec_mat_reorganized[offsetASMReorganized ] =
258 averaged_spec_mat[ offsetASM ] / divider;
287 (divider != 0.0) ? averaged_spec_mat[ offsetASM ] / divider : 0.0;
259 }
288 }
260 }
289 }
261 }
290 }
@@ -93,3 +93,4 float cp_rpw_sc_rw4_f2;
93 float sy_lfr_sc_rw_delta_f;
93 float sy_lfr_sc_rw_delta_f;
94
94
95 fbins_masks_t fbins_masks;
95 fbins_masks_t fbins_masks;
96 unsigned int acquisitionDurations[3] = {ACQUISITION_DURATION_F0, ACQUISITION_DURATION_F1, ACQUISITION_DURATION_F2};
@@ -98,7 +98,7 rtems_task avf0_task( rtems_task_argumen
98 current_ring_node_asm_burst_sbm_f0->matrix,
98 current_ring_node_asm_burst_sbm_f0->matrix,
99 ring_node_tab,
99 ring_node_tab,
100 nb_norm_bp1, nb_sbm_bp1,
100 nb_norm_bp1, nb_sbm_bp1,
101 &msgForPRC );
101 &msgForPRC, 0 ); // 0 => frequency channel 0
102
102
103 // update nb_average
103 // update nb_average
104 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
104 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
@@ -195,6 +195,8 rtems_task prc0_task( rtems_task_argumen
195 bp_packet packet_sbm_bp1;
195 bp_packet packet_sbm_bp1;
196 bp_packet packet_sbm_bp2;
196 bp_packet packet_sbm_bp2;
197 ring_node *current_ring_node_to_send_asm_f0;
197 ring_node *current_ring_node_to_send_asm_f0;
198 float nbSMInASMNORM;
199 float nbSMInASMSBM;
198
200
199 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
201 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
200 init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM );
202 init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM );
@@ -265,6 +267,9 rtems_task prc0_task( rtems_task_argumen
265 ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm );
267 ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm );
266 ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm );
268 ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm );
267
269
270 nbSMInASMNORM = incomingMsg->numberOfSMInASMNORM;
271 nbSMInASMSBM = incomingMsg->numberOfSMInASMSBM;
272
268 //****************
273 //****************
269 //****************
274 //****************
270 // BURST SBM1 SBM2
275 // BURST SBM1 SBM2
@@ -275,7 +280,7 rtems_task prc0_task( rtems_task_argumen
275 sid = getSID( incomingMsg->event );
280 sid = getSID( incomingMsg->event );
276 // 1) compress the matrix for Basic Parameters calculation
281 // 1) compress the matrix for Basic Parameters calculation
277 ASM_compress_reorganize_and_divide_mask( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0,
282 ASM_compress_reorganize_and_divide_mask( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0,
278 nb_sm_before_f0.burst_sbm_bp1,
283 nbSMInASMSBM,
279 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
284 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
280 ASM_F0_INDICE_START, CHANNELF0);
285 ASM_F0_INDICE_START, CHANNELF0);
281 // 2) compute the BP1 set
286 // 2) compute the BP1 set
@@ -313,7 +318,7 rtems_task prc0_task( rtems_task_argumen
313 {
318 {
314 // 1) compress the matrix for Basic Parameters calculation
319 // 1) compress the matrix for Basic Parameters calculation
315 ASM_compress_reorganize_and_divide_mask( asm_f0_patched_norm, compressed_sm_norm_f0,
320 ASM_compress_reorganize_and_divide_mask( asm_f0_patched_norm, compressed_sm_norm_f0,
316 nb_sm_before_f0.norm_bp1,
321 nbSMInASMNORM,
317 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
322 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
318 ASM_F0_INDICE_START, CHANNELF0 );
323 ASM_F0_INDICE_START, CHANNELF0 );
319 // 2) compute the BP1 set
324 // 2) compute the BP1 set
@@ -346,7 +351,7 rtems_task prc0_task( rtems_task_argumen
346 // 1) reorganize the ASM and divide
351 // 1) reorganize the ASM and divide
347 ASM_reorganize_and_divide( asm_f0_patched_norm,
352 ASM_reorganize_and_divide( asm_f0_patched_norm,
348 (float*) current_ring_node_to_send_asm_f0->buffer_address,
353 (float*) current_ring_node_to_send_asm_f0->buffer_address,
349 nb_sm_before_f0.norm_bp1 );
354 nbSMInASMNORM );
350 current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM;
355 current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM;
351 current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM;
356 current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM;
352 current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0;
357 current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0;
@@ -99,7 +99,7 rtems_task avf1_task( rtems_task_argumen
99 current_ring_node_asm_burst_sbm_f1->matrix,
99 current_ring_node_asm_burst_sbm_f1->matrix,
100 ring_node_tab,
100 ring_node_tab,
101 nb_norm_bp1, nb_sbm_bp1,
101 nb_norm_bp1, nb_sbm_bp1,
102 &msgForPRC );
102 &msgForPRC, 1 ); // 1 => frequency channel 1
103
103
104 // update nb_average
104 // update nb_average
105 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
105 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
@@ -196,8 +196,8 rtems_task prc1_task( rtems_task_argumen
196 bp_packet packet_sbm_bp1;
196 bp_packet packet_sbm_bp1;
197 bp_packet packet_sbm_bp2;
197 bp_packet packet_sbm_bp2;
198 ring_node *current_ring_node_to_send_asm_f1;
198 ring_node *current_ring_node_to_send_asm_f1;
199
199 float nbSMInASMNORM;
200 unsigned long long int localTime;
200 float nbSMInASMSBM;
201
201
202 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
202 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
203 init_ring( ring_to_send_asm_f1, NB_RING_NODES_ASM_F1, (volatile int*) buffer_asm_f1, TOTAL_SIZE_SM );
203 init_ring( ring_to_send_asm_f1, NB_RING_NODES_ASM_F1, (volatile int*) buffer_asm_f1, TOTAL_SIZE_SM );
@@ -259,7 +259,9 rtems_task prc1_task( rtems_task_argumen
259 ASM_patch( incomingMsg->norm->matrix, asm_f1_patched_norm );
259 ASM_patch( incomingMsg->norm->matrix, asm_f1_patched_norm );
260 ASM_patch( incomingMsg->burst_sbm->matrix, asm_f1_patched_burst_sbm );
260 ASM_patch( incomingMsg->burst_sbm->matrix, asm_f1_patched_burst_sbm );
261
261
262 localTime = getTimeAsUnsignedLongLongInt( );
262 nbSMInASMNORM = incomingMsg->numberOfSMInASMNORM;
263 nbSMInASMSBM = incomingMsg->numberOfSMInASMSBM;
264
263 //***********
265 //***********
264 //***********
266 //***********
265 // BURST SBM2
267 // BURST SBM2
@@ -270,7 +272,7 rtems_task prc1_task( rtems_task_argumen
270 sid = getSID( incomingMsg->event );
272 sid = getSID( incomingMsg->event );
271 // 1) compress the matrix for Basic Parameters calculation
273 // 1) compress the matrix for Basic Parameters calculation
272 ASM_compress_reorganize_and_divide_mask( asm_f1_patched_burst_sbm, compressed_sm_sbm_f1,
274 ASM_compress_reorganize_and_divide_mask( asm_f1_patched_burst_sbm, compressed_sm_sbm_f1,
273 nb_sm_before_f1.burst_sbm_bp1,
275 nbSMInASMSBM,
274 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
276 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
275 ASM_F1_INDICE_START, CHANNELF1);
277 ASM_F1_INDICE_START, CHANNELF1);
276 // 2) compute the BP1 set
278 // 2) compute the BP1 set
@@ -308,7 +310,7 rtems_task prc1_task( rtems_task_argumen
308 {
310 {
309 // 1) compress the matrix for Basic Parameters calculation
311 // 1) compress the matrix for Basic Parameters calculation
310 ASM_compress_reorganize_and_divide_mask( asm_f1_patched_norm, compressed_sm_norm_f1,
312 ASM_compress_reorganize_and_divide_mask( asm_f1_patched_norm, compressed_sm_norm_f1,
311 nb_sm_before_f1.norm_bp1,
313 nbSMInASMNORM,
312 NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1,
314 NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1,
313 ASM_F1_INDICE_START, CHANNELF1 );
315 ASM_F1_INDICE_START, CHANNELF1 );
314 // 2) compute the BP1 set
316 // 2) compute the BP1 set
@@ -341,7 +343,7 rtems_task prc1_task( rtems_task_argumen
341 // 1) reorganize the ASM and divide
343 // 1) reorganize the ASM and divide
342 ASM_reorganize_and_divide( asm_f1_patched_norm,
344 ASM_reorganize_and_divide( asm_f1_patched_norm,
343 (float*) current_ring_node_to_send_asm_f1->buffer_address,
345 (float*) current_ring_node_to_send_asm_f1->buffer_address,
344 nb_sm_before_f1.norm_bp1 );
346 nbSMInASMNORM );
345 current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM;
347 current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM;
346 current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM;
348 current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM;
347 current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1;
349 current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1;
@@ -143,6 +143,7 rtems_task prc2_task( rtems_task_argumen
143 bp_packet packet_norm_bp1;
143 bp_packet packet_norm_bp1;
144 bp_packet packet_norm_bp2;
144 bp_packet packet_norm_bp2;
145 ring_node *current_ring_node_to_send_asm_f2;
145 ring_node *current_ring_node_to_send_asm_f2;
146 float nbSMInASMNORM;
146
147
147 unsigned long long int localTime;
148 unsigned long long int localTime;
148
149
@@ -182,14 +183,16 rtems_task prc2_task( rtems_task_argumen
182
183
183 localTime = getTimeAsUnsignedLongLongInt( );
184 localTime = getTimeAsUnsignedLongLongInt( );
184
185
186 nbSMInASMNORM = incomingMsg->numberOfSMInASMNORM;
187
185 //*****
188 //*****
186 //*****
189 //*****
187 // NORM
190 // NORM
188 //*****
191 //*****
189 //*****
192 //*****
190 // 1) compress the matrix for Basic Parameters calculation
193 // 1) compress the matrix for Basic Parameters calculation
191 ASM_compress_reorganize_and_divide_mask( asm_f2_patched_norm, compressed_sm_norm_f2,
194 ASM_compress_reorganize_and_divide_mask( asm_f2_patched_norm, compressed_sm_norm_f2,
192 nb_sm_before_f2.norm_bp1,
195 nbSMInASMNORM,
193 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
196 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
194 ASM_F2_INDICE_START, CHANNELF2 );
197 ASM_F2_INDICE_START, CHANNELF2 );
195 // BP1_F2
198 // BP1_F2
@@ -258,19 +261,60 void SM_average_f2( float *averaged_spec
258 {
261 {
259 float sum;
262 float sum;
260 unsigned int i;
263 unsigned int i;
264 unsigned char keepMatrix;
265
266 // test acquisitionTime validity
267 keepMatrix = acquisitionTimeIsValid( ring_node->coarseTime, ring_node->fineTime, 2 );
261
268
262 for(i=0; i<TOTAL_SIZE_SM; i++)
269 for(i=0; i<TOTAL_SIZE_SM; i++)
263 {
270 {
264 sum = ( (int *) (ring_node->buffer_address) ) [ i ];
271 sum = ( (int *) (ring_node->buffer_address) ) [ i ];
265 if ( (nbAverageNormF2 == 0) )
272 if ( (nbAverageNormF2 == 0) ) // average initialization
266 {
273 {
267 averaged_spec_mat_f2[ i ] = sum;
274 if (keepMatrix == 1) // keep the matrix and add it to the average
275 {
276 averaged_spec_mat_f2[ i ] = sum;
277 }
278 else // drop the matrix and initialize the average
279 {
280 averaged_spec_mat_f2[ i ] = 0.;
281 }
268 msgForMATR->coarseTimeNORM = ring_node->coarseTime;
282 msgForMATR->coarseTimeNORM = ring_node->coarseTime;
269 msgForMATR->fineTimeNORM = ring_node->fineTime;
283 msgForMATR->fineTimeNORM = ring_node->fineTime;
270 }
284 }
271 else
285 else
272 {
286 {
273 averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum );
287 if (keepMatrix == 1) // keep the matrix and add it to the average
288 {
289 averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum );
290 }
291 else
292 {
293 // nothing to do, the matrix is not valid
294 }
295 }
296 }
297
298 if (keepMatrix == 1)
299 {
300 if ( (nbAverageNormF2 == 0) )
301 {
302 msgForMATR->numberOfSMInASMNORM = 1;
303 }
304 else
305 {
306 msgForMATR->numberOfSMInASMNORM++;
307 }
308 }
309 else
310 {
311 if ( (nbAverageNormF2 == 0) )
312 {
313 msgForMATR->numberOfSMInASMNORM = 0;
314 }
315 else
316 {
317 // nothing to do
274 }
318 }
275 }
319 }
276 }
320 }
@@ -666,7 +666,7 void ASM_compress_reorganize_and_divide_
666 + averaged_spec_mat[ offsetASM + k ] * fBinMask );
666 + averaged_spec_mat[ offsetASM + k ] * fBinMask );
667 }
667 }
668 compressed_spec_mat[ offsetCompressed ] =
668 compressed_spec_mat[ offsetCompressed ] =
669 compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage);
669 (divider != 0.) ? compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage) : 0.0;
670 }
670 }
671 }
671 }
672
672
@@ -704,6 +704,81 int getFBinMask( int index, unsigned cha
704 return fbin;
704 return fbin;
705 }
705 }
706
706
707 unsigned char acquisitionTimeIsValid( unsigned int coarseTime, unsigned int fineTime, unsigned char channel)
708 {
709 u_int64_t acquisitionTime;
710 u_int64_t timecodeReference;
711 u_int64_t offsetInFineTime;
712 u_int64_t shiftInFineTime;
713 u_int64_t tBadInFineTime;
714 u_int64_t acquisitionTimeRangeMin;
715 u_int64_t acquisitionTimeRangeMax;
716 unsigned char pasFilteringIsEnabled;
717 unsigned char ret;
718
719 pasFilteringIsEnabled = (parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & 0x01); // [0000 0001]
720 ret = 1;
721
722 //***************************
723 // <FOR TESTING PURPOSE ONLY>
724 unsigned char sy_lfr_pas_filter_modulus = 4;
725 unsigned char sy_lfr_pas_filter_offset = 1;
726 float sy_lfr_pas_filter_shift = 0.5;
727 float sy_lfr_pas_filter_tbad = 1.0;
728 // </FOR TESTING PURPOSE ONLY>
729 //****************************
730
731 // compute acquisition time from caoarseTime and fineTime
732 acquisitionTime = ( ((u_int64_t)coarseTime) << 16 )
733 + (u_int64_t) fineTime;
734
735 // compute the timecode reference
736 timecodeReference = (u_int64_t) (floor( ((double) coarseTime) / ((double) sy_lfr_pas_filter_modulus) )
737 * ((double) sy_lfr_pas_filter_modulus)) * 65536;
738
739 // compute the acquitionTime range
740 offsetInFineTime = ((double) sy_lfr_pas_filter_offset) * 65536;
741 shiftInFineTime = ((double) sy_lfr_pas_filter_shift) * 65536;
742 tBadInFineTime = ((double) sy_lfr_pas_filter_tbad) * 65536;
743
744 acquisitionTimeRangeMin =
745 timecodeReference
746 + offsetInFineTime
747 + shiftInFineTime
748 - acquisitionDurations[channel];
749 acquisitionTimeRangeMax =
750 timecodeReference
751 + offsetInFineTime
752 + shiftInFineTime
753 + tBadInFineTime;
754
755 if ( (acquisitionTime >= acquisitionTimeRangeMin)
756 && (acquisitionTime <= acquisitionTimeRangeMax)
757 && (pasFilteringIsEnabled == 1) )
758 {
759 ret = 0; // the acquisition time is INSIDE the range, the matrix shall be ignored
760 }
761 else
762 {
763 ret = 1; // the acquisition time is OUTSIDE the range, the matrix can be used for the averaging
764 }
765
766 // printf("coarseTime = %x, fineTime = %x\n",
767 // coarseTime,
768 // fineTime);
769
770 // printf("[ret = %d] *** acquisitionTime = %f, Reference = %f",
771 // ret,
772 // acquisitionTime / 65536.,
773 // timecodeReference / 65536.);
774
775 // printf(", Min = %f, Max = %f\n",
776 // acquisitionTimeRangeMin / 65536.,
777 // acquisitionTimeRangeMax / 65536.);
778
779 return ret;
780 }
781
707 void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm)
782 void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm)
708 {
783 {
709 unsigned char bin;
784 unsigned char bin;
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now