OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
process_group2_packet1_vdata.c
Go to the documentation of this file.
1 #include "L1A_prototype.h"
2 #include "EN_eng_data.h"
3 #include "PGS_IO_L0.h"
4 #include "hntdefs.h"
5 #include "PGS_SMF.h"
6 #include "PGS_IO.h"
7 #include "PGS_MODIS_35005.h"
8 
9 void process_group2_packet1_vdata ( PGSt_IO_L0_Packet *pkt, EN_VDATA_TYPE_t *eng_data)
10 
11 /*
12 !C************************************************************************
13 !Description: This function adds the data for the Prior and Current Ancillary
14  Vdata to the Vdata array (eng_data). This procedure extracts the
15  data from the packet, and stores the data in the eng_data structure.
16 
17 !Input Parameters:
18  PGSt_IO_L0_Packet *pkt ** The current eng **
19  ** packet **
20 
21 !Output Parameters:
22  EN_VDATA_TYPE_t *eng_data ** Stores Vdata values **
23 
24 !Input/Output Parameters:
25  None
26 
27 Return Values:
28  None
29 
30 Externally Defined:
31  PGSt_IO_L0_Packet (PGS_IO_L0.h)
32  EN_VDATA_TYPE_t (EN_eng_data.h)
33  EN_SC_ANCILLARY_VDATA_START (EN_eng_data.h)
34  EN_SC_ANCILLARY_VDATA_END (EN_eng_data.h)
35  PD_NUM_BITS_IN_BYTE (PD_pkt_data.h)
36  PD_PKT_CONTENTS_BYTE_OFFSET (PD_pkt_data.h)
37  DFNT_INT8 (hntdefs.h)
38  DFNT_UINT8 (hntdefs.h)
39  DFNT_INT16 (hntdefs.h)
40  DFNT_UINT16 (hntdefs.h)
41  DFNT_INT32 (hntdefs.h)
42  DFNT_UINT32 (hntdefs.h)
43  EN_MAX_VDATA_ORDER (EN_eng_data.h)
44  MODIS_E_INVALID_VDATA_ORDER (PGS_MODIS_35005.h)
45  MODIS_E_INVALID_VDATA_TYPE (PGS_MODIS_35005.h)
46 
47 Called By:
48  process_eng_packet
49 
50 Routines Called:
51  extr_bits
52  log_fmt_msg
53 
54 !Revision History:
55  Revision 1.0 1998/10/26 11:45:00 EST
56  John Seaton/SAIC/GSC (seaton@ltpmail.gsfc.nasa.gov)
57  Original design.
58 
59 !Team-unique Header:
60  This software is developed by the MODIS Science
61  Data Support Team (SDST) for the National Aeronautics
62  and Space Administration (NASA), Goddard Space Flight
63  Center (GSFC), under contract NAS5-32373.
64 
65 !References and Credits:
66  None
67 
68 !Design Notes:
69  This routine is written in ANSI C.
70  This routine assumes that the vdatas with orders greater than 1
71  all have type of uint8. If this changes, code changes will need
72  to be made to the start_pos calculation to replace k with
73  the number of bytes in the field.
74  This routine assumes that the data currently stored in the
75  int16 union value field is really 12 bit signed data. Sign
76  extension is performed on all data stored in the int16 union value.
77 
78 !END************************************************************************
79 */
80 {
81  int i,j, k; /* loop control variables */
82  int start_pos; /* starting position of data in pkt */
83  int num_bits; /* number of bits to extract from pkt */
84  int start_byte; /* starting byte for data extraction from pkt */
85  int start_bit; /* starting bit for data extraction from pkt */
86  char msg[300]; /* array to store error messages */
87  char *routine = "process_group2_packet1_vdata";
88  uint16 ui16_value; /* unsigned int16 value for proper sign extension */
89 
90 /****************************************************************************/
91 /* Check for NULL input paramaters. */
92 /****************************************************************************/
93 
94 if ((pkt == NULL) || (eng_data == NULL)) {
95  log_fmt_msg(MODIS_E_NULL_POINTER, routine, " ");
96  return;
97 }
98 
99 /****************************************************************************/
100 /* Loop through the 2 S/C Ancillary Data Vdatas. */
101 /****************************************************************************/
103 
104 /****************************************************************************/
105 /* Loop through all fields for each vdata. */
106 /****************************************************************************/
107  for (j=0; j< eng_data[i].num_fields; j++) {
108 
109 /****************************************************************************/
110 /* Loop through all orders for each field. */
111 /****************************************************************************/
112  if ((eng_data[i].field[j].order > 0) && (eng_data[i].field[j].order <=
114 
115 /****************************************************************************/
116 /* Calculate where in the packet the data for this vdata field exists. */
117 /****************************************************************************/
118  num_bits = eng_data[i].field[j].num_bits / eng_data[i].field[j].order;
119  for (k=0; k < eng_data[i].field[j].order; k++) {
120  start_pos = eng_data[i].field[j].start_bit_pos;
121  start_pos += (PD_NUM_BITS_IN_BYTE * k);
122  start_byte = (start_pos / PD_NUM_BITS_IN_BYTE) +
124  start_bit = start_pos % PD_NUM_BITS_IN_BYTE;
125 
126 /****************************************************************************/
127 /* Extract data from packet into proper union type value field. */
128 /****************************************************************************/
129  switch (eng_data[i].field[j].type) {
130  case DFNT_INT8 : eng_data[i].field[j].union_value[k].i8type =
131  (int8) extr_bits(pkt,start_bit,start_byte,num_bits);
132  break;
133  case DFNT_UINT8 :
134  eng_data[i].field[j].union_value[k].ui8type =
135  (uint8) extr_bits(pkt,start_bit,start_byte,num_bits);
136  break;
137  case DFNT_INT16 :
138  ui16_value = (uint16) extr_bits(pkt,start_bit,start_byte,num_bits);
139  if (ui16_value > 0x800)
140  eng_data[i].field[j].union_value[k].i16type =
141  (int16) (ui16_value - 0x1000);
142  else
143  eng_data[i].field[j].union_value[k].i16type = (int16) ui16_value;
144  break;
145  case DFNT_UINT16 :
146  eng_data[i].field[j].union_value[k].ui16type =
147  (uint16) extr_bits(pkt,start_bit,start_byte,num_bits);
148  break;
149  case DFNT_INT32 :
150  eng_data[i].field[j].union_value[k].i32type =
151  (int32) extr_bits(pkt,start_bit,start_byte,num_bits);
152  break;
153  case DFNT_UINT32 :
154  eng_data[i].field[j].union_value[k].ui32type =
155  (uint32) extr_bits(pkt,start_bit,start_byte,num_bits);
156  break;
157  default :
158  sprintf(msg, "Vdata Name = %s, Field Name = %s", eng_data[i].vdata_name,
159  eng_data[i].field[j].field_name);
161  break;
162 
163  } /* end switch */
164 
165  } /* for k */
166 
167  } /* if order */
168 
169 /**********************************************************************************/
170 /* Invalid order value error. */
171 /**********************************************************************************/
172  else {
173  sprintf(msg, "Vdata Name = %s, Field Name = %s", eng_data[i].vdata_name,
174  eng_data[i].field[j].field_name);
176  } /* else */
177 
178  } /* end for j*/
179 
180  } /* end for i */
181 
182  return;
183 
184 }/* eng process_group2_packet1_vdata.c */
185 
integer, parameter int16
Definition: cubeio.f90:3
EN_FIELD_TYPE_t field[EN_MAX_FIELDS_PER_VDATA]
Definition: EN_eng_data.h:125
int j
Definition: decode_rs.h:73
#define NULL
Definition: decode_rs.h:63
uint16 start_bit_pos
Definition: EN_eng_data.h:109
HDF4 data type of the output SDS Default is DFNT_FLOAT32 Common types used DFNT_INT32
#define EN_MAX_VDATA_ORDER
Definition: EN_eng_data.h:95
union EN_FIELD_TYPE_t::@18 union_value[EN_MAX_VDATA_ORDER]
#define EN_SC_ANCILLARY_VDATA_END
Definition: EN_eng_data.h:88
#define PD_NUM_BITS_IN_BYTE
Definition: PD_pkt_data.h:71
#define MODIS_E_INVALID_VDATA_ORDER
#define PD_PKT_CONTENTS_BYTE_OFFSET
Definition: PD_pkt_data.h:77
#define EN_SC_ANCILLARY_VDATA_START
Definition: EN_eng_data.h:87
void log_fmt_msg(PGSt_SMF_status code, const char *routine, const char *msg_fmt,...)
Definition: log_fmt_msg.c:6
HDF4 data type of the output SDS Default is DFNT_FLOAT32 Common types used DFNT_INT16
void process_group2_packet1_vdata(PGSt_IO_L0_Packet *pkt, EN_VDATA_TYPE_t *eng_data)
uint32 extr_bits(uint8 *a, int start_bit, int start_byte, int num_bits)
Definition: extr_bits.c:6
string msg
Definition: mapgen.py:227
#define MODIS_E_INVALID_VDATA_TYPE
int i
Definition: decode_rs.h:71
#define MODIS_E_NULL_POINTER
int k
Definition: decode_rs.h:73