1 |
|
|
/*------------------------------------------------------------------------------ |
2 |
|
|
-- Solar Orbiter's Low Frequency Receiver Flight Software (LFR FSW), |
3 |
|
|
-- This file is a part of the LFR FSW |
4 |
|
|
-- Copyright (C) 2012-2018, Plasma Physics Laboratory - CNRS |
5 |
|
|
-- |
6 |
|
|
-- This program is free software; you can redistribute it and/or modify |
7 |
|
|
-- it under the terms of the GNU General Public License as published by |
8 |
|
|
-- the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
-- (at your option) any later version. |
10 |
|
|
-- |
11 |
|
|
-- This program is distributed in the hope that it will be useful, |
12 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
-- GNU General Public License for more details. |
15 |
|
|
-- |
16 |
|
|
-- You should have received a copy of the GNU General Public License |
17 |
|
|
-- along with this program; if not, write to the Free Software |
18 |
|
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
|
|
-------------------------------------------------------------------------------*/ |
20 |
|
|
/*-- Author : Paul Leroy |
21 |
|
|
-- Contact : Alexis Jeandet |
22 |
|
|
-- Mail : alexis.jeandet@lpp.polytechnique.fr |
23 |
|
|
----------------------------------------------------------------------------*/ |
24 |
|
|
|
25 |
|
|
/** Functions related to data processing. |
26 |
|
|
* |
27 |
|
|
* @file |
28 |
|
|
* @author P. LEROY |
29 |
|
|
* |
30 |
|
|
* These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. |
31 |
|
|
* |
32 |
|
|
*/ |
33 |
|
|
|
34 |
|
|
#include "avf0_prc0.h" |
35 |
|
|
|
36 |
|
|
nb_sm_before_bp_asm_f0 nb_sm_before_f0 = {0}; |
37 |
|
|
|
38 |
|
|
//*** |
39 |
|
|
// F0 |
40 |
|
|
ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ] = {0}; |
41 |
|
|
ring_node_asm asm_ring_burst_sbm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ] = {0}; |
42 |
|
|
|
43 |
|
|
ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ] = {0}; |
44 |
|
|
int buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ] = {0}; |
45 |
|
|
|
46 |
|
|
float asm_f0_patched_norm [ TOTAL_SIZE_SM ] = {0}; |
47 |
|
|
float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ] = {0}; |
48 |
|
|
float asm_f0_reorganized [ TOTAL_SIZE_SM ] = {0}; |
49 |
|
|
|
50 |
|
|
float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0] = {0}; |
51 |
|
|
float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ] = {0}; |
52 |
|
|
|
53 |
|
|
float k_coeff_intercalib_f0_norm[ NB_BINS_COMPRESSED_SM_F0 * NB_K_COEFF_PER_BIN ] = {0}; // 11 * 32 = 352 |
54 |
|
|
float k_coeff_intercalib_f0_sbm[ NB_BINS_COMPRESSED_SM_SBM_F0 * NB_K_COEFF_PER_BIN ] = {0}; // 22 * 32 = 704 |
55 |
|
|
|
56 |
|
|
//************ |
57 |
|
|
// RTEMS TASKS |
58 |
|
|
|
59 |
|
1606 |
rtems_task avf0_task( rtems_task_argument lfrRequestedMode ) |
60 |
|
|
{ |
61 |
|
|
int i; |
62 |
|
|
|
63 |
|
|
rtems_event_set event_out; |
64 |
|
|
rtems_status_code status; |
65 |
|
|
rtems_id queue_id_prc0; |
66 |
|
|
asm_msg msgForPRC; |
67 |
|
|
ring_node *nodeForAveraging; |
68 |
|
|
ring_node *ring_node_tab[NB_SM_BEFORE_AVF0_F1]; |
69 |
|
|
ring_node_asm *current_ring_node_asm_burst_sbm_f0; |
70 |
|
|
ring_node_asm *current_ring_node_asm_norm_f0; |
71 |
|
|
|
72 |
|
|
unsigned int nb_norm_bp1; |
73 |
|
|
unsigned int nb_norm_bp2; |
74 |
|
|
unsigned int nb_norm_asm; |
75 |
|
|
unsigned int nb_sbm_bp1; |
76 |
|
|
unsigned int nb_sbm_bp2; |
77 |
|
|
|
78 |
|
1606 |
nb_norm_bp1 = 0; |
79 |
|
1606 |
nb_norm_bp2 = 0; |
80 |
|
1606 |
nb_norm_asm = 0; |
81 |
|
1606 |
nb_sbm_bp1 = 0; |
82 |
|
1606 |
nb_sbm_bp2 = 0; |
83 |
|
1606 |
event_out = EVENT_SETS_NONE_PENDING; |
84 |
|
1606 |
queue_id_prc0 = RTEMS_ID_NONE; |
85 |
|
|
|
86 |
|
1606 |
reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions |
87 |
|
1606 |
ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 ); |
88 |
|
1606 |
ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 ); |
89 |
|
1606 |
current_ring_node_asm_norm_f0 = asm_ring_norm_f0; |
90 |
|
1606 |
current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0; |
91 |
|
|
|
92 |
|
|
BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode); |
93 |
|
|
|
94 |
|
1606 |
status = get_message_queue_id_prc0( &queue_id_prc0 ); |
95 |
|
|
if (status != RTEMS_SUCCESSFUL) |
96 |
|
|
{ |
97 |
|
|
PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status) |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
while(1){ |
101 |
|
1294589 |
rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
102 |
|
|
|
103 |
|
|
//**************************************** |
104 |
|
|
// initialize the mesage for the MATR task |
105 |
|
1293416 |
msgForPRC.norm = current_ring_node_asm_norm_f0; |
106 |
|
1293416 |
msgForPRC.burst_sbm = current_ring_node_asm_burst_sbm_f0; |
107 |
|
1293416 |
msgForPRC.event = EVENT_SETS_NONE_PENDING; // this composite event will be sent to the PRC0 task |
108 |
|
|
// |
109 |
|
|
//**************************************** |
110 |
|
|
|
111 |
|
1293416 |
nodeForAveraging = getRingNodeForAveraging( 0 ); |
112 |
|
|
|
113 |
|
1293415 |
ring_node_tab[NB_SM_BEFORE_AVF0_F1-1] = nodeForAveraging; |
114 |
✓✓ |
10347320 |
for ( i = 1; i < (NB_SM_BEFORE_AVF0_F1); i++ ) |
115 |
|
|
{ |
116 |
|
9053905 |
nodeForAveraging = nodeForAveraging->previous; |
117 |
|
9053905 |
ring_node_tab[NB_SM_BEFORE_AVF0_F1 - i - 1] = nodeForAveraging; |
118 |
|
|
} |
119 |
|
|
|
120 |
|
|
// compute the average and store it in the averaged_sm_f1 buffer |
121 |
|
1293415 |
SM_average( current_ring_node_asm_norm_f0->matrix, |
122 |
|
|
current_ring_node_asm_burst_sbm_f0->matrix, |
123 |
|
|
ring_node_tab, |
124 |
|
|
nb_norm_bp1, nb_sbm_bp1, |
125 |
|
|
&msgForPRC, 0 ); // 0 => frequency channel 0 |
126 |
|
|
|
127 |
|
|
// update nb_average |
128 |
|
1292983 |
nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0_F1; |
129 |
|
1292983 |
nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0_F1; |
130 |
|
1292983 |
nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0_F1; |
131 |
|
1292983 |
nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0_F1; |
132 |
|
1292983 |
nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0_F1; |
133 |
|
|
|
134 |
✓✓ |
1292983 |
if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1) |
135 |
|
|
{ |
136 |
|
184807 |
nb_sbm_bp1 = 0; |
137 |
|
|
// set another ring for the ASM storage |
138 |
|
184807 |
current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next; |
139 |
✓✓ |
184807 |
if ( lfrCurrentMode == LFR_MODE_BURST ) |
140 |
|
|
{ |
141 |
|
10519 |
msgForPRC.event = msgForPRC.event | RTEMS_EVENT_BURST_BP1_F0; |
142 |
|
|
} |
143 |
✓✓ |
174288 |
else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
144 |
|
|
{ |
145 |
|
128937 |
msgForPRC.event = msgForPRC.event | RTEMS_EVENT_SBM_BP1_F0; |
146 |
|
|
} |
147 |
|
|
} |
148 |
|
|
|
149 |
✓✓ |
1292983 |
if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2) |
150 |
|
|
{ |
151 |
|
41970 |
nb_sbm_bp2 = 0; |
152 |
✓✓ |
41970 |
if ( lfrCurrentMode == LFR_MODE_BURST ) |
153 |
|
|
{ |
154 |
|
2044 |
msgForPRC.event = msgForPRC.event | RTEMS_EVENT_BURST_BP2_F0; |
155 |
|
|
} |
156 |
✓✓ |
39926 |
else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
157 |
|
|
{ |
158 |
|
30919 |
msgForPRC.event = msgForPRC.event | RTEMS_EVENT_SBM_BP2_F0; |
159 |
|
|
} |
160 |
|
|
} |
161 |
|
|
|
162 |
✓✓ |
1292983 |
if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1) |
163 |
|
|
{ |
164 |
|
26558 |
nb_norm_bp1 = 0; |
165 |
|
|
// set another ring for the ASM storage |
166 |
|
26558 |
current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next; |
167 |
✓✓✓✓
|
35217 |
if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
168 |
|
35217 |
|| (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
169 |
|
|
{ |
170 |
|
23980 |
msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_BP1_F0; |
171 |
|
|
} |
172 |
|
|
} |
173 |
|
|
|
174 |
✓✓ |
1292983 |
if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2) |
175 |
|
|
{ |
176 |
|
5185 |
nb_norm_bp2 = 0; |
177 |
✓✓✓✓
|
6859 |
if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
178 |
|
6859 |
|| (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
179 |
|
|
{ |
180 |
|
4696 |
msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_BP2_F0; |
181 |
|
|
} |
182 |
|
|
} |
183 |
|
|
|
184 |
✓✓ |
1292983 |
if (nb_norm_asm == nb_sm_before_f0.norm_asm) |
185 |
|
|
{ |
186 |
|
17261 |
nb_norm_asm = 0; |
187 |
✓✓✓✓
|
22719 |
if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
188 |
|
22719 |
|| (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
189 |
|
|
{ |
190 |
|
16118 |
msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_ASM_F0; |
191 |
|
|
} |
192 |
|
|
} |
193 |
|
|
|
194 |
|
|
//************************* |
195 |
|
|
// send the message to PRC |
196 |
✓✓ |
1292983 |
if (msgForPRC.event != EVENT_SETS_NONE_PENDING) |
197 |
|
|
{ |
198 |
|
150918 |
status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForPRC, MSG_QUEUE_SIZE_PRC0); |
199 |
|
|
} |
200 |
|
|
|
201 |
|
|
if (status != RTEMS_SUCCESSFUL) { |
202 |
|
|
PRINTF1("in AVF0 *** Error sending message to PRC, code %d\n", status) |
203 |
|
|
} |
204 |
|
|
} |
205 |
|
|
} |
206 |
|
|
|
207 |
|
1606 |
rtems_task prc0_task( rtems_task_argument lfrRequestedMode ) |
208 |
|
|
{ |
209 |
|
|
char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
210 |
|
|
size_t size; // size of the incoming TC packet |
211 |
|
|
asm_msg *incomingMsg; |
212 |
|
|
// |
213 |
|
|
unsigned char sid; |
214 |
|
|
rtems_status_code status; |
215 |
|
|
rtems_id queue_id; |
216 |
|
|
rtems_id queue_id_q_p0; |
217 |
|
|
bp_packet_with_spare __attribute__((aligned(4))) packet_norm_bp1; |
218 |
|
|
bp_packet __attribute__((aligned(4))) packet_norm_bp2; |
219 |
|
|
bp_packet __attribute__((aligned(4))) packet_sbm_bp1; |
220 |
|
|
bp_packet __attribute__((aligned(4))) packet_sbm_bp2; |
221 |
|
|
ring_node *current_ring_node_to_send_asm_f0; |
222 |
|
|
float nbSMInASMNORM; |
223 |
|
|
float nbSMInASMSBM; |
224 |
|
|
|
225 |
|
1606 |
size = 0; |
226 |
|
1606 |
queue_id = RTEMS_ID_NONE; |
227 |
|
1606 |
queue_id_q_p0 = RTEMS_ID_NONE; |
228 |
|
1606 |
memset( &packet_norm_bp1, 0, sizeof(bp_packet_with_spare) ); |
229 |
|
1606 |
memset( &packet_norm_bp2, 0, sizeof(bp_packet) ); |
230 |
|
1606 |
memset( &packet_sbm_bp1, 0, sizeof(bp_packet) ); |
231 |
|
1606 |
memset( &packet_sbm_bp2, 0, sizeof(bp_packet) ); |
232 |
|
|
|
233 |
|
|
// init the ring of the averaged spectral matrices which will be transmitted to the DPU |
234 |
|
1606 |
init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM ); |
235 |
|
1606 |
current_ring_node_to_send_asm_f0 = ring_to_send_asm_f0; |
236 |
|
|
|
237 |
|
|
//************* |
238 |
|
|
// NORM headers |
239 |
|
1606 |
BP_init_header_with_spare( &packet_norm_bp1, |
240 |
|
|
APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0, |
241 |
|
|
PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 ); |
242 |
|
1606 |
BP_init_header( &packet_norm_bp2, |
243 |
|
|
APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0, |
244 |
|
|
PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0); |
245 |
|
|
|
246 |
|
|
//**************************** |
247 |
|
|
// BURST SBM1 and SBM2 headers |
248 |
✓✓ |
1606 |
if ( lfrRequestedMode == LFR_MODE_BURST ) |
249 |
|
|
{ |
250 |
|
398 |
BP_init_header( &packet_sbm_bp1, |
251 |
|
|
APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0, |
252 |
|
|
PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
253 |
|
398 |
BP_init_header( &packet_sbm_bp2, |
254 |
|
|
APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0, |
255 |
|
|
PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
256 |
|
|
} |
257 |
✓✓ |
1208 |
else if ( lfrRequestedMode == LFR_MODE_SBM1 ) |
258 |
|
|
{ |
259 |
|
391 |
BP_init_header( &packet_sbm_bp1, |
260 |
|
|
APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0, |
261 |
|
|
PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
262 |
|
391 |
BP_init_header( &packet_sbm_bp2, |
263 |
|
|
APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0, |
264 |
|
|
PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
265 |
|
|
} |
266 |
✓✓ |
817 |
else if ( lfrRequestedMode == LFR_MODE_SBM2 ) |
267 |
|
|
{ |
268 |
|
413 |
BP_init_header( &packet_sbm_bp1, |
269 |
|
|
APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0, |
270 |
|
|
PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
271 |
|
413 |
BP_init_header( &packet_sbm_bp2, |
272 |
|
|
APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0, |
273 |
|
|
PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
274 |
|
|
} |
275 |
|
|
else |
276 |
|
|
{ |
277 |
|
|
PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) |
278 |
|
|
} |
279 |
|
|
|
280 |
|
1606 |
status = get_message_queue_id_send( &queue_id ); |
281 |
|
|
if (status != RTEMS_SUCCESSFUL) |
282 |
|
|
{ |
283 |
|
|
PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status) |
284 |
|
|
} |
285 |
|
1606 |
status = get_message_queue_id_prc0( &queue_id_q_p0); |
286 |
|
|
if (status != RTEMS_SUCCESSFUL) |
287 |
|
|
{ |
288 |
|
|
PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status) |
289 |
|
|
} |
290 |
|
|
|
291 |
|
|
BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) |
292 |
|
|
|
293 |
|
|
while(1){ |
294 |
|
152443 |
status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************ |
295 |
|
|
RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 |
296 |
|
|
|
297 |
|
150837 |
incomingMsg = (asm_msg*) incomingData; |
298 |
|
|
|
299 |
|
150837 |
ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm ); |
300 |
|
150837 |
ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm ); |
301 |
|
|
|
302 |
|
150837 |
nbSMInASMNORM = incomingMsg->numberOfSMInASMNORM; |
303 |
|
150837 |
nbSMInASMSBM = incomingMsg->numberOfSMInASMSBM; |
304 |
|
|
|
305 |
|
|
//**************** |
306 |
|
|
//**************** |
307 |
|
|
// BURST SBM1 SBM2 |
308 |
|
|
//**************** |
309 |
|
|
//**************** |
310 |
✓✓ |
150837 |
if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) ) |
311 |
|
|
{ |
312 |
|
139378 |
sid = getSID( incomingMsg->event ); |
313 |
|
|
// 1) compress the matrix for Basic Parameters calculation |
314 |
|
139378 |
ASM_compress_reorganize_and_divide_mask( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0, |
315 |
|
|
nbSMInASMSBM, |
316 |
|
|
NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0, |
317 |
|
|
ASM_F0_INDICE_START, CHANNELF0); |
318 |
|
|
// 2) compute the BP1 set |
319 |
|
139378 |
BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data ); |
320 |
|
|
// 3) send the BP1 set |
321 |
|
139378 |
set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
322 |
|
139378 |
set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
323 |
|
139378 |
packet_sbm_bp1.pa_bia_status_info = pa_bia_status_info; |
324 |
|
139378 |
packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
325 |
|
139378 |
BP_send_s1_s2( (char *) &packet_sbm_bp1, queue_id, |
326 |
|
|
PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA, |
327 |
|
|
sid); |
328 |
|
|
// 4) compute the BP2 set if needed |
329 |
✓✓ |
139378 |
if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) ) |
330 |
|
|
{ |
331 |
|
|
// 1) compute the BP2 set |
332 |
|
32939 |
BP2_set( compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data ); |
333 |
|
|
// 2) send the BP2 set |
334 |
|
32939 |
set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
335 |
|
32939 |
set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
336 |
|
32939 |
packet_sbm_bp2.pa_bia_status_info = pa_bia_status_info; |
337 |
|
32939 |
packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
338 |
|
32939 |
BP_send_s1_s2( (char *) &packet_sbm_bp2, queue_id, |
339 |
|
|
PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA, |
340 |
|
|
sid); |
341 |
|
|
} |
342 |
|
|
} |
343 |
|
|
|
344 |
|
|
//***** |
345 |
|
|
//***** |
346 |
|
|
// NORM |
347 |
|
|
//***** |
348 |
|
|
//***** |
349 |
✓✓ |
150837 |
if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0) |
350 |
|
|
{ |
351 |
|
|
// 1) compress the matrix for Basic Parameters calculation |
352 |
|
23971 |
ASM_compress_reorganize_and_divide_mask( asm_f0_patched_norm, compressed_sm_norm_f0, |
353 |
|
|
nbSMInASMNORM, |
354 |
|
|
NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, |
355 |
|
|
ASM_F0_INDICE_START, CHANNELF0 ); |
356 |
|
|
// 2) compute the BP1 set |
357 |
|
23971 |
BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data ); |
358 |
|
|
// 3) send the BP1 set |
359 |
|
23971 |
set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
360 |
|
23971 |
set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
361 |
|
23971 |
packet_norm_bp1.pa_bia_status_info = pa_bia_status_info; |
362 |
|
23971 |
packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
363 |
|
23971 |
BP_send( (char *) &packet_norm_bp1, queue_id, |
364 |
|
|
PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA, |
365 |
|
|
SID_NORM_BP1_F0 ); |
366 |
✓✓ |
23971 |
if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0) |
367 |
|
|
{ |
368 |
|
|
// 1) compute the BP2 set using the same ASM as the one used for BP1 |
369 |
|
4694 |
BP2_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp2.data ); |
370 |
|
|
// 2) send the BP2 set |
371 |
|
4694 |
set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
372 |
|
4694 |
set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
373 |
|
4694 |
packet_norm_bp2.pa_bia_status_info = pa_bia_status_info; |
374 |
|
4694 |
packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
375 |
|
4694 |
BP_send( (char *) &packet_norm_bp2, queue_id, |
376 |
|
|
PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA, |
377 |
|
|
SID_NORM_BP2_F0); |
378 |
|
|
} |
379 |
|
|
} |
380 |
|
|
|
381 |
✓✓ |
150837 |
if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0) |
382 |
|
|
{ |
383 |
|
|
// 1) reorganize the ASM and divide |
384 |
|
16114 |
ASM_reorganize_and_divide( asm_f0_patched_norm, |
385 |
|
16114 |
(float*) current_ring_node_to_send_asm_f0->buffer_address, |
386 |
|
|
nbSMInASMNORM ); |
387 |
|
16114 |
current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM; |
388 |
|
16114 |
current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM; |
389 |
|
16114 |
current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0; |
390 |
|
|
|
391 |
|
|
// 3) send the spectral matrix packets |
392 |
|
16114 |
status = rtems_message_queue_send( queue_id, ¤t_ring_node_to_send_asm_f0, sizeof( ring_node* ) ); |
393 |
|
|
|
394 |
|
|
// change asm ring node |
395 |
|
16114 |
current_ring_node_to_send_asm_f0 = current_ring_node_to_send_asm_f0->next; |
396 |
|
|
} |
397 |
|
|
|
398 |
|
150837 |
update_queue_max_count( queue_id_q_p0, &hk_lfr_q_p0_fifo_size_max ); |
399 |
|
|
|
400 |
|
150837 |
} |
401 |
|
|
} |
402 |
|
|
|
403 |
|
|
//********** |
404 |
|
|
// FUNCTIONS |
405 |
|
|
|
406 |
|
1606 |
void reset_nb_sm_f0( unsigned char lfrMode ) |
407 |
|
|
{ |
408 |
|
1606 |
nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * NB_SM_PER_S_F0; |
409 |
|
1606 |
nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * NB_SM_PER_S_F0; |
410 |
|
1606 |
nb_sm_before_f0.norm_asm = |
411 |
|
1606 |
( (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256) + parameter_dump_packet.sy_lfr_n_asm_p[1]) * NB_SM_PER_S_F0; |
412 |
|
1606 |
nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * NB_SM_PER_S1_BP_P0; // 0.25 s per digit |
413 |
|
1606 |
nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * NB_SM_PER_S_F0; |
414 |
|
1606 |
nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * NB_SM_PER_S_F0; |
415 |
|
1606 |
nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * NB_SM_PER_S_F0; |
416 |
|
1606 |
nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * NB_SM_PER_S_F0; |
417 |
|
1606 |
nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * NB_SM_PER_S_F0; |
418 |
|
|
|
419 |
✓✓ |
1606 |
if (lfrMode == LFR_MODE_SBM1) |
420 |
|
|
{ |
421 |
|
391 |
nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1; |
422 |
|
391 |
nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2; |
423 |
|
|
} |
424 |
✓✓ |
1215 |
else if (lfrMode == LFR_MODE_SBM2) |
425 |
|
|
{ |
426 |
|
413 |
nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1; |
427 |
|
413 |
nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2; |
428 |
|
|
} |
429 |
✓✓ |
802 |
else if (lfrMode == LFR_MODE_BURST) |
430 |
|
|
{ |
431 |
|
398 |
nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; |
432 |
|
398 |
nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; |
433 |
|
|
} |
434 |
|
|
else |
435 |
|
|
{ |
436 |
|
404 |
nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; |
437 |
|
404 |
nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; |
438 |
|
|
} |
439 |
|
1606 |
} |
440 |
|
|
|
441 |
|
87 |
void init_k_coefficients_prc0( void ) |
442 |
|
|
{ |
443 |
|
87 |
init_k_coefficients( k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0 ); |
444 |
|
|
|
445 |
|
87 |
init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f0_norm, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_F0); |
446 |
|
87 |
} |
447 |
|
|
|