##// END OF EJS Templates
Bug 418, wrong data BP2_F1 in all modes except NORMAL
paul -
r204:d84039284b10 R3
parent child
Show More
@@ -1,389 +1,389
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "avf1_prc1.h"
10 #include "avf1_prc1.h"
11
11
12 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
12 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
13
13
14 extern ring_node sm_ring_f1[ ];
14 extern ring_node sm_ring_f1[ ];
15
15
16 //***
16 //***
17 // F1
17 // F1
18 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ];
18 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ];
19 ring_node_asm asm_ring_burst_sbm_f1 [ NB_RING_NODES_ASM_BURST_SBM_F1 ];
19 ring_node_asm asm_ring_burst_sbm_f1 [ NB_RING_NODES_ASM_BURST_SBM_F1 ];
20
20
21 ring_node ring_to_send_asm_f1 [ NB_RING_NODES_ASM_F1 ];
21 ring_node ring_to_send_asm_f1 [ NB_RING_NODES_ASM_F1 ];
22 int buffer_asm_f1 [ NB_RING_NODES_ASM_F1 * TOTAL_SIZE_SM ];
22 int buffer_asm_f1 [ NB_RING_NODES_ASM_F1 * TOTAL_SIZE_SM ];
23
23
24 float asm_f1_patched_norm [ TOTAL_SIZE_SM ];
24 float asm_f1_patched_norm [ TOTAL_SIZE_SM ];
25 float asm_f1_patched_burst_sbm [ TOTAL_SIZE_SM ];
25 float asm_f1_patched_burst_sbm [ TOTAL_SIZE_SM ];
26 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
26 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
27
27
28 char asm_f1_char [ TOTAL_SIZE_SM * 2 ];
28 char asm_f1_char [ TOTAL_SIZE_SM * 2 ];
29 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
29 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
30 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
30 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
31
31
32 float k_coeff_intercalib_f1_norm[ NB_BINS_COMPRESSED_SM_F1 * NB_K_COEFF_PER_BIN ]; // 13 * 32 = 416
32 float k_coeff_intercalib_f1_norm[ NB_BINS_COMPRESSED_SM_F1 * NB_K_COEFF_PER_BIN ]; // 13 * 32 = 416
33 float k_coeff_intercalib_f1_sbm[ NB_BINS_COMPRESSED_SM_SBM_F1 * NB_K_COEFF_PER_BIN ]; // 26 * 32 = 832
33 float k_coeff_intercalib_f1_sbm[ NB_BINS_COMPRESSED_SM_SBM_F1 * NB_K_COEFF_PER_BIN ]; // 26 * 32 = 832
34
34
35 //************
35 //************
36 // RTEMS TASKS
36 // RTEMS TASKS
37
37
38 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
38 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
39 {
39 {
40 int i;
40 int i;
41
41
42 rtems_event_set event_out;
42 rtems_event_set event_out;
43 rtems_status_code status;
43 rtems_status_code status;
44 rtems_id queue_id_prc1;
44 rtems_id queue_id_prc1;
45 asm_msg msgForMATR;
45 asm_msg msgForMATR;
46 ring_node *nodeForAveraging;
46 ring_node *nodeForAveraging;
47 ring_node *ring_node_tab[NB_SM_BEFORE_AVF0];
47 ring_node *ring_node_tab[NB_SM_BEFORE_AVF0];
48 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
48 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
49 ring_node_asm *current_ring_node_asm_norm_f1;
49 ring_node_asm *current_ring_node_asm_norm_f1;
50
50
51 unsigned int nb_norm_bp1;
51 unsigned int nb_norm_bp1;
52 unsigned int nb_norm_bp2;
52 unsigned int nb_norm_bp2;
53 unsigned int nb_norm_asm;
53 unsigned int nb_norm_asm;
54 unsigned int nb_sbm_bp1;
54 unsigned int nb_sbm_bp1;
55 unsigned int nb_sbm_bp2;
55 unsigned int nb_sbm_bp2;
56
56
57 nb_norm_bp1 = 0;
57 nb_norm_bp1 = 0;
58 nb_norm_bp2 = 0;
58 nb_norm_bp2 = 0;
59 nb_norm_asm = 0;
59 nb_norm_asm = 0;
60 nb_sbm_bp1 = 0;
60 nb_sbm_bp1 = 0;
61 nb_sbm_bp2 = 0;
61 nb_sbm_bp2 = 0;
62
62
63 reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
63 reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
64 ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 );
64 ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 );
65 ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 );
65 ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 );
66 current_ring_node_asm_norm_f1 = asm_ring_norm_f1;
66 current_ring_node_asm_norm_f1 = asm_ring_norm_f1;
67 current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1;
67 current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1;
68
68
69 BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
69 BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
70
70
71 status = get_message_queue_id_prc1( &queue_id_prc1 );
71 status = get_message_queue_id_prc1( &queue_id_prc1 );
72 if (status != RTEMS_SUCCESSFUL)
72 if (status != RTEMS_SUCCESSFUL)
73 {
73 {
74 PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status)
74 PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status)
75 }
75 }
76
76
77 while(1){
77 while(1){
78 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
78 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
79
79
80 //****************************************
80 //****************************************
81 // initialize the mesage for the MATR task
81 // initialize the mesage for the MATR task
82 msgForMATR.norm = current_ring_node_asm_norm_f1;
82 msgForMATR.norm = current_ring_node_asm_norm_f1;
83 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
83 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
84 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
84 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
85 //
85 //
86 //****************************************
86 //****************************************
87
87
88 nodeForAveraging = getRingNodeForAveraging( 1 );
88 nodeForAveraging = getRingNodeForAveraging( 1 );
89
89
90 ring_node_tab[NB_SM_BEFORE_AVF1-1] = nodeForAveraging;
90 ring_node_tab[NB_SM_BEFORE_AVF1-1] = nodeForAveraging;
91 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
91 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
92 {
92 {
93 nodeForAveraging = nodeForAveraging->previous;
93 nodeForAveraging = nodeForAveraging->previous;
94 ring_node_tab[NB_SM_BEFORE_AVF1-i] = nodeForAveraging;
94 ring_node_tab[NB_SM_BEFORE_AVF1-i] = nodeForAveraging;
95 }
95 }
96
96
97 // compute the average and store it in the averaged_sm_f1 buffer
97 // compute the average and store it in the averaged_sm_f1 buffer
98 SM_average( current_ring_node_asm_norm_f1->matrix,
98 SM_average( current_ring_node_asm_norm_f1->matrix,
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 &msgForMATR );
102 &msgForMATR );
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;
106 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
106 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
107 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
107 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
108 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
108 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
109 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
109 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
110
110
111 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
111 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
112 {
112 {
113 nb_sbm_bp1 = 0;
113 nb_sbm_bp1 = 0;
114 // set another ring for the ASM storage
114 // set another ring for the ASM storage
115 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
115 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
116 if ( lfrCurrentMode == LFR_MODE_BURST )
116 if ( lfrCurrentMode == LFR_MODE_BURST )
117 {
117 {
118 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1;
118 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1;
119 }
119 }
120 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
120 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
121 {
121 {
122 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1;
122 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1;
123 }
123 }
124 }
124 }
125
125
126 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
126 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
127 {
127 {
128 nb_sbm_bp2 = 0;
128 nb_sbm_bp2 = 0;
129 if ( lfrCurrentMode == LFR_MODE_BURST )
129 if ( lfrCurrentMode == LFR_MODE_BURST )
130 {
130 {
131 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1;
131 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1;
132 }
132 }
133 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
133 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
134 {
134 {
135 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1;
135 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1;
136 }
136 }
137 }
137 }
138
138
139 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
139 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
140 {
140 {
141 nb_norm_bp1 = 0;
141 nb_norm_bp1 = 0;
142 // set another ring for the ASM storage
142 // set another ring for the ASM storage
143 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
143 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
144 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
144 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
145 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
145 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
146 {
146 {
147 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
147 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
148 }
148 }
149 }
149 }
150
150
151 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
151 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
152 {
152 {
153 nb_norm_bp2 = 0;
153 nb_norm_bp2 = 0;
154 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
154 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
155 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
155 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
156 {
156 {
157 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
157 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
158 }
158 }
159 }
159 }
160
160
161 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
161 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
162 {
162 {
163 nb_norm_asm = 0;
163 nb_norm_asm = 0;
164 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
164 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
165 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
165 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
166 {
166 {
167 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
167 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
168 }
168 }
169 }
169 }
170
170
171 //*************************
171 //*************************
172 // send the message to MATR
172 // send the message to MATR
173 if (msgForMATR.event != 0x00)
173 if (msgForMATR.event != 0x00)
174 {
174 {
175 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
175 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
176 }
176 }
177
177
178 if (status != RTEMS_SUCCESSFUL) {
178 if (status != RTEMS_SUCCESSFUL) {
179 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
179 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
180 }
180 }
181 }
181 }
182 }
182 }
183
183
184 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
184 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
185 {
185 {
186 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
186 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
187 size_t size; // size of the incoming TC packet
187 size_t size; // size of the incoming TC packet
188 asm_msg *incomingMsg;
188 asm_msg *incomingMsg;
189 //
189 //
190 unsigned char sid;
190 unsigned char sid;
191 rtems_status_code status;
191 rtems_status_code status;
192 rtems_id queue_id_send;
192 rtems_id queue_id_send;
193 rtems_id queue_id_q_p1;
193 rtems_id queue_id_q_p1;
194 bp_packet_with_spare packet_norm_bp1;
194 bp_packet_with_spare packet_norm_bp1;
195 bp_packet packet_norm_bp2;
195 bp_packet packet_norm_bp2;
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
200 unsigned long long int localTime;
200 unsigned long long int localTime;
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 );
204 current_ring_node_to_send_asm_f1 = ring_to_send_asm_f1;
204 current_ring_node_to_send_asm_f1 = ring_to_send_asm_f1;
205
205
206 //*************
206 //*************
207 // NORM headers
207 // NORM headers
208 BP_init_header_with_spare( &packet_norm_bp1,
208 BP_init_header_with_spare( &packet_norm_bp1,
209 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
209 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
210 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
210 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
211 BP_init_header( &packet_norm_bp2,
211 BP_init_header( &packet_norm_bp2,
212 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
212 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
213 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
213 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
214
214
215 //***********************
215 //***********************
216 // BURST and SBM2 headers
216 // BURST and SBM2 headers
217 if ( lfrRequestedMode == LFR_MODE_BURST )
217 if ( lfrRequestedMode == LFR_MODE_BURST )
218 {
218 {
219 BP_init_header( &packet_sbm_bp1,
219 BP_init_header( &packet_sbm_bp1,
220 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
220 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
221 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
221 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
222 BP_init_header( &packet_sbm_bp2,
222 BP_init_header( &packet_sbm_bp2,
223 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
223 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
224 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
224 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
225 }
225 }
226 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
226 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
227 {
227 {
228 BP_init_header( &packet_sbm_bp1,
228 BP_init_header( &packet_sbm_bp1,
229 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
229 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
230 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
230 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
231 BP_init_header( &packet_sbm_bp2,
231 BP_init_header( &packet_sbm_bp2,
232 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
232 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
233 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
233 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
234 }
234 }
235 else
235 else
236 {
236 {
237 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
237 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
238 }
238 }
239
239
240 status = get_message_queue_id_send( &queue_id_send );
240 status = get_message_queue_id_send( &queue_id_send );
241 if (status != RTEMS_SUCCESSFUL)
241 if (status != RTEMS_SUCCESSFUL)
242 {
242 {
243 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
243 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
244 }
244 }
245 status = get_message_queue_id_prc1( &queue_id_q_p1);
245 status = get_message_queue_id_prc1( &queue_id_q_p1);
246 if (status != RTEMS_SUCCESSFUL)
246 if (status != RTEMS_SUCCESSFUL)
247 {
247 {
248 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
248 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
249 }
249 }
250
250
251 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
251 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
252
252
253 while(1){
253 while(1){
254 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
254 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
255 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
255 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
256
256
257 incomingMsg = (asm_msg*) incomingData;
257 incomingMsg = (asm_msg*) incomingData;
258
258
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 localTime = getTimeAsUnsignedLongLongInt( );
263 //***********
263 //***********
264 //***********
264 //***********
265 // BURST SBM2
265 // BURST SBM2
266 //***********
266 //***********
267 //***********
267 //***********
268 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) )
268 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) )
269 {
269 {
270 sid = getSID( incomingMsg->event );
270 sid = getSID( incomingMsg->event );
271 // 1) compress the matrix for Basic Parameters calculation
271 // 1) compress the matrix for Basic Parameters calculation
272 ASM_compress_reorganize_and_divide( asm_f1_patched_burst_sbm, compressed_sm_sbm_f1,
272 ASM_compress_reorganize_and_divide( asm_f1_patched_burst_sbm, compressed_sm_sbm_f1,
273 nb_sm_before_f1.burst_sbm_bp1,
273 nb_sm_before_f1.burst_sbm_bp1,
274 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
274 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
275 ASM_F1_INDICE_START);
275 ASM_F1_INDICE_START);
276 // 2) compute the BP1 set
276 // 2) compute the BP1 set
277 BP1_set( compressed_sm_sbm_f1, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp1.data );
277 BP1_set( compressed_sm_sbm_f1, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp1.data );
278 // 3) send the BP1 set
278 // 3) send the BP1 set
279 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
279 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
280 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
280 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
281 packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
281 packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
282 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
282 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
283 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
283 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
284 sid );
284 sid );
285 // 4) compute the BP2 set if needed
285 // 4) compute the BP2 set if needed
286 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
286 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
287 {
287 {
288 // 1) compute the BP2 set
288 // 1) compute the BP2 set
289 BP2_set( compressed_sm_sbm_f1, NB_BINS_COMPRESSED_SM_SBM_F1, packet_norm_bp2.data );
289 BP2_set( compressed_sm_sbm_f1, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp2.data );
290 // 2) send the BP2 set
290 // 2) send the BP2 set
291 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
291 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
292 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
292 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
293 packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
293 packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
294 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
294 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
295 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
295 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
296 sid );
296 sid );
297 }
297 }
298 }
298 }
299
299
300 //*****
300 //*****
301 //*****
301 //*****
302 // NORM
302 // NORM
303 //*****
303 //*****
304 //*****
304 //*****
305 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
305 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
306 {
306 {
307 // 1) compress the matrix for Basic Parameters calculation
307 // 1) compress the matrix for Basic Parameters calculation
308 ASM_compress_reorganize_and_divide( asm_f1_patched_norm, compressed_sm_norm_f1,
308 ASM_compress_reorganize_and_divide( asm_f1_patched_norm, compressed_sm_norm_f1,
309 nb_sm_before_f1.norm_bp1,
309 nb_sm_before_f1.norm_bp1,
310 NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1,
310 NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1,
311 ASM_F1_INDICE_START );
311 ASM_F1_INDICE_START );
312 // 2) compute the BP1 set
312 // 2) compute the BP1 set
313 BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data );
313 BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data );
314 // 3) send the BP1 set
314 // 3) send the BP1 set
315 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
315 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
316 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
316 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
317 packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
317 packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
318 BP_send( (char *) &packet_norm_bp1, queue_id_send,
318 BP_send( (char *) &packet_norm_bp1, queue_id_send,
319 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
319 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
320 SID_NORM_BP1_F1 );
320 SID_NORM_BP1_F1 );
321 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
321 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
322 {
322 {
323 // 1) compute the BP2 set
323 // 1) compute the BP2 set
324 BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data );
324 BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data );
325 // 2) send the BP2 set
325 // 2) send the BP2 set
326 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
326 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
327 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
327 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
328 packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
328 packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
329 BP_send( (char *) &packet_norm_bp2, queue_id_send,
329 BP_send( (char *) &packet_norm_bp2, queue_id_send,
330 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
330 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
331 SID_NORM_BP2_F1 );
331 SID_NORM_BP2_F1 );
332 }
332 }
333 }
333 }
334
334
335 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
335 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
336 {
336 {
337 // 1) reorganize the ASM and divide
337 // 1) reorganize the ASM and divide
338 ASM_reorganize_and_divide( asm_f1_patched_norm,
338 ASM_reorganize_and_divide( asm_f1_patched_norm,
339 (float*) current_ring_node_to_send_asm_f1->buffer_address,
339 (float*) current_ring_node_to_send_asm_f1->buffer_address,
340 nb_sm_before_f1.norm_bp1 );
340 nb_sm_before_f1.norm_bp1 );
341 current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM;
341 current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM;
342 current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM;
342 current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM;
343 current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1;
343 current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1;
344 // 3) send the spectral matrix packets
344 // 3) send the spectral matrix packets
345 status = rtems_message_queue_send( queue_id_send, &current_ring_node_to_send_asm_f1, sizeof( ring_node* ) );
345 status = rtems_message_queue_send( queue_id_send, &current_ring_node_to_send_asm_f1, sizeof( ring_node* ) );
346 // change asm ring node
346 // change asm ring node
347 current_ring_node_to_send_asm_f1 = current_ring_node_to_send_asm_f1->next;
347 current_ring_node_to_send_asm_f1 = current_ring_node_to_send_asm_f1->next;
348 }
348 }
349
349
350 update_queue_max_count( queue_id_q_p1, &hk_lfr_q_p1_fifo_size_max );
350 update_queue_max_count( queue_id_q_p1, &hk_lfr_q_p1_fifo_size_max );
351
351
352 }
352 }
353 }
353 }
354
354
355 //**********
355 //**********
356 // FUNCTIONS
356 // FUNCTIONS
357
357
358 void reset_nb_sm_f1( unsigned char lfrMode )
358 void reset_nb_sm_f1( unsigned char lfrMode )
359 {
359 {
360 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
360 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
361 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
361 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
362 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;
362 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;
363 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
363 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
364 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
364 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
365 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
365 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
366 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
366 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
367
367
368 if (lfrMode == LFR_MODE_SBM2)
368 if (lfrMode == LFR_MODE_SBM2)
369 {
369 {
370 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
370 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
371 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
371 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
372 }
372 }
373 else if (lfrMode == LFR_MODE_BURST)
373 else if (lfrMode == LFR_MODE_BURST)
374 {
374 {
375 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
375 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
376 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
376 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
377 }
377 }
378 else
378 else
379 {
379 {
380 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
380 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
381 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
381 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
382 }
382 }
383 }
383 }
384
384
385 void init_k_coefficients_f1( void )
385 void init_k_coefficients_f1( void )
386 {
386 {
387 init_k_coefficients( k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1 );
387 init_k_coefficients( k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1 );
388 init_k_coefficients( k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1);
388 init_k_coefficients( k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1);
389 }
389 }
General Comments 0
You need to be logged in to leave comments. Login now