@@ -1,6 +1,6 | |||||
1 | ############################################################################# |
|
1 | ############################################################################# | |
2 | # Makefile for building: bin/fsw |
|
2 | # Makefile for building: bin/fsw | |
3 |
# Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Apr 3 1 |
|
3 | # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Apr 3 13:43:01 2014 | |
4 | # Project: fsw-qt.pro |
|
4 | # Project: fsw-qt.pro | |
5 | # Template: app |
|
5 | # Template: app | |
6 | # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
6 | # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro | |
@@ -10,7 +10,7 | |||||
10 |
|
10 | |||
11 | CC = sparc-rtems-gcc |
|
11 | CC = sparc-rtems-gcc | |
12 | CXX = sparc-rtems-g++ |
|
12 | CXX = sparc-rtems-g++ | |
13 |
DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4= |
|
13 | DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS | |
14 | CFLAGS = -pipe -O3 -Wall $(DEFINES) |
|
14 | CFLAGS = -pipe -O3 -Wall $(DEFINES) | |
15 | CXXFLAGS = -pipe -O3 -Wall $(DEFINES) |
|
15 | CXXFLAGS = -pipe -O3 -Wall $(DEFINES) | |
16 | INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../../LFR_basic-parameters |
|
16 | INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../../LFR_basic-parameters |
@@ -1,7 +1,7 | |||||
1 | TEMPLATE = app |
|
1 | TEMPLATE = app | |
2 | # CONFIG += console v8 sim |
|
2 | # CONFIG += console v8 sim | |
3 | # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch |
|
3 | # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch | |
4 | CONFIG += console verbose |
|
4 | CONFIG += console verbose cpu_usage_report | |
5 | CONFIG -= qt |
|
5 | CONFIG -= qt | |
6 |
|
6 | |||
7 | include(./sparc.pri) |
|
7 | include(./sparc.pri) | |
@@ -11,7 +11,7 SWVERSION=-1-0 | |||||
11 | DEFINES += SW_VERSION_N1=1 # major |
|
11 | DEFINES += SW_VERSION_N1=1 # major | |
12 | DEFINES += SW_VERSION_N2=0 # minor |
|
12 | DEFINES += SW_VERSION_N2=0 # minor | |
13 | DEFINES += SW_VERSION_N3=0 # patch |
|
13 | DEFINES += SW_VERSION_N3=0 # patch | |
14 |
DEFINES += SW_VERSION_N4= |
|
14 | DEFINES += SW_VERSION_N4=6 # internal | |
15 |
|
15 | |||
16 | contains( CONFIG, debug_tch ) { |
|
16 | contains( CONFIG, debug_tch ) { | |
17 | DEFINES += DEBUG_TCH |
|
17 | DEFINES += DEBUG_TCH |
@@ -1,6 +1,6 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <!DOCTYPE QtCreatorProject> |
|
2 | <!DOCTYPE QtCreatorProject> | |
3 |
<!-- Written by QtCreator 3.0.1, 2014-04-03T |
|
3 | <!-- Written by QtCreator 3.0.1, 2014-04-03T15:58:50. --> | |
4 | <qtcreator> |
|
4 | <qtcreator> | |
5 | <data> |
|
5 | <data> | |
6 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
|
6 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
@@ -203,9 +203,11 enum apid_destid{ | |||||
203 | #define PACKET_LENGTH_TC_EXE_CORRUPTED (32 - CCSDS_TC_TM_PACKET_OFFSET) |
|
203 | #define PACKET_LENGTH_TC_EXE_CORRUPTED (32 - CCSDS_TC_TM_PACKET_OFFSET) | |
204 | #define PACKET_LENGTH_HK (124 - CCSDS_TC_TM_PACKET_OFFSET) |
|
204 | #define PACKET_LENGTH_HK (124 - CCSDS_TC_TM_PACKET_OFFSET) | |
205 | #define PACKET_LENGTH_PARAMETER_DUMP (36 - CCSDS_TC_TM_PACKET_OFFSET) |
|
205 | #define PACKET_LENGTH_PARAMETER_DUMP (36 - CCSDS_TC_TM_PACKET_OFFSET) | |
206 |
#define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0 |
|
206 | #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0 (2228 - CCSDS_TC_TM_PACKET_OFFSET) // 44 * 25 * 2 + 28 - 7 | |
207 |
#define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1 |
|
207 | #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1 (2628 - CCSDS_TC_TM_PACKET_OFFSET) // 52 * 25 * 2 + 28 - 7 | |
208 |
#define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2 |
|
208 | #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2 (2428 - CCSDS_TC_TM_PACKET_OFFSET) // 48 * 25 * 2 + 28 - 7 | |
|
209 | #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 (126 - CCSDS_TC_TM_PACKET_OFFSET) // 11 * 9 + 27 - 7 | |||
|
210 | #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 (224 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 9 + 26 - 7 | |||
209 |
|
211 | |||
210 | #define SPARE1_PUSVERSION_SPARE2 0x10 |
|
212 | #define SPARE1_PUSVERSION_SPARE2 0x10 | |
211 |
|
213 | |||
@@ -466,7 +468,28 typedef struct { | |||||
466 | unsigned char acquisitionTime[6]; |
|
468 | unsigned char acquisitionTime[6]; | |
467 | unsigned char spare_source_data; |
|
469 | unsigned char spare_source_data; | |
468 | unsigned char pa_lfr_bp_blk_nr[2]; |
|
470 | unsigned char pa_lfr_bp_blk_nr[2]; | |
469 | } Header_TM_LFR_SCIENCE_BP_t; |
|
471 | } Header_TM_LFR_SCIENCE_BP_NORM_t; | |
|
472 | ||||
|
473 | typedef struct { | |||
|
474 | unsigned char targetLogicalAddress; | |||
|
475 | unsigned char protocolIdentifier; | |||
|
476 | unsigned char reserved; | |||
|
477 | unsigned char userApplication; | |||
|
478 | unsigned char packetID[2]; | |||
|
479 | unsigned char packetSequenceControl[2]; | |||
|
480 | unsigned char packetLength[2]; | |||
|
481 | // DATA FIELD HEADER | |||
|
482 | unsigned char spare1_pusVersion_spare2; | |||
|
483 | unsigned char serviceType; | |||
|
484 | unsigned char serviceSubType; | |||
|
485 | unsigned char destinationID; | |||
|
486 | unsigned char time[6]; | |||
|
487 | // AUXILIARY HEADER | |||
|
488 | unsigned char sid; | |||
|
489 | unsigned char biaStatusInfo; | |||
|
490 | unsigned char acquisitionTime[6]; | |||
|
491 | unsigned char pa_lfr_bp_blk_nr[2]; | |||
|
492 | } Header_TM_LFR_SCIENCE_BP_SBM_t; | |||
470 |
|
493 | |||
471 | typedef struct { |
|
494 | typedef struct { | |
472 | //targetLogicalAddress is removed by the grspw module |
|
495 | //targetLogicalAddress is removed by the grspw module |
@@ -28,6 +28,26 typedef struct ring_node_sm | |||||
28 | unsigned int fineTime; |
|
28 | unsigned int fineTime; | |
29 | } ring_node_sm; |
|
29 | } ring_node_sm; | |
30 |
|
30 | |||
|
31 | typedef struct ring_node_bp | |||
|
32 | { | |||
|
33 | struct ring_node_bp *previous; | |||
|
34 | struct ring_node_bp *next; | |||
|
35 | unsigned int status; | |||
|
36 | unsigned int coarseTime; | |||
|
37 | unsigned int fineTime; | |||
|
38 | Header_TM_LFR_SCIENCE_BP_SBM_t header; | |||
|
39 | unsigned char data[ 9 * 22 ]; | |||
|
40 | } ring_node_bp; | |||
|
41 | ||||
|
42 | typedef struct | |||
|
43 | { | |||
|
44 | unsigned int status; | |||
|
45 | unsigned int coarseTime; | |||
|
46 | unsigned int fineTime; | |||
|
47 | Header_TM_LFR_SCIENCE_BP_NORM_t header; | |||
|
48 | unsigned char data[ 9 * 22 ]; | |||
|
49 | } ring_node_norm_bp; | |||
|
50 | ||||
31 | //************************ |
|
51 | //************************ | |
32 | // flight software version |
|
52 | // flight software version | |
33 | // this parameters is handled by the Qt project options |
|
53 | // this parameters is handled by the Qt project options | |
@@ -144,6 +164,7 typedef struct ring_node_sm | |||||
144 | // LPP CODES |
|
164 | // LPP CODES | |
145 | #define LFR_SUCCESSFUL 0 |
|
165 | #define LFR_SUCCESSFUL 0 | |
146 | #define LFR_DEFAULT 1 |
|
166 | #define LFR_DEFAULT 1 | |
|
167 | #define LFR_EXE_ERROR 2 | |||
147 |
|
168 | |||
148 | //****** |
|
169 | //****** | |
149 | // RTEMS |
|
170 | // RTEMS | |
@@ -184,7 +205,8 typedef struct ring_node_sm | |||||
184 |
|
205 | |||
185 | #define ACTION_MSG_QUEUE_COUNT 10 |
|
206 | #define ACTION_MSG_QUEUE_COUNT 10 | |
186 | #define ACTION_MSG_PKTS_COUNT 50 |
|
207 | #define ACTION_MSG_PKTS_COUNT 50 | |
187 | #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES) |
|
208 | //#define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES) | |
|
209 | #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES) | |||
188 | #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options |
|
210 | #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options | |
189 |
|
211 | |||
190 | #define QUEUE_RECV 0 |
|
212 | #define QUEUE_RECV 0 |
@@ -4,13 +4,15 | |||||
4 | #define NB_BINS_PER_SM 128 |
|
4 | #define NB_BINS_PER_SM 128 | |
5 | #define NB_VALUES_PER_SM 25 |
|
5 | #define NB_VALUES_PER_SM 25 | |
6 | #define TOTAL_SIZE_SM 3200 // 25 * 128 |
|
6 | #define TOTAL_SIZE_SM 3200 // 25 * 128 | |
7 |
#define TOTAL_SIZE_BP1_F0 |
|
7 | #define TOTAL_SIZE_NORM_BP1_F0 99 // 11 * 9 = 99 | |
8 |
#define TOTAL_SIZE_BP1_F1 |
|
8 | #define TOTAL_SIZE_NORM_BP1_F1 117 // 13 * 9 = 117 | |
9 |
#define TOTAL_SIZE_BP1_F2 |
|
9 | #define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108 | |
|
10 | #define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198 | |||
10 | // |
|
11 | // | |
11 | #define NB_RING_NODES_ASM_F0 12 // AT LEAST 3 |
|
12 | #define NB_RING_NODES_ASM_F0 12 // AT LEAST 3 | |
12 | #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3 |
|
13 | #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3 | |
13 | #define NB_RING_NODES_ASM_F2 2 // AT LEAST 3 |
|
14 | #define NB_RING_NODES_ASM_F2 2 // AT LEAST 3 | |
|
15 | #define NB_RING_NODES_BP1_SBM1 10 // AT LEAST 3 | |||
14 | // |
|
16 | // | |
15 | #define NB_BINS_PER_ASM_F0 88 |
|
17 | #define NB_BINS_PER_ASM_F0 88 | |
16 | #define NB_BINS_PER_PKT_ASM_F0 44 |
|
18 | #define NB_BINS_PER_PKT_ASM_F0 44 | |
@@ -33,10 +35,12 | |||||
33 | #define NB_BINS_COMPRESSED_SM_F0 11 |
|
35 | #define NB_BINS_COMPRESSED_SM_F0 11 | |
34 | #define NB_BINS_COMPRESSED_SM_F1 13 |
|
36 | #define NB_BINS_COMPRESSED_SM_F1 13 | |
35 | #define NB_BINS_COMPRESSED_SM_F2 12 |
|
37 | #define NB_BINS_COMPRESSED_SM_F2 12 | |
|
38 | #define NB_BINS_COMPRESSED_SM_SBM1_F0 22 | |||
36 | // |
|
39 | // | |
37 | #define NB_BINS_TO_AVERAGE_ASM_F0 8 |
|
40 | #define NB_BINS_TO_AVERAGE_ASM_F0 8 | |
38 | #define NB_BINS_TO_AVERAGE_ASM_F1 8 |
|
41 | #define NB_BINS_TO_AVERAGE_ASM_F1 8 | |
39 | #define NB_BINS_TO_AVERAGE_ASM_F2 8 |
|
42 | #define NB_BINS_TO_AVERAGE_ASM_F2 8 | |
|
43 | #define NB_BINS_TO_AVERAGE_ASM_SBM1_F0 4 | |||
40 | // |
|
44 | // | |
41 | #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25 WORDS |
|
45 | #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25 WORDS | |
42 | #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25 WORDS |
|
46 | #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25 WORDS | |
@@ -46,14 +50,4 | |||||
46 | #define NB_AVERAGE_SBM1_F0 24 // 24 matrices at f0 = 0.25 second |
|
50 | #define NB_AVERAGE_SBM1_F0 24 // 24 matrices at f0 = 0.25 second | |
47 | #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8 |
|
51 | #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8 | |
48 |
|
52 | |||
49 | typedef struct { |
|
|||
50 | volatile unsigned char PE[2]; |
|
|||
51 | volatile unsigned char PB[2]; |
|
|||
52 | volatile unsigned char V0; |
|
|||
53 | volatile unsigned char V1; |
|
|||
54 | volatile unsigned char V2_ELLIP_DOP; |
|
|||
55 | volatile unsigned char SZ; |
|
|||
56 | volatile unsigned char VPHI; |
|
|||
57 | } BP1_t; |
|
|||
58 |
|
||||
59 | #endif // FSW_PARAMS_PROCESSING_H |
|
53 | #endif // FSW_PARAMS_PROCESSING_H |
@@ -38,20 +38,27 rtems_task avf0_task(rtems_task_argument | |||||
38 | rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator |
|
38 | rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator | |
39 | rtems_task matr_task(rtems_task_argument argument); |
|
39 | rtems_task matr_task(rtems_task_argument argument); | |
40 |
|
40 | |||
41 | void BP1_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1); |
|
41 | //***************************** | |
42 | void BP2_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat); |
|
42 | // Spectral matrices processing | |
43 | // |
|
43 | ||
44 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header); |
|
|||
45 | void matrix_reset(volatile float *averaged_spec_mat); |
|
|||
46 | void ASM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1, |
|
44 | void ASM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1, | |
47 | ring_node_sm *ring_node_tab[], |
|
45 | ring_node_sm *ring_node_tab[], | |
48 | unsigned int firstTimeF0, unsigned int firstTimeF1 ); |
|
46 | unsigned int firstTimeF0, unsigned int firstTimeF1 ); | |
49 |
void ASM_reorganize( |
|
47 | void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, | |
50 | void ASM_compress( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat ); |
|
48 | float divider ); | |
|
49 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, | |||
|
50 | float divider, | |||
|
51 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); | |||
51 | void ASM_convert(volatile float *input_matrix, char *output_matrix); |
|
52 | void ASM_convert(volatile float *input_matrix, char *output_matrix); | |
52 | void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, |
|
53 | void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, | |
53 | unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id); |
|
54 | unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id); | |
54 | void fill_averaged_spectral_matrix( void ); |
|
55 | ||
55 | void reset_spectral_matrix_regs(); |
|
56 | void BP1_send( ring_node_bp *ring_node_to_send, unsigned int sid, rtems_id queue_id ); | |
|
57 | ||||
|
58 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header); | |||
|
59 | void init_headers_bp_ring_sbm1(); | |||
|
60 | void init_header_bp( Header_TM_LFR_SCIENCE_BP_SBM_t *header); | |||
|
61 | ||||
|
62 | void reset_spectral_matrix_regs( void ); | |||
56 |
|
63 | |||
57 | #endif // FSW_PROCESSING_H_INCLUDED |
|
64 | #endif // FSW_PROCESSING_H_INCLUDED |
@@ -21,24 +21,27 ring_node_sm *ring_node_for_averaging_sm | |||||
21 | ring_node_sm *current_ring_node_sm_f1; |
|
21 | ring_node_sm *current_ring_node_sm_f1; | |
22 | ring_node_sm *current_ring_node_sm_f2; |
|
22 | ring_node_sm *current_ring_node_sm_f2; | |
23 |
|
23 | |||
24 | BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ]; |
|
24 | //********************** | |
|
25 | // basic parameter rings | |||
|
26 | ring_node_bp *current_node_sbm1_bp1_f0; | |||
|
27 | ring_node_bp bp_ring_sbm1[ NB_RING_NODES_BP1_SBM1 ]; | |||
25 |
|
28 | |||
26 | //***** |
|
29 | //***** | |
27 | // NORM |
|
30 | // NORM | |
28 | // F0 |
|
31 | // F0 | |
29 |
float a |
|
32 | float asm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ]; | |
30 |
float a |
|
33 | float asm_f0_reorganized[ TIME_OFFSET + TOTAL_SIZE_SM ]; | |
31 |
char a |
|
34 | char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; | |
32 | float compressed_sm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_F0 ]; |
|
35 | float compressed_sm_f0 [ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_F0 ]; | |
33 |
|
36 | |||
34 | //***** |
|
37 | //***** | |
35 | // SBM1 |
|
38 | // SBM1 | |
36 |
float averaged_sm_sbm1 |
|
39 | float averaged_sm_sbm1 [ TIME_OFFSET + TOTAL_SIZE_SM ]; | |
37 |
float compressed_sm_sbm1 |
|
40 | float compressed_sm_sbm1 [ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_SBM1 ]; | |
38 |
|
41 | |||
39 | unsigned char LFR_BP1_F0[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_BP1_F0 * 2 ]; |
|
42 | unsigned char LFR_BP1_F0[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F0 * 2 ]; | |
40 | unsigned char LFR_BP1_F1[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_BP1_F1 ]; |
|
43 | unsigned char LFR_BP1_F1[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F1 ]; | |
41 | unsigned char LFR_BP1_F2[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_BP1_F2 ]; |
|
44 | unsigned char LFR_BP1_F2[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F2 ]; | |
42 |
|
45 | |||
43 | unsigned int nb_sm_f0; |
|
46 | unsigned int nb_sm_f0; | |
44 |
|
47 | |||
@@ -120,6 +123,11 void reset_current_sm_ring_nodes( void ) | |||||
120 | ring_node_for_averaging_sm_f0 = sm_ring_f0; |
|
123 | ring_node_for_averaging_sm_f0 = sm_ring_f0; | |
121 | } |
|
124 | } | |
122 |
|
125 | |||
|
126 | void reset_current_node_sbm1_bp1_f0( void ) | |||
|
127 | { | |||
|
128 | current_node_sbm1_bp1_f0 = bp_ring_sbm1; | |||
|
129 | } | |||
|
130 | ||||
123 | //*********************************************************** |
|
131 | //*********************************************************** | |
124 | // Interrupt Service Routine for spectral matrices processing |
|
132 | // Interrupt Service Routine for spectral matrices processing | |
125 | void reset_nb_sm_f0( void ) |
|
133 | void reset_nb_sm_f0( void ) | |
@@ -223,14 +231,14 rtems_task avf0_task(rtems_task_argument | |||||
223 | ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0; |
|
231 | ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0; | |
224 | } |
|
232 | } | |
225 |
|
233 | |||
226 |
// copy time information in the a |
|
234 | // copy time information in the asm_f0 buffer | |
227 |
a |
|
235 | asm_f0[0] = ring_node_tab[7]->coarseTime; | |
228 |
a |
|
236 | asm_f0[1] = ring_node_tab[7]->fineTime; | |
229 | averaged_sm_sbm1[0] = ring_node_tab[7]->coarseTime; |
|
237 | averaged_sm_sbm1[0] = ring_node_tab[7]->coarseTime; | |
230 | averaged_sm_sbm1[1] = ring_node_tab[7]->fineTime; |
|
238 | averaged_sm_sbm1[1] = ring_node_tab[7]->fineTime; | |
231 |
|
239 | |||
232 | // compute the average and store it in the averaged_sm_f1 buffer |
|
240 | // compute the average and store it in the averaged_sm_f1 buffer | |
233 |
ASM_average( a |
|
241 | ASM_average( asm_f0, averaged_sm_sbm1, | |
234 | ring_node_tab, |
|
242 | ring_node_tab, | |
235 | nb_average_norm_f0, nb_average_sbm1_f0 ); |
|
243 | nb_average_norm_f0, nb_average_sbm1_f0 ); | |
236 |
|
244 | |||
@@ -271,8 +279,10 rtems_task matr_task(rtems_task_argument | |||||
271 | rtems_status_code status; |
|
279 | rtems_status_code status; | |
272 | rtems_id queue_id; |
|
280 | rtems_id queue_id; | |
273 | Header_TM_LFR_SCIENCE_ASM_t headerASM; |
|
281 | Header_TM_LFR_SCIENCE_ASM_t headerASM; | |
|
282 | ring_node_norm_bp current_node_norm_bp1_f0; | |||
274 |
|
283 | |||
275 | init_header_asm( &headerASM ); |
|
284 | init_header_asm( &headerASM ); | |
|
285 | // init_header_bp( ¤t_node_norm_bp1_f0.header ); | |||
276 |
|
286 | |||
277 | status = get_message_queue_id_send( &queue_id ); |
|
287 | status = get_message_queue_id_send( &queue_id ); | |
278 | if (status != RTEMS_SUCCESSFUL) |
|
288 | if (status != RTEMS_SUCCESSFUL) | |
@@ -282,33 +292,40 rtems_task matr_task(rtems_task_argument | |||||
282 |
|
292 | |||
283 | BOOT_PRINTF("in MATR *** \n") |
|
293 | BOOT_PRINTF("in MATR *** \n") | |
284 |
|
294 | |||
285 | fill_averaged_spectral_matrix( ); |
|
|||
286 |
|
||||
287 | while(1){ |
|
295 | while(1){ | |
288 | rtems_event_receive( RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1, |
|
296 | rtems_event_receive( RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1, | |
289 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
297 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
290 | if (event_out==RTEMS_EVENT_MODE_NORMAL) |
|
298 | if (event_out==RTEMS_EVENT_MODE_NORMAL) | |
291 | { |
|
299 | { | |
292 | // 1) compress the matrix for Basic Parameters calculation |
|
300 | // 1) compress the matrix for Basic Parameters calculation | |
293 |
ASM_compress( a |
|
301 | ASM_compress_reorganize_and_divide( asm_f0, compressed_sm_f0, | |
|
302 | NB_AVERAGE_NORMAL_F0, | |||
|
303 | NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, | |||
|
304 | ASM_F0_INDICE_START ); | |||
294 | // 2) compute the BP1 set |
|
305 | // 2) compute the BP1 set | |
295 |
|
306 | |||
296 | // 3) send the BP1 set |
|
307 | // 3) send the BP1 set | |
297 |
|
308 | BP1_send( ¤t_node_norm_bp1_f0, SID_NORM_BP1_F0, queue_id ); | ||
298 | // 4) convert the float array in a char array |
|
309 | // 4) reorganize the ASM and divide | |
299 |
ASM_reorganize( a |
|
310 | ASM_reorganize_and_divide( asm_f0, asm_f0_reorganized, NB_AVERAGE_NORMAL_F0 ); | |
300 | ASM_convert( averaged_sm_f0_reorganized, averaged_sm_f0_char); |
|
311 | // 5) convert the float array in a char array | |
301 | // 5) send the spectral matrix packets |
|
312 | ASM_convert( asm_f0_reorganized, asm_f0_char); | |
302 | ASM_send( &headerASM, averaged_sm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id); |
|
313 | // 6) send the spectral matrix packets | |
|
314 | ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id); | |||
303 | } |
|
315 | } | |
304 | else if (event_out==RTEMS_EVENT_MODE_SBM1) |
|
316 | else if (event_out==RTEMS_EVENT_MODE_SBM1) | |
305 | { |
|
317 | { | |
306 | // 1) compress the matrix for Basic Parameters calculation |
|
318 | // 1) compress the matrix for Basic Parameters calculation | |
307 |
ASM_compress( averaged_sm_sbm1, |
|
319 | ASM_compress_reorganize_and_divide( averaged_sm_sbm1, compressed_sm_sbm1, | |
|
320 | NB_AVERAGE_SBM1_F0, | |||
|
321 | NB_BINS_COMPRESSED_SM_SBM1_F0, NB_BINS_TO_AVERAGE_ASM_SBM1_F0, | |||
|
322 | ASM_F0_INDICE_START); | |||
308 | // 2) compute the BP1 set |
|
323 | // 2) compute the BP1 set | |
309 |
|
324 | |||
310 | // 3) send the basic parameters set 1 packet |
|
325 | // 3) send the basic parameters set 1 packet | |
311 |
|
326 | BP1_send( current_node_sbm1_bp1_f0, SID_SBM1_BP1_F0, queue_id ); | ||
|
327 | // 4) update current_node_sbm1_bp1_f0 | |||
|
328 | current_node_sbm1_bp1_f0 = current_node_sbm1_bp1_f0->next; | |||
312 | } |
|
329 | } | |
313 | else |
|
330 | else | |
314 | { |
|
331 | { | |
@@ -320,14 +337,6 rtems_task matr_task(rtems_task_argument | |||||
320 | //***************************** |
|
337 | //***************************** | |
321 | // Spectral matrices processing |
|
338 | // Spectral matrices processing | |
322 |
|
339 | |||
323 | void matrix_reset(volatile float *averaged_spec_mat) |
|
|||
324 | { |
|
|||
325 | int i; |
|
|||
326 | for(i=0; i<TOTAL_SIZE_SM; i++){ |
|
|||
327 | averaged_spec_mat[i] = 0; |
|
|||
328 | } |
|
|||
329 | } |
|
|||
330 |
|
||||
331 | void ASM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1, |
|
340 | void ASM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1, | |
332 | ring_node_sm *ring_node_tab[], |
|
341 | ring_node_sm *ring_node_tab[], | |
333 | unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 ) |
|
342 | unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 ) | |
@@ -368,7 +377,7 void ASM_average( float *averaged_spec_m | |||||
368 | } |
|
377 | } | |
369 | } |
|
378 | } | |
370 |
|
379 | |||
371 | void ASM_reorganize( float *averaged_spec_mat, float *averaged_spec_mat_reorganized ) |
|
380 | void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) | |
372 | { |
|
381 | { | |
373 | int frequencyBin; |
|
382 | int frequencyBin; | |
374 | int asmComponent; |
|
383 | int asmComponent; | |
@@ -382,12 +391,13 void ASM_reorganize( float *averaged_spe | |||||
382 | for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) |
|
391 | for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) | |
383 | { |
|
392 | { | |
384 | averaged_spec_mat_reorganized[ TIME_OFFSET + frequencyBin * NB_VALUES_PER_SM + asmComponent ] = |
|
393 | averaged_spec_mat_reorganized[ TIME_OFFSET + frequencyBin * NB_VALUES_PER_SM + asmComponent ] = | |
385 | averaged_spec_mat[ TIME_OFFSET + asmComponent * NB_BINS_PER_SM + frequencyBin ]; |
|
394 | averaged_spec_mat[ TIME_OFFSET + asmComponent * NB_BINS_PER_SM + frequencyBin ] / divider; | |
386 | } |
|
395 | } | |
387 | } |
|
396 | } | |
388 | } |
|
397 | } | |
389 |
|
398 | |||
390 |
void ASM_compress( |
|
399 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, | |
|
400 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) | |||
391 | { |
|
401 | { | |
392 | int frequencyBin; |
|
402 | int frequencyBin; | |
393 | int asmComponent; |
|
403 | int asmComponent; | |
@@ -395,40 +405,25 void ASM_compress( float *averaged_spec_ | |||||
395 | int offsetCompressed; |
|
405 | int offsetCompressed; | |
396 | int k; |
|
406 | int k; | |
397 |
|
407 | |||
398 | switch (fChannel){ |
|
|||
399 | case 0: |
|
|||
400 |
|
|
408 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) | |
401 |
|
|
409 | { | |
402 |
|
|
410 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) | |
403 |
|
|
411 | { | |
404 |
|
|
412 | offsetCompressed = TIME_OFFSET | |
405 |
|
|
413 | + frequencyBin * NB_VALUES_PER_SM | |
406 |
|
|
414 | + asmComponent; | |
407 |
|
|
415 | offsetASM = TIME_OFFSET | |
408 |
|
|
416 | + asmComponent * NB_BINS_PER_SM | |
409 |
|
|
417 | + ASMIndexStart | |
410 |
|
|
418 | + frequencyBin * nbBinsToAverage; | |
411 |
|
|
419 | compressed_spec_mat[ offsetCompressed ] = 0; | |
412 |
|
|
420 | for ( k = 0; k < nbBinsToAverage; k++ ) | |
413 |
|
|
421 | { | |
414 |
|
|
422 | compressed_spec_mat[offsetCompressed ] = | |
415 |
|
|
423 | ( compressed_spec_mat[ offsetCompressed ] | |
416 |
|
|
424 | + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage); | |
417 | } |
|
|||
418 | } |
|
425 | } | |
419 | } |
|
426 | } | |
420 | break; |
|
|||
421 |
|
||||
422 | case 1: |
|
|||
423 | // case fChannel = f1 to be completed later |
|
|||
424 | break; |
|
|||
425 |
|
||||
426 | case 2: |
|
|||
427 | // case fChannel = f1 to be completed later |
|
|||
428 | break; |
|
|||
429 |
|
||||
430 | default: |
|
|||
431 | break; |
|
|||
432 | } |
|
427 | } | |
433 | } |
|
428 | } | |
434 |
|
429 | |||
@@ -526,191 +521,65 void ASM_send(Header_TM_LFR_SCIENCE_ASM_ | |||||
526 | } |
|
521 | } | |
527 | } |
|
522 | } | |
528 |
|
523 | |||
529 | void BP1_send() |
|
524 | void BP1_send( ring_node_bp *ring_node_to_send, unsigned int sid, rtems_id queue_id ) | |
|
525 | { | |||
|
526 | unsigned int length = 0; | |||
|
527 | rtems_status_code status; | |||
|
528 | unsigned char nbBytesTosend; | |||
|
529 | ||||
|
530 | // (1) BUILD THE DATA | |||
|
531 | switch(sid) | |||
530 | { |
|
532 | { | |
531 |
|
533 | case SID_NORM_BP1_F0: | ||
|
534 | length = PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0; | |||
|
535 | ring_node_to_send->header.packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); | |||
|
536 | ring_node_to_send->header.packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); | |||
|
537 | ring_node_to_send->header.pa_lfr_bp_blk_nr[0] = (unsigned char) ( (NB_BINS_COMPRESSED_SM_F0) >> 8 ); // BLK_NR MSB | |||
|
538 | ring_node_to_send->header.pa_lfr_bp_blk_nr[1] = (unsigned char) (NB_BINS_COMPRESSED_SM_F0); // BLK_NR LSB | |||
|
539 | nbBytesTosend = PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 | |||
|
540 | + CCSDS_TC_TM_PACKET_OFFSET | |||
|
541 | + CCSDS_PROTOCOLE_EXTRA_BYTES; | |||
|
542 | case SID_SBM1_BP1_F0: | |||
|
543 | length = PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0; | |||
|
544 | ring_node_to_send->header.packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8); | |||
|
545 | ring_node_to_send->header.packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2); | |||
|
546 | ring_node_to_send->header.pa_lfr_bp_blk_nr[0] = (unsigned char) ( (NB_BINS_COMPRESSED_SM_SBM1_F0) >> 8 ); // BLK_NR MSB | |||
|
547 | ring_node_to_send->header.pa_lfr_bp_blk_nr[1] = (unsigned char) (NB_BINS_COMPRESSED_SM_SBM1_F0); // BLK_NR LSB | |||
|
548 | nbBytesTosend = PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 | |||
|
549 | + CCSDS_TC_TM_PACKET_OFFSET | |||
|
550 | + CCSDS_PROTOCOLE_EXTRA_BYTES; | |||
|
551 | break; | |||
|
552 | default: | |||
|
553 | nbBytesTosend = 0; | |||
|
554 | PRINTF1("ERR *** in BP1_send *** unexpected sid %d\n", sid) | |||
|
555 | break; | |||
532 | } |
|
556 | } | |
533 |
|
557 | |||
534 | void BP1_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){ |
|
558 | // (2) BUILD THE HEADER | |
535 | int i; |
|
559 | ring_node_to_send->header.packetLength[0] = (unsigned char) (length>>8); | |
536 | int j; |
|
560 | ring_node_to_send->header.packetLength[1] = (unsigned char) (length); | |
537 | unsigned char tmp_u_char; |
|
561 | ring_node_to_send->header.sid = sid; | |
538 | unsigned char * pt_char = NULL; |
|
|||
539 | float PSDB, PSDE; |
|
|||
540 | float NVEC_V0; |
|
|||
541 | float NVEC_V1; |
|
|||
542 | float NVEC_V2; |
|
|||
543 | //float significand; |
|
|||
544 | //int exponent; |
|
|||
545 | float aux; |
|
|||
546 | float tr_SB_SB; |
|
|||
547 | float tmp; |
|
|||
548 | float sx_re; |
|
|||
549 | float sx_im; |
|
|||
550 | float nebx_re = 0; |
|
|||
551 | float nebx_im = 0; |
|
|||
552 | float ny = 0; |
|
|||
553 | float nz = 0; |
|
|||
554 | float bx_bx_star = 0; |
|
|||
555 | for(i=0; i<nb_bins_compressed_spec_mat; i++){ |
|
|||
556 | //============================================== |
|
|||
557 | // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits |
|
|||
558 | PSDB = compressed_spec_mat[i*30] // S11 |
|
|||
559 | + compressed_spec_mat[(i*30) + 10] // S22 |
|
|||
560 | + compressed_spec_mat[(i*30) + 18]; // S33 |
|
|||
561 | //significand = frexp(PSDB, &exponent); |
|
|||
562 | pt_char = (unsigned char*) &PSDB; |
|
|||
563 | LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float |
|
|||
564 | LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float |
|
|||
565 | //============================================== |
|
|||
566 | // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits |
|
|||
567 | PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44 |
|
|||
568 | + compressed_spec_mat[(i*30) + 28] * K55_pe // S55 |
|
|||
569 | + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45 |
|
|||
570 | - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45 |
|
|||
571 | pt_char = (unsigned char*) &PSDE; |
|
|||
572 | LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float |
|
|||
573 | LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float |
|
|||
574 | //============================================================================== |
|
|||
575 | // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits |
|
|||
576 | // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits |
|
|||
577 | // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits |
|
|||
578 | tmp = sqrt( |
|
|||
579 | compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12 |
|
|||
580 | +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13 |
|
|||
581 | +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23 |
|
|||
582 | ); |
|
|||
583 | NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23 |
|
|||
584 | NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13 |
|
|||
585 | NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12 |
|
|||
586 | LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127); |
|
|||
587 | LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127); |
|
|||
588 | pt_char = (unsigned char*) &NVEC_V2; |
|
|||
589 | LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2 |
|
|||
590 | //======================================================= |
|
|||
591 | // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits |
|
|||
592 | aux = 2*tmp / PSDB; // compute the ellipticity |
|
|||
593 | tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity |
|
|||
594 | LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char |
|
|||
595 | //============================================================== |
|
|||
596 | // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits |
|
|||
597 | for(j = 0; j<NB_VALUES_PER_SM;j++){ |
|
|||
598 | tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30] |
|
|||
599 | + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10] |
|
|||
600 | + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18] |
|
|||
601 | + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2] |
|
|||
602 | + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3] |
|
|||
603 | + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4] |
|
|||
604 | + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5] |
|
|||
605 | + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12] |
|
|||
606 | + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13]; |
|
|||
607 | } |
|
|||
608 | aux = PSDB*PSDB; |
|
|||
609 | tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) ); |
|
|||
610 | tmp_u_char = (unsigned char) (NVEC_V0*(8-1)); |
|
|||
611 | LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char |
|
|||
612 | //======================================================================================= |
|
|||
613 | // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1) |
|
|||
614 | sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re |
|
|||
615 | + compressed_spec_mat[(i*30) + 6] * K14_sx_re |
|
|||
616 | + compressed_spec_mat[(i*30) + 8] * K15_sx_re |
|
|||
617 | + compressed_spec_mat[(i*30) + 14] * K24_sx_re |
|
|||
618 | + compressed_spec_mat[(i*30) + 16] * K25_sx_re |
|
|||
619 | + compressed_spec_mat[(i*30) + 22] * K35_sx_re; |
|
|||
620 | sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im |
|
|||
621 | + compressed_spec_mat[(i*30) + 7] * K14_sx_im |
|
|||
622 | + compressed_spec_mat[(i*30) + 9] * K15_sx_im |
|
|||
623 | + compressed_spec_mat[(i*30) + 15] * K24_sx_im |
|
|||
624 | + compressed_spec_mat[(i*30) + 17] * K25_sx_im |
|
|||
625 | + compressed_spec_mat[(i*30) + 23] * K35_sx_im; |
|
|||
626 | LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression |
|
|||
627 | if ( abs(sx_re) > abs(sx_im) ) { |
|
|||
628 | LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx |
|
|||
629 | } |
|
|||
630 | else { |
|
|||
631 | LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx |
|
|||
632 | } |
|
|||
633 | //====================================================================== |
|
|||
634 | // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1) |
|
|||
635 | ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2; |
|
|||
636 | nz = NVEC_V0; |
|
|||
637 | bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22 |
|
|||
638 | + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33 |
|
|||
639 | - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23 |
|
|||
640 | nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re |
|
|||
641 | +compressed_spec_mat[(i*30) + 16] * K25_ny_re |
|
|||
642 | +compressed_spec_mat[(i*30) + 20] * K34_ny_re |
|
|||
643 | +compressed_spec_mat[(i*30) + 22] * K35_ny_re) |
|
|||
644 | + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re |
|
|||
645 | +compressed_spec_mat[(i*30) + 16] * K25_nz_re |
|
|||
646 | +compressed_spec_mat[(i*30) + 20] * K34_nz_re |
|
|||
647 | +compressed_spec_mat[(i*30) + 22] * K35_nz_re); |
|
|||
648 | nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re |
|
|||
649 | +compressed_spec_mat[(i*30) + 17] * K25_ny_re |
|
|||
650 | +compressed_spec_mat[(i*30) + 21] * K34_ny_re |
|
|||
651 | +compressed_spec_mat[(i*30) + 23] * K35_ny_re) |
|
|||
652 | + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im |
|
|||
653 | +compressed_spec_mat[(i*30) + 17] * K25_nz_im |
|
|||
654 | +compressed_spec_mat[(i*30) + 21] * K34_nz_im |
|
|||
655 | +compressed_spec_mat[(i*30) + 23] * K35_nz_im); |
|
|||
656 | tmp = nebx_re / bx_bx_star; |
|
|||
657 | LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression |
|
|||
658 | if ( abs(nebx_re) > abs(nebx_im) ) { |
|
|||
659 | LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx |
|
|||
660 | } |
|
|||
661 | else { |
|
|||
662 | LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx |
|
|||
663 | } |
|
|||
664 | } |
|
|||
665 |
|
562 | |||
666 | } |
|
563 | // (3) SET PACKET TIME | |
667 |
|
564 | ring_node_to_send->header.time[0] = (unsigned char) (ring_node_to_send->coarseTime>>24); | ||
668 | void BP2_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){ |
|
565 | ring_node_to_send->header.time[1] = (unsigned char) (ring_node_to_send->coarseTime>>16); | |
669 | // BP2 autocorrelation |
|
566 | ring_node_to_send->header.time[2] = (unsigned char) (ring_node_to_send->coarseTime>>8); | |
670 | int i; |
|
567 | ring_node_to_send->header.time[3] = (unsigned char) (ring_node_to_send->coarseTime); | |
671 | int aux = 0; |
|
568 | ring_node_to_send->header.time[4] = (unsigned char) (ring_node_to_send->fineTime>>8); | |
|
569 | ring_node_to_send->header.time[5] = (unsigned char) (ring_node_to_send->fineTime); | |||
|
570 | // | |||
|
571 | ring_node_to_send->header.acquisitionTime[0] = (unsigned char) (ring_node_to_send->coarseTime>>24); | |||
|
572 | ring_node_to_send->header.acquisitionTime[1] = (unsigned char) (ring_node_to_send->coarseTime>>16); | |||
|
573 | ring_node_to_send->header.acquisitionTime[2] = (unsigned char) (ring_node_to_send->coarseTime>>8); | |||
|
574 | ring_node_to_send->header.acquisitionTime[3] = (unsigned char) (ring_node_to_send->coarseTime); | |||
|
575 | ring_node_to_send->header.acquisitionTime[4] = (unsigned char) (ring_node_to_send->fineTime>>8); | |||
|
576 | ring_node_to_send->header.acquisitionTime[5] = (unsigned char) (ring_node_to_send->fineTime); | |||
672 |
|
577 | |||
673 | for(i = 0; i<nb_bins_compressed_spec_mat; i++){ |
|
578 | // (4) SEND PACKET | |
674 | // S12 |
|
579 | status = rtems_message_queue_send( queue_id, &ring_node_to_send->header, nbBytesTosend); | |
675 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]); |
|
580 | if (status != RTEMS_SUCCESSFUL) | |
676 | compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux; |
|
581 | { | |
677 | compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux; |
|
582 | printf("ERR *** in BP1_send *** ERR %d\n", (int) status); | |
678 | // S13 |
|
|||
679 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]); |
|
|||
680 | compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux; |
|
|||
681 | compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux; |
|
|||
682 | // S23 |
|
|||
683 | aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]); |
|
|||
684 | compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux; |
|
|||
685 | compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux; |
|
|||
686 | // S45 |
|
|||
687 | aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]); |
|
|||
688 | compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux; |
|
|||
689 | compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux; |
|
|||
690 | // S14 |
|
|||
691 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]); |
|
|||
692 | compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux; |
|
|||
693 | compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux; |
|
|||
694 | // S15 |
|
|||
695 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]); |
|
|||
696 | compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux; |
|
|||
697 | compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux; |
|
|||
698 | // S24 |
|
|||
699 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]); |
|
|||
700 | compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux; |
|
|||
701 | compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux; |
|
|||
702 | // S25 |
|
|||
703 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]); |
|
|||
704 | compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux; |
|
|||
705 | compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux; |
|
|||
706 | // S34 |
|
|||
707 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]); |
|
|||
708 | compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux; |
|
|||
709 | compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux; |
|
|||
710 | // S35 |
|
|||
711 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]); |
|
|||
712 | compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux; |
|
|||
713 | compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux; |
|
|||
714 | } |
|
583 | } | |
715 | } |
|
584 | } | |
716 |
|
585 | |||
@@ -746,14 +615,41 void init_header_asm( Header_TM_LFR_SCIE | |||||
746 | header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB |
|
615 | header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB | |
747 | } |
|
616 | } | |
748 |
|
617 | |||
749 | void init_header_bp( Header_TM_LFR_SCIENCE_BP_t *header) |
|
618 | void init_bp_ring_sbm1() | |
|
619 | { | |||
|
620 | unsigned int i; | |||
|
621 | ||||
|
622 | //******** | |||
|
623 | // F0 RING | |||
|
624 | bp_ring_sbm1[0].next = (ring_node_bp*) &bp_ring_sbm1[1]; | |||
|
625 | bp_ring_sbm1[0].previous = (ring_node_bp*) &bp_ring_sbm1[NB_RING_NODES_BP1_SBM1-1]; | |||
|
626 | ||||
|
627 | bp_ring_sbm1[NB_RING_NODES_BP1_SBM1-1].next = (ring_node_bp*) &bp_ring_sbm1[0]; | |||
|
628 | bp_ring_sbm1[NB_RING_NODES_BP1_SBM1-1].previous = (ring_node_bp*) &bp_ring_sbm1[NB_RING_NODES_ASM_F0-2]; | |||
|
629 | ||||
|
630 | for(i=1; i<NB_RING_NODES_BP1_SBM1-1; i++) | |||
|
631 | { | |||
|
632 | bp_ring_sbm1[i].next = (ring_node_bp*) &bp_ring_sbm1[i+1]; | |||
|
633 | bp_ring_sbm1[i].previous = (ring_node_bp*) &bp_ring_sbm1[i-1]; | |||
|
634 | } | |||
|
635 | // | |||
|
636 | //******** | |||
|
637 | ||||
|
638 | for (i=0; i<NB_RING_NODES_BP1_SBM1; i++) | |||
|
639 | { | |||
|
640 | init_header_bp( (Header_TM_LFR_SCIENCE_BP_SBM_t*) &bp_ring_sbm1[ i ] ); | |||
|
641 | bp_ring_sbm1[ i ].status = 0; | |||
|
642 | } | |||
|
643 | } | |||
|
644 | ||||
|
645 | void init_header_bp(Header_TM_LFR_SCIENCE_BP_SBM_t *header ) | |||
750 | { |
|
646 | { | |
751 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
647 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
752 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
648 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
753 | header->reserved = 0x00; |
|
649 | header->reserved = 0x00; | |
754 | header->userApplication = CCSDS_USER_APP; |
|
650 | header->userApplication = CCSDS_USER_APP; | |
755 |
|
|
651 | header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8); | |
756 |
|
|
652 | header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2); | |
757 | header->packetSequenceControl[0] = 0xc0; |
|
653 | header->packetSequenceControl[0] = 0xc0; | |
758 | header->packetSequenceControl[1] = 0x00; |
|
654 | header->packetSequenceControl[1] = 0x00; | |
759 | header->packetLength[0] = 0x00; |
|
655 | header->packetLength[0] = 0x00; | |
@@ -776,86 +672,7 void init_header_bp( Header_TM_LFR_SCIEN | |||||
776 | header->pa_lfr_bp_blk_nr[1] = 0x00; // BLK_NR LSB |
|
672 | header->pa_lfr_bp_blk_nr[1] = 0x00; // BLK_NR LSB | |
777 | } |
|
673 | } | |
778 |
|
674 | |||
779 |
void |
|
675 | void reset_spectral_matrix_regs( void ) | |
780 | { |
|
|||
781 | /** This function fills spectral matrices related buffers with arbitrary data. |
|
|||
782 | * |
|
|||
783 | * This function is for testing purpose only. |
|
|||
784 | * |
|
|||
785 | */ |
|
|||
786 |
|
||||
787 | float offset; |
|
|||
788 | float coeff; |
|
|||
789 |
|
||||
790 | offset = 10.; |
|
|||
791 | coeff = 100000.; |
|
|||
792 | averaged_sm_f0[ 0 + 25 * 0 ] = 0. + offset; |
|
|||
793 | averaged_sm_f0[ 0 + 25 * 1 ] = 1. + offset; |
|
|||
794 | averaged_sm_f0[ 0 + 25 * 2 ] = 2. + offset; |
|
|||
795 | averaged_sm_f0[ 0 + 25 * 3 ] = 3. + offset; |
|
|||
796 | averaged_sm_f0[ 0 + 25 * 4 ] = 4. + offset; |
|
|||
797 | averaged_sm_f0[ 0 + 25 * 5 ] = 5. + offset; |
|
|||
798 | averaged_sm_f0[ 0 + 25 * 6 ] = 6. + offset; |
|
|||
799 | averaged_sm_f0[ 0 + 25 * 7 ] = 7. + offset; |
|
|||
800 | averaged_sm_f0[ 0 + 25 * 8 ] = 8. + offset; |
|
|||
801 | averaged_sm_f0[ 0 + 25 * 9 ] = 9. + offset; |
|
|||
802 | averaged_sm_f0[ 0 + 25 * 10 ] = 10. + offset; |
|
|||
803 | averaged_sm_f0[ 0 + 25 * 11 ] = 11. + offset; |
|
|||
804 | averaged_sm_f0[ 0 + 25 * 12 ] = 12. + offset; |
|
|||
805 | averaged_sm_f0[ 0 + 25 * 13 ] = 13. + offset; |
|
|||
806 | averaged_sm_f0[ 0 + 25 * 14 ] = 14. + offset; |
|
|||
807 | averaged_sm_f0[ 9 + 25 * 0 ] = -(0. + offset)* coeff; |
|
|||
808 | averaged_sm_f0[ 9 + 25 * 1 ] = -(1. + offset)* coeff; |
|
|||
809 | averaged_sm_f0[ 9 + 25 * 2 ] = -(2. + offset)* coeff; |
|
|||
810 | averaged_sm_f0[ 9 + 25 * 3 ] = -(3. + offset)* coeff; |
|
|||
811 | averaged_sm_f0[ 9 + 25 * 4 ] = -(4. + offset)* coeff; |
|
|||
812 | averaged_sm_f0[ 9 + 25 * 5 ] = -(5. + offset)* coeff; |
|
|||
813 | averaged_sm_f0[ 9 + 25 * 6 ] = -(6. + offset)* coeff; |
|
|||
814 | averaged_sm_f0[ 9 + 25 * 7 ] = -(7. + offset)* coeff; |
|
|||
815 | averaged_sm_f0[ 9 + 25 * 8 ] = -(8. + offset)* coeff; |
|
|||
816 | averaged_sm_f0[ 9 + 25 * 9 ] = -(9. + offset)* coeff; |
|
|||
817 | averaged_sm_f0[ 9 + 25 * 10 ] = -(10. + offset)* coeff; |
|
|||
818 | averaged_sm_f0[ 9 + 25 * 11 ] = -(11. + offset)* coeff; |
|
|||
819 | averaged_sm_f0[ 9 + 25 * 12 ] = -(12. + offset)* coeff; |
|
|||
820 | averaged_sm_f0[ 9 + 25 * 13 ] = -(13. + offset)* coeff; |
|
|||
821 | averaged_sm_f0[ 9 + 25 * 14 ] = -(14. + offset)* coeff; |
|
|||
822 |
|
||||
823 | offset = 10000000; |
|
|||
824 | averaged_sm_f0[ 16 + 25 * 0 ] = (0. + offset)* coeff; |
|
|||
825 | averaged_sm_f0[ 16 + 25 * 1 ] = (1. + offset)* coeff; |
|
|||
826 | averaged_sm_f0[ 16 + 25 * 2 ] = (2. + offset)* coeff; |
|
|||
827 | averaged_sm_f0[ 16 + 25 * 3 ] = (3. + offset)* coeff; |
|
|||
828 | averaged_sm_f0[ 16 + 25 * 4 ] = (4. + offset)* coeff; |
|
|||
829 | averaged_sm_f0[ 16 + 25 * 5 ] = (5. + offset)* coeff; |
|
|||
830 | averaged_sm_f0[ 16 + 25 * 6 ] = (6. + offset)* coeff; |
|
|||
831 | averaged_sm_f0[ 16 + 25 * 7 ] = (7. + offset)* coeff; |
|
|||
832 | averaged_sm_f0[ 16 + 25 * 8 ] = (8. + offset)* coeff; |
|
|||
833 | averaged_sm_f0[ 16 + 25 * 9 ] = (9. + offset)* coeff; |
|
|||
834 | averaged_sm_f0[ 16 + 25 * 10 ] = (10. + offset)* coeff; |
|
|||
835 | averaged_sm_f0[ 16 + 25 * 11 ] = (11. + offset)* coeff; |
|
|||
836 | averaged_sm_f0[ 16 + 25 * 12 ] = (12. + offset)* coeff; |
|
|||
837 | averaged_sm_f0[ 16 + 25 * 13 ] = (13. + offset)* coeff; |
|
|||
838 | averaged_sm_f0[ 16 + 25 * 14 ] = (14. + offset)* coeff; |
|
|||
839 |
|
||||
840 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 0 ] = averaged_sm_f0[ 0 ]; |
|
|||
841 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 1 ] = averaged_sm_f0[ 1 ]; |
|
|||
842 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 2 ] = averaged_sm_f0[ 2 ]; |
|
|||
843 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 3 ] = averaged_sm_f0[ 3 ]; |
|
|||
844 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 4 ] = averaged_sm_f0[ 4 ]; |
|
|||
845 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 5 ] = averaged_sm_f0[ 5 ]; |
|
|||
846 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 6 ] = averaged_sm_f0[ 6 ]; |
|
|||
847 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 7 ] = averaged_sm_f0[ 7 ]; |
|
|||
848 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 8 ] = averaged_sm_f0[ 8 ]; |
|
|||
849 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 9 ] = averaged_sm_f0[ 9 ]; |
|
|||
850 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 10 ] = averaged_sm_f0[ 10 ]; |
|
|||
851 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 11 ] = averaged_sm_f0[ 11 ]; |
|
|||
852 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 12 ] = averaged_sm_f0[ 12 ]; |
|
|||
853 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 13 ] = averaged_sm_f0[ 13 ]; |
|
|||
854 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 14 ] = averaged_sm_f0[ 14 ]; |
|
|||
855 | averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 15 ] = averaged_sm_f0[ 15 ]; |
|
|||
856 | } |
|
|||
857 |
|
||||
858 | void reset_spectral_matrix_regs() |
|
|||
859 | { |
|
676 | { | |
860 | /** This function resets the spectral matrices module registers. |
|
677 | /** This function resets the spectral matrices module registers. | |
861 | * |
|
678 | * |
@@ -532,7 +532,7 int enter_mode( unsigned char mode, unsi | |||||
532 | #endif |
|
532 | #endif | |
533 | status = restart_science_tasks(); |
|
533 | status = restart_science_tasks(); | |
534 | launch_waveform_picker( mode, transitionCoarseTime ); |
|
534 | launch_waveform_picker( mode, transitionCoarseTime ); | |
535 |
|
|
535 | launch_spectral_matrix_simu( mode ); | |
536 | } |
|
536 | } | |
537 | else if ( mode == LFR_MODE_STANDBY ) |
|
537 | else if ( mode == LFR_MODE_STANDBY ) | |
538 | { |
|
538 | { | |
@@ -842,7 +842,7 void close_action(ccsdsTelecommandPacket | |||||
842 | updateLFRCurrentMode(); |
|
842 | updateLFRCurrentMode(); | |
843 | } |
|
843 | } | |
844 | } |
|
844 | } | |
845 | else |
|
845 | else if (result == LFR_EXE_ERROR) | |
846 | { |
|
846 | { | |
847 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
847 | send_tm_lfr_tc_exe_error( TC, queue_id ); | |
848 | } |
|
848 | } |
General Comments 0
You need to be logged in to leave comments.
Login now