FreeCalypso > hg > fc-magnetite
comparison src/g23m-gprs/grlc/grlc_meass.c @ 183:219afcfc6250
src/g23m-gprs: initial import from TCS3.2/LoCosto
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 13 Oct 2016 04:24:13 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
182:f02d0a0e1849 | 183:219afcfc6250 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GPRS (8441) | |
4 | Modul : GRLC | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This module implements signal handler functions for service | |
18 | MEAS of entity GRLC. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef GRLC_MEASS_C | |
23 #define GRLC_MEASS_C | |
24 #endif /* #ifndef GRLC_MEASS_C */ | |
25 | |
26 #define ENTITY_GRLC | |
27 | |
28 /*==== INCLUDES =============================================================*/ | |
29 | |
30 #include "typedefs.h" | |
31 #include "vsi.h" | |
32 #include "macdef.h" | |
33 #include "gprs.h" | |
34 #include "gsm.h" | |
35 #include "ccdapi.h" | |
36 #include "prim.h" | |
37 #include "message.h" | |
38 #include "grlc.h" | |
39 #include "grlc_meass.h" | |
40 #include "grlc_measf.h" | |
41 #include "cl_rlcmac.h" | |
42 | |
43 /*==== CONST ================================================================*/ | |
44 | |
45 #define MEAS_MAX_NUM_MEAN 1000 /* maximum numbers of element considered for */ | |
46 /* calculating the mean */ | |
47 /* maybe for later use */ | |
48 /* | |
49 #define M_ROUND_UP(x,meas_acrcy) (((x)>=0)? \ | |
50 ((((x)%(meas_acrcy))< ((meas_acrcy)/ 2))? \ | |
51 ( (x)/(meas_acrcy) ):(((x)/(meas_acrcy))+1)): \ | |
52 ((((x)%(meas_acrcy))<=((meas_acrcy)/-2))? \ | |
53 (((x)/(meas_acrcy))-1):( (x)/(meas_acrcy) ))) | |
54 */ | |
55 | |
56 #define M_ROUND_UP(x,meas_acrcy) ((((x)%(meas_acrcy))< ((meas_acrcy)/ 2))? \ | |
57 ( (x)/(meas_acrcy) ):(((x)/(meas_acrcy))+1)) | |
58 | |
59 #define MEAS_C_INC_INDEX(index) { \ | |
60 if( index < (T_C_INDEX)(~0) ) index++; \ | |
61 } | |
62 | |
63 #define NORM_FFB_MAX (ULONG)100000 /* normalised forgetting factor b maximum value */ | |
64 #define NORM_FFC_MAX (ULONG)500000 /* normalised forgetting factor c maximum value */ | |
65 #define NORM_FFB_DIV (ULONG)10 /* normalised forgetting factor b divisor value */ | |
66 #define NORM_FFC_DIV (ULONG)20 /* normalised forgetting factor c divisor value */ | |
67 | |
68 #define SV_ACRCY_DIV (ULONG)10 /* signal variance accuracy divisor */ | |
69 | |
70 #define C_VALUE_IDX_DEFAULT 0 | |
71 #define C_VALUE_DEFAULT 0 | |
72 #define SV_VALUE_DEFAULT 0 | |
73 #define RXQUAL_VALUE_DEFAULT 0 | |
74 | |
75 #define SV_LEVEL_MAX 63 | |
76 #define SV_LEVEL_STEP ((T_SIGN_VAR_VALUE)(MEAS_ACRCY/4)) | |
77 /* dB2 step size of the signal */ | |
78 /* variance */ | |
79 | |
80 /*==== LOCAL VARS ===========================================================*/ | |
81 | |
82 /* | |
83 * normalised forgetting factor b used in context of C value calculation | |
84 * | |
85 * NORM_FFB_MAX * ( 1 / ( 6 * t_avg_t ) ) | |
86 */ | |
87 LOCAL const ULONG norm_ffb[] = { NORM_FFB_MAX, | |
88 70711, 50000, 35355, 25000, 17678, 12500, | |
89 8839, 6250, 4419, 3125, 2210, 1563, | |
90 1105, 781, 552, 391, 276, 195, | |
91 138, 98, 69, 49, 35, 24, | |
92 17 }; | |
93 | |
94 /* | |
95 * normalised forgetting factor c used in context of C value calculation | |
96 * | |
97 * NORM_FFC_MAX * ( 1 / ( 12 * t_avg_t ) ) | |
98 */ | |
99 LOCAL const ULONG norm_ffc[] = { NORM_FFC_MAX, | |
100 353553, 250000, 176777, 125000, 88388, 62500, | |
101 44194, 31250, 22097, 15625, 11049, 7813, | |
102 5524, 3906, 2762, 1953, 1381, 977, | |
103 691, 488, 345, 244, 173, 122, | |
104 86 }; | |
105 | |
106 /*==== LOCAL TYPES===========================================================*/ | |
107 | |
108 #if !defined (NTRACE) | |
109 | |
110 LOCAL void meas_int_trace_i_level( T_ilev *i_level ); | |
111 | |
112 #endif /* #if !defined (NTRACE) */ | |
113 | |
114 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
115 /* | |
116 +------------------------------------------------------------------------------ | |
117 | Function : meas_grlc_init | |
118 +------------------------------------------------------------------------------ | |
119 | Description : | |
120 | | |
121 | Parameters : | |
122 | | |
123 +------------------------------------------------------------------------------ | |
124 */ | |
125 GLOBAL void meas_grlc_init ( void ) | |
126 { | |
127 TRACE_FUNCTION( "meas_grlc_init" ); | |
128 | |
129 /* initialization of C value management */ | |
130 meas_c_restart( ); | |
131 | |
132 /* initialization of signal variance management */ | |
133 meas_sv_restart( ); | |
134 | |
135 /* initialization of signal quality management */ | |
136 meas_sq_restart( ); | |
137 | |
138 } /* grlc_meas_init() */ | |
139 | |
140 /* | |
141 +------------------------------------------------------------------------------ | |
142 | Function : sig_rd_meas_qual_rpt_sent | |
143 +------------------------------------------------------------------------------ | |
144 | Description : Handles the internal signal SIG_RD_MEAS_QUAL_RPT_SENT | |
145 | Parameters : void | |
146 | | |
147 +------------------------------------------------------------------------------ | |
148 */ | |
149 GLOBAL void sig_rd_meas_qual_rpt_sent ( void ) | |
150 { | |
151 TRACE_ISIG( "sig_rd_meas_qual_rpt_sent" ); | |
152 | |
153 meas_sv_restart( ); | |
154 | |
155 grlc_data->meas.sq_restart = TRUE; | |
156 | |
157 } /* sig_rd_meas_qual_rpt_sent() */ | |
158 | |
159 /* | |
160 +------------------------------------------------------------------------------ | |
161 | Function : sig_tm_meas_ptm | |
162 +------------------------------------------------------------------------------ | |
163 | Description : Handles the internal signal SIG_TM_MEAS_PTM | |
164 | | |
165 | Parameters : void | |
166 | | |
167 +------------------------------------------------------------------------------ | |
168 */ | |
169 GLOBAL void sig_tm_meas_ptm ( void ) | |
170 { | |
171 TRACE_ISIG( "sig_tm_meas_ptm" ); | |
172 | |
173 meas_sv_restart( ); | |
174 meas_sq_restart( ); | |
175 | |
176 } /* sig_tm_meas_ptm() */ | |
177 | |
178 /* | |
179 +------------------------------------------------------------------------------ | |
180 | Function : meas_grlc_c_get_value | |
181 +------------------------------------------------------------------------------ | |
182 | Description : This function returns the current C value. | |
183 | | |
184 | Parameters : void | |
185 | | |
186 +------------------------------------------------------------------------------ | |
187 */ | |
188 GLOBAL UBYTE meas_grlc_c_get_value ( void ) | |
189 { | |
190 UBYTE c_value; | |
191 | |
192 TRACE_FUNCTION( "meas_grlc_c_get_value" ); | |
193 | |
194 if( grlc_data->meas.c_filter.index > 0 ) | |
195 { | |
196 c_value = ( M_ROUND_UP( grlc_data->meas.c_filter.value, MEAS_ACRCY ) ); | |
197 } | |
198 else | |
199 { | |
200 | |
201 #ifdef _SIMULATION_ | |
202 TRACE_ERROR( "meas_grlc_c_get_value: grlc_data->meas.c_filter.index EQ 0" ); | |
203 #endif /* #ifdef _SIMULATION_ */ | |
204 | |
205 c_value = C_VALUE_DEFAULT; | |
206 } | |
207 | |
208 return( c_value ); | |
209 | |
210 } /* meas_grlc_c_get_value() */ | |
211 | |
212 /* | |
213 +------------------------------------------------------------------------------ | |
214 | Function : meas_grlc_c_get_c_value | |
215 +------------------------------------------------------------------------------ | |
216 | Description : | |
217 | | |
218 | Parameters : | |
219 | | |
220 +------------------------------------------------------------------------------ | |
221 */ | |
222 GLOBAL void meas_grlc_c_get_c_value ( T_CGRLC_c_value *c_value ) | |
223 { | |
224 TRACE_FUNCTION( "meas_grlc_c_get_c_value" ); | |
225 | |
226 c_value->c_acrcy = MEAS_ACRCY; | |
227 c_value->c_lev = grlc_data->meas.c_filter.value; | |
228 c_value->c_idx = grlc_data->meas.c_filter.index; | |
229 | |
230 } /* meas_grlc_c_get_c_value() */ | |
231 | |
232 /* | |
233 +------------------------------------------------------------------------------ | |
234 | Function : meas_grlc_c_set_c_value | |
235 +------------------------------------------------------------------------------ | |
236 | Description : | |
237 | | |
238 | Parameters : | |
239 | | |
240 +------------------------------------------------------------------------------ | |
241 */ | |
242 GLOBAL void meas_grlc_c_set_c_value ( T_CGRLC_c_value *c_value ) | |
243 { | |
244 TRACE_FUNCTION( "meas_grlc_c_set_c_value" ); | |
245 | |
246 grlc_data->meas.c_filter.value = (c_value->c_lev / c_value->c_acrcy) * | |
247 MEAS_ACRCY; | |
248 | |
249 grlc_data->meas.c_filter.index = c_value->c_idx; | |
250 | |
251 } /* meas_grlc_c_set_c_value() */ | |
252 | |
253 /* | |
254 +------------------------------------------------------------------------------ | |
255 | Function : meas_c_val_update_ptm | |
256 +------------------------------------------------------------------------------ | |
257 | Description : ... | |
258 | | |
259 | Parameters : - | |
260 | | |
261 +------------------------------------------------------------------------------ | |
262 */ | |
263 GLOBAL void meas_c_val_update_ptm ( T_MAC_PWR_CTRL_IND *mac_pwr_ctrl_ind, | |
264 T_CGRLC_glbl_pwr_ctrl_param *pwr_ctrl_param, | |
265 T_CGRLC_freq_param *freq_param ) | |
266 { | |
267 UBYTE pb_rdc; /* Pb reduction */ | |
268 UBYTE vld_smpl = 0; /* valid measurement samples */ | |
269 | |
270 ULONG ff_value; | |
271 ULONG c_value; | |
272 | |
273 T_C_FILTER *c_filter = &grlc_data->meas.c_filter; | |
274 | |
275 TRACE_FUNCTION( "meas_c_val_update_ptm" ); | |
276 | |
277 if( pwr_ctrl_param->pc_meas_chan EQ CGRLC_MEAS_CHAN_BCCH AND | |
278 mac_pwr_ctrl_ind->bcch_level NEQ MAC_RXLEV_NONE ) | |
279 { | |
280 MEAS_C_INC_INDEX( c_filter->index ); | |
281 | |
282 if( c_filter->index EQ 1 ) | |
283 { | |
284 c_filter->value = MEAS_ACRCY * mac_pwr_ctrl_ind->bcch_level; | |
285 } | |
286 else | |
287 { | |
288 /* calculate the forgetting factor */ | |
289 ff_value = norm_ffb[pwr_ctrl_param->t_avg_t]; | |
290 | |
291 /* update the filter */ | |
292 c_value = ( NORM_FFB_MAX - ff_value ) * | |
293 ( c_filter->value / NORM_FFB_DIV ) | |
294 + | |
295 ff_value * | |
296 ( MEAS_ACRCY / NORM_FFB_DIV ) * | |
297 mac_pwr_ctrl_ind->bcch_level; | |
298 | |
299 c_filter->value = (T_C_VALUE)(c_value / (NORM_FFB_MAX / NORM_FFB_DIV)); | |
300 } | |
301 | |
302 #ifdef _SIMULATION_ | |
303 TRACE_EVENT_P2( "C-Value = %d, C-Index = %d", | |
304 c_filter->value, c_filter->index ); | |
305 #endif /* #ifdef _SIMULATION_ */ | |
306 } | |
307 else if( pwr_ctrl_param->pc_meas_chan EQ CGRLC_MEAS_CHAN_PDCH ) | |
308 { | |
309 vld_smpl = meas_c_calc_mean ( mac_pwr_ctrl_ind->burst_level, | |
310 mac_pwr_ctrl_ind->radio_freq, | |
311 &c_value, &pb_rdc, freq_param ); | |
312 | |
313 if( vld_smpl ) | |
314 { | |
315 MEAS_C_INC_INDEX( c_filter->index ); | |
316 | |
317 /* consider the BTS output power reduction */ | |
318 c_value -= ( ( 2 * pwr_ctrl_param->pb ) * | |
319 ( MEAS_ACRCY * pb_rdc ) / MAC_BURST_PER_BLOCK ); | |
320 | |
321 | |
322 if( c_filter->index EQ 1 ) | |
323 { | |
324 c_filter->value = (T_C_VALUE)c_value; | |
325 } | |
326 else | |
327 { | |
328 /* calculate the forgetting factor */ | |
329 ff_value = norm_ffc[pwr_ctrl_param->t_avg_t]; | |
330 | |
331 /* update the filter */ | |
332 c_value = ( NORM_FFC_MAX - ff_value ) * | |
333 ( c_filter->value / NORM_FFC_DIV ) | |
334 + | |
335 ff_value * | |
336 ( c_value / NORM_FFC_DIV ); | |
337 | |
338 c_filter->value = (T_C_VALUE)(c_value / (NORM_FFC_MAX / NORM_FFC_DIV)); | |
339 } | |
340 } | |
341 else | |
342 { | |
343 #ifdef _SIMULATION_ | |
344 TRACE_EVENT( "no valid RXLEV information in meas_c_val_update_ptm 1" ); | |
345 #endif /* #ifdef _SIMULATION_ */ | |
346 } | |
347 | |
348 #ifdef _SIMULATION_ | |
349 TRACE_EVENT_P2( "C-Value = %d, C-Index = %d", | |
350 c_filter->value, c_filter->index ); | |
351 #endif /* #ifdef _SIMULATION_ */ | |
352 } | |
353 else | |
354 { | |
355 #ifdef _SIMULATION_ | |
356 TRACE_EVENT( "no valid RXLEV information in meas_c_val_update_ptm 2" ); | |
357 #endif /* #ifdef _SIMULATION_ */ | |
358 } | |
359 } /* meas_c_val_update_ptm() */ | |
360 | |
361 /* | |
362 +------------------------------------------------------------------------------ | |
363 | Function : meas_c_restart | |
364 +------------------------------------------------------------------------------ | |
365 | Description : This function initializes the parameters for deriving the | |
366 | C value. | |
367 | | |
368 | Parameters : void | |
369 | | |
370 +------------------------------------------------------------------------------ | |
371 */ | |
372 GLOBAL void meas_c_restart ( void ) | |
373 { | |
374 TRACE_FUNCTION( "meas_c_restart" ); | |
375 | |
376 grlc_data->meas.c_filter.value = 0; | |
377 grlc_data->meas.c_filter.index = 0; | |
378 } /* meas_c_restart() */ | |
379 | |
380 /* | |
381 +------------------------------------------------------------------------------ | |
382 | Function : meas_sv_get_value | |
383 +------------------------------------------------------------------------------ | |
384 | Description : This function returns the current signal variance. | |
385 | | |
386 | Parameters : void | |
387 | | |
388 +------------------------------------------------------------------------------ | |
389 */ | |
390 GLOBAL UBYTE meas_sv_get_value ( void ) | |
391 { | |
392 T_SIGN_VAR_VALUE sv_val; | |
393 | |
394 TRACE_FUNCTION( "meas_sv_get_value" ); | |
395 | |
396 sv_val = grlc_data->meas.sign_var.value / SV_LEVEL_STEP; | |
397 | |
398 if( grlc_data->meas.sign_var.value % SV_LEVEL_STEP EQ 0 AND | |
399 grlc_data->meas.sign_var.value NEQ 0 ) | |
400 { | |
401 sv_val -= 1; | |
402 } | |
403 | |
404 if( sv_val > SV_LEVEL_MAX ) | |
405 { | |
406 sv_val = SV_LEVEL_MAX; | |
407 } | |
408 | |
409 return( (UBYTE)sv_val ); | |
410 } /* meas_sv_get_value() */ | |
411 | |
412 /* | |
413 +------------------------------------------------------------------------------ | |
414 | Function : meas_sv_update | |
415 +------------------------------------------------------------------------------ | |
416 | Description : ... | |
417 | | |
418 | Parameters : - | |
419 | | |
420 +------------------------------------------------------------------------------ | |
421 */ | |
422 GLOBAL void meas_sv_update ( T_MAC_PWR_CTRL_IND *mac_pwr_ctrl_ind, | |
423 T_CGRLC_glbl_pwr_ctrl_param *pwr_ctrl_param, | |
424 T_CGRLC_freq_param *freq_param ) | |
425 { | |
426 T_SIGN_VAR *sign_var = &grlc_data->meas.sign_var; | |
427 | |
428 UBYTE i; /* used for counting */ | |
429 UBYTE ss_on_bcch[MAC_BURST_PER_BLOCK]; | |
430 /* receive signal level measured on BCCH */ | |
431 UBYTE ss_off_bcch[MAC_BURST_PER_BLOCK]; | |
432 /* receive signal level not measured on BCCH */ | |
433 UBYTE j = 0; /* indicates the number of bursts received */ | |
434 /* on BCCH frequency */ | |
435 UBYTE *ss_k = NULL; /* points to the receive signal levels */ | |
436 | |
437 TRACE_FUNCTION( "meas_sv_update" ); | |
438 | |
439 /* initialize arrays */ | |
440 for( i = 0; i < MAC_BURST_PER_BLOCK; i++ ) | |
441 { | |
442 ss_on_bcch [i] = MAC_RXLEV_NONE; | |
443 ss_off_bcch[i] = MAC_RXLEV_NONE; | |
444 } | |
445 | |
446 if( mac_pwr_ctrl_ind->crc_error EQ GRLC_CRC_PASS AND | |
447 pwr_ctrl_param->pc_meas_chan EQ CGRLC_MEAS_CHAN_PDCH ) | |
448 { | |
449 if( !freq_param->pdch_hopping ) | |
450 { | |
451 /* sort burst level acc. its radio frequency */ | |
452 for( i = 0; i < MAC_BURST_PER_BLOCK; i++ ) | |
453 { | |
454 if( mac_pwr_ctrl_ind->radio_freq[i] EQ freq_param->bcch_arfcn ) | |
455 { | |
456 j++; | |
457 | |
458 ss_on_bcch[i] = mac_pwr_ctrl_ind->burst_level[i]; | |
459 } | |
460 else | |
461 { | |
462 ss_off_bcch[i] = mac_pwr_ctrl_ind->burst_level[i]; | |
463 } | |
464 } | |
465 | |
466 /* calculate the burst level that should be taken into account */ | |
467 switch( j ) | |
468 { | |
469 case( 0 ): ss_k = &ss_off_bcch[0]; j = 4; break; | |
470 case( 1 ): ss_k = &ss_off_bcch[0]; j = 3; break; | |
471 case( 2 ): ss_k = NULL; break; | |
472 case( 3 ): ss_k = &ss_on_bcch[0]; j = 3; break; | |
473 case( 4 ): ss_k = &ss_on_bcch[0]; j = 4; break; | |
474 default : TRACE_ASSERT( j < 4 ); break; | |
475 | |
476 } | |
477 } | |
478 else | |
479 { | |
480 /* calculate the burst level that should be taken into account */ | |
481 ss_k = &mac_pwr_ctrl_ind->burst_level[0]; | |
482 j = 4; | |
483 } | |
484 } | |
485 | |
486 if( ss_k NEQ NULL ) | |
487 { | |
488 T_SIGN_VAR_INDEX old_num; | |
489 ULONG old_elem; | |
490 UBYTE pb_rdc; /* Pb reduction */ | |
491 LONG base; | |
492 ULONG sum = 0; /* sum of all squares */ | |
493 ULONG bl_var; /* block variance */ | |
494 ULONG ss_block; | |
495 | |
496 if( meas_c_calc_mean ( ss_k, mac_pwr_ctrl_ind->radio_freq, | |
497 &ss_block, &pb_rdc, freq_param ) > 0 ) | |
498 { | |
499 /* calculate the sum of the squares of the difference between */ | |
500 /* each individual burst level value and the mean */ | |
501 for( i = 0; i < j; i++ ) | |
502 { | |
503 if( ss_k[i] NEQ MAC_RXLEV_NONE ) | |
504 { | |
505 base = ( ( ss_k[i] * MEAS_ACRCY ) / SV_ACRCY_DIV ) - | |
506 ( ss_block / SV_ACRCY_DIV ); | |
507 sum += ( ULONG )( base * base ); | |
508 } | |
509 } | |
510 | |
511 /* | |
512 * calculate block variance | |
513 * | |
514 * in case ss_k NEQ NULL, j will be either set to the value 3 or 4 | |
515 * | |
516 * the lint comment below only works when linting current file alone, | |
517 * when linting current file together with all other files of the project, | |
518 * an error message will be generated anyway | |
519 * | |
520 * I don't know why and gave-up to fix it | |
521 */ | |
522 bl_var = sum / ( UBYTE )( j - 1 ); /*lint !e414*/ | |
523 | |
524 /* calculate the signal variance */ | |
525 if( sign_var->index EQ MEAS_MAX_NUM_MEAN ) | |
526 { | |
527 old_num = MEAS_MAX_NUM_MEAN - 1; | |
528 } | |
529 else | |
530 { | |
531 old_num = sign_var->index; | |
532 sign_var->index++; | |
533 } | |
534 | |
535 old_elem = sign_var->value * old_num; | |
536 | |
537 sign_var->value = | |
538 (T_SIGN_VAR_VALUE)((old_elem + (bl_var / SV_ACRCY_DIV)) / sign_var->index); | |
539 } | |
540 else | |
541 { | |
542 #ifdef _SIMULATION_ | |
543 TRACE_EVENT( "no valid RXLEV information in meas_sv_update 1" ); | |
544 #endif /* #ifdef _SIMULATION_ */ | |
545 } | |
546 | |
547 #ifdef _SIMULATION_ | |
548 TRACE_EVENT_P2( "SIGN-VAR-Value = %d, SIGN-VAR-Index = %d", | |
549 sign_var->value, sign_var->index ); | |
550 #endif /* #ifdef _SIMULATION_ */ | |
551 } | |
552 else | |
553 { | |
554 #ifdef _SIMULATION_ | |
555 TRACE_EVENT( "no valid RXLEV information in meas_sv_update 2" ); | |
556 #endif /* #ifdef _SIMULATION_ */ | |
557 } | |
558 } /* meas_sv_update() */ | |
559 | |
560 /* | |
561 +------------------------------------------------------------------------------ | |
562 | Function : meas_sv_restart | |
563 +------------------------------------------------------------------------------ | |
564 | Description : This function initializes the parameters for deriving the | |
565 | signal variance. | |
566 | | |
567 | Parameters : void | |
568 | | |
569 +------------------------------------------------------------------------------ | |
570 */ | |
571 GLOBAL void meas_sv_restart ( void ) | |
572 { | |
573 TRACE_FUNCTION( "meas_sv_restart" ); | |
574 | |
575 grlc_data->meas.sign_var.value = 0; | |
576 grlc_data->meas.sign_var.index = 0; | |
577 } /* meas_sv_restart() */ | |
578 | |
579 /* | |
580 +------------------------------------------------------------------------------ | |
581 | Function : meas_sq_get_rxqual_value | |
582 +------------------------------------------------------------------------------ | |
583 | Description : This function returns the current RXQUAL value | |
584 | | |
585 | Parameters : void | |
586 | | |
587 +------------------------------------------------------------------------------ | |
588 */ | |
589 GLOBAL UBYTE meas_sq_get_rxqual_value ( void) | |
590 { | |
591 UBYTE rxqual; | |
592 T_BER_AVG *ber_avg = &grlc_data->meas.ber_avg; | |
593 | |
594 TRACE_FUNCTION( "meas_sq_get_rxqual_value" ); | |
595 | |
596 if ( ber_avg->value < 200 ) | |
597 { | |
598 rxqual = 0; /* RX_QUAL_0 */ | |
599 } | |
600 else if ( ber_avg->value < 400 ) | |
601 { | |
602 rxqual = 1; /* RX_QUAL_1 */ | |
603 } | |
604 else if ( ber_avg->value < 800 ) | |
605 { | |
606 rxqual = 2; /* RX_QUAL_2 */ | |
607 } | |
608 else if ( ber_avg->value < 1600 ) | |
609 { | |
610 rxqual = 3; /* RX_QUAL_3 */ | |
611 } | |
612 else if ( ber_avg->value < 3200 ) | |
613 { | |
614 rxqual = 4; /* RX_QUAL_4 */ | |
615 } | |
616 else if ( ber_avg->value < 6400 ) | |
617 { | |
618 rxqual = 5; /* RX_QUAL_5 */ | |
619 } | |
620 else if ( ber_avg->value < 12800 ) | |
621 { | |
622 rxqual = 6; /* RX_QUAL_6 */ | |
623 } | |
624 else | |
625 { | |
626 rxqual = 7; /* RX_QUAL_7 */ | |
627 } | |
628 | |
629 return ( rxqual ); | |
630 } /* meas_sq_get_rxqual_value() */ | |
631 | |
632 /* | |
633 +------------------------------------------------------------------------------ | |
634 | Function : meas_sq_update | |
635 +------------------------------------------------------------------------------ | |
636 | Description : This function updates the RXQUAL value. | |
637 | | |
638 | Parameters : per_ind - Ptr to struct T_BER_IND | |
639 | | |
640 +------------------------------------------------------------------------------ | |
641 */ | |
642 GLOBAL void meas_sq_update ( T_BER_IND *ber_ind ) | |
643 { | |
644 UBYTE i; | |
645 ULONG norm_fault; | |
646 ULONG norm_ber; | |
647 ULONG old_elem; | |
648 T_BER_INDEX old_num; | |
649 | |
650 T_BER_AVG *ber_avg = &grlc_data->meas.ber_avg; | |
651 | |
652 TRACE_FUNCTION( "meas_sq_update" ); | |
653 | |
654 if(grlc_data->meas.sq_restart) | |
655 { | |
656 grlc_data->meas.ber_avg.value = 0; | |
657 grlc_data->meas.ber_avg.index = 0; | |
658 | |
659 grlc_data->meas.sq_restart = FALSE; | |
660 } | |
661 | |
662 for( i = 0; i < ber_ind->num_dl_blck; i++ ) | |
663 { | |
664 if( ber_ind->be_info[i].total NEQ 0 ) | |
665 { | |
666 if( ber_avg->index EQ MEAS_MAX_NUM_MEAN ) | |
667 { | |
668 old_num = MEAS_MAX_NUM_MEAN - 1; | |
669 } | |
670 else | |
671 { | |
672 old_num = ber_avg->index; | |
673 ber_avg->index++; | |
674 } | |
675 | |
676 old_elem = ber_avg->value * old_num; | |
677 norm_fault = ber_ind->be_info[i].fault * MEAS_ACRCY * 100; | |
678 norm_ber = norm_fault / ber_ind->be_info[i].total; | |
679 ber_avg->value = (T_BER_VALUE)((old_elem + norm_ber) / ber_avg->index); | |
680 | |
681 RX_SetRxQual( meas_sq_get_rxqual_value( ) ); | |
682 } | |
683 } | |
684 | |
685 #ifdef _SIMULATION_ | |
686 TRACE_EVENT_P2( "BER-Value = %d, BER-Index = %d", | |
687 ber_avg->value, ber_avg->index ); | |
688 #endif /* #ifdef _SIMULATION_ */ | |
689 } /* meas_sq_update() */ | |
690 | |
691 /* | |
692 +------------------------------------------------------------------------------ | |
693 | Function : meas_sq_restart | |
694 +------------------------------------------------------------------------------ | |
695 | Description : This function initializes the parameters for deriving the | |
696 | RXQUAL value. | |
697 | | |
698 | Parameters : void | |
699 | | |
700 +------------------------------------------------------------------------------ | |
701 */ | |
702 GLOBAL void meas_sq_restart ( void ) | |
703 { | |
704 TRACE_FUNCTION( "meas_sq_restart" ); | |
705 | |
706 grlc_data->meas.ber_avg.value = 0; | |
707 grlc_data->meas.ber_avg.index = 0; | |
708 } /* meas_sq_restart() */ | |
709 | |
710 /* | |
711 +------------------------------------------------------------------------------ | |
712 | Function : meas_int_get_rel_i_level | |
713 +------------------------------------------------------------------------------ | |
714 | Description : This function returns the interference level values mapped to | |
715 | values relative to the C value. | |
716 | | |
717 | Parameters : *i_level - Ptr to relative interference level values | |
718 | | |
719 +------------------------------------------------------------------------------ | |
720 */ | |
721 GLOBAL void meas_int_get_rel_i_level ( T_ilev *i_level ) | |
722 { | |
723 USHORT c_raw_data_lev = grlc_data->meas.c_filter.value; | |
724 | |
725 TRACE_FUNCTION( "meas_int_get_rel_i_level" ); | |
726 | |
727 meas_int_fill_rel_iLevel( &i_level->v_ilev0, &i_level->ilev0, 0, c_raw_data_lev ); | |
728 meas_int_fill_rel_iLevel( &i_level->v_ilev1, &i_level->ilev1, 1, c_raw_data_lev ); | |
729 meas_int_fill_rel_iLevel( &i_level->v_ilev2, &i_level->ilev2, 2, c_raw_data_lev ); | |
730 meas_int_fill_rel_iLevel( &i_level->v_ilev3, &i_level->ilev3, 3, c_raw_data_lev ); | |
731 meas_int_fill_rel_iLevel( &i_level->v_ilev4, &i_level->ilev4, 4, c_raw_data_lev ); | |
732 meas_int_fill_rel_iLevel( &i_level->v_ilev5, &i_level->ilev5, 5, c_raw_data_lev ); | |
733 meas_int_fill_rel_iLevel( &i_level->v_ilev6, &i_level->ilev6, 6, c_raw_data_lev ); | |
734 meas_int_fill_rel_iLevel( &i_level->v_ilev7, &i_level->ilev7, 7, c_raw_data_lev ); | |
735 | |
736 #if !defined (NTRACE) | |
737 | |
738 meas_int_trace_i_level( i_level ); | |
739 | |
740 #endif /* #if !defined (NTRACE) */ | |
741 | |
742 } /* meas_int_get_rel_i_level() */ | |
743 | |
744 #if !defined (NTRACE) | |
745 | |
746 /* | |
747 +------------------------------------------------------------------------------ | |
748 | Function : meas_int_trace_i_level | |
749 +------------------------------------------------------------------------------ | |
750 | Description : | |
751 | | |
752 | Parameters : | |
753 | | |
754 +------------------------------------------------------------------------------ | |
755 */ | |
756 LOCAL void meas_int_trace_i_level( T_ilev *i_level ) | |
757 { | |
758 if( grlc_data->meas.v_im_trace NEQ 0 ) | |
759 { | |
760 TRACE_EVENT_P8( "meas_int_trace_i_level: %02X %02X %02X %02X %02X %02X %02X %02X", | |
761 i_level->ilev0, i_level->ilev1, i_level->ilev2, | |
762 i_level->ilev3, i_level->ilev4, i_level->ilev5, | |
763 i_level->ilev6, i_level->ilev7 ); | |
764 } | |
765 } /* meas_int_trace_i_level() */ | |
766 | |
767 #endif /* #if !defined (NTRACE) */ |