/* ******************************
 * *                            *
 * *  IRIS Asterix header File  *
 * *                            *
 * ******************************
 * File: utils/asterix/SigAsterix.h
 *
 *                    COPYRIGHT (c) 2003, 2006 BY
 *              VAISALA INC., 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.
 */

/* Asterix Message Types, used for data item I008/000 */
#define AST_MSG_POLAR_VECTOR     (1)
#define AST_MSG_CARTESIAN_VECTOR (2)
#define AST_MSG_CONTOUR_RECORD   (3)
#define AST_MSG_CARTESIAN_ENDS   (4)
#define AST_MSG_SOP              (254)
#define AST_MSG_EOP              (255)

/* Asterix Field Spec numbers which are ORed together to indicate
 * which data will follow in the record.
 */
#define AST_FRN1_DATA_SOURCE       (0x80)
#define AST_FRN1_MESSAGE_TYPE      (0x40)
#define AST_FRN1_VECTOR_QUALIFIER  (0x20)
#define AST_FRN1_CARTESIAN_VECTORS (0x10)
#define AST_FRN1_POLAR_VECTORS     (0x08)
#define AST_FRN1_CONTOUR_ID        (0x04)
#define AST_FRN1_CONTOUR_POINTS    (0x02)
#define AST_FRN1_EXTENSION         (0x01)

#define AST_FRN2_TIME_OF_DAY       (0x80)
#define AST_FRN2_PROCESSING_STATUS (0x40)
#define AST_FRN2_STATION_CONFIG    (0x20)
#define AST_FRN2_TOTAL_NUMBER      (0x10)
#define AST_FRN2_WEATHER_VECTORS   (0x08)

/* -----------------------------------------------
 * Structures related to the data format.
 */
struct ast_data_block
{
  UINT1 iCategory;
  UINT1 iLength[2];
  UINT1 iData[1];    /* Data size is variable */
};

struct ast_single_vector
{
  SINT1 iXComp;
  SINT1 iYComp;
  UINT1 iLength;
};

/* Useful structures for the converters.
 */
struct convert_site_table
{
  int   iSAC;   /* System area code */
  int   iSIC;   /* System identification code */
  char  sSitename16[20];   /* IRIS Sitename, null terminated */
};
#define MAX_CONVERT_SITES (20)

/* Information from the config file to customize the convertor */
struct convert_config
{
  struct convert_site_table Sites[ MAX_CONVERT_SITES ];
  UINT1 lLogToFile;
  UINT1 lLogToTerm;
  UINT1 lVerbose;              /* Log more details */
  UINT1 lAppendToLog;          /* Append to previous log file */
  FILE *iLogFile;              /* Open file descriptor to log file */
  SINT4 iMaxBlockSize;         /* Maximum block size */
  SINT4 iSiteCount;
};

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

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