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