##// END OF EJS Templates
avf2 prc2 tasks added...
paul -
r124:9657f56b7e43 VHDLib206
parent child
Show More
@@ -0,0 +1,358
1 /** Functions related to data processing.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
8 */
9
10 #include "avf0_prc0.h"
11
12 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
13 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
14 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
15 ring_node_asm *current_ring_node_asm_norm_f0;
16
17 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
18 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
19 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
20 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
21
22 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
23
24 void reset_nb_sm_f0( unsigned char lfrMode )
25 {
26 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
27 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
28 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
29 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
30 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
31 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
32 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
33 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
34 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
35
36 if (lfrMode == LFR_MODE_SBM1)
37 {
38 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
39 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
40 }
41 else if (lfrMode == LFR_MODE_SBM2)
42 {
43 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
44 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
45 }
46 else if (lfrMode == LFR_MODE_BURST)
47 {
48 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
49 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
50 }
51 else
52 {
53 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
54 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
55 }
56 }
57
58 //************
59 // RTEMS TASKS
60
61 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
62 {
63 int i;
64
65 rtems_event_set event_out;
66 rtems_status_code status;
67 rtems_id queue_id_prc0;
68 asm_msg msgForMATR;
69 ring_node_sm *ring_node_tab[8];
70
71 unsigned int nb_norm_bp1;
72 unsigned int nb_norm_bp2;
73 unsigned int nb_norm_asm;
74 unsigned int nb_sbm_bp1;
75 unsigned int nb_sbm_bp2;
76
77 nb_norm_bp1 = 0;
78 nb_norm_bp2 = 0;
79 nb_norm_asm = 0;
80 nb_sbm_bp1 = 0;
81 nb_sbm_bp2 = 0;
82
83 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
84 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
85 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
86 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
87 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
88
89 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
90
91 status = get_message_queue_id_prc0( &queue_id_prc0 );
92 if (status != RTEMS_SUCCESSFUL)
93 {
94 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
95 }
96
97 while(1){
98 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
99 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
100 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
101 {
102 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
103 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
104 }
105
106 // compute the average and store it in the averaged_sm_f1 buffer
107 SM_average( current_ring_node_asm_norm_f0->matrix,
108 current_ring_node_asm_burst_sbm_f0->matrix,
109 ring_node_tab,
110 nb_norm_bp1, nb_sbm_bp1 );
111
112 // update nb_average
113 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
114 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
115 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
116 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
117 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
118
119 //****************************************
120 // initialize the mesage for the MATR task
121 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
122 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
123 msgForMATR.norm = current_ring_node_asm_norm_f0;
124 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
125 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
126 msgForMATR.coarseTime = time_management_regs->coarse_time;
127 msgForMATR.fineTime = time_management_regs->fine_time;
128
129 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
130 {
131 nb_sbm_bp1 = 0;
132 // set another ring for the ASM storage
133 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
134 if ( (lfrCurrentMode == LFR_MODE_BURST)
135 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
136 {
137 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0;
138 }
139 }
140
141 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
142 {
143 nb_sbm_bp2 = 0;
144 if ( (lfrCurrentMode == LFR_MODE_BURST)
145 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
146 {
147 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0;
148 }
149 }
150
151 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
152 {
153 nb_norm_bp1 = 0;
154 // set another ring for the ASM storage
155 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
156 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
157 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
158 {
159 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
160 }
161 }
162
163 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
164 {
165 nb_norm_bp2 = 0;
166 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
167 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
168 {
169 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
170 }
171 }
172
173 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
174 {
175 nb_norm_asm = 0;
176 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
177 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
178 {
179 // PRINTF1("%lld\n", localTime)
180 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
181 }
182 }
183
184 //*************************
185 // send the message to MATR
186 if (msgForMATR.event != 0x00)
187 {
188 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
189 }
190
191 if (status != RTEMS_SUCCESSFUL) {
192 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
193 }
194 }
195 }
196
197 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
198 {
199 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
200 size_t size; // size of the incoming TC packet
201 asm_msg *incomingMsg;
202 //
203 spw_ioctl_pkt_send spw_ioctl_send_ASM;
204 rtems_status_code status;
205 rtems_id queue_id;
206 rtems_id queue_id_q_p0;
207 Header_TM_LFR_SCIENCE_ASM_t headerASM;
208 bp_packet_with_spare packet_norm_bp1_f0;
209 bp_packet packet_norm_bp2_f0;
210 bp_packet packet_sbm_bp1_f0;
211 bp_packet packet_sbm_bp2_f0;
212
213 unsigned long long int localTime;
214
215 ASM_init_header( &headerASM );
216
217 //*************
218 // NORM headers
219 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
220 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
221 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
222 BP_init_header( &packet_norm_bp2_f0.header,
223 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
224 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
225
226 //****************************
227 // BURST SBM1 and SBM2 headers
228 if ( lfrRequestedMode == LFR_MODE_BURST )
229 {
230 BP_init_header( &packet_sbm_bp1_f0.header,
231 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
232 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
233 BP_init_header( &packet_sbm_bp2_f0.header,
234 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
235 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
236 }
237 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
238 {
239 BP_init_header( &packet_sbm_bp1_f0.header,
240 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
241 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
242 BP_init_header( &packet_sbm_bp2_f0.header,
243 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
244 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
245 }
246 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
247 {
248 BP_init_header( &packet_sbm_bp1_f0.header,
249 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
250 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
251 BP_init_header( &packet_sbm_bp2_f0.header,
252 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
253 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
254 }
255 else
256 {
257 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
258 }
259
260 status = get_message_queue_id_send( &queue_id );
261 if (status != RTEMS_SUCCESSFUL)
262 {
263 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
264 }
265 status = get_message_queue_id_prc0( &queue_id_q_p0);
266 if (status != RTEMS_SUCCESSFUL)
267 {
268 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
269 }
270
271 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
272
273 while(1){
274 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
275 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
276
277 incomingMsg = (asm_msg*) incomingData;
278
279 localTime = getTimeAsUnsignedLongLongInt( );
280 //****************
281 //****************
282 // BURST SBM1 SBM2
283 //****************
284 //****************
285 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 )
286 {
287 // 1) compress the matrix for Basic Parameters calculation
288 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
289 nb_sm_before_f0.burst_sbm_bp1,
290 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
291 ASM_F0_INDICE_START);
292 // 2) compute the BP1 set
293
294 // 3) send the BP1 set
295 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
296 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
297 BP_send( (char *) &packet_sbm_bp1_f0.header, queue_id,
298 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
299 // 4) compute the BP2 set if needed
300 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 )
301 {
302 // 1) compute the BP2 set
303
304 // 2) send the BP2 set
305 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
306 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
307 BP_send( (char *) &packet_sbm_bp2_f0.header, queue_id,
308 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
309 }
310 }
311
312 //*****
313 //*****
314 // NORM
315 //*****
316 //*****
317 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
318 {
319 // 1) compress the matrix for Basic Parameters calculation
320 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
321 nb_sm_before_f0.norm_bp1,
322 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
323 ASM_F0_INDICE_START );
324 // 2) compute the BP1 set
325
326 // 3) send the BP1 set
327 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
328 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
329 BP_send( (char *) &packet_norm_bp1_f0.header, queue_id,
330 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
331 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
332 {
333 // 1) compute the BP2 set using the same ASM as the one used for BP1
334
335 // 2) send the BP2 set
336 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
337 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
338 BP_send( (char *) &packet_norm_bp2_f0.header, queue_id,
339 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
340 }
341 }
342
343 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
344 {
345 // 1) reorganize the ASM and divide
346 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
347 asm_f0_reorganized,
348 nb_sm_before_f0.norm_bp1 );
349 // 2) convert the float array in a char array
350 ASM_convert( asm_f0_reorganized, asm_f0_char);
351 // 3) send the spectral matrix packets
352 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
353 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
354 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
355 }
356
357 }
358 }
@@ -0,0 +1,30
1 #ifndef AVF0_PRC0_H
2 #define AVF0_PRC0_H
3
4 #include "fsw_processing.h"
5
6 typedef struct {
7 unsigned int norm_bp1;
8 unsigned int norm_bp2;
9 unsigned int norm_asm;
10 unsigned int burst_sbm_bp1;
11 unsigned int burst_sbm_bp2;
12 unsigned int burst_bp1;
13 unsigned int burst_bp2;
14 unsigned int sbm1_bp1;
15 unsigned int sbm1_bp2;
16 unsigned int sbm2_bp1;
17 unsigned int sbm2_bp2;
18 } nb_sm_before_bp_asm_f0;
19
20 extern struct ring_node_sm *current_ring_node_sm_f0;
21 extern struct ring_node_sm *ring_node_for_averaging_sm_f0;
22
23 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
24
25 void reset_nb_sm_f0( unsigned char lfrMode );
26
27 rtems_task avf0_task( rtems_task_argument lfrRequestedMode );
28 rtems_task prc0_task( rtems_task_argument lfrRequestedMode );
29
30 #endif // AVF0_PRC0_H
@@ -0,0 +1,339
1 /** Functions related to data processing.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
8 */
9
10 #include "avf1_prc1.h"
11
12 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ];
13 ring_node_asm asm_ring_burst_sbm_f1[ NB_RING_NODES_ASM_BURST_SBM_F1 ];
14 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
15 ring_node_asm *current_ring_node_asm_norm_f1;
16
17 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
18 char asm_f1_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
19 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
20 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
21
22 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
23
24 void reset_nb_sm_f1( unsigned char lfrMode )
25 {
26 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
27 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
28 nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16;
29 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
30 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
31 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
32 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
33
34 if (lfrMode == LFR_MODE_SBM2)
35 {
36 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
37 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
38 }
39 else if (lfrMode == LFR_MODE_BURST)
40 {
41 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
42 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
43 }
44 else
45 {
46 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
47 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
48 }
49 }
50
51 //************
52 // RTEMS TASKS
53
54 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
55 {
56 int i;
57
58 rtems_event_set event_out;
59 rtems_status_code status;
60 rtems_id queue_id_prc1;
61 asm_msg msgForMATR;
62 ring_node_sm *ring_node_tab[8];
63
64 unsigned int nb_norm_bp1;
65 unsigned int nb_norm_bp2;
66 unsigned int nb_norm_asm;
67 unsigned int nb_sbm_bp1;
68 unsigned int nb_sbm_bp2;
69
70 nb_norm_bp1 = 0;
71 nb_norm_bp2 = 0;
72 nb_norm_asm = 0;
73 nb_sbm_bp1 = 0;
74 nb_sbm_bp2 = 0;
75
76 reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
77 ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 );
78 ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 );
79 current_ring_node_asm_norm_f1 = asm_ring_norm_f1;
80 current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1;
81
82 BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
83
84 status = get_message_queue_id_prc1( &queue_id_prc1 );
85 if (status != RTEMS_SUCCESSFUL)
86 {
87 PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status)
88 }
89
90 while(1){
91 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
92 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
93 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
94 {
95 ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous;
96 ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1;
97 }
98
99 // compute the average and store it in the averaged_sm_f1 buffer
100 SM_average( current_ring_node_asm_norm_f1->matrix,
101 current_ring_node_asm_burst_sbm_f1->matrix,
102 ring_node_tab,
103 nb_norm_bp1, nb_sbm_bp1 );
104
105 // update nb_average
106 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
107 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
108 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
109 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
110 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
111
112 //****************************************
113 // initialize the mesage for the MATR task
114 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
115 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
116 msgForMATR.norm = current_ring_node_asm_norm_f1;
117 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
118 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
119 msgForMATR.coarseTime = time_management_regs->coarse_time;
120 msgForMATR.fineTime = time_management_regs->fine_time;
121
122 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
123 {
124 nb_sbm_bp1 = 0;
125 // set another ring for the ASM storage
126 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
127 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
128 {
129 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F1;
130 }
131 }
132
133 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
134 {
135 nb_sbm_bp2 = 0;
136 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
137 {
138 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F1;
139 }
140 }
141
142 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
143 {
144 nb_norm_bp1 = 0;
145 // set another ring for the ASM storage
146 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
147 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
148 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
149 {
150 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
151 }
152 }
153
154 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
155 {
156 nb_norm_bp2 = 0;
157 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
158 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
159 {
160 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
161 }
162 }
163
164 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
165 {
166 nb_norm_asm = 0;
167 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
168 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
169 {
170 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
171 }
172 }
173
174 //*************************
175 // send the message to MATR
176 if (msgForMATR.event != 0x00)
177 {
178 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
179 }
180
181 if (status != RTEMS_SUCCESSFUL) {
182 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
183 }
184 }
185 }
186
187 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
188 {
189 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
190 size_t size; // size of the incoming TC packet
191 asm_msg *incomingMsg;
192 //
193 spw_ioctl_pkt_send spw_ioctl_send_ASM;
194 rtems_status_code status;
195 rtems_id queue_id_send;
196 rtems_id queue_id_q_p1;
197 Header_TM_LFR_SCIENCE_ASM_t headerASM;
198 bp_packet_with_spare packet_norm_bp1;
199 bp_packet packet_norm_bp2;
200 bp_packet packet_sbm_bp1;
201 bp_packet packet_sbm_bp2;
202
203 unsigned long long int localTime;
204
205 ASM_init_header( &headerASM );
206
207 //*************
208 // NORM headers
209 BP_init_header_with_spare( &packet_norm_bp1.header,
210 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
211 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
212 BP_init_header( &packet_norm_bp2.header,
213 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
214 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
215
216 //***********************
217 // BURST and SBM2 headers
218 if ( lfrRequestedMode == LFR_MODE_BURST )
219 {
220 BP_init_header( &packet_sbm_bp1.header,
221 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
222 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F1);
223 BP_init_header( &packet_sbm_bp2.header,
224 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
225 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F1);
226 }
227 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
228 {
229 BP_init_header( &packet_sbm_bp1.header,
230 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
231 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
232 BP_init_header( &packet_sbm_bp2.header,
233 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
234 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
235 }
236 else
237 {
238 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
239 }
240
241 status = get_message_queue_id_send( &queue_id_send );
242 if (status != RTEMS_SUCCESSFUL)
243 {
244 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
245 }
246 status = get_message_queue_id_prc1( &queue_id_q_p1);
247 if (status != RTEMS_SUCCESSFUL)
248 {
249 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
250 }
251
252 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
253
254 while(1){
255 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
256 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
257
258 incomingMsg = (asm_msg*) incomingData;
259
260 localTime = getTimeAsUnsignedLongLongInt( );
261 //***********
262 //***********
263 // BURST SBM2
264 //***********
265 //***********
266 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F1 )
267 {
268 // 1) compress the matrix for Basic Parameters calculation
269 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1,
270 nb_sm_before_f1.burst_sbm_bp1,
271 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
272 ASM_F1_INDICE_START);
273 // 2) compute the BP1 set
274
275 // 3) send the BP1 set
276 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
277 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
278 BP_send( (char *) &packet_sbm_bp1.header, queue_id_send,
279 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA);
280 // 4) compute the BP2 set if needed
281 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F1 )
282 {
283 // 1) compute the BP2 set
284
285 // 2) send the BP2 set
286 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
287 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
288 BP_send( (char *) &packet_sbm_bp2.header, queue_id_send,
289 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA);
290 }
291 }
292
293 //*****
294 //*****
295 // NORM
296 //*****
297 //*****
298 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
299 {
300 // 1) compress the matrix for Basic Parameters calculation
301 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1,
302 nb_sm_before_f1.norm_bp1,
303 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
304 ASM_F0_INDICE_START );
305 // 2) compute the BP1 set
306
307 // 3) send the BP1 set
308 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
309 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
310 BP_send( (char *) &packet_norm_bp1.header, queue_id_send,
311 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA);
312 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
313 {
314 // 1) compute the BP2 set
315
316 // 2) send the BP2 set
317 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
318 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
319 BP_send( (char *) &packet_norm_bp2.header, queue_id_send,
320 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA);
321 }
322 }
323
324 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
325 {
326 // 1) reorganize the ASM and divide
327 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
328 asm_f1_reorganized,
329 nb_sm_before_f1.norm_bp1 );
330 // 2) convert the float array in a char array
331 ASM_convert( asm_f1_reorganized, asm_f1_char);
332 // 3) send the spectral matrix packets
333 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
334 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
335 ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send);
336 }
337
338 }
339 }
@@ -0,0 +1,28
1 #ifndef AVF1_PRC1_H
2 #define AVF1_PRC1_H
3
4 #include "fsw_processing.h"
5
6 typedef struct {
7 unsigned int norm_bp1;
8 unsigned int norm_bp2;
9 unsigned int norm_asm;
10 unsigned int burst_sbm_bp1;
11 unsigned int burst_sbm_bp2;
12 unsigned int burst_bp1;
13 unsigned int burst_bp2;
14 unsigned int sbm2_bp1;
15 unsigned int sbm2_bp2;
16 } nb_sm_before_bp_asm_f1;
17
18 extern struct ring_node_sm *current_ring_node_sm_f1;
19 extern struct ring_node_sm *ring_node_for_averaging_sm_f1;
20
21 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
22
23 void reset_nb_sm_f1( unsigned char lfrMode );
24
25 rtems_task avf1_task( rtems_task_argument lfrRequestedMode );
26 rtems_task prc1_task( rtems_task_argument lfrRequestedMode );
27
28 #endif // AVF1_PRC1_H