/* *********************************
 * *                               *
 * *  IRIS GRIB Table Header File  *
 * *                               *
 * *********************************
 * File: utils/grib1/siggrib1.h
 *
 *                   COPYRIGHT (c) 2002, 2003  BY
 *          SIGMET INCORPORATED, WESTFORD MASSACHUSETTS, U.S.A.
 * 
 * THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
 * ONLY  IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
 * INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE  OR  ANY OTHER
 * COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
 * OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
 * TRANSFERED.
 */

/* -----------------------------------------------
 * Things related to the IRIS convertor code.
 */
#define GRIB_TABLE2_HEIGHT        (8)
#define GRIB_TABLE2_RAINRATE     (59)
#define GRIB_TABLE2_RAINACC      (61)

#define GRIB_TABLE3_GROUND        (1)
#define GRIB_TABLE3_ALTITUDE    (103)
#define GRIB_TABLE3_LAYER       (104)
#define GRIB_TABLE3_ATMOSPHERE  (200)

#define GRIB_TABLE4_HOURS         (1)

#define GRIB_TABLE5_INSTANTANEOUS (0)
#define GRIB_TABLE5_ACCUMULATION  (4)

#define GRIB_TABLE6_EDC           (0)  /* Equidistand cylindrical */
#define GRIB_TABLE6_MERCATOR      (1)
#define GRIB_TABLE6_POL_STEREO    (5)
#define GRIB_TABLE6_UTM           (6)
#define GRIB_TABLE6_PERSPECTIVE  (90)

/* Useful structures
 */
#if 0
struct convert_site_table8
{
  struct latlon8 Center;
  int   iBlockNumber;
  int   iStationNumber;
  SINT4 iMinutesWest;
  char  sSitename16[20];   /* IRIS Sitename, null terminated */
  SINT4 iSiteNumber;     /* IRIS Sitenumber, range 0-30 */
};
#define MAX_CONVERT_SITES (20)
#endif

/* Information about how to convert one datatype.
 */
struct convert_datatype
{
  SINT2 iDecScaleFactor;       /* The decimal scale factor to use */
  SINT2 iBinScaleFactor;       /* The binary scale factor to use */
  FLT4  fGribScaleFactor;      /* Number to multipy IRIS data by to get GRIB value */
  UINT1 iCode;                 /* Code value from table 2 */
  char  ipad_end[3];
};

/* Information from the config file to customize the convertor */
struct convert_config8
{
  //  struct convert_site_table8 Sites[ MAX_CONVERT_SITES ];
  UINT1 lLogToFile;
  UINT1 lLogToTerm;
  UINT1 lVerbose;              /* Log more details */
  UINT1 lAppendToLog;          /* Append to previous log file */

  struct convert_datatype Dbz;
  struct convert_datatype Vel;
  struct convert_datatype Width;
  struct convert_datatype RainRate;
  struct convert_datatype RainAcc;
  struct convert_datatype Zdr;
  struct convert_datatype Height;

  UINT1 iGenCenterId;          /* Placed in section 1, Octet 5 */
  UINT1 iGenProcessId;         /* Placed in section 1, Octet 6 */
  UINT1 iSubCenterId;          /* Placed in section 1, Octet 26 */

  FILE *iLogFile;              /* Open file descriptor to log file */
  FLT4  fMinReflectivity;      /* Minimum refl. All lower values are thresholded */
  //  SINT4 iSiteCount;
};

/* Function prototypes 
 */
void GribBitClear                      /* File: GribSubs.C */
( void *pBitMap_a,
  SINT4 iGribBit_a );

void GribBitPut                        /* File: GribSubs.C */
( void *pBitMap_a,
  SINT4 iGribBit_a,
  UINT1 iVal_a );

void LoadSetup                         /* File: GribSubs.C */
( struct convert_config8 *pCSetup_a,
  const char* sFile_a,                  /* Filename of config file */
  int iDevice_a );                      /* Device number */

void Lprintf                           /* File: GribSubs.C */
( const struct convert_config8 *pCSetup_a,
  const char *sString_a );

void PackIbmFloat4
( char iTarget_a[4],
  double local_float);

void Pack4
( char iTarget_a[4], 
  int iValue_a );

void Pack3
( char iTarget_a[3], 
  int iValue_a );

void Pack2
( char iTarget_a[2], 
  int iValue_a );
