@@ -1,2 +1,2 | |||||
1 | 0f2eb26d750be2b6d8a3f5dee479b4575d3b93be LFR_basic-parameters |
|
1 | cc82265fd480dbd0344bbf888476c76602b3e9c0 LFR_basic-parameters | |
2 | 95a8d83f1d0c59f28a679e66e23464f21c12dd8a header/lfr_common_headers |
|
2 | 95a8d83f1d0c59f28a679e66e23464f21c12dd8a header/lfr_common_headers |
@@ -1,397 +1,397 | |||||
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 | #include "fsw_processing.h" |
|
11 | #include "fsw_processing.h" | |
12 |
|
12 | |||
13 | nb_sm_before_bp_asm_f0 nb_sm_before_f0; |
|
13 | nb_sm_before_bp_asm_f0 nb_sm_before_f0; | |
14 |
|
14 | |||
15 | //*** |
|
15 | //*** | |
16 | // F0 |
|
16 | // F0 | |
17 | ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ]; |
|
17 | ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ]; | |
18 | ring_node_asm asm_ring_burst_sbm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ]; |
|
18 | ring_node_asm asm_ring_burst_sbm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ]; | |
19 |
|
19 | |||
20 | ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ]; |
|
20 | ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ]; | |
21 | int buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ]; |
|
21 | int buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ]; | |
22 |
|
22 | |||
23 | float asm_f0_patched_norm [ TOTAL_SIZE_SM ]; |
|
23 | float asm_f0_patched_norm [ TOTAL_SIZE_SM ]; | |
24 | float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ]; |
|
24 | float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ]; | |
25 | float asm_f0_reorganized [ TOTAL_SIZE_SM ]; |
|
25 | float asm_f0_reorganized [ TOTAL_SIZE_SM ]; | |
26 |
|
26 | |||
27 | char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; |
|
27 | char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; | |
28 | float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0]; |
|
28 | float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0]; | |
29 | float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ]; |
|
29 | float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ]; | |
30 |
|
30 | |||
31 | float k_coeff_intercalib_f0_norm[ NB_BINS_COMPRESSED_SM_F0 * NB_K_COEFF_PER_BIN ]; // 11 * 32 = 352 |
|
31 | float k_coeff_intercalib_f0_norm[ NB_BINS_COMPRESSED_SM_F0 * NB_K_COEFF_PER_BIN ]; // 11 * 32 = 352 | |
32 | float k_coeff_intercalib_f0_sbm[ NB_BINS_COMPRESSED_SM_SBM_F0 * NB_K_COEFF_PER_BIN ]; // 22 * 32 = 704 |
|
32 | float k_coeff_intercalib_f0_sbm[ NB_BINS_COMPRESSED_SM_SBM_F0 * NB_K_COEFF_PER_BIN ]; // 22 * 32 = 704 | |
33 |
|
33 | |||
34 | //************ |
|
34 | //************ | |
35 | // RTEMS TASKS |
|
35 | // RTEMS TASKS | |
36 |
|
36 | |||
37 | rtems_task avf0_task( rtems_task_argument lfrRequestedMode ) |
|
37 | rtems_task avf0_task( rtems_task_argument lfrRequestedMode ) | |
38 | { |
|
38 | { | |
39 | int i; |
|
39 | int i; | |
40 |
|
40 | |||
41 | rtems_event_set event_out; |
|
41 | rtems_event_set event_out; | |
42 | rtems_status_code status; |
|
42 | rtems_status_code status; | |
43 | rtems_id queue_id_prc0; |
|
43 | rtems_id queue_id_prc0; | |
44 | asm_msg msgForMATR; |
|
44 | asm_msg msgForMATR; | |
45 | ring_node *nodeForAveraging; |
|
45 | ring_node *nodeForAveraging; | |
46 | ring_node *ring_node_tab[8]; |
|
46 | ring_node *ring_node_tab[8]; | |
47 | ring_node_asm *current_ring_node_asm_burst_sbm_f0; |
|
47 | ring_node_asm *current_ring_node_asm_burst_sbm_f0; | |
48 | ring_node_asm *current_ring_node_asm_norm_f0; |
|
48 | ring_node_asm *current_ring_node_asm_norm_f0; | |
49 |
|
49 | |||
50 | unsigned int nb_norm_bp1; |
|
50 | unsigned int nb_norm_bp1; | |
51 | unsigned int nb_norm_bp2; |
|
51 | unsigned int nb_norm_bp2; | |
52 | unsigned int nb_norm_asm; |
|
52 | unsigned int nb_norm_asm; | |
53 | unsigned int nb_sbm_bp1; |
|
53 | unsigned int nb_sbm_bp1; | |
54 | unsigned int nb_sbm_bp2; |
|
54 | unsigned int nb_sbm_bp2; | |
55 |
|
55 | |||
56 | nb_norm_bp1 = 0; |
|
56 | nb_norm_bp1 = 0; | |
57 | nb_norm_bp2 = 0; |
|
57 | nb_norm_bp2 = 0; | |
58 | nb_norm_asm = 0; |
|
58 | nb_norm_asm = 0; | |
59 | nb_sbm_bp1 = 0; |
|
59 | nb_sbm_bp1 = 0; | |
60 | nb_sbm_bp2 = 0; |
|
60 | nb_sbm_bp2 = 0; | |
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 | msgForMATR.norm = current_ring_node_asm_norm_f0; |
|
81 | msgForMATR.norm = current_ring_node_asm_norm_f0; | |
82 | msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0; |
|
82 | msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0; | |
83 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC0 task |
|
83 | msgForMATR.event = 0x00; // 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-1] = nodeForAveraging; |
|
89 | ring_node_tab[NB_SM_BEFORE_AVF0-1] = nodeForAveraging; | |
90 | for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ ) |
|
90 | for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ ) | |
91 | { |
|
91 | { | |
92 | nodeForAveraging = nodeForAveraging->previous; |
|
92 | nodeForAveraging = nodeForAveraging->previous; | |
93 | ring_node_tab[NB_SM_BEFORE_AVF0-i] = nodeForAveraging; |
|
93 | ring_node_tab[NB_SM_BEFORE_AVF0-i] = 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 | &msgForMATR ); |
|
101 | &msgForMATR ); | |
102 |
|
102 | |||
103 | // update nb_average |
|
103 | // update nb_average | |
104 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0; |
|
104 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0; | |
105 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0; |
|
105 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0; | |
106 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0; |
|
106 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0; | |
107 | nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0; |
|
107 | nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0; | |
108 | nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0; |
|
108 | nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0; | |
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 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0; |
|
117 | msgForMATR.event = msgForMATR.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 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0; |
|
121 | msgForMATR.event = msgForMATR.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 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0; |
|
130 | msgForMATR.event = msgForMATR.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 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0; |
|
134 | msgForMATR.event = msgForMATR.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 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0; |
|
146 | msgForMATR.event = msgForMATR.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 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0; |
|
156 | msgForMATR.event = msgForMATR.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 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0; |
|
166 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0; | |
167 | } |
|
167 | } | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | //************************* |
|
170 | //************************* | |
171 | // send the message to MATR |
|
171 | // send the message to MATR | |
172 | if (msgForMATR.event != 0x00) |
|
172 | if (msgForMATR.event != 0x00) | |
173 | { |
|
173 | { | |
174 | status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0); |
|
174 | status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0); | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | if (status != RTEMS_SUCCESSFUL) { |
|
177 | if (status != RTEMS_SUCCESSFUL) { | |
178 | printf("in AVF0 *** Error sending message to MATR, code %d\n", status); |
|
178 | printf("in AVF0 *** Error sending message to MATR, 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 |
|
198 | |||
199 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU |
|
199 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU | |
200 | init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM ); |
|
200 | init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM ); | |
201 | current_ring_node_to_send_asm_f0 = ring_to_send_asm_f0; |
|
201 | current_ring_node_to_send_asm_f0 = ring_to_send_asm_f0; | |
202 |
|
202 | |||
203 | //************* |
|
203 | //************* | |
204 | // NORM headers |
|
204 | // NORM headers | |
205 | BP_init_header_with_spare( &packet_norm_bp1, |
|
205 | BP_init_header_with_spare( &packet_norm_bp1, | |
206 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0, |
|
206 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0, | |
207 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 ); |
|
207 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 ); | |
208 | BP_init_header( &packet_norm_bp2, |
|
208 | BP_init_header( &packet_norm_bp2, | |
209 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0, |
|
209 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0, | |
210 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0); |
|
210 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0); | |
211 |
|
211 | |||
212 | //**************************** |
|
212 | //**************************** | |
213 | // BURST SBM1 and SBM2 headers |
|
213 | // BURST SBM1 and SBM2 headers | |
214 | if ( lfrRequestedMode == LFR_MODE_BURST ) |
|
214 | if ( lfrRequestedMode == LFR_MODE_BURST ) | |
215 | { |
|
215 | { | |
216 | BP_init_header( &packet_sbm_bp1, |
|
216 | BP_init_header( &packet_sbm_bp1, | |
217 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0, |
|
217 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0, | |
218 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
218 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
219 | BP_init_header( &packet_sbm_bp2, |
|
219 | BP_init_header( &packet_sbm_bp2, | |
220 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0, |
|
220 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0, | |
221 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
221 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
222 | } |
|
222 | } | |
223 | else if ( lfrRequestedMode == LFR_MODE_SBM1 ) |
|
223 | else if ( lfrRequestedMode == LFR_MODE_SBM1 ) | |
224 | { |
|
224 | { | |
225 | BP_init_header( &packet_sbm_bp1, |
|
225 | BP_init_header( &packet_sbm_bp1, | |
226 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0, |
|
226 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0, | |
227 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
227 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
228 | BP_init_header( &packet_sbm_bp2, |
|
228 | BP_init_header( &packet_sbm_bp2, | |
229 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0, |
|
229 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0, | |
230 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
230 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
231 | } |
|
231 | } | |
232 | else if ( lfrRequestedMode == LFR_MODE_SBM2 ) |
|
232 | else if ( lfrRequestedMode == LFR_MODE_SBM2 ) | |
233 | { |
|
233 | { | |
234 | BP_init_header( &packet_sbm_bp1, |
|
234 | BP_init_header( &packet_sbm_bp1, | |
235 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0, |
|
235 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0, | |
236 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
236 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
237 | BP_init_header( &packet_sbm_bp2, |
|
237 | BP_init_header( &packet_sbm_bp2, | |
238 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0, |
|
238 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0, | |
239 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
239 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
240 | } |
|
240 | } | |
241 | else |
|
241 | else | |
242 | { |
|
242 | { | |
243 | PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) |
|
243 | PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) | |
244 | } |
|
244 | } | |
245 |
|
245 | |||
246 | status = get_message_queue_id_send( &queue_id ); |
|
246 | status = get_message_queue_id_send( &queue_id ); | |
247 | if (status != RTEMS_SUCCESSFUL) |
|
247 | if (status != RTEMS_SUCCESSFUL) | |
248 | { |
|
248 | { | |
249 | PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status) |
|
249 | PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status) | |
250 | } |
|
250 | } | |
251 | status = get_message_queue_id_prc0( &queue_id_q_p0); |
|
251 | status = get_message_queue_id_prc0( &queue_id_q_p0); | |
252 | if (status != RTEMS_SUCCESSFUL) |
|
252 | if (status != RTEMS_SUCCESSFUL) | |
253 | { |
|
253 | { | |
254 | PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status) |
|
254 | PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status) | |
255 | } |
|
255 | } | |
256 |
|
256 | |||
257 | BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) |
|
257 | BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) | |
258 |
|
258 | |||
259 | while(1){ |
|
259 | while(1){ | |
260 | status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************ |
|
260 | status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************ | |
261 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 |
|
261 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 | |
262 |
|
262 | |||
263 | incomingMsg = (asm_msg*) incomingData; |
|
263 | incomingMsg = (asm_msg*) incomingData; | |
264 |
|
264 | |||
265 | ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm ); |
|
265 | ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm ); | |
266 | ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm ); |
|
266 | ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm ); | |
267 |
|
267 | |||
268 | //**************** |
|
268 | //**************** | |
269 | //**************** |
|
269 | //**************** | |
270 | // BURST SBM1 SBM2 |
|
270 | // BURST SBM1 SBM2 | |
271 | //**************** |
|
271 | //**************** | |
272 | //**************** |
|
272 | //**************** | |
273 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) ) |
|
273 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) ) | |
274 | { |
|
274 | { | |
275 | sid = getSID( incomingMsg->event ); |
|
275 | sid = getSID( incomingMsg->event ); | |
276 | // 1) compress the matrix for Basic Parameters calculation |
|
276 | // 1) compress the matrix for Basic Parameters calculation | |
277 | ASM_compress_reorganize_and_divide( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0, |
|
277 | ASM_compress_reorganize_and_divide( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0, | |
278 | nb_sm_before_f0.burst_sbm_bp1, |
|
278 | nb_sm_before_f0.burst_sbm_bp1, | |
279 | NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0, |
|
279 | NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0, | |
280 | ASM_F0_INDICE_START); |
|
280 | ASM_F0_INDICE_START); | |
281 | // 2) compute the BP1 set |
|
281 | // 2) compute the BP1 set | |
282 |
|
|
282 | BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data ); | |
283 | // 3) send the BP1 set |
|
283 | // 3) send the BP1 set | |
284 | set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
284 | set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
285 | set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
285 | set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
286 | BP_send( (char *) &packet_sbm_bp1, queue_id, |
|
286 | BP_send( (char *) &packet_sbm_bp1, queue_id, | |
287 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA, |
|
287 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA, | |
288 | sid); |
|
288 | sid); | |
289 | // 4) compute the BP2 set if needed |
|
289 | // 4) compute the BP2 set if needed | |
290 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) ) |
|
290 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) ) | |
291 | { |
|
291 | { | |
292 | // 1) compute the BP2 set |
|
292 | // 1) compute the BP2 set | |
293 | BP2_set( compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data ); |
|
293 | BP2_set( compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data ); | |
294 | // 2) send the BP2 set |
|
294 | // 2) send the BP2 set | |
295 | set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
295 | set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
296 | set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
296 | set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
297 | BP_send( (char *) &packet_sbm_bp2, queue_id, |
|
297 | BP_send( (char *) &packet_sbm_bp2, queue_id, | |
298 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA, |
|
298 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA, | |
299 | sid); |
|
299 | sid); | |
300 | } |
|
300 | } | |
301 | } |
|
301 | } | |
302 |
|
302 | |||
303 | //***** |
|
303 | //***** | |
304 | //***** |
|
304 | //***** | |
305 | // NORM |
|
305 | // NORM | |
306 | //***** |
|
306 | //***** | |
307 | //***** |
|
307 | //***** | |
308 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0) |
|
308 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0) | |
309 | { |
|
309 | { | |
310 | // 1) compress the matrix for Basic Parameters calculation |
|
310 | // 1) compress the matrix for Basic Parameters calculation | |
311 | ASM_compress_reorganize_and_divide( asm_f0_patched_norm, compressed_sm_norm_f0, |
|
311 | ASM_compress_reorganize_and_divide( asm_f0_patched_norm, compressed_sm_norm_f0, | |
312 | nb_sm_before_f0.norm_bp1, |
|
312 | nb_sm_before_f0.norm_bp1, | |
313 | NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, |
|
313 | NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, | |
314 | ASM_F0_INDICE_START ); |
|
314 | ASM_F0_INDICE_START ); | |
315 | // 2) compute the BP1 set |
|
315 | // 2) compute the BP1 set | |
316 |
|
|
316 | BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data ); | |
317 | // 3) send the BP1 set |
|
317 | // 3) send the BP1 set | |
318 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
318 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
319 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
319 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
320 | BP_send( (char *) &packet_norm_bp1, queue_id, |
|
320 | BP_send( (char *) &packet_norm_bp1, queue_id, | |
321 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA, |
|
321 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA, | |
322 | SID_NORM_BP1_F0 ); |
|
322 | SID_NORM_BP1_F0 ); | |
323 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0) |
|
323 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0) | |
324 | { |
|
324 | { | |
325 | // 1) compute the BP2 set using the same ASM as the one used for BP1 |
|
325 | // 1) compute the BP2 set using the same ASM as the one used for BP1 | |
326 | BP2_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp2.data ); |
|
326 | BP2_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp2.data ); | |
327 | // 2) send the BP2 set |
|
327 | // 2) send the BP2 set | |
328 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
328 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
329 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
329 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
330 | BP_send( (char *) &packet_norm_bp2, queue_id, |
|
330 | BP_send( (char *) &packet_norm_bp2, queue_id, | |
331 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA, |
|
331 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA, | |
332 | SID_NORM_BP2_F0); |
|
332 | SID_NORM_BP2_F0); | |
333 | } |
|
333 | } | |
334 | } |
|
334 | } | |
335 |
|
335 | |||
336 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0) |
|
336 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0) | |
337 | { |
|
337 | { | |
338 | // 1) reorganize the ASM and divide |
|
338 | // 1) reorganize the ASM and divide | |
339 | ASM_reorganize_and_divide( asm_f0_patched_norm, |
|
339 | ASM_reorganize_and_divide( asm_f0_patched_norm, | |
340 | asm_f0_reorganized, |
|
340 | asm_f0_reorganized, | |
341 | nb_sm_before_f0.norm_bp1 ); |
|
341 | nb_sm_before_f0.norm_bp1 ); | |
342 | // 2) convert the float array in a char array |
|
342 | // 2) convert the float array in a char array | |
343 | ASM_convert( asm_f0_reorganized, (char*) current_ring_node_to_send_asm_f0->buffer_address ); |
|
343 | ASM_convert( asm_f0_reorganized, (char*) current_ring_node_to_send_asm_f0->buffer_address ); | |
344 | current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM; |
|
344 | current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM; | |
345 | current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM; |
|
345 | current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM; | |
346 | current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0; |
|
346 | current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0; | |
347 |
|
347 | |||
348 | // 3) send the spectral matrix packets |
|
348 | // 3) send the spectral matrix packets | |
349 | status = rtems_message_queue_send( queue_id, ¤t_ring_node_to_send_asm_f0, sizeof( ring_node* ) ); |
|
349 | status = rtems_message_queue_send( queue_id, ¤t_ring_node_to_send_asm_f0, sizeof( ring_node* ) ); | |
350 | // change asm ring node |
|
350 | // change asm ring node | |
351 | current_ring_node_to_send_asm_f0 = current_ring_node_to_send_asm_f0->next; |
|
351 | current_ring_node_to_send_asm_f0 = current_ring_node_to_send_asm_f0->next; | |
352 | } |
|
352 | } | |
353 | } |
|
353 | } | |
354 | } |
|
354 | } | |
355 |
|
355 | |||
356 | //********** |
|
356 | //********** | |
357 | // FUNCTIONS |
|
357 | // FUNCTIONS | |
358 |
|
358 | |||
359 | void reset_nb_sm_f0( unsigned char lfrMode ) |
|
359 | void reset_nb_sm_f0( unsigned char lfrMode ) | |
360 | { |
|
360 | { | |
361 | nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96; |
|
361 | nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96; | |
362 | nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96; |
|
362 | nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96; | |
363 | nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96; |
|
363 | nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96; | |
364 | nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit |
|
364 | nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit | |
365 | nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96; |
|
365 | nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96; | |
366 | nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96; |
|
366 | nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96; | |
367 | nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96; |
|
367 | nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96; | |
368 | nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96; |
|
368 | nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96; | |
369 | nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96; |
|
369 | nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96; | |
370 |
|
370 | |||
371 | if (lfrMode == LFR_MODE_SBM1) |
|
371 | if (lfrMode == LFR_MODE_SBM1) | |
372 | { |
|
372 | { | |
373 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1; |
|
373 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1; | |
374 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2; |
|
374 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2; | |
375 | } |
|
375 | } | |
376 | else if (lfrMode == LFR_MODE_SBM2) |
|
376 | else if (lfrMode == LFR_MODE_SBM2) | |
377 | { |
|
377 | { | |
378 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1; |
|
378 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1; | |
379 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2; |
|
379 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2; | |
380 | } |
|
380 | } | |
381 | else if (lfrMode == LFR_MODE_BURST) |
|
381 | else if (lfrMode == LFR_MODE_BURST) | |
382 | { |
|
382 | { | |
383 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; |
|
383 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; | |
384 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; |
|
384 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; | |
385 | } |
|
385 | } | |
386 | else |
|
386 | else | |
387 | { |
|
387 | { | |
388 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; |
|
388 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; | |
389 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; |
|
389 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; | |
390 | } |
|
390 | } | |
391 | } |
|
391 | } | |
392 |
|
392 | |||
393 | void init_k_coefficients_f0( void ) |
|
393 | void init_k_coefficients_f0( void ) | |
394 | { |
|
394 | { | |
395 | init_k_coefficients( k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0 ); |
|
395 | init_k_coefficients( k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0 ); | |
396 | init_k_coefficients( k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
396 | init_k_coefficients( k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0); | |
397 | } |
|
397 | } |
@@ -1,379 +1,385 | |||||
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 ]; | |||
|
25 | float asm_f1_patched_burst_sbm [ TOTAL_SIZE_SM ]; | |||
24 | float asm_f1_reorganized [ TOTAL_SIZE_SM ]; |
|
26 | float asm_f1_reorganized [ TOTAL_SIZE_SM ]; | |
|
27 | ||||
25 | char asm_f1_char [ TOTAL_SIZE_SM * 2 ]; |
|
28 | char asm_f1_char [ TOTAL_SIZE_SM * 2 ]; | |
26 | float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1]; |
|
29 | float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1]; | |
27 | float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ]; |
|
30 | float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ]; | |
28 |
|
31 | |||
29 | 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 | |
30 | 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 | |
31 |
|
34 | |||
32 | //************ |
|
35 | //************ | |
33 | // RTEMS TASKS |
|
36 | // RTEMS TASKS | |
34 |
|
37 | |||
35 | rtems_task avf1_task( rtems_task_argument lfrRequestedMode ) |
|
38 | rtems_task avf1_task( rtems_task_argument lfrRequestedMode ) | |
36 | { |
|
39 | { | |
37 | int i; |
|
40 | int i; | |
38 |
|
41 | |||
39 | rtems_event_set event_out; |
|
42 | rtems_event_set event_out; | |
40 | rtems_status_code status; |
|
43 | rtems_status_code status; | |
41 | rtems_id queue_id_prc1; |
|
44 | rtems_id queue_id_prc1; | |
42 | asm_msg msgForMATR; |
|
45 | asm_msg msgForMATR; | |
43 | ring_node *nodeForAveraging; |
|
46 | ring_node *nodeForAveraging; | |
44 | ring_node *ring_node_tab[NB_SM_BEFORE_AVF0]; |
|
47 | ring_node *ring_node_tab[NB_SM_BEFORE_AVF0]; | |
45 | ring_node_asm *current_ring_node_asm_burst_sbm_f1; |
|
48 | ring_node_asm *current_ring_node_asm_burst_sbm_f1; | |
46 | ring_node_asm *current_ring_node_asm_norm_f1; |
|
49 | ring_node_asm *current_ring_node_asm_norm_f1; | |
47 |
|
50 | |||
48 | unsigned int nb_norm_bp1; |
|
51 | unsigned int nb_norm_bp1; | |
49 | unsigned int nb_norm_bp2; |
|
52 | unsigned int nb_norm_bp2; | |
50 | unsigned int nb_norm_asm; |
|
53 | unsigned int nb_norm_asm; | |
51 | unsigned int nb_sbm_bp1; |
|
54 | unsigned int nb_sbm_bp1; | |
52 | unsigned int nb_sbm_bp2; |
|
55 | unsigned int nb_sbm_bp2; | |
53 |
|
56 | |||
54 | nb_norm_bp1 = 0; |
|
57 | nb_norm_bp1 = 0; | |
55 | nb_norm_bp2 = 0; |
|
58 | nb_norm_bp2 = 0; | |
56 | nb_norm_asm = 0; |
|
59 | nb_norm_asm = 0; | |
57 | nb_sbm_bp1 = 0; |
|
60 | nb_sbm_bp1 = 0; | |
58 | nb_sbm_bp2 = 0; |
|
61 | nb_sbm_bp2 = 0; | |
59 |
|
62 | |||
60 | 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 | |
61 | 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 ); | |
62 | 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 ); | |
63 | current_ring_node_asm_norm_f1 = asm_ring_norm_f1; |
|
66 | current_ring_node_asm_norm_f1 = asm_ring_norm_f1; | |
64 | 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; | |
65 |
|
68 | |||
66 | BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) |
|
69 | BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) | |
67 |
|
70 | |||
68 | status = get_message_queue_id_prc1( &queue_id_prc1 ); |
|
71 | status = get_message_queue_id_prc1( &queue_id_prc1 ); | |
69 | if (status != RTEMS_SUCCESSFUL) |
|
72 | if (status != RTEMS_SUCCESSFUL) | |
70 | { |
|
73 | { | |
71 | 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) | |
72 | } |
|
75 | } | |
73 |
|
76 | |||
74 | while(1){ |
|
77 | while(1){ | |
75 | 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 | |
76 |
|
79 | |||
77 | //**************************************** |
|
80 | //**************************************** | |
78 | // initialize the mesage for the MATR task |
|
81 | // initialize the mesage for the MATR task | |
79 | msgForMATR.norm = current_ring_node_asm_norm_f1; |
|
82 | msgForMATR.norm = current_ring_node_asm_norm_f1; | |
80 | msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1; |
|
83 | msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1; | |
81 | 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 | |
82 | // |
|
85 | // | |
83 | //**************************************** |
|
86 | //**************************************** | |
84 |
|
87 | |||
85 | nodeForAveraging = getRingNodeForAveraging( 1 ); |
|
88 | nodeForAveraging = getRingNodeForAveraging( 1 ); | |
86 |
|
89 | |||
87 | ring_node_tab[NB_SM_BEFORE_AVF1-1] = nodeForAveraging; |
|
90 | ring_node_tab[NB_SM_BEFORE_AVF1-1] = nodeForAveraging; | |
88 | for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ ) |
|
91 | for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ ) | |
89 | { |
|
92 | { | |
90 | nodeForAveraging = nodeForAveraging->previous; |
|
93 | nodeForAveraging = nodeForAveraging->previous; | |
91 | ring_node_tab[NB_SM_BEFORE_AVF1-i] = nodeForAveraging; |
|
94 | ring_node_tab[NB_SM_BEFORE_AVF1-i] = nodeForAveraging; | |
92 | } |
|
95 | } | |
93 |
|
96 | |||
94 | // 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 | |
95 | SM_average( current_ring_node_asm_norm_f1->matrix, |
|
98 | SM_average( current_ring_node_asm_norm_f1->matrix, | |
96 | current_ring_node_asm_burst_sbm_f1->matrix, |
|
99 | current_ring_node_asm_burst_sbm_f1->matrix, | |
97 | ring_node_tab, |
|
100 | ring_node_tab, | |
98 | nb_norm_bp1, nb_sbm_bp1, |
|
101 | nb_norm_bp1, nb_sbm_bp1, | |
99 | &msgForMATR ); |
|
102 | &msgForMATR ); | |
100 |
|
103 | |||
101 | // update nb_average |
|
104 | // update nb_average | |
102 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1; |
|
105 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1; | |
103 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1; |
|
106 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1; | |
104 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1; |
|
107 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1; | |
105 | nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1; |
|
108 | nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1; | |
106 | nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1; |
|
109 | nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1; | |
107 |
|
110 | |||
108 | if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1) |
|
111 | if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1) | |
109 | { |
|
112 | { | |
110 | nb_sbm_bp1 = 0; |
|
113 | nb_sbm_bp1 = 0; | |
111 | // set another ring for the ASM storage |
|
114 | // set another ring for the ASM storage | |
112 | 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; | |
113 | if ( lfrCurrentMode == LFR_MODE_BURST ) |
|
116 | if ( lfrCurrentMode == LFR_MODE_BURST ) | |
114 | { |
|
117 | { | |
115 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1; |
|
118 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1; | |
116 | } |
|
119 | } | |
117 | else if ( lfrCurrentMode == LFR_MODE_SBM2 ) |
|
120 | else if ( lfrCurrentMode == LFR_MODE_SBM2 ) | |
118 | { |
|
121 | { | |
119 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1; |
|
122 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1; | |
120 | } |
|
123 | } | |
121 | } |
|
124 | } | |
122 |
|
125 | |||
123 | if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2) |
|
126 | if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2) | |
124 | { |
|
127 | { | |
125 | nb_sbm_bp2 = 0; |
|
128 | nb_sbm_bp2 = 0; | |
126 | if ( lfrCurrentMode == LFR_MODE_BURST ) |
|
129 | if ( lfrCurrentMode == LFR_MODE_BURST ) | |
127 | { |
|
130 | { | |
128 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1; |
|
131 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1; | |
129 | } |
|
132 | } | |
130 | else if ( lfrCurrentMode == LFR_MODE_SBM2 ) |
|
133 | else if ( lfrCurrentMode == LFR_MODE_SBM2 ) | |
131 | { |
|
134 | { | |
132 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1; |
|
135 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1; | |
133 | } |
|
136 | } | |
134 | } |
|
137 | } | |
135 |
|
138 | |||
136 | if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1) |
|
139 | if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1) | |
137 | { |
|
140 | { | |
138 | nb_norm_bp1 = 0; |
|
141 | nb_norm_bp1 = 0; | |
139 | // set another ring for the ASM storage |
|
142 | // set another ring for the ASM storage | |
140 | 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; | |
141 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
144 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
142 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
145 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
143 | { |
|
146 | { | |
144 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1; |
|
147 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1; | |
145 | } |
|
148 | } | |
146 | } |
|
149 | } | |
147 |
|
150 | |||
148 | if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2) |
|
151 | if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2) | |
149 | { |
|
152 | { | |
150 | nb_norm_bp2 = 0; |
|
153 | nb_norm_bp2 = 0; | |
151 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
154 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
152 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
155 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
153 | { |
|
156 | { | |
154 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1; |
|
157 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1; | |
155 | } |
|
158 | } | |
156 | } |
|
159 | } | |
157 |
|
160 | |||
158 | if (nb_norm_asm == nb_sm_before_f1.norm_asm) |
|
161 | if (nb_norm_asm == nb_sm_before_f1.norm_asm) | |
159 | { |
|
162 | { | |
160 | nb_norm_asm = 0; |
|
163 | nb_norm_asm = 0; | |
161 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
164 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
162 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
165 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
163 | { |
|
166 | { | |
164 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1; |
|
167 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1; | |
165 | } |
|
168 | } | |
166 | } |
|
169 | } | |
167 |
|
170 | |||
168 | //************************* |
|
171 | //************************* | |
169 | // send the message to MATR |
|
172 | // send the message to MATR | |
170 | if (msgForMATR.event != 0x00) |
|
173 | if (msgForMATR.event != 0x00) | |
171 | { |
|
174 | { | |
172 | 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); | |
173 | } |
|
176 | } | |
174 |
|
177 | |||
175 | if (status != RTEMS_SUCCESSFUL) { |
|
178 | if (status != RTEMS_SUCCESSFUL) { | |
176 | 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); | |
177 | } |
|
180 | } | |
178 | } |
|
181 | } | |
179 | } |
|
182 | } | |
180 |
|
183 | |||
181 | rtems_task prc1_task( rtems_task_argument lfrRequestedMode ) |
|
184 | rtems_task prc1_task( rtems_task_argument lfrRequestedMode ) | |
182 | { |
|
185 | { | |
183 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
186 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
184 | size_t size; // size of the incoming TC packet |
|
187 | size_t size; // size of the incoming TC packet | |
185 | asm_msg *incomingMsg; |
|
188 | asm_msg *incomingMsg; | |
186 | // |
|
189 | // | |
187 | unsigned char sid; |
|
190 | unsigned char sid; | |
188 | rtems_status_code status; |
|
191 | rtems_status_code status; | |
189 | rtems_id queue_id_send; |
|
192 | rtems_id queue_id_send; | |
190 | rtems_id queue_id_q_p1; |
|
193 | rtems_id queue_id_q_p1; | |
191 | bp_packet_with_spare packet_norm_bp1; |
|
194 | bp_packet_with_spare packet_norm_bp1; | |
192 | bp_packet packet_norm_bp2; |
|
195 | bp_packet packet_norm_bp2; | |
193 | bp_packet packet_sbm_bp1; |
|
196 | bp_packet packet_sbm_bp1; | |
194 | bp_packet packet_sbm_bp2; |
|
197 | bp_packet packet_sbm_bp2; | |
195 | ring_node *current_ring_node_to_send_asm_f1; |
|
198 | ring_node *current_ring_node_to_send_asm_f1; | |
196 |
|
199 | |||
197 | unsigned long long int localTime; |
|
200 | unsigned long long int localTime; | |
198 |
|
201 | |||
199 | // 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 | |
200 | 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 ); | |
201 | 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; | |
202 |
|
205 | |||
203 | //************* |
|
206 | //************* | |
204 | // NORM headers |
|
207 | // NORM headers | |
205 | BP_init_header_with_spare( &packet_norm_bp1, |
|
208 | BP_init_header_with_spare( &packet_norm_bp1, | |
206 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1, |
|
209 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1, | |
207 | 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 ); | |
208 | BP_init_header( &packet_norm_bp2, |
|
211 | BP_init_header( &packet_norm_bp2, | |
209 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1, |
|
212 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1, | |
210 | 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); | |
211 |
|
214 | |||
212 | //*********************** |
|
215 | //*********************** | |
213 | // BURST and SBM2 headers |
|
216 | // BURST and SBM2 headers | |
214 | if ( lfrRequestedMode == LFR_MODE_BURST ) |
|
217 | if ( lfrRequestedMode == LFR_MODE_BURST ) | |
215 | { |
|
218 | { | |
216 | BP_init_header( &packet_sbm_bp1, |
|
219 | BP_init_header( &packet_sbm_bp1, | |
217 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1, |
|
220 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1, | |
218 | 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); | |
219 | BP_init_header( &packet_sbm_bp2, |
|
222 | BP_init_header( &packet_sbm_bp2, | |
220 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1, |
|
223 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1, | |
221 | 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); | |
222 | } |
|
225 | } | |
223 | else if ( lfrRequestedMode == LFR_MODE_SBM2 ) |
|
226 | else if ( lfrRequestedMode == LFR_MODE_SBM2 ) | |
224 | { |
|
227 | { | |
225 | BP_init_header( &packet_sbm_bp1, |
|
228 | BP_init_header( &packet_sbm_bp1, | |
226 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1, |
|
229 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1, | |
227 | 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); | |
228 | BP_init_header( &packet_sbm_bp2, |
|
231 | BP_init_header( &packet_sbm_bp2, | |
229 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1, |
|
232 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1, | |
230 | 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); | |
231 | } |
|
234 | } | |
232 | else |
|
235 | else | |
233 | { |
|
236 | { | |
234 | 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) | |
235 | } |
|
238 | } | |
236 |
|
239 | |||
237 | status = get_message_queue_id_send( &queue_id_send ); |
|
240 | status = get_message_queue_id_send( &queue_id_send ); | |
238 | if (status != RTEMS_SUCCESSFUL) |
|
241 | if (status != RTEMS_SUCCESSFUL) | |
239 | { |
|
242 | { | |
240 | 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) | |
241 | } |
|
244 | } | |
242 | status = get_message_queue_id_prc1( &queue_id_q_p1); |
|
245 | status = get_message_queue_id_prc1( &queue_id_q_p1); | |
243 | if (status != RTEMS_SUCCESSFUL) |
|
246 | if (status != RTEMS_SUCCESSFUL) | |
244 | { |
|
247 | { | |
245 | 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) | |
246 | } |
|
249 | } | |
247 |
|
250 | |||
248 | BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) |
|
251 | BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) | |
249 |
|
252 | |||
250 | while(1){ |
|
253 | while(1){ | |
251 | status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************ |
|
254 | status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************ | |
252 | 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 | |
253 |
|
256 | |||
254 | incomingMsg = (asm_msg*) incomingData; |
|
257 | incomingMsg = (asm_msg*) incomingData; | |
255 |
|
258 | |||
|
259 | ASM_patch( incomingMsg->norm->matrix, asm_f1_patched_norm ); | |||
|
260 | ASM_patch( incomingMsg->burst_sbm->matrix, asm_f1_patched_burst_sbm ); | |||
|
261 | ||||
256 | localTime = getTimeAsUnsignedLongLongInt( ); |
|
262 | localTime = getTimeAsUnsignedLongLongInt( ); | |
257 | //*********** |
|
263 | //*********** | |
258 | //*********** |
|
264 | //*********** | |
259 | // BURST SBM2 |
|
265 | // BURST SBM2 | |
260 | //*********** |
|
266 | //*********** | |
261 | //*********** |
|
267 | //*********** | |
262 | 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) ) | |
263 | { |
|
269 | { | |
264 | sid = getSID( incomingMsg->event ); |
|
270 | sid = getSID( incomingMsg->event ); | |
265 | // 1) compress the matrix for Basic Parameters calculation |
|
271 | // 1) compress the matrix for Basic Parameters calculation | |
266 |
ASM_compress_reorganize_and_divide( |
|
272 | ASM_compress_reorganize_and_divide( asm_f1_patched_burst_sbm, compressed_sm_sbm_f1, | |
267 | nb_sm_before_f1.burst_sbm_bp1, |
|
273 | nb_sm_before_f1.burst_sbm_bp1, | |
268 | 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, | |
269 | ASM_F1_INDICE_START); |
|
275 | ASM_F1_INDICE_START); | |
270 | // 2) compute the BP1 set |
|
276 | // 2) compute the BP1 set | |
271 | 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 ); | |
272 | // 3) send the BP1 set |
|
278 | // 3) send the BP1 set | |
273 | set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
279 | set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
274 | set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
280 | set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
275 | BP_send( (char *) &packet_sbm_bp1, queue_id_send, |
|
281 | BP_send( (char *) &packet_sbm_bp1, queue_id_send, | |
276 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA, |
|
282 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA, | |
277 | sid ); |
|
283 | sid ); | |
278 | // 4) compute the BP2 set if needed |
|
284 | // 4) compute the BP2 set if needed | |
279 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) ) |
|
285 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) ) | |
280 | { |
|
286 | { | |
281 | // 1) compute the BP2 set |
|
287 | // 1) compute the BP2 set | |
282 | BP2_set( compressed_sm_sbm_f1, NB_BINS_COMPRESSED_SM_SBM_F1, packet_norm_bp2.data ); |
|
288 | BP2_set( compressed_sm_sbm_f1, NB_BINS_COMPRESSED_SM_SBM_F1, packet_norm_bp2.data ); | |
283 | // 2) send the BP2 set |
|
289 | // 2) send the BP2 set | |
284 | set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
290 | set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
285 | set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
291 | set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
286 | BP_send( (char *) &packet_sbm_bp2, queue_id_send, |
|
292 | BP_send( (char *) &packet_sbm_bp2, queue_id_send, | |
287 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA, |
|
293 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA, | |
288 | sid ); |
|
294 | sid ); | |
289 | } |
|
295 | } | |
290 | } |
|
296 | } | |
291 |
|
297 | |||
292 | //***** |
|
298 | //***** | |
293 | //***** |
|
299 | //***** | |
294 | // NORM |
|
300 | // NORM | |
295 | //***** |
|
301 | //***** | |
296 | //***** |
|
302 | //***** | |
297 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1) |
|
303 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1) | |
298 | { |
|
304 | { | |
299 | // 1) compress the matrix for Basic Parameters calculation |
|
305 | // 1) compress the matrix for Basic Parameters calculation | |
300 |
ASM_compress_reorganize_and_divide( |
|
306 | ASM_compress_reorganize_and_divide( asm_f1_patched_norm, compressed_sm_norm_f1, | |
301 | nb_sm_before_f1.norm_bp1, |
|
307 | nb_sm_before_f1.norm_bp1, | |
302 | NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1, |
|
308 | NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1, | |
303 | ASM_F1_INDICE_START ); |
|
309 | ASM_F1_INDICE_START ); | |
304 | // 2) compute the BP1 set |
|
310 | // 2) compute the BP1 set | |
305 |
|
|
311 | BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data ); | |
306 | // 3) send the BP1 set |
|
312 | // 3) send the BP1 set | |
307 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
313 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
308 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
314 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
309 | BP_send( (char *) &packet_norm_bp1, queue_id_send, |
|
315 | BP_send( (char *) &packet_norm_bp1, queue_id_send, | |
310 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA, |
|
316 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA, | |
311 | SID_NORM_BP1_F1 ); |
|
317 | SID_NORM_BP1_F1 ); | |
312 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1) |
|
318 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1) | |
313 | { |
|
319 | { | |
314 | // 1) compute the BP2 set |
|
320 | // 1) compute the BP2 set | |
315 | BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data ); |
|
321 | BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data ); | |
316 | // 2) send the BP2 set |
|
322 | // 2) send the BP2 set | |
317 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
323 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
318 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
324 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
319 | BP_send( (char *) &packet_norm_bp2, queue_id_send, |
|
325 | BP_send( (char *) &packet_norm_bp2, queue_id_send, | |
320 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA, |
|
326 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA, | |
321 | SID_NORM_BP2_F1 ); |
|
327 | SID_NORM_BP2_F1 ); | |
322 | } |
|
328 | } | |
323 | } |
|
329 | } | |
324 |
|
330 | |||
325 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1) |
|
331 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1) | |
326 | { |
|
332 | { | |
327 | // 1) reorganize the ASM and divide |
|
333 | // 1) reorganize the ASM and divide | |
328 |
ASM_reorganize_and_divide( |
|
334 | ASM_reorganize_and_divide( asm_f1_patched_norm, | |
329 | asm_f1_reorganized, |
|
335 | asm_f1_reorganized, | |
330 | nb_sm_before_f1.norm_bp1 ); |
|
336 | nb_sm_before_f1.norm_bp1 ); | |
331 | // 2) convert the float array in a char array |
|
337 | // 2) convert the float array in a char array | |
332 | ASM_convert( asm_f1_reorganized, (char*) current_ring_node_to_send_asm_f1->buffer_address ); |
|
338 | ASM_convert( asm_f1_reorganized, (char*) current_ring_node_to_send_asm_f1->buffer_address ); | |
333 | current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM; |
|
339 | current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM; | |
334 | current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM; |
|
340 | current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM; | |
335 | current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1; |
|
341 | current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1; | |
336 | // 3) send the spectral matrix packets |
|
342 | // 3) send the spectral matrix packets | |
337 | status = rtems_message_queue_send( queue_id_send, ¤t_ring_node_to_send_asm_f1, sizeof( ring_node* ) ); |
|
343 | status = rtems_message_queue_send( queue_id_send, ¤t_ring_node_to_send_asm_f1, sizeof( ring_node* ) ); | |
338 | // change asm ring node |
|
344 | // change asm ring node | |
339 | current_ring_node_to_send_asm_f1 = current_ring_node_to_send_asm_f1->next; |
|
345 | current_ring_node_to_send_asm_f1 = current_ring_node_to_send_asm_f1->next; | |
340 | } |
|
346 | } | |
341 |
|
347 | |||
342 | } |
|
348 | } | |
343 | } |
|
349 | } | |
344 |
|
350 | |||
345 | //********** |
|
351 | //********** | |
346 | // FUNCTIONS |
|
352 | // FUNCTIONS | |
347 |
|
353 | |||
348 | void reset_nb_sm_f1( unsigned char lfrMode ) |
|
354 | void reset_nb_sm_f1( unsigned char lfrMode ) | |
349 | { |
|
355 | { | |
350 | nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16; |
|
356 | nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16; | |
351 | nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16; |
|
357 | nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16; | |
352 | 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; |
|
358 | 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; | |
353 | nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16; |
|
359 | nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16; | |
354 | nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16; |
|
360 | nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16; | |
355 | nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16; |
|
361 | nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16; | |
356 | nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16; |
|
362 | nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16; | |
357 |
|
363 | |||
358 | if (lfrMode == LFR_MODE_SBM2) |
|
364 | if (lfrMode == LFR_MODE_SBM2) | |
359 | { |
|
365 | { | |
360 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1; |
|
366 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1; | |
361 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2; |
|
367 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2; | |
362 | } |
|
368 | } | |
363 | else if (lfrMode == LFR_MODE_BURST) |
|
369 | else if (lfrMode == LFR_MODE_BURST) | |
364 | { |
|
370 | { | |
365 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; |
|
371 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; | |
366 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; |
|
372 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; | |
367 | } |
|
373 | } | |
368 | else |
|
374 | else | |
369 | { |
|
375 | { | |
370 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; |
|
376 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; | |
371 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; |
|
377 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; | |
372 | } |
|
378 | } | |
373 | } |
|
379 | } | |
374 |
|
380 | |||
375 | void init_k_coefficients_f1( void ) |
|
381 | void init_k_coefficients_f1( void ) | |
376 | { |
|
382 | { | |
377 | init_k_coefficients( k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1 ); |
|
383 | init_k_coefficients( k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1 ); | |
378 | init_k_coefficients( k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1); |
|
384 | init_k_coefficients( k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1); | |
379 | } |
|
385 | } |
@@ -1,285 +1,289 | |||||
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 "avf2_prc2.h" |
|
10 | #include "avf2_prc2.h" | |
11 |
|
11 | |||
12 | nb_sm_before_bp_asm_f2 nb_sm_before_f2; |
|
12 | nb_sm_before_bp_asm_f2 nb_sm_before_f2; | |
13 |
|
13 | |||
14 | extern ring_node sm_ring_f2[ ]; |
|
14 | extern ring_node sm_ring_f2[ ]; | |
15 |
|
15 | |||
16 | //*** |
|
16 | //*** | |
17 | // F2 |
|
17 | // F2 | |
18 | ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ]; |
|
18 | ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ]; | |
19 |
|
19 | |||
20 | ring_node ring_to_send_asm_f2 [ NB_RING_NODES_ASM_F2 ]; |
|
20 | ring_node ring_to_send_asm_f2 [ NB_RING_NODES_ASM_F2 ]; | |
21 | int buffer_asm_f2 [ NB_RING_NODES_ASM_F2 * TOTAL_SIZE_SM ]; |
|
21 | int buffer_asm_f2 [ NB_RING_NODES_ASM_F2 * TOTAL_SIZE_SM ]; | |
22 |
|
22 | |||
|
23 | float asm_f2_patched_norm [ TOTAL_SIZE_SM ]; | |||
23 | float asm_f2_reorganized [ TOTAL_SIZE_SM ]; |
|
24 | float asm_f2_reorganized [ TOTAL_SIZE_SM ]; | |
|
25 | ||||
24 | char asm_f2_char [ TOTAL_SIZE_SM * 2 ]; |
|
26 | char asm_f2_char [ TOTAL_SIZE_SM * 2 ]; | |
25 | float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2]; |
|
27 | float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2]; | |
26 |
|
28 | |||
27 | float k_coeff_intercalib_f2[ NB_BINS_COMPRESSED_SM_F2 * NB_K_COEFF_PER_BIN ]; // 12 * 32 = 384 |
|
29 | float k_coeff_intercalib_f2[ NB_BINS_COMPRESSED_SM_F2 * NB_K_COEFF_PER_BIN ]; // 12 * 32 = 384 | |
28 |
|
30 | |||
29 | //************ |
|
31 | //************ | |
30 | // RTEMS TASKS |
|
32 | // RTEMS TASKS | |
31 |
|
33 | |||
32 | //*** |
|
34 | //*** | |
33 | // F2 |
|
35 | // F2 | |
34 | rtems_task avf2_task( rtems_task_argument argument ) |
|
36 | rtems_task avf2_task( rtems_task_argument argument ) | |
35 | { |
|
37 | { | |
36 | rtems_event_set event_out; |
|
38 | rtems_event_set event_out; | |
37 | rtems_status_code status; |
|
39 | rtems_status_code status; | |
38 | rtems_id queue_id_prc2; |
|
40 | rtems_id queue_id_prc2; | |
39 | asm_msg msgForMATR; |
|
41 | asm_msg msgForMATR; | |
40 | ring_node *nodeForAveraging; |
|
42 | ring_node *nodeForAveraging; | |
41 | ring_node_asm *current_ring_node_asm_norm_f2; |
|
43 | ring_node_asm *current_ring_node_asm_norm_f2; | |
42 |
|
44 | |||
43 | unsigned int nb_norm_bp1; |
|
45 | unsigned int nb_norm_bp1; | |
44 | unsigned int nb_norm_bp2; |
|
46 | unsigned int nb_norm_bp2; | |
45 | unsigned int nb_norm_asm; |
|
47 | unsigned int nb_norm_asm; | |
46 |
|
48 | |||
47 | nb_norm_bp1 = 0; |
|
49 | nb_norm_bp1 = 0; | |
48 | nb_norm_bp2 = 0; |
|
50 | nb_norm_bp2 = 0; | |
49 | nb_norm_asm = 0; |
|
51 | nb_norm_asm = 0; | |
50 |
|
52 | |||
51 | reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions |
|
53 | reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions | |
52 | ASM_generic_init_ring( asm_ring_norm_f2, NB_RING_NODES_ASM_NORM_F2 ); |
|
54 | ASM_generic_init_ring( asm_ring_norm_f2, NB_RING_NODES_ASM_NORM_F2 ); | |
53 | current_ring_node_asm_norm_f2 = asm_ring_norm_f2; |
|
55 | current_ring_node_asm_norm_f2 = asm_ring_norm_f2; | |
54 |
|
56 | |||
55 | BOOT_PRINTF("in AVF2 ***\n") |
|
57 | BOOT_PRINTF("in AVF2 ***\n") | |
56 |
|
58 | |||
57 | status = get_message_queue_id_prc2( &queue_id_prc2 ); |
|
59 | status = get_message_queue_id_prc2( &queue_id_prc2 ); | |
58 | if (status != RTEMS_SUCCESSFUL) |
|
60 | if (status != RTEMS_SUCCESSFUL) | |
59 | { |
|
61 | { | |
60 | PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status) |
|
62 | PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status) | |
61 | } |
|
63 | } | |
62 |
|
64 | |||
63 | while(1){ |
|
65 | while(1){ | |
64 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
66 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
65 |
|
67 | |||
66 | //**************************************** |
|
68 | //**************************************** | |
67 | // initialize the mesage for the MATR task |
|
69 | // initialize the mesage for the MATR task | |
68 | msgForMATR.norm = current_ring_node_asm_norm_f2; |
|
70 | msgForMATR.norm = current_ring_node_asm_norm_f2; | |
69 | msgForMATR.burst_sbm = NULL; |
|
71 | msgForMATR.burst_sbm = NULL; | |
70 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC2 task |
|
72 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC2 task | |
71 | // |
|
73 | // | |
72 | //**************************************** |
|
74 | //**************************************** | |
73 |
|
75 | |||
74 | nodeForAveraging = getRingNodeForAveraging( 2 ); |
|
76 | nodeForAveraging = getRingNodeForAveraging( 2 ); | |
75 |
|
77 | |||
76 | // printf(" **0** %x . %x", sm_ring_f2[0].coarseTime, sm_ring_f2[0].fineTime); |
|
78 | // printf(" **0** %x . %x", sm_ring_f2[0].coarseTime, sm_ring_f2[0].fineTime); | |
77 | // printf(" **1** %x . %x", sm_ring_f2[1].coarseTime, sm_ring_f2[1].fineTime); |
|
79 | // printf(" **1** %x . %x", sm_ring_f2[1].coarseTime, sm_ring_f2[1].fineTime); | |
78 | // printf(" **2** %x . %x", sm_ring_f2[2].coarseTime, sm_ring_f2[2].fineTime); |
|
80 | // printf(" **2** %x . %x", sm_ring_f2[2].coarseTime, sm_ring_f2[2].fineTime); | |
79 | // printf(" **3** %x . %x", sm_ring_f2[3].coarseTime, sm_ring_f2[3].fineTime); |
|
81 | // printf(" **3** %x . %x", sm_ring_f2[3].coarseTime, sm_ring_f2[3].fineTime); | |
80 | // printf(" **4** %x . %x", sm_ring_f2[4].coarseTime, sm_ring_f2[4].fineTime); |
|
82 | // printf(" **4** %x . %x", sm_ring_f2[4].coarseTime, sm_ring_f2[4].fineTime); | |
81 | // printf(" **5** %x . %x", sm_ring_f2[5].coarseTime, sm_ring_f2[5].fineTime); |
|
83 | // printf(" **5** %x . %x", sm_ring_f2[5].coarseTime, sm_ring_f2[5].fineTime); | |
82 | // printf(" **6** %x . %x", sm_ring_f2[6].coarseTime, sm_ring_f2[6].fineTime); |
|
84 | // printf(" **6** %x . %x", sm_ring_f2[6].coarseTime, sm_ring_f2[6].fineTime); | |
83 | // printf(" **7** %x . %x", sm_ring_f2[7].coarseTime, sm_ring_f2[7].fineTime); |
|
85 | // printf(" **7** %x . %x", sm_ring_f2[7].coarseTime, sm_ring_f2[7].fineTime); | |
84 | // printf(" **8** %x . %x", sm_ring_f2[8].coarseTime, sm_ring_f2[8].fineTime); |
|
86 | // printf(" **8** %x . %x", sm_ring_f2[8].coarseTime, sm_ring_f2[8].fineTime); | |
85 | // printf(" **9** %x . %x", sm_ring_f2[9].coarseTime, sm_ring_f2[9].fineTime); |
|
87 | // printf(" **9** %x . %x", sm_ring_f2[9].coarseTime, sm_ring_f2[9].fineTime); | |
86 | // printf(" **10** %x . %x\n", sm_ring_f2[10].coarseTime, sm_ring_f2[10].fineTime); |
|
88 | // printf(" **10** %x . %x\n", sm_ring_f2[10].coarseTime, sm_ring_f2[10].fineTime); | |
87 |
|
89 | |||
88 | // compute the average and store it in the averaged_sm_f2 buffer |
|
90 | // compute the average and store it in the averaged_sm_f2 buffer | |
89 | SM_average_f2( current_ring_node_asm_norm_f2->matrix, |
|
91 | SM_average_f2( current_ring_node_asm_norm_f2->matrix, | |
90 | nodeForAveraging, |
|
92 | nodeForAveraging, | |
91 | nb_norm_bp1, |
|
93 | nb_norm_bp1, | |
92 | &msgForMATR ); |
|
94 | &msgForMATR ); | |
93 |
|
95 | |||
94 | // update nb_average |
|
96 | // update nb_average | |
95 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2; |
|
97 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2; | |
96 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2; |
|
98 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2; | |
97 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2; |
|
99 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2; | |
98 |
|
100 | |||
99 | if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1) |
|
101 | if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1) | |
100 | { |
|
102 | { | |
101 | nb_norm_bp1 = 0; |
|
103 | nb_norm_bp1 = 0; | |
102 | // set another ring for the ASM storage |
|
104 | // set another ring for the ASM storage | |
103 | current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next; |
|
105 | current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next; | |
104 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) |
|
106 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) | |
105 | || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
107 | || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
106 | { |
|
108 | { | |
107 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F2; |
|
109 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F2; | |
108 | } |
|
110 | } | |
109 | } |
|
111 | } | |
110 |
|
112 | |||
111 | if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2) |
|
113 | if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2) | |
112 | { |
|
114 | { | |
113 | nb_norm_bp2 = 0; |
|
115 | nb_norm_bp2 = 0; | |
114 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) |
|
116 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) | |
115 | || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
117 | || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
116 | { |
|
118 | { | |
117 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2; |
|
119 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2; | |
118 | } |
|
120 | } | |
119 | } |
|
121 | } | |
120 |
|
122 | |||
121 | if (nb_norm_asm == nb_sm_before_f2.norm_asm) |
|
123 | if (nb_norm_asm == nb_sm_before_f2.norm_asm) | |
122 | { |
|
124 | { | |
123 | nb_norm_asm = 0; |
|
125 | nb_norm_asm = 0; | |
124 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) |
|
126 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) | |
125 | || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
127 | || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
126 | { |
|
128 | { | |
127 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2; |
|
129 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2; | |
128 | } |
|
130 | } | |
129 | } |
|
131 | } | |
130 |
|
132 | |||
131 | //************************* |
|
133 | //************************* | |
132 | // send the message to MATR |
|
134 | // send the message to MATR | |
133 | if (msgForMATR.event != 0x00) |
|
135 | if (msgForMATR.event != 0x00) | |
134 | { |
|
136 | { | |
135 | status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC2); |
|
137 | status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC2); | |
136 | } |
|
138 | } | |
137 |
|
139 | |||
138 | if (status != RTEMS_SUCCESSFUL) { |
|
140 | if (status != RTEMS_SUCCESSFUL) { | |
139 | printf("in AVF2 *** Error sending message to MATR, code %d\n", status); |
|
141 | printf("in AVF2 *** Error sending message to MATR, code %d\n", status); | |
140 | } |
|
142 | } | |
141 | } |
|
143 | } | |
142 | } |
|
144 | } | |
143 |
|
145 | |||
144 | rtems_task prc2_task( rtems_task_argument argument ) |
|
146 | rtems_task prc2_task( rtems_task_argument argument ) | |
145 | { |
|
147 | { | |
146 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
148 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
147 | size_t size; // size of the incoming TC packet |
|
149 | size_t size; // size of the incoming TC packet | |
148 | asm_msg *incomingMsg; |
|
150 | asm_msg *incomingMsg; | |
149 | // |
|
151 | // | |
150 | rtems_status_code status; |
|
152 | rtems_status_code status; | |
151 | rtems_id queue_id_send; |
|
153 | rtems_id queue_id_send; | |
152 | rtems_id queue_id_q_p2; |
|
154 | rtems_id queue_id_q_p2; | |
153 | bp_packet packet_norm_bp1; |
|
155 | bp_packet packet_norm_bp1; | |
154 | bp_packet packet_norm_bp2; |
|
156 | bp_packet packet_norm_bp2; | |
155 | ring_node *current_ring_node_to_send_asm_f2; |
|
157 | ring_node *current_ring_node_to_send_asm_f2; | |
156 |
|
158 | |||
157 | unsigned long long int localTime; |
|
159 | unsigned long long int localTime; | |
158 |
|
160 | |||
159 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU |
|
161 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU | |
160 | init_ring( ring_to_send_asm_f2, NB_RING_NODES_ASM_F2, (volatile int*) buffer_asm_f2, TOTAL_SIZE_SM ); |
|
162 | init_ring( ring_to_send_asm_f2, NB_RING_NODES_ASM_F2, (volatile int*) buffer_asm_f2, TOTAL_SIZE_SM ); | |
161 | current_ring_node_to_send_asm_f2 = ring_to_send_asm_f2; |
|
163 | current_ring_node_to_send_asm_f2 = ring_to_send_asm_f2; | |
162 |
|
164 | |||
163 | //************* |
|
165 | //************* | |
164 | // NORM headers |
|
166 | // NORM headers | |
165 | BP_init_header( &packet_norm_bp1, |
|
167 | BP_init_header( &packet_norm_bp1, | |
166 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2, |
|
168 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2, | |
167 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 ); |
|
169 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 ); | |
168 | BP_init_header( &packet_norm_bp2, |
|
170 | BP_init_header( &packet_norm_bp2, | |
169 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2, |
|
171 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2, | |
170 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 ); |
|
172 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 ); | |
171 |
|
173 | |||
172 | status = get_message_queue_id_send( &queue_id_send ); |
|
174 | status = get_message_queue_id_send( &queue_id_send ); | |
173 | if (status != RTEMS_SUCCESSFUL) |
|
175 | if (status != RTEMS_SUCCESSFUL) | |
174 | { |
|
176 | { | |
175 | PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status) |
|
177 | PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status) | |
176 | } |
|
178 | } | |
177 | status = get_message_queue_id_prc2( &queue_id_q_p2); |
|
179 | status = get_message_queue_id_prc2( &queue_id_q_p2); | |
178 | if (status != RTEMS_SUCCESSFUL) |
|
180 | if (status != RTEMS_SUCCESSFUL) | |
179 | { |
|
181 | { | |
180 | PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status) |
|
182 | PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status) | |
181 | } |
|
183 | } | |
182 |
|
184 | |||
183 | BOOT_PRINTF("in PRC2 ***\n") |
|
185 | BOOT_PRINTF("in PRC2 ***\n") | |
184 |
|
186 | |||
185 | while(1){ |
|
187 | while(1){ | |
186 | status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************ |
|
188 | status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************ | |
187 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF2 |
|
189 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF2 | |
188 |
|
190 | |||
189 | incomingMsg = (asm_msg*) incomingData; |
|
191 | incomingMsg = (asm_msg*) incomingData; | |
190 |
|
192 | |||
|
193 | ASM_patch( incomingMsg->norm->matrix, asm_f2_patched_norm ); | |||
|
194 | ||||
191 | localTime = getTimeAsUnsignedLongLongInt( ); |
|
195 | localTime = getTimeAsUnsignedLongLongInt( ); | |
192 |
|
196 | |||
193 | //***** |
|
197 | //***** | |
194 | //***** |
|
198 | //***** | |
195 | // NORM |
|
199 | // NORM | |
196 | //***** |
|
200 | //***** | |
197 | //***** |
|
201 | //***** | |
198 | // 1) compress the matrix for Basic Parameters calculation |
|
202 | // 1) compress the matrix for Basic Parameters calculation | |
199 |
ASM_compress_reorganize_and_divide( |
|
203 | ASM_compress_reorganize_and_divide( asm_f2_patched_norm, compressed_sm_norm_f2, | |
200 | nb_sm_before_f2.norm_bp1, |
|
204 | nb_sm_before_f2.norm_bp1, | |
201 | NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2, |
|
205 | NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2, | |
202 | ASM_F2_INDICE_START ); |
|
206 | ASM_F2_INDICE_START ); | |
203 | // BP1_F2 |
|
207 | // BP1_F2 | |
204 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2) |
|
208 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2) | |
205 | { |
|
209 | { | |
206 | // 1) compute the BP1 set |
|
210 | // 1) compute the BP1 set | |
207 |
|
|
211 | BP1_set( compressed_sm_norm_f2, k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp1.data ); | |
208 | // 2) send the BP1 set |
|
212 | // 2) send the BP1 set | |
209 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
213 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
210 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
214 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
211 | BP_send( (char *) &packet_norm_bp1, queue_id_send, |
|
215 | BP_send( (char *) &packet_norm_bp1, queue_id_send, | |
212 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA, |
|
216 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA, | |
213 | SID_NORM_BP1_F2 ); |
|
217 | SID_NORM_BP1_F2 ); | |
214 | } |
|
218 | } | |
215 | // BP2_F2 |
|
219 | // BP2_F2 | |
216 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2) |
|
220 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2) | |
217 | { |
|
221 | { | |
218 | // 1) compute the BP2 set |
|
222 | // 1) compute the BP2 set | |
219 | BP2_set( compressed_sm_norm_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp2.data ); |
|
223 | BP2_set( compressed_sm_norm_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp2.data ); | |
220 | // 2) send the BP2 set |
|
224 | // 2) send the BP2 set | |
221 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
225 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
222 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
226 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
223 | BP_send( (char *) &packet_norm_bp2, queue_id_send, |
|
227 | BP_send( (char *) &packet_norm_bp2, queue_id_send, | |
224 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA, |
|
228 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA, | |
225 | SID_NORM_BP2_F2 ); |
|
229 | SID_NORM_BP2_F2 ); | |
226 | } |
|
230 | } | |
227 |
|
231 | |||
228 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2) |
|
232 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2) | |
229 | { |
|
233 | { | |
230 | // 1) reorganize the ASM and divide |
|
234 | // 1) reorganize the ASM and divide | |
231 |
ASM_reorganize_and_divide( |
|
235 | ASM_reorganize_and_divide( asm_f2_patched_norm, | |
232 | asm_f2_reorganized, |
|
236 | asm_f2_reorganized, | |
233 | nb_sm_before_f2.norm_bp1 ); |
|
237 | nb_sm_before_f2.norm_bp1 ); | |
234 | // 2) convert the float array in a char array |
|
238 | // 2) convert the float array in a char array | |
235 | ASM_convert( asm_f2_reorganized, (char*) current_ring_node_to_send_asm_f2->buffer_address ); |
|
239 | ASM_convert( asm_f2_reorganized, (char*) current_ring_node_to_send_asm_f2->buffer_address ); | |
236 | current_ring_node_to_send_asm_f2->coarseTime = incomingMsg->coarseTimeNORM; |
|
240 | current_ring_node_to_send_asm_f2->coarseTime = incomingMsg->coarseTimeNORM; | |
237 | current_ring_node_to_send_asm_f2->fineTime = incomingMsg->fineTimeNORM; |
|
241 | current_ring_node_to_send_asm_f2->fineTime = incomingMsg->fineTimeNORM; | |
238 | current_ring_node_to_send_asm_f2->sid = SID_NORM_ASM_F2; |
|
242 | current_ring_node_to_send_asm_f2->sid = SID_NORM_ASM_F2; | |
239 | // 3) send the spectral matrix packets |
|
243 | // 3) send the spectral matrix packets | |
240 | status = rtems_message_queue_send( queue_id_send, ¤t_ring_node_to_send_asm_f2, sizeof( ring_node* ) ); |
|
244 | status = rtems_message_queue_send( queue_id_send, ¤t_ring_node_to_send_asm_f2, sizeof( ring_node* ) ); | |
241 | // change asm ring node |
|
245 | // change asm ring node | |
242 | current_ring_node_to_send_asm_f2 = current_ring_node_to_send_asm_f2->next; |
|
246 | current_ring_node_to_send_asm_f2 = current_ring_node_to_send_asm_f2->next; | |
243 | } |
|
247 | } | |
244 |
|
248 | |||
245 | } |
|
249 | } | |
246 | } |
|
250 | } | |
247 |
|
251 | |||
248 | //********** |
|
252 | //********** | |
249 | // FUNCTIONS |
|
253 | // FUNCTIONS | |
250 |
|
254 | |||
251 | void reset_nb_sm_f2( void ) |
|
255 | void reset_nb_sm_f2( void ) | |
252 | { |
|
256 | { | |
253 | nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0; |
|
257 | nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0; | |
254 | nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1; |
|
258 | nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1; | |
255 | nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]; |
|
259 | nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]; | |
256 | } |
|
260 | } | |
257 |
|
261 | |||
258 | void SM_average_f2( float *averaged_spec_mat_f2, |
|
262 | void SM_average_f2( float *averaged_spec_mat_f2, | |
259 | ring_node *ring_node, |
|
263 | ring_node *ring_node, | |
260 | unsigned int nbAverageNormF2, |
|
264 | unsigned int nbAverageNormF2, | |
261 | asm_msg *msgForMATR ) |
|
265 | asm_msg *msgForMATR ) | |
262 | { |
|
266 | { | |
263 | float sum; |
|
267 | float sum; | |
264 | unsigned int i; |
|
268 | unsigned int i; | |
265 |
|
269 | |||
266 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
270 | for(i=0; i<TOTAL_SIZE_SM; i++) | |
267 | { |
|
271 | { | |
268 | sum = ( (int *) (ring_node->buffer_address) ) [ i ]; |
|
272 | sum = ( (int *) (ring_node->buffer_address) ) [ i ]; | |
269 | if ( (nbAverageNormF2 == 0) ) |
|
273 | if ( (nbAverageNormF2 == 0) ) | |
270 | { |
|
274 | { | |
271 | averaged_spec_mat_f2[ i ] = sum; |
|
275 | averaged_spec_mat_f2[ i ] = sum; | |
272 | msgForMATR->coarseTimeNORM = ring_node->coarseTime; |
|
276 | msgForMATR->coarseTimeNORM = ring_node->coarseTime; | |
273 | msgForMATR->fineTimeNORM = ring_node->fineTime; |
|
277 | msgForMATR->fineTimeNORM = ring_node->fineTime; | |
274 | } |
|
278 | } | |
275 | else |
|
279 | else | |
276 | { |
|
280 | { | |
277 | averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum ); |
|
281 | averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum ); | |
278 | } |
|
282 | } | |
279 | } |
|
283 | } | |
280 | } |
|
284 | } | |
281 |
|
285 | |||
282 | void init_k_coefficients_f2( void ) |
|
286 | void init_k_coefficients_f2( void ) | |
283 | { |
|
287 | { | |
284 | init_k_coefficients( k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2); |
|
288 | init_k_coefficients( k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2); | |
285 | } |
|
289 | } |
General Comments 0
You need to be logged in to leave comments.
Login now