##// END OF EJS Templates
Two bugs corrected:...
paul -
r323:4edb4fc1ba23 R3_plus draft
parent child
Show More
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 6bab694410c69700e3455ffba21ce58dbb4da870 header/lfr_common_headers
2 d4a9a4d748d56d86427bfe03a6777fae4cfe3ae1 header/lfr_common_headers
@@ -1,14 +1,14
1 # LOAD FSW USING LINK 1
1 # LOAD FSW USING LINK 1
2 SpwPlugin0.StarDundeeSelectLinkNumber( 1 )
2 SpwPlugin0.StarDundeeSelectLinkNumber( 1 )
3
3
4 dsu3plugin0.openFile("/home/pleroy/DEV/DEV_PLE/build-DEV_PLE-Desktop-Default/src/fsw")
4 dsu3plugin0.openFile("/home/pleroy/DEV/build-DEV_PLE-Desktop-Default/src/fsw")
5 #dsu3plugin0.openFile("/opt/LFR/LFR-FSW/2.0.2.3/fsw")
5 #dsu3plugin0.openFile("/opt/LFR/LFR-FSW/2.0.2.3/fsw")
6 dsu3plugin0.loadFile()
6 dsu3plugin0.loadFile()
7
7
8 dsu3plugin0.run()
8 dsu3plugin0.run()
9
9
10 # START SENDING TIMECODES AT 1 Hz
10 # START SENDING TIMECODES AT 1 Hz
11 #SpwPlugin0.StarDundeeStartTimecodes( 1 )
11 #SpwPlugin0.StarDundeeStartTimecodes( 1 )
12
12
13 # it is possible to change the time code frequency
13 # it is possible to change the time code frequency
14 #RMAPPlugin0.changeTimecodeFrequency(2)
14 #RMAPPlugin0.changeTimecodeFrequency(2)
@@ -1,423 +1,423
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 "avf0_prc0.h"
10 #include "avf0_prc0.h"
11
11
12 nb_sm_before_bp_asm_f0 nb_sm_before_f0 = {0};
12 nb_sm_before_bp_asm_f0 nb_sm_before_f0 = {0};
13
13
14 //***
14 //***
15 // F0
15 // F0
16 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ] = {0};
16 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ] = {0};
17 ring_node_asm asm_ring_burst_sbm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ] = {0};
17 ring_node_asm asm_ring_burst_sbm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ] = {0};
18
18
19 ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ] = {0};
19 ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ] = {0};
20 int buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ] = {0};
20 int buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ] = {0};
21
21
22 float asm_f0_patched_norm [ TOTAL_SIZE_SM ] = {0};
22 float asm_f0_patched_norm [ TOTAL_SIZE_SM ] = {0};
23 float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ] = {0};
23 float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ] = {0};
24 float asm_f0_reorganized [ TOTAL_SIZE_SM ] = {0};
24 float asm_f0_reorganized [ TOTAL_SIZE_SM ] = {0};
25
25
26 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0] = {0};
26 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0] = {0};
27 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ] = {0};
27 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ] = {0};
28
28
29 float k_coeff_intercalib_f0_norm[ NB_BINS_COMPRESSED_SM_F0 * NB_K_COEFF_PER_BIN ] = {0}; // 11 * 32 = 352
29 float k_coeff_intercalib_f0_norm[ NB_BINS_COMPRESSED_SM_F0 * NB_K_COEFF_PER_BIN ] = {0}; // 11 * 32 = 352
30 float k_coeff_intercalib_f0_sbm[ NB_BINS_COMPRESSED_SM_SBM_F0 * NB_K_COEFF_PER_BIN ] = {0}; // 22 * 32 = 704
30 float k_coeff_intercalib_f0_sbm[ NB_BINS_COMPRESSED_SM_SBM_F0 * NB_K_COEFF_PER_BIN ] = {0}; // 22 * 32 = 704
31
31
32 //************
32 //************
33 // RTEMS TASKS
33 // RTEMS TASKS
34
34
35 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
35 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
36 {
36 {
37 int i;
37 int i;
38
38
39 rtems_event_set event_out;
39 rtems_event_set event_out;
40 rtems_status_code status;
40 rtems_status_code status;
41 rtems_id queue_id_prc0;
41 rtems_id queue_id_prc0;
42 asm_msg msgForPRC;
42 asm_msg msgForPRC;
43 ring_node *nodeForAveraging;
43 ring_node *nodeForAveraging;
44 ring_node *ring_node_tab[NB_SM_BEFORE_AVF0_F1];
44 ring_node *ring_node_tab[NB_SM_BEFORE_AVF0_F1];
45 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
45 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
46 ring_node_asm *current_ring_node_asm_norm_f0;
46 ring_node_asm *current_ring_node_asm_norm_f0;
47
47
48 unsigned int nb_norm_bp1;
48 unsigned int nb_norm_bp1;
49 unsigned int nb_norm_bp2;
49 unsigned int nb_norm_bp2;
50 unsigned int nb_norm_asm;
50 unsigned int nb_norm_asm;
51 unsigned int nb_sbm_bp1;
51 unsigned int nb_sbm_bp1;
52 unsigned int nb_sbm_bp2;
52 unsigned int nb_sbm_bp2;
53
53
54 nb_norm_bp1 = 0;
54 nb_norm_bp1 = 0;
55 nb_norm_bp2 = 0;
55 nb_norm_bp2 = 0;
56 nb_norm_asm = 0;
56 nb_norm_asm = 0;
57 nb_sbm_bp1 = 0;
57 nb_sbm_bp1 = 0;
58 nb_sbm_bp2 = 0;
58 nb_sbm_bp2 = 0;
59 event_out = EVENT_SETS_NONE_PENDING;
59 event_out = EVENT_SETS_NONE_PENDING;
60 queue_id_prc0 = RTEMS_ID_NONE;
60 queue_id_prc0 = RTEMS_ID_NONE;
61
61
62 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
62 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
63 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
63 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
64 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
64 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
65 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
65 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
66 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
66 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
67
67
68 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode);
68 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode);
69
69
70 status = get_message_queue_id_prc0( &queue_id_prc0 );
70 status = get_message_queue_id_prc0( &queue_id_prc0 );
71 if (status != RTEMS_SUCCESSFUL)
71 if (status != RTEMS_SUCCESSFUL)
72 {
72 {
73 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
73 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
74 }
74 }
75
75
76 while(1){
76 while(1){
77 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
77 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
78
78
79 //****************************************
79 //****************************************
80 // initialize the mesage for the MATR task
80 // initialize the mesage for the MATR task
81 msgForPRC.norm = current_ring_node_asm_norm_f0;
81 msgForPRC.norm = current_ring_node_asm_norm_f0;
82 msgForPRC.burst_sbm = current_ring_node_asm_burst_sbm_f0;
82 msgForPRC.burst_sbm = current_ring_node_asm_burst_sbm_f0;
83 msgForPRC.event = EVENT_SETS_NONE_PENDING; // this composite event will be sent to the PRC0 task
83 msgForPRC.event = EVENT_SETS_NONE_PENDING; // this composite event will be sent to the PRC0 task
84 //
84 //
85 //****************************************
85 //****************************************
86
86
87 nodeForAveraging = getRingNodeForAveraging( 0 );
87 nodeForAveraging = getRingNodeForAveraging( 0 );
88
88
89 ring_node_tab[NB_SM_BEFORE_AVF0_F1-1] = nodeForAveraging;
89 ring_node_tab[NB_SM_BEFORE_AVF0_F1-1] = nodeForAveraging;
90 for ( i = 1; i < (NB_SM_BEFORE_AVF0_F1); i++ )
90 for ( i = 1; i < (NB_SM_BEFORE_AVF0_F1); i++ )
91 {
91 {
92 nodeForAveraging = nodeForAveraging->previous;
92 nodeForAveraging = nodeForAveraging->previous;
93 ring_node_tab[NB_SM_BEFORE_AVF0_F1-i] = nodeForAveraging;
93 ring_node_tab[NB_SM_BEFORE_AVF0_F1 - i - 1] = nodeForAveraging;
94 }
94 }
95
95
96 // compute the average and store it in the averaged_sm_f1 buffer
96 // compute the average and store it in the averaged_sm_f1 buffer
97 SM_average( current_ring_node_asm_norm_f0->matrix,
97 SM_average( current_ring_node_asm_norm_f0->matrix,
98 current_ring_node_asm_burst_sbm_f0->matrix,
98 current_ring_node_asm_burst_sbm_f0->matrix,
99 ring_node_tab,
99 ring_node_tab,
100 nb_norm_bp1, nb_sbm_bp1,
100 nb_norm_bp1, nb_sbm_bp1,
101 &msgForPRC, 0 ); // 0 => frequency channel 0
101 &msgForPRC, 0 ); // 0 => frequency channel 0
102
102
103 // update nb_average
103 // update nb_average
104 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0_F1;
104 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0_F1;
105 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0_F1;
105 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0_F1;
106 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0_F1;
106 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0_F1;
107 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0_F1;
107 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0_F1;
108 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0_F1;
108 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0_F1;
109
109
110 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
110 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
111 {
111 {
112 nb_sbm_bp1 = 0;
112 nb_sbm_bp1 = 0;
113 // set another ring for the ASM storage
113 // set another ring for the ASM storage
114 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
114 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
115 if ( lfrCurrentMode == LFR_MODE_BURST )
115 if ( lfrCurrentMode == LFR_MODE_BURST )
116 {
116 {
117 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_BURST_BP1_F0;
117 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_BURST_BP1_F0;
118 }
118 }
119 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
119 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
120 {
120 {
121 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_SBM_BP1_F0;
121 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_SBM_BP1_F0;
122 }
122 }
123 }
123 }
124
124
125 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
125 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
126 {
126 {
127 nb_sbm_bp2 = 0;
127 nb_sbm_bp2 = 0;
128 if ( lfrCurrentMode == LFR_MODE_BURST )
128 if ( lfrCurrentMode == LFR_MODE_BURST )
129 {
129 {
130 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_BURST_BP2_F0;
130 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_BURST_BP2_F0;
131 }
131 }
132 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
132 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
133 {
133 {
134 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_SBM_BP2_F0;
134 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_SBM_BP2_F0;
135 }
135 }
136 }
136 }
137
137
138 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
138 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
139 {
139 {
140 nb_norm_bp1 = 0;
140 nb_norm_bp1 = 0;
141 // set another ring for the ASM storage
141 // set another ring for the ASM storage
142 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
142 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
143 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
143 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
144 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
144 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
145 {
145 {
146 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_BP1_F0;
146 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_BP1_F0;
147 }
147 }
148 }
148 }
149
149
150 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
150 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
151 {
151 {
152 nb_norm_bp2 = 0;
152 nb_norm_bp2 = 0;
153 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
153 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
154 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
154 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
155 {
155 {
156 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_BP2_F0;
156 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_BP2_F0;
157 }
157 }
158 }
158 }
159
159
160 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
160 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
161 {
161 {
162 nb_norm_asm = 0;
162 nb_norm_asm = 0;
163 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
163 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
164 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
164 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
165 {
165 {
166 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_ASM_F0;
166 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_ASM_F0;
167 }
167 }
168 }
168 }
169
169
170 //*************************
170 //*************************
171 // send the message to PRC
171 // send the message to PRC
172 if (msgForPRC.event != EVENT_SETS_NONE_PENDING)
172 if (msgForPRC.event != EVENT_SETS_NONE_PENDING)
173 {
173 {
174 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForPRC, MSG_QUEUE_SIZE_PRC0);
174 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForPRC, MSG_QUEUE_SIZE_PRC0);
175 }
175 }
176
176
177 if (status != RTEMS_SUCCESSFUL) {
177 if (status != RTEMS_SUCCESSFUL) {
178 PRINTF1("in AVF0 *** Error sending message to PRC, code %d\n", status)
178 PRINTF1("in AVF0 *** Error sending message to PRC, code %d\n", status)
179 }
179 }
180 }
180 }
181 }
181 }
182
182
183 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
183 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
184 {
184 {
185 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
185 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
186 size_t size; // size of the incoming TC packet
186 size_t size; // size of the incoming TC packet
187 asm_msg *incomingMsg;
187 asm_msg *incomingMsg;
188 //
188 //
189 unsigned char sid;
189 unsigned char sid;
190 rtems_status_code status;
190 rtems_status_code status;
191 rtems_id queue_id;
191 rtems_id queue_id;
192 rtems_id queue_id_q_p0;
192 rtems_id queue_id_q_p0;
193 bp_packet_with_spare packet_norm_bp1;
193 bp_packet_with_spare packet_norm_bp1;
194 bp_packet packet_norm_bp2;
194 bp_packet packet_norm_bp2;
195 bp_packet packet_sbm_bp1;
195 bp_packet packet_sbm_bp1;
196 bp_packet packet_sbm_bp2;
196 bp_packet packet_sbm_bp2;
197 ring_node *current_ring_node_to_send_asm_f0;
197 ring_node *current_ring_node_to_send_asm_f0;
198 float nbSMInASMNORM;
198 float nbSMInASMNORM;
199 float nbSMInASMSBM;
199 float nbSMInASMSBM;
200
200
201 size = 0;
201 size = 0;
202 queue_id = RTEMS_ID_NONE;
202 queue_id = RTEMS_ID_NONE;
203 queue_id_q_p0 = RTEMS_ID_NONE;
203 queue_id_q_p0 = RTEMS_ID_NONE;
204 memset( &packet_norm_bp1, 0, sizeof(bp_packet_with_spare) );
204 memset( &packet_norm_bp1, 0, sizeof(bp_packet_with_spare) );
205 memset( &packet_norm_bp2, 0, sizeof(bp_packet) );
205 memset( &packet_norm_bp2, 0, sizeof(bp_packet) );
206 memset( &packet_sbm_bp1, 0, sizeof(bp_packet) );
206 memset( &packet_sbm_bp1, 0, sizeof(bp_packet) );
207 memset( &packet_sbm_bp2, 0, sizeof(bp_packet) );
207 memset( &packet_sbm_bp2, 0, sizeof(bp_packet) );
208
208
209 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
209 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
210 init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM );
210 init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM );
211 current_ring_node_to_send_asm_f0 = ring_to_send_asm_f0;
211 current_ring_node_to_send_asm_f0 = ring_to_send_asm_f0;
212
212
213 //*************
213 //*************
214 // NORM headers
214 // NORM headers
215 BP_init_header_with_spare( &packet_norm_bp1,
215 BP_init_header_with_spare( &packet_norm_bp1,
216 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
216 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
217 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
217 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
218 BP_init_header( &packet_norm_bp2,
218 BP_init_header( &packet_norm_bp2,
219 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
219 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
220 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
220 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
221
221
222 //****************************
222 //****************************
223 // BURST SBM1 and SBM2 headers
223 // BURST SBM1 and SBM2 headers
224 if ( lfrRequestedMode == LFR_MODE_BURST )
224 if ( lfrRequestedMode == LFR_MODE_BURST )
225 {
225 {
226 BP_init_header( &packet_sbm_bp1,
226 BP_init_header( &packet_sbm_bp1,
227 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
227 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
228 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
228 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
229 BP_init_header( &packet_sbm_bp2,
229 BP_init_header( &packet_sbm_bp2,
230 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
230 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
231 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
231 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
232 }
232 }
233 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
233 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
234 {
234 {
235 BP_init_header( &packet_sbm_bp1,
235 BP_init_header( &packet_sbm_bp1,
236 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
236 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
237 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
237 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
238 BP_init_header( &packet_sbm_bp2,
238 BP_init_header( &packet_sbm_bp2,
239 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
239 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
240 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
240 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
241 }
241 }
242 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
242 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
243 {
243 {
244 BP_init_header( &packet_sbm_bp1,
244 BP_init_header( &packet_sbm_bp1,
245 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
245 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
246 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
246 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
247 BP_init_header( &packet_sbm_bp2,
247 BP_init_header( &packet_sbm_bp2,
248 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
248 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
249 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
249 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
250 }
250 }
251 else
251 else
252 {
252 {
253 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
253 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
254 }
254 }
255
255
256 status = get_message_queue_id_send( &queue_id );
256 status = get_message_queue_id_send( &queue_id );
257 if (status != RTEMS_SUCCESSFUL)
257 if (status != RTEMS_SUCCESSFUL)
258 {
258 {
259 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
259 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
260 }
260 }
261 status = get_message_queue_id_prc0( &queue_id_q_p0);
261 status = get_message_queue_id_prc0( &queue_id_q_p0);
262 if (status != RTEMS_SUCCESSFUL)
262 if (status != RTEMS_SUCCESSFUL)
263 {
263 {
264 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
264 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
265 }
265 }
266
266
267 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
267 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
268
268
269 while(1){
269 while(1){
270 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
270 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
271 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
271 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
272
272
273 incomingMsg = (asm_msg*) incomingData;
273 incomingMsg = (asm_msg*) incomingData;
274
274
275 ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm );
275 ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm );
276 ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm );
276 ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm );
277
277
278 nbSMInASMNORM = incomingMsg->numberOfSMInASMNORM;
278 nbSMInASMNORM = incomingMsg->numberOfSMInASMNORM;
279 nbSMInASMSBM = incomingMsg->numberOfSMInASMSBM;
279 nbSMInASMSBM = incomingMsg->numberOfSMInASMSBM;
280
280
281 //****************
281 //****************
282 //****************
282 //****************
283 // BURST SBM1 SBM2
283 // BURST SBM1 SBM2
284 //****************
284 //****************
285 //****************
285 //****************
286 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) )
286 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) )
287 {
287 {
288 sid = getSID( incomingMsg->event );
288 sid = getSID( incomingMsg->event );
289 // 1) compress the matrix for Basic Parameters calculation
289 // 1) compress the matrix for Basic Parameters calculation
290 ASM_compress_reorganize_and_divide_mask( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0,
290 ASM_compress_reorganize_and_divide_mask( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0,
291 nbSMInASMSBM,
291 nbSMInASMSBM,
292 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
292 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
293 ASM_F0_INDICE_START, CHANNELF0);
293 ASM_F0_INDICE_START, CHANNELF0);
294 // 2) compute the BP1 set
294 // 2) compute the BP1 set
295 BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data );
295 BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data );
296 // 3) send the BP1 set
296 // 3) send the BP1 set
297 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
297 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
298 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
298 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
299 packet_sbm_bp1.pa_bia_status_info = pa_bia_status_info;
299 packet_sbm_bp1.pa_bia_status_info = pa_bia_status_info;
300 packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
300 packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
301 BP_send_s1_s2( (char *) &packet_sbm_bp1, queue_id,
301 BP_send_s1_s2( (char *) &packet_sbm_bp1, queue_id,
302 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
302 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
303 sid);
303 sid);
304 // 4) compute the BP2 set if needed
304 // 4) compute the BP2 set if needed
305 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
305 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
306 {
306 {
307 // 1) compute the BP2 set
307 // 1) compute the BP2 set
308 BP2_set( compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data );
308 BP2_set( compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data );
309 // 2) send the BP2 set
309 // 2) send the BP2 set
310 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
310 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
311 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
311 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
312 packet_sbm_bp2.pa_bia_status_info = pa_bia_status_info;
312 packet_sbm_bp2.pa_bia_status_info = pa_bia_status_info;
313 packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
313 packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
314 BP_send_s1_s2( (char *) &packet_sbm_bp2, queue_id,
314 BP_send_s1_s2( (char *) &packet_sbm_bp2, queue_id,
315 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
315 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
316 sid);
316 sid);
317 }
317 }
318 }
318 }
319
319
320 //*****
320 //*****
321 //*****
321 //*****
322 // NORM
322 // NORM
323 //*****
323 //*****
324 //*****
324 //*****
325 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
325 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
326 {
326 {
327 // 1) compress the matrix for Basic Parameters calculation
327 // 1) compress the matrix for Basic Parameters calculation
328 ASM_compress_reorganize_and_divide_mask( asm_f0_patched_norm, compressed_sm_norm_f0,
328 ASM_compress_reorganize_and_divide_mask( asm_f0_patched_norm, compressed_sm_norm_f0,
329 nbSMInASMNORM,
329 nbSMInASMNORM,
330 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
330 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
331 ASM_F0_INDICE_START, CHANNELF0 );
331 ASM_F0_INDICE_START, CHANNELF0 );
332 // 2) compute the BP1 set
332 // 2) compute the BP1 set
333 BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data );
333 BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data );
334 // 3) send the BP1 set
334 // 3) send the BP1 set
335 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
335 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
336 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
336 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
337 packet_norm_bp1.pa_bia_status_info = pa_bia_status_info;
337 packet_norm_bp1.pa_bia_status_info = pa_bia_status_info;
338 packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
338 packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
339 BP_send( (char *) &packet_norm_bp1, queue_id,
339 BP_send( (char *) &packet_norm_bp1, queue_id,
340 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
340 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
341 SID_NORM_BP1_F0 );
341 SID_NORM_BP1_F0 );
342 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
342 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
343 {
343 {
344 // 1) compute the BP2 set using the same ASM as the one used for BP1
344 // 1) compute the BP2 set using the same ASM as the one used for BP1
345 BP2_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp2.data );
345 BP2_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp2.data );
346 // 2) send the BP2 set
346 // 2) send the BP2 set
347 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
347 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
348 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
348 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
349 packet_norm_bp2.pa_bia_status_info = pa_bia_status_info;
349 packet_norm_bp2.pa_bia_status_info = pa_bia_status_info;
350 packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
350 packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
351 BP_send( (char *) &packet_norm_bp2, queue_id,
351 BP_send( (char *) &packet_norm_bp2, queue_id,
352 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
352 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
353 SID_NORM_BP2_F0);
353 SID_NORM_BP2_F0);
354 }
354 }
355 }
355 }
356
356
357 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
357 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
358 {
358 {
359 // 1) reorganize the ASM and divide
359 // 1) reorganize the ASM and divide
360 ASM_reorganize_and_divide( asm_f0_patched_norm,
360 ASM_reorganize_and_divide( asm_f0_patched_norm,
361 (float*) current_ring_node_to_send_asm_f0->buffer_address,
361 (float*) current_ring_node_to_send_asm_f0->buffer_address,
362 nbSMInASMNORM );
362 nbSMInASMNORM );
363 current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM;
363 current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM;
364 current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM;
364 current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM;
365 current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0;
365 current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0;
366
366
367 // 3) send the spectral matrix packets
367 // 3) send the spectral matrix packets
368 status = rtems_message_queue_send( queue_id, &current_ring_node_to_send_asm_f0, sizeof( ring_node* ) );
368 status = rtems_message_queue_send( queue_id, &current_ring_node_to_send_asm_f0, sizeof( ring_node* ) );
369
369
370 // change asm ring node
370 // change asm ring node
371 current_ring_node_to_send_asm_f0 = current_ring_node_to_send_asm_f0->next;
371 current_ring_node_to_send_asm_f0 = current_ring_node_to_send_asm_f0->next;
372 }
372 }
373
373
374 update_queue_max_count( queue_id_q_p0, &hk_lfr_q_p0_fifo_size_max );
374 update_queue_max_count( queue_id_q_p0, &hk_lfr_q_p0_fifo_size_max );
375
375
376 }
376 }
377 }
377 }
378
378
379 //**********
379 //**********
380 // FUNCTIONS
380 // FUNCTIONS
381
381
382 void reset_nb_sm_f0( unsigned char lfrMode )
382 void reset_nb_sm_f0( unsigned char lfrMode )
383 {
383 {
384 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * NB_SM_PER_S_F0;
384 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * NB_SM_PER_S_F0;
385 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * NB_SM_PER_S_F0;
385 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * NB_SM_PER_S_F0;
386 nb_sm_before_f0.norm_asm =
386 nb_sm_before_f0.norm_asm =
387 ( (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256) + parameter_dump_packet.sy_lfr_n_asm_p[1]) * NB_SM_PER_S_F0;
387 ( (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256) + parameter_dump_packet.sy_lfr_n_asm_p[1]) * NB_SM_PER_S_F0;
388 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
388 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
389 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * NB_SM_PER_S_F0;
389 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * NB_SM_PER_S_F0;
390 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * NB_SM_PER_S_F0;
390 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * NB_SM_PER_S_F0;
391 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * NB_SM_PER_S_F0;
391 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * NB_SM_PER_S_F0;
392 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * NB_SM_PER_S_F0;
392 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * NB_SM_PER_S_F0;
393 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * NB_SM_PER_S_F0;
393 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * NB_SM_PER_S_F0;
394
394
395 if (lfrMode == LFR_MODE_SBM1)
395 if (lfrMode == LFR_MODE_SBM1)
396 {
396 {
397 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
397 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
398 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
398 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
399 }
399 }
400 else if (lfrMode == LFR_MODE_SBM2)
400 else if (lfrMode == LFR_MODE_SBM2)
401 {
401 {
402 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
402 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
403 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
403 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
404 }
404 }
405 else if (lfrMode == LFR_MODE_BURST)
405 else if (lfrMode == LFR_MODE_BURST)
406 {
406 {
407 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
407 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
408 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
408 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
409 }
409 }
410 else
410 else
411 {
411 {
412 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
412 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
413 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
413 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
414 }
414 }
415 }
415 }
416
416
417 void init_k_coefficients_prc0( void )
417 void init_k_coefficients_prc0( void )
418 {
418 {
419 init_k_coefficients( k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0 );
419 init_k_coefficients( k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0 );
420
420
421 init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f0_norm, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_F0);
421 init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f0_norm, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_F0);
422 }
422 }
423
423
@@ -1,407 +1,407
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 = {0};
12 nb_sm_before_bp_asm_f1 nb_sm_before_f1 = {0};
13
13
14 //***
14 //***
15 // F1
15 // F1
16 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ] = {0};
16 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ] = {0};
17 ring_node_asm asm_ring_burst_sbm_f1 [ NB_RING_NODES_ASM_BURST_SBM_F1 ] = {0};
17 ring_node_asm asm_ring_burst_sbm_f1 [ NB_RING_NODES_ASM_BURST_SBM_F1 ] = {0};
18
18
19 ring_node ring_to_send_asm_f1 [ NB_RING_NODES_ASM_F1 ] = {0};
19 ring_node ring_to_send_asm_f1 [ NB_RING_NODES_ASM_F1 ] = {0};
20 int buffer_asm_f1 [ NB_RING_NODES_ASM_F1 * TOTAL_SIZE_SM ] = {0};
20 int buffer_asm_f1 [ NB_RING_NODES_ASM_F1 * TOTAL_SIZE_SM ] = {0};
21
21
22 float asm_f1_patched_norm [ TOTAL_SIZE_SM ] = {0};
22 float asm_f1_patched_norm [ TOTAL_SIZE_SM ] = {0};
23 float asm_f1_patched_burst_sbm [ TOTAL_SIZE_SM ] = {0};
23 float asm_f1_patched_burst_sbm [ TOTAL_SIZE_SM ] = {0};
24 float asm_f1_reorganized [ TOTAL_SIZE_SM ] = {0};
24 float asm_f1_reorganized [ TOTAL_SIZE_SM ] = {0};
25
25
26 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1] = {0};
26 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1] = {0};
27 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ] = {0};
27 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ] = {0};
28
28
29 float k_coeff_intercalib_f1_norm[ NB_BINS_COMPRESSED_SM_F1 * NB_K_COEFF_PER_BIN ] = {0}; // 13 * 32 = 416
29 float k_coeff_intercalib_f1_norm[ NB_BINS_COMPRESSED_SM_F1 * NB_K_COEFF_PER_BIN ] = {0}; // 13 * 32 = 416
30 float k_coeff_intercalib_f1_sbm[ NB_BINS_COMPRESSED_SM_SBM_F1 * NB_K_COEFF_PER_BIN ] = {0}; // 26 * 32 = 832
30 float k_coeff_intercalib_f1_sbm[ NB_BINS_COMPRESSED_SM_SBM_F1 * NB_K_COEFF_PER_BIN ] = {0}; // 26 * 32 = 832
31
31
32 //************
32 //************
33 // RTEMS TASKS
33 // RTEMS TASKS
34
34
35 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
35 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
36 {
36 {
37 int i;
37 int i;
38
38
39 rtems_event_set event_out;
39 rtems_event_set event_out;
40 rtems_status_code status;
40 rtems_status_code status;
41 rtems_id queue_id_prc1;
41 rtems_id queue_id_prc1;
42 asm_msg msgForPRC;
42 asm_msg msgForPRC;
43 ring_node *nodeForAveraging;
43 ring_node *nodeForAveraging;
44 ring_node *ring_node_tab[NB_SM_BEFORE_AVF0_F1];
44 ring_node *ring_node_tab[NB_SM_BEFORE_AVF0_F1];
45 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
45 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
46 ring_node_asm *current_ring_node_asm_norm_f1;
46 ring_node_asm *current_ring_node_asm_norm_f1;
47
47
48 unsigned int nb_norm_bp1;
48 unsigned int nb_norm_bp1;
49 unsigned int nb_norm_bp2;
49 unsigned int nb_norm_bp2;
50 unsigned int nb_norm_asm;
50 unsigned int nb_norm_asm;
51 unsigned int nb_sbm_bp1;
51 unsigned int nb_sbm_bp1;
52 unsigned int nb_sbm_bp2;
52 unsigned int nb_sbm_bp2;
53
53
54 event_out = EVENT_SETS_NONE_PENDING;
54 event_out = EVENT_SETS_NONE_PENDING;
55 queue_id_prc1 = RTEMS_ID_NONE;
55 queue_id_prc1 = RTEMS_ID_NONE;
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 msgForPRC.norm = current_ring_node_asm_norm_f1;
82 msgForPRC.norm = current_ring_node_asm_norm_f1;
83 msgForPRC.burst_sbm = current_ring_node_asm_burst_sbm_f1;
83 msgForPRC.burst_sbm = current_ring_node_asm_burst_sbm_f1;
84 msgForPRC.event = EVENT_SETS_NONE_PENDING; // this composite event will be sent to the PRC1 task
84 msgForPRC.event = EVENT_SETS_NONE_PENDING; // 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_AVF0_F1-1] = nodeForAveraging;
90 ring_node_tab[NB_SM_BEFORE_AVF0_F1-1] = nodeForAveraging;
91 for ( i = 1; i < (NB_SM_BEFORE_AVF0_F1); i++ )
91 for ( i = 1; i < (NB_SM_BEFORE_AVF0_F1); i++ )
92 {
92 {
93 nodeForAveraging = nodeForAveraging->previous;
93 nodeForAveraging = nodeForAveraging->previous;
94 ring_node_tab[NB_SM_BEFORE_AVF0_F1-i] = nodeForAveraging;
94 ring_node_tab[NB_SM_BEFORE_AVF0_F1 - i - 1] = 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 &msgForPRC, 1 ); // 1 => frequency channel 1
102 &msgForPRC, 1 ); // 1 => frequency channel 1
103
103
104 // update nb_average
104 // update nb_average
105 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0_F1;
105 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0_F1;
106 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0_F1;
106 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0_F1;
107 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0_F1;
107 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0_F1;
108 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0_F1;
108 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0_F1;
109 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0_F1;
109 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0_F1;
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 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_BURST_BP1_F1;
118 msgForPRC.event = msgForPRC.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 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_SBM_BP1_F1;
122 msgForPRC.event = msgForPRC.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 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_BURST_BP2_F1;
131 msgForPRC.event = msgForPRC.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 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_SBM_BP2_F1;
135 msgForPRC.event = msgForPRC.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 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_BP1_F1;
147 msgForPRC.event = msgForPRC.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 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_BP2_F1;
157 msgForPRC.event = msgForPRC.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 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_ASM_F1;
167 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_ASM_F1;
168 }
168 }
169 }
169 }
170
170
171 //*************************
171 //*************************
172 // send the message to PRC
172 // send the message to PRC
173 if (msgForPRC.event != EVENT_SETS_NONE_PENDING)
173 if (msgForPRC.event != EVENT_SETS_NONE_PENDING)
174 {
174 {
175 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForPRC, MSG_QUEUE_SIZE_PRC1);
175 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForPRC, MSG_QUEUE_SIZE_PRC1);
176 }
176 }
177
177
178 if (status != RTEMS_SUCCESSFUL) {
178 if (status != RTEMS_SUCCESSFUL) {
179 PRINTF1("in AVF1 *** Error sending message to PRC1, code %d\n", status)
179 PRINTF1("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 float nbSMInASMNORM;
199 float nbSMInASMNORM;
200 float nbSMInASMSBM;
200 float nbSMInASMSBM;
201
201
202 size = 0;
202 size = 0;
203 queue_id_send = RTEMS_ID_NONE;
203 queue_id_send = RTEMS_ID_NONE;
204 queue_id_q_p1 = RTEMS_ID_NONE;
204 queue_id_q_p1 = RTEMS_ID_NONE;
205 memset( &packet_norm_bp1, 0, sizeof(bp_packet_with_spare) );
205 memset( &packet_norm_bp1, 0, sizeof(bp_packet_with_spare) );
206 memset( &packet_norm_bp2, 0, sizeof(bp_packet) );
206 memset( &packet_norm_bp2, 0, sizeof(bp_packet) );
207 memset( &packet_sbm_bp1, 0, sizeof(bp_packet) );
207 memset( &packet_sbm_bp1, 0, sizeof(bp_packet) );
208 memset( &packet_sbm_bp2, 0, sizeof(bp_packet) );
208 memset( &packet_sbm_bp2, 0, sizeof(bp_packet) );
209
209
210 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
210 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
211 init_ring( ring_to_send_asm_f1, NB_RING_NODES_ASM_F1, (volatile int*) buffer_asm_f1, TOTAL_SIZE_SM );
211 init_ring( ring_to_send_asm_f1, NB_RING_NODES_ASM_F1, (volatile int*) buffer_asm_f1, TOTAL_SIZE_SM );
212 current_ring_node_to_send_asm_f1 = ring_to_send_asm_f1;
212 current_ring_node_to_send_asm_f1 = ring_to_send_asm_f1;
213
213
214 //*************
214 //*************
215 // NORM headers
215 // NORM headers
216 BP_init_header_with_spare( &packet_norm_bp1,
216 BP_init_header_with_spare( &packet_norm_bp1,
217 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
217 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
218 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
218 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
219 BP_init_header( &packet_norm_bp2,
219 BP_init_header( &packet_norm_bp2,
220 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
220 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
221 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
221 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
222
222
223 //***********************
223 //***********************
224 // BURST and SBM2 headers
224 // BURST and SBM2 headers
225 if ( lfrRequestedMode == LFR_MODE_BURST )
225 if ( lfrRequestedMode == LFR_MODE_BURST )
226 {
226 {
227 BP_init_header( &packet_sbm_bp1,
227 BP_init_header( &packet_sbm_bp1,
228 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
228 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
229 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
229 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
230 BP_init_header( &packet_sbm_bp2,
230 BP_init_header( &packet_sbm_bp2,
231 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
231 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
232 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
232 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
233 }
233 }
234 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
234 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
235 {
235 {
236 BP_init_header( &packet_sbm_bp1,
236 BP_init_header( &packet_sbm_bp1,
237 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
237 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
238 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
238 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
239 BP_init_header( &packet_sbm_bp2,
239 BP_init_header( &packet_sbm_bp2,
240 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
240 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
241 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
241 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
242 }
242 }
243 else
243 else
244 {
244 {
245 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
245 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
246 }
246 }
247
247
248 status = get_message_queue_id_send( &queue_id_send );
248 status = get_message_queue_id_send( &queue_id_send );
249 if (status != RTEMS_SUCCESSFUL)
249 if (status != RTEMS_SUCCESSFUL)
250 {
250 {
251 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
251 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
252 }
252 }
253 status = get_message_queue_id_prc1( &queue_id_q_p1);
253 status = get_message_queue_id_prc1( &queue_id_q_p1);
254 if (status != RTEMS_SUCCESSFUL)
254 if (status != RTEMS_SUCCESSFUL)
255 {
255 {
256 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
256 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
257 }
257 }
258
258
259 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
259 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
260
260
261 while(1){
261 while(1){
262 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
262 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
263 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
263 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
264
264
265 incomingMsg = (asm_msg*) incomingData;
265 incomingMsg = (asm_msg*) incomingData;
266
266
267 ASM_patch( incomingMsg->norm->matrix, asm_f1_patched_norm );
267 ASM_patch( incomingMsg->norm->matrix, asm_f1_patched_norm );
268 ASM_patch( incomingMsg->burst_sbm->matrix, asm_f1_patched_burst_sbm );
268 ASM_patch( incomingMsg->burst_sbm->matrix, asm_f1_patched_burst_sbm );
269
269
270 nbSMInASMNORM = incomingMsg->numberOfSMInASMNORM;
270 nbSMInASMNORM = incomingMsg->numberOfSMInASMNORM;
271 nbSMInASMSBM = incomingMsg->numberOfSMInASMSBM;
271 nbSMInASMSBM = incomingMsg->numberOfSMInASMSBM;
272
272
273 //***********
273 //***********
274 //***********
274 //***********
275 // BURST SBM2
275 // BURST SBM2
276 //***********
276 //***********
277 //***********
277 //***********
278 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) )
278 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) )
279 {
279 {
280 sid = getSID( incomingMsg->event );
280 sid = getSID( incomingMsg->event );
281 // 1) compress the matrix for Basic Parameters calculation
281 // 1) compress the matrix for Basic Parameters calculation
282 ASM_compress_reorganize_and_divide_mask( asm_f1_patched_burst_sbm, compressed_sm_sbm_f1,
282 ASM_compress_reorganize_and_divide_mask( asm_f1_patched_burst_sbm, compressed_sm_sbm_f1,
283 nbSMInASMSBM,
283 nbSMInASMSBM,
284 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
284 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
285 ASM_F1_INDICE_START, CHANNELF1);
285 ASM_F1_INDICE_START, CHANNELF1);
286 // 2) compute the BP1 set
286 // 2) compute the BP1 set
287 BP1_set( compressed_sm_sbm_f1, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp1.data );
287 BP1_set( compressed_sm_sbm_f1, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp1.data );
288 // 3) send the BP1 set
288 // 3) send the BP1 set
289 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
289 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
290 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
290 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
291 packet_sbm_bp1.pa_bia_status_info = pa_bia_status_info;
291 packet_sbm_bp1.pa_bia_status_info = pa_bia_status_info;
292 packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
292 packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
293 BP_send_s1_s2( (char *) &packet_sbm_bp1, queue_id_send,
293 BP_send_s1_s2( (char *) &packet_sbm_bp1, queue_id_send,
294 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
294 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
295 sid );
295 sid );
296 // 4) compute the BP2 set if needed
296 // 4) compute the BP2 set if needed
297 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
297 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
298 {
298 {
299 // 1) compute the BP2 set
299 // 1) compute the BP2 set
300 BP2_set( compressed_sm_sbm_f1, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp2.data );
300 BP2_set( compressed_sm_sbm_f1, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp2.data );
301 // 2) send the BP2 set
301 // 2) send the BP2 set
302 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
302 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
303 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
303 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
304 packet_sbm_bp2.pa_bia_status_info = pa_bia_status_info;
304 packet_sbm_bp2.pa_bia_status_info = pa_bia_status_info;
305 packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
305 packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
306 BP_send_s1_s2( (char *) &packet_sbm_bp2, queue_id_send,
306 BP_send_s1_s2( (char *) &packet_sbm_bp2, queue_id_send,
307 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
307 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
308 sid );
308 sid );
309 }
309 }
310 }
310 }
311
311
312 //*****
312 //*****
313 //*****
313 //*****
314 // NORM
314 // NORM
315 //*****
315 //*****
316 //*****
316 //*****
317 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
317 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
318 {
318 {
319 // 1) compress the matrix for Basic Parameters calculation
319 // 1) compress the matrix for Basic Parameters calculation
320 ASM_compress_reorganize_and_divide_mask( asm_f1_patched_norm, compressed_sm_norm_f1,
320 ASM_compress_reorganize_and_divide_mask( asm_f1_patched_norm, compressed_sm_norm_f1,
321 nbSMInASMNORM,
321 nbSMInASMNORM,
322 NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1,
322 NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1,
323 ASM_F1_INDICE_START, CHANNELF1 );
323 ASM_F1_INDICE_START, CHANNELF1 );
324 // 2) compute the BP1 set
324 // 2) compute the BP1 set
325 BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data );
325 BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data );
326 // 3) send the BP1 set
326 // 3) send the BP1 set
327 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
327 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
328 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
328 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
329 packet_norm_bp1.pa_bia_status_info = pa_bia_status_info;
329 packet_norm_bp1.pa_bia_status_info = pa_bia_status_info;
330 packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
330 packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
331 BP_send( (char *) &packet_norm_bp1, queue_id_send,
331 BP_send( (char *) &packet_norm_bp1, queue_id_send,
332 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
332 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
333 SID_NORM_BP1_F1 );
333 SID_NORM_BP1_F1 );
334 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
334 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
335 {
335 {
336 // 1) compute the BP2 set
336 // 1) compute the BP2 set
337 BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data );
337 BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data );
338 // 2) send the BP2 set
338 // 2) send the BP2 set
339 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
339 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
340 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
340 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
341 packet_norm_bp2.pa_bia_status_info = pa_bia_status_info;
341 packet_norm_bp2.pa_bia_status_info = pa_bia_status_info;
342 packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
342 packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
343 BP_send( (char *) &packet_norm_bp2, queue_id_send,
343 BP_send( (char *) &packet_norm_bp2, queue_id_send,
344 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
344 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
345 SID_NORM_BP2_F1 );
345 SID_NORM_BP2_F1 );
346 }
346 }
347 }
347 }
348
348
349 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
349 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
350 {
350 {
351 // 1) reorganize the ASM and divide
351 // 1) reorganize the ASM and divide
352 ASM_reorganize_and_divide( asm_f1_patched_norm,
352 ASM_reorganize_and_divide( asm_f1_patched_norm,
353 (float*) current_ring_node_to_send_asm_f1->buffer_address,
353 (float*) current_ring_node_to_send_asm_f1->buffer_address,
354 nbSMInASMNORM );
354 nbSMInASMNORM );
355 current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM;
355 current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM;
356 current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM;
356 current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM;
357 current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1;
357 current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1;
358
358
359 // 3) send the spectral matrix packets
359 // 3) send the spectral matrix packets
360 status = rtems_message_queue_send( queue_id_send, &current_ring_node_to_send_asm_f1, sizeof( ring_node* ) );
360 status = rtems_message_queue_send( queue_id_send, &current_ring_node_to_send_asm_f1, sizeof( ring_node* ) );
361
361
362 // change asm ring node
362 // change asm ring node
363 current_ring_node_to_send_asm_f1 = current_ring_node_to_send_asm_f1->next;
363 current_ring_node_to_send_asm_f1 = current_ring_node_to_send_asm_f1->next;
364 }
364 }
365
365
366 update_queue_max_count( queue_id_q_p1, &hk_lfr_q_p1_fifo_size_max );
366 update_queue_max_count( queue_id_q_p1, &hk_lfr_q_p1_fifo_size_max );
367
367
368 }
368 }
369 }
369 }
370
370
371 //**********
371 //**********
372 // FUNCTIONS
372 // FUNCTIONS
373
373
374 void reset_nb_sm_f1( unsigned char lfrMode )
374 void reset_nb_sm_f1( unsigned char lfrMode )
375 {
375 {
376 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * NB_SM_PER_S_F1;
376 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * NB_SM_PER_S_F1;
377 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * NB_SM_PER_S_F1;
377 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * NB_SM_PER_S_F1;
378 nb_sm_before_f1.norm_asm =
378 nb_sm_before_f1.norm_asm =
379 ( (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256) + parameter_dump_packet.sy_lfr_n_asm_p[1]) * NB_SM_PER_S_F1;
379 ( (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256) + parameter_dump_packet.sy_lfr_n_asm_p[1]) * NB_SM_PER_S_F1;
380 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * NB_SM_PER_S_F1;
380 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * NB_SM_PER_S_F1;
381 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * NB_SM_PER_S_F1;
381 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * NB_SM_PER_S_F1;
382 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * NB_SM_PER_S_F1;
382 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * NB_SM_PER_S_F1;
383 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * NB_SM_PER_S_F1;
383 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * NB_SM_PER_S_F1;
384
384
385 if (lfrMode == LFR_MODE_SBM2)
385 if (lfrMode == LFR_MODE_SBM2)
386 {
386 {
387 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
387 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
388 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
388 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
389 }
389 }
390 else if (lfrMode == LFR_MODE_BURST)
390 else if (lfrMode == LFR_MODE_BURST)
391 {
391 {
392 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
392 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
393 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
393 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
394 }
394 }
395 else
395 else
396 {
396 {
397 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
397 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
398 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
398 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
399 }
399 }
400 }
400 }
401
401
402 void init_k_coefficients_prc1( void )
402 void init_k_coefficients_prc1( void )
403 {
403 {
404 init_k_coefficients( k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1 );
404 init_k_coefficients( k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1 );
405
405
406 init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f1_norm, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_F1);
406 init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f1_norm, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_F1);
407 }
407 }
General Comments 0
You need to be logged in to leave comments. Login now