/* **********************************************************************
 * *                                                                    *
 * *                  Headers for IRIS Structures                       * 
 * *                                                                    *
 * ********************************************************************** 
 * File: include/headers.h
 *
 *     COPYRIGHT (c) 1988, 1989, 1990, 1992, 1993, 1995, 1996, 1997, 
 *       1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 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. 
 *
 * Include Requirements : sigtypes.h
 */
#ifndef SIGMET_HEADERS_H
#define SIGMET_HEADERS_H 1

#ifdef __cplusplus
extern "C" {
#endif
  
  /* - - - - - - - - - - - System-Wide Variables   */
  /* Do not change this without changing the event flags defined in event_flags.h */
#define MAX_NETWORK_LINKS     (18)       /*Max # of incoming network links*/


/* - - - - - - - - - - - DSP and Data related parameters   */
#define MAX_BINS            (3072)       /*Max # bins in any ray at any time*/
#define MAX_MOMENTS           (16)       /*Max # moments recordable at once*/

/* - - - - - - - - - - - INGEST definitions */
#define MAX_INGEST_RAYS     (1024)       /*Max # rays per INGEST data file*/

#define LATE_SKIP_TIME        (60)       /*Grace period (in seconds) for late*/
                                         /* skip tasks.*/

/* - - - - - - - - - - - Task related parameters */
#define MAX_TSC_SLOTS      (100)         /*Max # tasks in schedule*/
#define MAX_SWEEPS          (40)         /*Max # sweeps in any scan mode    */
#define MAX_TSC_TASKS_MAJ    (8)           
#define MAX_TSC_TASKS_MIN   (26)

/* - - - - - - - - - - - Product related parameters
 * Note that MAX_PSC_SLOTS should be increased along with num_def.. to keep
 * space for users, because one slot is used up for each defined product.
 */
#define NUM_DEFINED_PRODUCTS  34                /*# different product types   */

  /* Check that the array is dimensioned properly.  It must be a multiple
   * of 4, and be larger than NUM_DEFINED_PRODUCTS.
   */
#if defined(NUM_DEFINED_PRIORITIES) && (NUM_DEFINED_PRIORITIES < NUM_DEFINED_PRODUCTS)
#error Please manually maintain the dimension of iprod_priorities[] in setup.h
#endif
#define MAX_PSC_SLOTS (NUM_DEFINED_PRODUCTS+800) /*Max # products in schedule*/

#define MAX_PSC_TASKS_MINOR (26)  /* Max number of minor tasks */



/* - - - - - - - - - - - Output and Formatting parameters */
#define TAPE_RECORD_LEN      (6144)      /*Tape record length in bytes*/

  /* - - - - - - - - - - - File I/O Parameters
   * The INGEST and PRODUCT directories are permitted to temporarily grow
   * beyond their advertised limits.  This gives the watchdog time to
   * respond, without actually hiting the hard file count limit.
   */
#define INGEST_FILES_CUSHION  (  20)
#define MAX_INGEST_FILES      ( 1000 + INGEST_FILES_CUSHION)

  /* To save network bandwidth, we default to a minimum scroll size if
   * not specified elsewhere.
   */

#define MIN_SCROLL_SIZE ( 10 )
  /* The maximum number of lines in any of the scrolled windows of
   * data supplied by the server to the client.
   */
#define MAX_SCROLL_SIZE ( 1000 )

/* -------------------- Structure Header --------------------
 * The following five words appear at the beginning of many IRIS structures
 * to help identify and use them.
 */
#define STRUCT_HEADER_SIZE   12          /* Size of header */

struct structure_header 
{
  SINT2 id;                             /*Structure identifier */
#define ST_TASK_CONF       (22)    /* Task_Configuration */
#define ST_INGEST_HDR      (23)    /* ingest_header */
#define ST_INGEST_DATA     (24)    /* INGEST_data_header */
#define ST_TAPE_INVEN      (25)    /* Tape inventory */
#define ST_PRODUCT_CONF    (26)    /* Product_configuration */
#define ST_PRODUCT_HDR     (27)    /* Product_hdr */
#define ST_TAPE_HEADER     (28)    /* Tape_header_record */
#define ST_VERSION_STEP    (20)    /* Step between version 1 and 2 */

  SINT2 ivers;                         /*Format version # */
#define SVER_TASK_CONF_P     5     /* Task_Configuration */
#define SVER_INGEST_HDR_P    4     /* ingest_header */
#define SVER_INGEST_DATA_P   3     /* ingest_data_header */
#define SVER_PRODUCT_CONF_P  6     /* Product_configuration */
#define SVER_PRODUCT_HDR_P   8     /* Product_hdr */
  SINT4 ibytes;                        /*# of bytes in entire structure */

  SINT2 reserved;
  SINT2 iflags;                        /* Flag Bits */
#define HD_STRUCTURE_COMPLETE  (0x0001)      /*  Structure Complete */
};

/* serv structure for passing data  between client and server
*/
struct serv_structure_header 
{
  SINT4 id;                             /*Structure identifier */
  SINT4 ibytes;                        /*# of bytes in entire structure */
  SINT4 ivers;                         /*Format version # */

  SINT4 reserved;
  SINT4 iflags;                        /* Flag Bits */
};

/* -------------------- A Doubly Linked List Structure --------------------
 * This simple structure is used for maintaining a list of indicies of items,
 * in a context where items are added, deleted, and sorted vigorously.  Only
 * the pointers are maintained here.  The actual data that they organize is
 * put in a separate structure array of the user0xs definition.
 *
 * The maximum size of the list will vary with each allocation and can not be
 * specified here.  To allocate a list, declare a Linked_List_Header record
 * followed by an N-Sized Linked_List_Item array.  Pass the header address
 * around to routines that work with linked lists.  The /Full_Linked_List/
 * defined below can be used as a declaration for subroutine formal parameters.
 */
#define LINKED_LIST_HEADER_SIZE (20)
struct linked_list_header
{
  SINT4 ifirst, ilast;                  /*Beginning and End of active list */
  SINT4 ifree;                          /*Beginning of free list */
  SINT4 iused, isize;                   /*# slots used, and total # slots */
};

#define LINKED_LIST_ITEM_SIZE (12)
struct linked_list_item
{
  SINT4 ifwd, irev;                     /* Forward and Reverse indicies */
  void *ipdata;                         /* Data pointer */
};

struct full_linked_list               /* Useful declaration for subroutine */
{
  struct linked_list_header lhdr;     /*  formal parameters when passed a */
  struct linked_list_item   llst[1];  /*  header followed by a linked list. */
};

/*-------------------- Product Specific Information --------------------------
 * This gives certain information that is specific to the type of product being
 * considered.  This structure is used in product.h and output.h, hence
 * its inclusion here.  Note that scale number of products using the same
 * projection should be in the same place.  The projection is given in () after
 * the product name.
 */
#define PSI_SIZE (80)

/* For immediate products that ordinarily run on one particular angle, the
 * following wildcard value is taken to mean "run on all angles".
 */
#define IMP_WILD_ANGLE2 ((BIN2)0x8001)
#define IMP_WILD_ANGLE4 ((BIN4)0x80010000)
#define WARN_MAX_INPUTS 3

struct beam_psi_struct
{
  UINT4 irmin,         irmax;          /* Range limits in centimeters */  
  BIN4  iaz_left,      iaz_right;      /* Azimuth limits */  
  BIN4  iel_low,       iel_high;       /* Elevation limits */  
  BIN4  iaz_smooth,    iel_smooth;     /* Smoothing angles */  
  BIN4  iaz_sun_start, iel_sun_start;  /* Sun starting position */  
  BIN4  iaz_sun_end,   iel_sun_end;    /* Sun ending position */  
  char  ipad_end[PSI_SIZE-48];
};

struct cappi_psi_struct		/*CAPPI [cappi] */
{
  UINT4 iShearFlags;              /* Same flags as in shear product */
  SINT4 icappi_hgt;               /* Height (cm above reference) */
  UINT2 icappi_flags;		  /* Option flags */
#define CAPPI_FLG_PSEUDO (0x0001)   /* Make a pseudo CAPPI (extend single tilts) */
#define CAPPI_FLG_HORVEL (0x0002)   /* Modify velocity to be horizontal winds */
#define CAPPI_FLGS_ALL (CAPPI_FLG_PSEUDO|CAPPI_FLG_HORVEL)
  BIN2  iAzSmooth;                /* Smoothing for azimuth shear */
  
  char  svvp_name[12];            /* Name of VVP task to use */
  UINT4 ivvp_max_age;             /* Maximum age of VVP in seconds */
  char ipad_end[PSI_SIZE-28];
};

struct catch_psi_struct		/*For CATCH [earth] */
{
  UINT4 iFlags ;		  /* Flags in lower 16-bits, RAIN1 flags in upper */
#define CATCH_FLG_WARNINGS_ON (0x0001)
#define CATCH_FLGS_ALL (CATCH_FLG_WARNINGS_ON)
  UINT4 iHours ;		  /* Number of hours to accumulate */
  SINT4 iThresholdOffset;	  /* Add this Offset to all thresholds (1/1000 of mm)*/
  SINT4 iThresholdFactor;	  /* Multiply this Factor with all thresholds (1/1000)*/
  char  sProduct[12] ;		  /* Name of RAIN1 pco, space padded */
  char  sSubCatchment[16];	  /* Name of subcatchment file, null terminated */
  UINT4 iSpanSeconds;             /* Seconds of accumulate (in lower 16-bits) */
  UINT4 iRain1MinZ;               /* Copied from RAIN1 input */
  UINT4 iRain1Span;               /* Span of the RAIN1 inputs in seconds */
  UINT4 iGageFactor;              /* Gage Correction Factor in DB_DBZ2 (lower 16-bits)*/
  char  ipad_end[PSI_SIZE-60];
};

#define COMP_MAX_INPUTS 16
struct comp_psi_struct
{
  UINT1 iPTypeIn;           /* Type of product used as input */
  UINT1 iCombineScheme;     /* Scheme used to combine inputs */
#define COMP_SCHEME_MAXIMUM   (0)
#define COMP_SCHEME_AVERAGE   (1)
#define COMP_SCHEME_PRIORITY  (2)
  /* The following schemes are used just for warning products */
#define COMP_SCHEME_AND_MAX   (0)
#define COMP_SCHEME_AND_AVG   (1)
#define COMP_SCHEME_OR_MAX    (2)
#define COMP_SCHEME_OR_AVG    (3)
  UINT2 iTimeSpan;          /* Time span in seconds, all inputs must be within */
  char  sPNameIn[12];       /* Name of product used as input */
  char  sSiteOut[4];        /* Site of output product */
  char  sSiteInList[COMP_MAX_INPUTS][3]; /* Site list of desired inputs */
  char  ipad_end[PSI_SIZE-68];
} ;

struct cross_psi_struct		/*Cross Section, User Section [cross] */
{
  BIN2 iazimuth;			/* Azimuth Bearing binary angle */
  char ipad2x10[10];
  SINT4 icenterx, icentery;		/* Coodinate in cm of center of section */
  SINT4 ivuser_misc[(PSI_SIZE-20)/4];	/* Unspecified contents */
};

#define DWELL_FLG_DATA       (0x01) /* Make output data rather then time */
#define DWELL_FLG_CONTRASTOR (0x02) /* Apply contrast filter */
#define DWELL_FLG_DATA_MIN   (0x04) /* Apply min data threshold */
#define DWELL_FLG_DATA_MAX   (0x08) /* Apply max data threshold */
#define DWELL_FLG_DIAGNOSTIC (0x10) /* Make diagnostic product */
#define DWELL_FLG_BIRD       (0x20) /* Apply bird algorithm */
#define DWELL_FLG_USE_VVP    (0x40) /* Use VVP to determine wind speed */
#define DWELL_FLG_ADD_WIND   (0x80) /* Add mean wind to the bird airspeed */

#define DWELL_FLG2_VVP_USED  (0x01) /* VVP was used to determine wind speed */
#define DWELL_FLG2_PPI_CONT  (0x02) /* Apply contrastor separately for each PPI angle */
#define DWELL_FLG2_AREA_MAX  (0x04) /* Apply max area threshold to warn */
#define DWELL_FLGS2_ALL (DWELL_FLG2_VVP_USED|DWELL_FLG2_PPI_CONT|DWELL_FLG2_AREA_MAX) /* All valid flags */

struct dwell_target_psi
{
  BIN2  iDirLeft;        /* Target direction limits */
  BIN2  iDirRight;     
  UINT2 iSpeedMin;       /* Target speed limits in 1/100 m/s */
  UINT2 iSpeedMax;  
  UINT4 iProtectMask;    /* Bit flags to choose protected areas */
  char  sWarnSymbol[12]; /* Symbol to display, space padded */
  SINT2 iPileThreshold;  /* Target confidence threshold */
  UINT1 iMergeRange;     /* Target merge range in 1/10 of km */
  char  ipad27x1;    
  UINT4 iFlags2;         /* Secondary flag word */
  UINT4 iAreaMax;        /* Maximum area of the target in 1/100 of square km */
  UINT2 iSpeedStep;      /* Target search speed step in 1/100 m/s, 0=default 4 m/s */
  BIN2  iDirStep;        /* Target search direction step in bin2, 0=default 5 deg*/
  char  ipad_end[PSI_SIZE-68];
};
struct dwell_warn_psi
{
  char  sWarnSuffix1[4];    /* Suffix string, null terminated */
  char  sWarnSuffix2[4];
  SINT4 iWarnAge2;          /* Age in seconds to transition to second suffix */
  char  ipad12x16[16];
  UINT4 iFlags2;            /* Secondary flag word */
  char  ipad_end[PSI_SIZE-60];
};

union dwell_psi_union
{
  struct dwell_target_psi Target;
  struct dwell_warn_psi   Warn;
};

struct dwell_psi_struct
{
  SINT4 iDataMin;	    /* Data value limits [in 1/100] */
  SINT4 iDataMax;
  SINT2 iContrastCoverage;  /* Contrastor coverage percentage [in 1/100] */
  SINT2 iContrastThreshold; /* Contraster threshold [in 1/100] */
  UINT2 iTimeSpan;          /* Dwell time all inputs are within */
  UINT1 iPTypeIn;           /* Type of product used as input */
  UINT1 iFlags;
  char  sPNameIn[12];       /* Name of product used as input */
  union dwell_psi_union u;

} ;

/*Use for forecast */
struct fcast_psi_struct
{
  UINT4 iCorrThreshold;           /* Correlation threshold */
  SINT4 iDataThreshold;           /* Data threshold levels [in 1/100] */
  SINT4 iMeanSpeed;               /* Mean speed in cm/hour */
  BIN4  iMeanDirection;           /* Mean speed in cm/hour */
  UINT4 imax_time_step;           /* Maximum age between products for motion calc. */
  SINT4 imax_velocity;            /* Maximum velocity allowed in motion calc. */
  UINT4 iflags;  
  SINT4 iOutputResolution;        /* Output resolution in cm */
  UINT4 iptype;                   /* Product type being used as input */
  char  spname[12];               /* Name of product file, space padded */
  char  ipad_end[PSI_SIZE-48];
};

struct gage_psi_struct		/*For GAGE [earth] */
{
  UINT4 iSpan;                    /* Number of seconds of data recorded in the file */
  UINT4 iFlag;
#define GAGE_PFLG_DISDRO (0x001)  /* File contains Z/R numbers (Disdrometer) */
#define GAGE_PFLG_NORAIN (0x002)  /* File does not contain a Rainrate (is not a gauge) */
#define GAGE_PFLGS_ALL (GAGE_PFLG_DISDRO|GAGE_PFLG_NORAIN)
  char  ipad_end[PSI_SIZE-8];

};

struct maximum_psi_struct	/*Maximum with side panels */
{
  char ipad0x4[4];
  SINT4 ibottom;                  /* Bottom of interval in cm */
  SINT4 itop;                     /* Top of interval in cm */
  SINT4 iside_size;               /* Number of pixels in side panels */
  SINT2 ihorz_smooth;             /* Horz. smoother in side panels */
  SINT2 ivert_smooth;             /* Vert. smoother in side panels */
  char  ipad_end[PSI_SIZE-20];
};

struct ndop_input
{
  char sTName[12] ;		/* Task names, space padded */
  char sSiteId[3] ;		/* Site ID, all NULLs if site is not used */
  UINT1 iflags ;		/* Flag bits (must follow sSiteId) */
#define NDOP_INFLG_VC      (0x01)  /*   Input is based on Vc, else V */
#define NDOP_INFLG_INFILE  (0x02)
#define NDOP_INFLGS_ALL    (NDOP_INFLG_VC|NDOP_INFLG_INFILE)
} ;
struct ndop_psi_struct
{
  struct ndop_input Inputs[WARN_MAX_INPUTS] ;
  SINT4 iTimeWindow;		/* Time window in seconds */
  SINT4 iCappiHeight;		/* Height of lowest cappi (cm above reference) */
  SINT4 iOutputResolution;	/* Output resolution in cm */
  BIN4  iMinCrossingAngle;	/* Minimum permitted ray crossing angle */
  UINT4 iFlags;                 /* Flag bits */
#define NDOP_FLG_DIAGNOSTIC (0x0001) /* Make diagnostic product */
#define NDOP_FLGS_ALL (NDOP_FLG_DIAGNOSTIC)
  char  sSiteOut[4];            /* Site of output product (4th char not used) */
  char  ipad_end[PSI_SIZE-72];
} ;

struct ppi_psi_struct		/* PPI [ppi] */
{
  BIN2  ippi_el;                /* Elevation binary angle */
  char  ipad2x2[2];
  SINT4 iMaxRange;              /* max range in cm (zero=none)*/
  SINT4 iMaxHeight;             /* max height in cm above reference (zero=none)*/
  char ipad_end[PSI_SIZE-12];
};

#define RAIN_FLG_CLT_MAP    (0x0001) /* Use clutter map */
#define RAIN_FLG_CLT_MAP_OK (0x0004) /* Clutter map was actually used */
#define RAIN_FLG_GAG_COR    (0x0002) /* Apply raingage correction */
#define RAIN_FLG_GAG_COR_OK (0x0008) /* Raingage correction was actually used */
#define RAIN_FLG_DIAGNOSTIC (0x0010) /* Make diagnostic product */
#define RAIN_FLG_SRI_INPUT  (0x0020) /* Input is SRI type, else CAPPI */
#define RAIN1_FLGS_USED (RAIN_FLG_CLT_MAP|RAIN_FLG_GAG_COR|RAIN_FLG_DIAGNOSTIC|RAIN_FLG_SRI_INPUT)  /* Used in the RAIN1 PCO */
#define RAIN_FLG_USED RAIN1_FLGS_USED
#define RAINN_FLGS_KEPT (RAIN_FLG_CLT_MAP|RAIN_FLG_CLT_MAP_OK|RAIN_FLG_GAG_COR|RAIN_FLG_GAG_COR_OK|RAIN_FLG_DIAGNOSTIC|RAIN_FLG_SRI_INPUT)  /* Kept in the RAINN PCO */
struct rain_psi_struct		/*For RAIN1 and RAIN-N [earth] */
{
  UINT4 irain1_minz;              /* Assume no rain below this level DB_DBZ2 format */
  UINT2 iAverageGageFactor;       /* Gage Correction Factor in DB_DBZ2 format */
  UINT2 iSeconds;                 /* Seconds of time interval (multiples of 15 min) */
  UINT2 irain_flags ;		  /* Flags */
  SINT2 irainn_hours ;		  /* RAINN number of hours to accumulate */
  char  sproduct[12] ;		  /* Name of CAPPI/SRI/RAIN1 pco, space padded */
  UINT4 iRain1Span;               /* Span of the RAIN1 inputs in seconds (only for RAINN) */
  char  ipad_end[PSI_SIZE-28];
};

struct raw_psi_struct		/*RAW [void] */
{
  UINT4 iDataMask0;               /* First word of Data bit mask */
  SINT4 iraw_bin_last;            /* Range of last bin in cm */
  UINT4 iraw_convert;		  /* Format conversion instructions */
#define IRAW_CONVERT_PRESERVE 0	     /* Preserve all INGEST data */
#define IRAW_CONVERT_8_TO_16  1	     /* Convert 8-bit data to 16-bit data */
#define IRAW_CONVERT_16_TO_8  2	     /* Convert 16-bit data to 8-bit data */

  UINT4 iflags;			  /* Control flags */
#define RAW_FLG_SWEEP    (0x00000001) /* Make sweep-by-sweep product files */
#define RAW_FLG_DATAMASK (0x00000002) /* Mask the data types recorded */
#define RAW_FLGS_ALL (RAW_FLG_SWEEP|RAW_FLG_DATAMASK) /* All bits in use */

  SINT4 isweep ;		  /* Individual sweep number, if RAW_FLG_SWEEP is set
				   *  in iflags; else zero. */
  UINT4 iXhdrType;                /* Extended header type */
  UINT4 iDataMask1;               /* Data bit mask */
  UINT4 iDataMask2;               /* Data bit mask */
  UINT4 iDataMask3;               /* Data bit mask */
  UINT4 iDataMask4;               /* Data bit mask */
  UINT4 iPlayback;                /* Playback version in low 16-bits */
  char ipad_end[PSI_SIZE-44];
};

struct rhi_psi_struct		/*RHI [rhi] */
{
  BIN2 irhi_az ;                  /* Azimuth binary angle */
  char ipad_end[PSI_SIZE-2];
};

struct rti_psi_struct		/*RTI [rti] */
{
  BIN4  iSweepAngle;              /* Nominal sweep angle */
  UINT4 iStartOffset;             /* Starting and ending time offsets from sweep time */
  UINT4 iEndOffset;               /* Times are in ms */
  BIN4  iStartAzimuth;            /* Direction of the first ray in the file */
  BIN4  iStartElevation;
  char  ipad_end[PSI_SIZE-20];
};

struct shear_psi_struct		/*SHEAR [earth] */
{
  BIN4  iaz_smooth;               /* Azimuthal smoothing angle, 0=none */
  BIN2  ishear_el;                /* Elevation binary angle */
  char  ipad6x2[2];
  UINT4 iflags;
#define SHEAR_FLG_RADIAL    (0x00000001)
#define SHEAR_FLG_AZIMUTHAL (0x00000002)
#define SHEAR_FLG_USE_VVP   (0x00000004)
#define SHEAR_FLG_VVP_USED  (0x00000008)
#define SHEAR_FLG_UNFOLDING (0x00000010)
#define SHEAR_FLG_ELEVATION (0x00000020)
#define SHEAR_FLG_DPRS      (0x00000040) /* Discard positive radial shear */
#define SHEAR_FLGS_ALL (SHEAR_FLG_RADIAL|SHEAR_FLG_AZIMUTHAL|SHEAR_FLG_USE_VVP|SHEAR_FLG_VVP_USED|SHEAR_FLG_UNFOLDING|SHEAR_FLG_ELEVATION|SHEAR_FLG_DPRS)
  char  svvp_name[12];            /* Name of VVP task to use */
  UINT4 ivvp_max_age;             /* Maximum age of VVP in seconds */
  char  ipad_end[PSI_SIZE-28];
};

struct sline_psi_struct		/*Shear Line [earth] */
{
  SINT4 iarea;                    /* Area in square meters */
  SINT4 ishear_threshold;         /* Shear threshold (cm/sec/km) */
  UINT4 iprotect_mask;            /* Bit flags to choose protected areas */
  SINT4 iforecast_time;           /* Maximum forecast time in seconds */
  UINT4 imax_time_step;           /* Maximum age between products for motion calc. */
  SINT4 imax_velocity;            /* Maximum velocity allowed in motion calc. */
  UINT4 iflags;                   /* Shear flags in low bits */
#define SLINE_FLG_2ANGLES    (0x00000100)
#define SLINE_FLG_DIAGNOSTIC (0x00000200)
#define SLINE_FLG_MAXWRN     (0x00000400)
#define SLINE_FLG_2FCAST     (0x00000800)  /* Display with 2 forecast lines */
#define SLINE_FLGS_ALL     (SLINE_FLG_2ANGLES|SLINE_FLG_DIAGNOSTIC|SLINE_FLG_MAXWRN|SLINE_FLG_2FCAST|SHEAR_FLGS_ALL)
  BIN4  iaz_smooth;               /* Azimuthal smoothing angle, 0=none */
  BIN4  iel1;                     /* Elevation binary angle */
  BIN4  iel2;                     /* Elevation binary angle */
  char svvp_name[12];             /* Name of VVP task to use */
  UINT4 ivvp_max_age;             /* Maximum age of VVP in seconds */
  SINT4 ifit_threshold;           /* Curve fit variance threshold */
  UINT4 iMaxs;                    /* Low byte: Max sline length in 1/10 km (unsigned) */
  char  ipad_end[PSI_SIZE-64];
};

#define IC_MELTING_UNKNOWN   (0x0000)  /* Melting layer height unknown */
#define iMeltFromData(_DATA) ((SINT2)( 0x8000 ^ (SINT2)(_DATA)))
#define iDataFromMelt(_MELT) ((SINT2)( 0x8000 ^ (SINT2)(_MELT)))
struct sri_psi_struct	    /*SRI [earth] */
{
  UINT4 iPsiFlags;	    /* Option flags */
  SINT4 iBinCount;          /* Total number of bins inserted */
  SINT4 iDataCount;         /* Total number of bins with data in them */
  SINT4 iCorrCount;         /* Number of data bins passing convection test */
  SINT2 iSurfaceHeight;     /* Height of surface to correct to (m above reference) */
  SINT2 iMaxHeight;         /* Max height to consider (m above reference) */
  SINT2 iMeltHeight;        /* Melting height (m above MSL), MSB complemented */
  SINT2 iMeltThickness;     /* Melting level thinkness in m (info only)*/
  SINT2 iMeltIntensity;     /* Melting level intensity (1/100 of dB) (info only)*/
  SINT2 iGradientAbove;     /* Gradient above melting level( 1/100 dB/km) (info only)*/
  SINT2 iGradientBelow;     /* Gradient below melting level( 1/100 dB/km) (info only)*/
  SINT2 iConvectiveHeight;  /* Height of convective check (m above Melting) */
  UINT2 iConvectiveZ;       /* dBZ of convective check (DB_DBZ2 format) */
  char  ipad_end[PSI_SIZE-34];
  
#define SRI_FLG_PROFILE_CORRECTION (0x01) /* Apply the profile correction */
#define SRI_FLG_DIAGNOSTIC         (0x02) /* Make diagnostic product */
#define SRI_FLG_TERRAIN_MAP        (0x04) /* Use terrain map file */
#define SRI_FLG_MELT_SOURCE0       (0x08) /* Melting source: */
#define SRI_FLG_MELT_SOURCE1       (0x10) /* 0:Ingest, 1:Setup, 2:TypeIn */
#define SRI_FLG_CHECK_CONVECTION   (0x20) /* Check for convection */
#define SRI_FLG_NO_CLUTTER         (0x40) /* Clutter correction not applied */
#define SRI_FLGS_ALL   (SRI_FLG_PROFILE_CORRECTION|SRI_FLG_DIAGNOSTIC|SRI_FLG_TERRAIN_MAP|SRI_FLG_MELT_SOURCE0|SRI_FLG_MELT_SOURCE1|SRI_FLG_CHECK_CONVECTION|SRI_FLG_NO_CLUTTER)
};

/* No server structure defined yet because no Product Configuration
 * Menu
 */
struct tdwr_psi_struct		/*TDWR [overlay] */
{
  UINT4 iFlags;
#define TDWR_FLG_LLWAS    (0x0001)
#define TDWR_FLG_WARN     (0x0002)
#define TDWR_FLG_SLINE    (0x0004)
#define TDWR_FLG_2FCAST   (0x0008) /* Display with 2 forecast lines */
  UINT4 iRMax;                    /* Maximum range in centimeters */  
  char  sSourceID[4];             /* LLWAS source ID, space padded */
  char  sCFDirection[3];
  UINT1 ipad7x1;
  char  sCFSpeed[2];
  char  sCFGustSpeed[2];
  UINT4 iprotect_mask;		  /* Mask showing which protected areas were checked */
  UINT4 iCentroidCount;		  /* Number of centroids also in file */
  UINT4 iSlineCount;		  /* Number of shearlines also in file */
  SINT4 iForecastTime;            /* Forecast time in seconds */
};

struct top_psi_struct		/*Echo tops and base [earth] */
{
  char ipad0x4[4];
  SINT2 iZThreshold;            /* Z threshold in 1/16 dbZ */
  char ipad_end[PSI_SIZE-6];
};

/*Use for track */
struct track_psi_struct
{
  SINT4 iarea;                    /* Area in square meters */
  SINT4 ithreshold;               /* Data threshold levels [in 1/100] */
  UINT4 iprotect_mask;            /* Bit flags to choose protected areas */
  SINT4 iforecast_time;           /* Maximum forecast time in seconds */
  UINT4 imax_time_step;           /* Maximum age between products for motion calc. */
  SINT4 imax_velocity;            /* Maximum velocity allowed in motion calc. */
  UINT4 iflags;  
#define TRACK_FLG_DIAGNOSTIC (0x00000200)
#define TRACK_FLGS_ALL (TRACK_FLG_DIAGNOSTIC)
  SINT4 ispan_time;               /* Maximum time span for points in product */
  UINT4 iptype;                   /* Product type being used as input */
  char  spname[12];               /* Name of product file, space padded */
  SINT4 iconnect_error;           /* Point connecting error allowance */
  char  ipad_end[PSI_SIZE-52];
};

struct user_psi_struct		/*For both User Map [earth], and Other */
{
  SINT4 imisc[PSI_SIZE/4];        /* Unspecified contents */
};

struct vil_psi_struct		/*VIL [earth] */
{
  char ipad0x4[4];
  SINT4 ivil_bottom;              /* Bottom of interval (cm above reference) */
  SINT4 ivil_top;                 /* Top of interval in (cm above reference) */
  char  ipad_end[PSI_SIZE-12];
};

struct vvp_psi_struct		/*Volume Velocity Processing [VVP] */
{
  SINT4 ivvp_rmin, ivvp_rmax;	        /* Range limits in centimeters */
  SINT4 ivvp_hmin, ivvp_hmax;		/* Height limits (cm above reference)*/
  SINT2 ivvp_intervals;			/* Number of height intervals  */
  char ipad18x2[2];
  SINT4 ivvp_quota;			/* Target # bins per interval  */
  UINT4 ivvp_switch;			/* Wind parameters to compute  */
					/*  (defined in product.h)   */
  char  ipad_end[PSI_SIZE-28];
};

struct warn_psi_struct		/*Warning [overlay] */
{
  SINT4 iwarn_area;			  /* Area in square meters */
  SINT4 iwarn_threshs[WARN_MAX_INPUTS];	  /* Data threshold levels [in 1/100] */
  SINT2 iwarn_seconds[WARN_MAX_INPUTS];	  /* Data valid times in seconds */
  char ipad22x2[2];
  char  swarn_symbol[12];		  /* Symbol to display, space padded */
  char  swarn_names[WARN_MAX_INPUTS][12]; /* Names of product files, space padded */
  UINT1 iwarn_prods[WARN_MAX_INPUTS];     /* Product types being used as input */
  UINT1 iflags ;		          /* Control Flags */
#define WARN_FLG_CMPLT0  0x01	          /*   Perform a "less than" comparison each */
#define WARN_FLG_CMPLT1  0x02	          /*   of these inputs if the bit is set. */
#define WARN_FLG_CMPLT2  0x04
#define WARN_FLG_DIAGNOSTIC (0x08)        /* Make diagnostic product */
#define WARN_FLGS_ALL (WARN_FLG_CMPLT0|WARN_FLG_CMPLT1|WARN_FLG_CMPLT2|WARN_FLG_DIAGNOSTIC)
  UINT4 iprotect_mask;			  /* Bit flags to choose protected areas */
};

struct wind_psi_struct		/* Horizontal Wind Field */
{
  SINT4 ihmin, ihmax;		/* Height limits (centimeters above reference) */
  SINT4 irmin, irmax ;          /* Range limits in centimeters */  
  SINT4 irange_count ;		/* Number of points in range */
  SINT4 iazimuth_count ;       	/* Number of points in azimuth */
  SINT4 isector_length ;       	/* Sector length in centimeters */
  BIN4  isector_width ;		/* Sector width as binary angle */
  UINT4 iflags ;                /* Control flags */
  UINT4 ivvp_switch ;	        /* Contents of embedded vvp_results */
  char  ipad_end[PSI_SIZE-40];
} ;
#define WIND_MAX_RANGE_COUNT   (40)
#define WIND_MAX_AZIMUTH_COUNT (36)

union product_specific_info
{
  struct    beam_psi_struct beam;
  struct   cappi_psi_struct cappi;
  struct   catch_psi_struct Catch;  /* Note that "catch" is a C++ keywork */
  struct    comp_psi_struct comp;
  struct   cross_psi_struct cross;
  struct   dwell_psi_struct Dwell;
  struct   fcast_psi_struct fcast;
  struct    gage_psi_struct Gage;
  struct maximum_psi_struct max;
  struct    ndop_psi_struct ndop;
  struct     ppi_psi_struct ppi;
  struct    rain_psi_struct rain;
  struct     raw_psi_struct raw;
  struct     rhi_psi_struct rhi;
  struct     rti_psi_struct rti;
  struct   shear_psi_struct shear;
  struct   sline_psi_struct sline;
  struct     sri_psi_struct Sri;
  struct    tdwr_psi_struct tdwr;
  struct     top_psi_struct top;
  struct   track_psi_struct track;
  struct    user_psi_struct user;
  struct     vil_psi_struct vil;
  struct     vvp_psi_struct vvp;
  struct    warn_psi_struct warn;
  struct    wind_psi_struct wind;
  char ipad[PSI_SIZE];
};
typedef union product_specific_info PSI;


/*-------------------- Serv Product Specific Information ----------------------
*/
struct serv_cappi_psi_struct	/*CAPPI [earth] */
{
  UINT4 iShearFlags;
  SINT4 icappi_hgt;               /* Height (cm above reference) */
  UINT4 icappi_flags;
  BIN4  iAzSmooth;
  char svvp_name[12];             /* Name of VVP task to use, space padded */
  UINT4 ivvp_max_age;             /* Maximum age of VVP in seconds */
};

struct serv_cross_psi_struct	/*Cross Section, User Section [cross] */
{
  BIN4 iazimuth;                  /* Azimuth Bearing binary angle */
  SINT4 icenterx, icentery;       /* Coodinate in cm of center of section */
                                  /*Used just for User Section: */
  SINT4 ivuser_misc[(PSI_SIZE-20)/4]; /* Unspecified contents */
};

struct serv_dwell_target_psi
{
  BIN4  iDirLeft;        /* Target direction limits */
  BIN4  iDirRight;     
  UINT4 iSpeedMin;       /* Target speed limits*/
  UINT4 iSpeedMax;  
  UINT4 iProtectMask;    /* Bit flags to choose protected areas */
  char  sWarnSymbol[12]; /* Symbol to display, space padded */
  SINT4 iPileThreshold;  /* Target pile threshold */
  UINT4 iFlags2;         /* Secondary flag word */
  UINT4 iAreaMax;        /* Max area of target in 1/100 of square km */
  UINT4 iSpeedStep;      /* Target search speed step in 1/100 m/s, 0=default 4 m/s */
  BIN4  iDirStep;        /* Target search direction step in bin2, 0=default 5 deg*/
  UINT4 iMergeRange;     /* Target merge range in meters */
} ;
struct serv_dwell_warn_psi
{
  char  sWarnSuffix1[4];    /* Suffix string, null terminated */
  char  sWarnSuffix2[4];
  SINT4 iWarnAge2;          /* Age in seconds to transition to second suffix */
  UINT4 iFlags2;              /* Secondary flag word */
} ;

union serv_dwell_psi_union
{
  struct serv_dwell_target_psi Target;
  struct serv_dwell_warn_psi   Warn;
};

struct serv_dwell_psi_struct
{
  SINT4 iDataMin;	      /* Data value limits [in 1/100] */
  SINT4 iDataMax;
  SINT4 iContrastCoverage;    /* Contrastor coverage percentage [in 1/100] */
  SINT4 iContrastThreshold;   /* Contraster threshold [in 1/100] */
  UINT4 iTimeSpan;            /* Dwell time all inputs are within */
  UINT4 iFlags;
  char  sPNameIn[12];         /* Name of product used as input */
  UINT4 iPTypeIn;             /* Type of product used as input */
  union serv_dwell_psi_union u;
} ;

struct serv_maximum_psi_struct  /*Maximum with side panels */
{
  SINT4 ibottom;                  /* Bottom of interval in cm */
  SINT4 itop;                     /* Top of interval in cm */
  SINT4 iside_size;               /* Number of pixels in side panels */
  SINT4 ihorz_smooth;             /* Horz. smoother in side panels */
  SINT4 ivert_smooth;             /* Vert. smoother in side panels */
};

struct serv_ppi_psi_struct	/*PPI and RTPPI [ppi] */
{
  BIN4  ippi_el;                /* Elevation binary angle */
  SINT4 iMaxRange;              /* max range in cm (zero=none)*/
  SINT4 iMaxHeight;             /* max height in cm above reference (zero=none)*/
};

struct serv_rain_psi_struct	/*For RAIN1 and RAIN-N [earth]: */
{
  UINT4 irain1_minz;              /* Assume no rain below this level DB_DBZ2 format */
  UINT4 irain_flags;              /* Flags */
  SINT4 irainn_hours ;		  /* RAINN number of hours to accumulate */
  char  sproduct[12] ;		  /* Name of CAPPI/SRI/RAIN1 pco, space padded */
  UINT4 iSeconds;                 /* Seconds of time interval (multiples of 15 min) */
};

struct serv_rhi_psi_struct	/*RHI and RTRHI [rhi] */
{
  BIN4 irhi_az;                  /* Azimuth binary angle */
};

struct serv_shear_psi_struct	/*SHEAR [earth] */
{
  BIN4 ishear_el;                 /* Elevation binary angle */
  UINT4 iflags;                   /* See shear_psi_struct for flags */
  char svvp_name[12];             /* Name of VVP task to use, space padded */
  UINT4 ivvp_max_age;             /* Maximum age of VVP in seconds */
  BIN4 iaz_smooth;                /* Azimuthal smoothing angle */

};

struct serv_sri_psi_struct	/*SRI [earth] */
{
  UINT4 iPsiFlags;		/* Option flags */
  SINT4 iSurfaceHeight;         /* Height of surface to correct to (m above reference) */
  SINT4 iMaxHeight;             /* Max height to consider (m above reference) */
  SINT4 iMeltHeight;            /* Melting height (m above MSL)*2**16, MSB complemented */
  SINT4 iConvectiveHeight;      /* Height of convective check (m above Melting) */
  SINT4 iConvectiveZ;           /* dBZ of convective check (1/100 dBZ) */
};

struct serv_top_psi_struct	/*Echo tops and base [earth] */
{
  SINT4 iZThreshold;            /* Z threshold in 1/16 dbZ */
};

struct serv_warn_psi_struct	/*Warning [overlay] */
{
  SINT4 iwarn_area;                     /* Area in square meters */
  SINT4 iwarn_threshs[WARN_MAX_INPUTS]; /* Data threshold levels [in 1/100] */
  SINT4 iwarn_seconds[WARN_MAX_INPUTS]; /* Data valid times in seconds */
  UINT4 iwarn_protect;                  /* Bit flags to choose protected areas */
  char  symbol[16];                     /* Symbol to display, null terminated */
  char  spnames[WARN_MAX_INPUTS][16];   /* Names of product files, null terminated */
  UINT4 iwarn_prods[WARN_MAX_INPUTS];   /* Product types being used as input */
  UINT4 iflags ;		        /* Control Flags */
};

struct serv_vvp_psi_struct	/*Volume Velocity Processing [VVP] */
{
  SINT4 ivvp_rmin, ivvp_rmax;     /* Range limits in centimeters */
  SINT4 ivvp_hmin, ivvp_hmax;     /* Height limits (centimeters above reference)*/
  SINT4 ivvp_intervals;           /* Number of height intervals  */
  SINT4 ivvp_quota;               /* Target # bins per interval  */
  UINT4 ivvp_switch;              /* Wind parameters to compute  */
                                 /*  (defined in product.inc]    */
};

struct serv_comp_psi_struct
{
  UINT4 iPTypeIn;           /* Type of product used as input */
  UINT4 iTimeSpan;          /* Time span which inputs must be within in seconds */
  UINT4 iCombineScheme;     /* Scheme used to combine inputs */
  char  sPNameIn[16];       /* Name of product used as input, null terminated */
  char  sSiteOut[4];        /* Site of output product, null terminated */
  char  sSiteInList[COMP_MAX_INPUTS][4]; /* Site list of desired inputs, null terminated */
} ;

union serv_product_specific_info
{
  struct         beam_psi_struct beam;
  struct   serv_cappi_psi_struct cappi;
  struct        catch_psi_struct Catch;
  struct    serv_comp_psi_struct comp;
  struct   serv_cross_psi_struct cross;
  struct   serv_dwell_psi_struct Dwell;
  struct        fcast_psi_struct fcast;
  struct serv_maximum_psi_struct max;
  struct         ndop_psi_struct ndop;
  struct     serv_ppi_psi_struct ppi;
  struct    serv_rain_psi_struct rain;
  struct          raw_psi_struct raw;
  struct     serv_rhi_psi_struct rhi;
  struct          rti_psi_struct rti;
  struct   serv_shear_psi_struct shear;
  struct        sline_psi_struct sline;
  struct     serv_sri_psi_struct Sri;
  struct     serv_top_psi_struct top;
  struct        track_psi_struct track;
  struct         user_psi_struct user;
  struct          vil_psi_struct vil;
  struct     serv_vvp_psi_struct vvp;
  struct    serv_warn_psi_struct warn;
  struct         wind_psi_struct wind;
};
typedef union serv_product_specific_info SPSI;


/* -------------------- Miscellaneous Definitions --------------------- */
/* An entry in the error handling structure: */
#define ERROR_TEXT_SIZE (160)
struct error_entry
{
  SINT4 index;                     /*Error entry count since IRIS started */
  UINT4 ierror;                    /*Message number */
  SINT4 irepeat_count;             /*# of successive occurrences */
  char  sprocess[16];              /*Process that got the error, space padded */
  char  stext[ERROR_TEXT_SIZE];    /*Error description text, null terminated */
  char  sname[32];                 /*Name of the signal, space padded */
  struct ymds_time time;           /*Time first one happened */
  UINT4 imsg_type;                 /*type of message */
};

struct server_message_entry
{
  SINT4 index;                     /*Error entry count since IRIS started */
  UINT4 ierror;                    /*Message number */
  SINT4 irepeat_count;             /*# of successive occurrences */
  char  sprocess[16];              /*Process that got the error, null terminated */
  char  stext[ERROR_TEXT_SIZE];    /*Error description text, null terminated */
  char  sname[32];                 /*Name of the signal, null terminated */
  struct serv_ymds_time time;      /*Time first one happened */
  UINT4 imsg_type;                 /*type of message */
};
typedef struct server_message_entry SMSG_ENT;

/* MAX_ERRORS is the size of the internal shared error log.  When this
 * log fills up, the oldest messages fall off the end.
 *
 * IRIS also maintains a larger version of the error log on disk.  Two
 * files are used: "IRIS_ERROR.LOG" which holds the first MAX_FILE_ERRORS
 * messages, and "IRIS_ERROR.RING" which holds the last MAX_FILE_ERRORS
 * messages.  The RING file is a circular ring of messages spaced by
 * RING_MSG_LENGTH and padded with NULLs between each message.  Writing
 * to the RING file begins only after writing to the LOG file ends, as
 * a result of the LOG file becoming full.
 */
#define MAX_ERRORS      (200)
#define MAX_FILE_ERRORS (800)
#define RING_MSG_LENGTH (160)

struct error_list
{
  /* This holds an entry for each unique type of error.
   */
  struct error_entry list[MAX_ERRORS];

  /* The number of errors in the structure.  This will be zero if
   * there are no errors.
   */
  SINT4 icount;
};
typedef struct error_list MSG_LST;

/* Signals may be modified by the application of pattern matching
 * rules.  Each rule is defined by one of these structures.
 */
#define SIGNAL_RULE_EXEC_LENGTH (120)
struct signal_rule {
  char sText[ERROR_TEXT_SIZE];  /* Wild card text to match */
  char sProcess[32] ;		/* Process name to match */
  SINT4 iFacility, iMsgNum ;	/* Facility and Message to match */
  SINT4 iType ;			/* Message type to change upon match */
  SINT4 iSetFault, iClrFault ;	/* Fault side effect to change upon match */
  char sExec[SIGNAL_RULE_EXEC_LENGTH] ;	/* Command line to EXEC upon match */
} ;

#define MAX_SIGNAL_RULES (25)

struct signal_rule_info {
  SINT4 iRuleCount ;
  struct signal_rule rules[ MAX_SIGNAL_RULES ] ;
} ;

/* These are used by the operator to control the transmitter.
 */
#define TRANSMITTER_ON   0	/* Radiate */
#define TRANSMITTER_OFF  1	/* Do not radiate */
#define TRANSMITTER_AUTO 2	/* Ingest process controls */

/* Structure giving information about the devices available on the
 * system.
 */ 
struct device_info
{
  UINT4 itype;			/* type of device */
  SINT4 iunit;			/* unit number of device */
  char  salias[16];		/* Alias, null terminated */
};
typedef struct device_info DEVICE_INFO;

/* Structure used to pass information from server to client
 */
#define SITE_WILD  ((UINT4)-1)
/* Fill in year with this value to get the most recent.
 * Number must be larger than any year
 */
#define YEAR_MOST_RECENT  ((UINT4)10000)

struct server_site_info
{
  char ipad0x20[20] ;		/* To help keep size constant */
  SINT4 iSocketMaxClients;      /* Maximum number of clients allowed */
  SINT4 iIngestActPsv ;		/* Passive/Active options */

  UINT4 isite_type;

#define USER_OPERATOR (1)
#define USER_OBSERVER (2)
  UINT4 iuser_type;

  char  site_name[20];  /* This is a null terminated string */
  char  ipad56x4[4];

  SINT4 iproduct_count; /* Number of products available at the site */
#define PRODUCT_LIST_SIZE (40)
  UINT4 iproduct_list[PRODUCT_LIST_SIZE]; /* List of products available */

  SINT4 isite_count;    /* Number of sites available at the site */
#define SITE_LIST_SIZE (40)
  char  site_list[SITE_LIST_SIZE][4];     /* Null terminated */
  char  site_names[SITE_LIST_SIZE][20];   /* Null terminated */

  SINT4 idevice_count;  /* Number of devices available at the site */
  struct device_info device_list[MAX_OUT_DEVICES];
  struct serv_ymds_time time; /* Current time on the server */

  /* This array holds the names of the protected areas corresponding to the bits
   * in the area mask.  There is no need for count variable; all are used unless
   * the string is null, in which case that bit is skipped.
   */
#define AREA_LIST_SIZE (32)
  char  sarea_list[AREA_LIST_SIZE][16];   /* Null terminated */

#define SITE_MOVING_PLATFORM (0x01) /* Antenna format contains moving platform info */
#define SITE_POLAR_FEATURES  (0x02) /* Polarization features available in product gen. */
#define SITE_CANADA_LICENSE  (0x04) /* Site licensed for Canada AES only */
#define SITE_NORDRAD_LICENSE (0x08) /* Site licensed for NORDRAD */
#define SITE_RIBBON_LICENSE  (0x10) /* Site licensed for Ribbon Display interface */
#define SITE_ALERT_FAULT     (0x20) /* Window alert on site faults enabled */
#define SITE_ALERT_STALE     (0x40) /* Window alert on stale images enabled */
  UINT4 iflags;
  UINT4 izr_const;                 /* Z/R relationship constant */
  UINT4 izr_exp;                   /* Z/R relationship exponent */
  UINT4 ikr_const;                 /* K/R relationship constant */
  UINT4 ikr_exp;                   /* K/R relationship exponent */
  char  sPassword[16];             /* Window operator password */
  UINT4 iWindowAlertStyle;         /* How to show the window alert */
  /* Time delay in seconds until the image is flagged as stale */
  UINT4 iWindowStaleTime;
};

/* Header structure used for communication with the iris client interface.
 * One sent first before the array in the ISM, POM, and ARC menus.  POM
 * uses the special structure below.
 */ 
struct server_list_header
{
  SINT4 ilist_max;         /* Maximum number of items allowed in the inventory */
  SINT4 isend_max;         /* Maximum number of items that will be sent */
  SINT4 ilist_num;         /* Total number of items in the inventory */
  SINT4 isend_num;         /*       number of items which are being sent */
  SINT4 ilist_bytes;       /* Total size of items in the inventory */
  SINT4 isend_bytes;       /*       size of items which are being sent */
  SINT4 ikeep_bytes;       /*       size of items with keep set */
};
typedef struct server_list_header SLST_HDR;

/* These parameters define which fields to filter on.  They are used for all
 * menus which have a filter scheme, and are placed in the "imask" field
 * when the request is made.
 */
#define FLT_PTYPE    (0x0001)  /* Filter on product type */
#define FLT_PNAME    (0x0002)  /* Filter on product name */
#define FLT_TNAME    (0x0004)  /* Filter on task name */
#define FLT_YEAR     (0x0008)  /* Filter on year */
#define FLT_MONTH    (0x0010)  /* Filter on month */
#define FLT_DAY      (0x0020)  /* Filter on day */
#define FLT_HOUR     (0x0400)  /* Filter on hour interval */
#define FLT_SITE     (0x0040)  /* Filter on site number */
#define FLT_PHEAD    (0x0080)  /* Filter out product headers without data files or sends */
#define FLT_PDATA    (0x0100)  /* Filter out product data files */
#define FLT_SCANTYPE (0x0200)  /* Filter on scan type */
#define FLT_YMDS     (0x0800)  /* Filter on Ymds */

/* Implied always on in old server */
#define FLT_DEVICE     (0x1000)  /* Filter on device number */
#define FLT_SENDMAX    (0x2000)  /* Filter on max list size */
#define FLT_LISTSTART  (0x4000)  /* Filter on list start */

struct server_filter
{                        
  UINT4 imask;                    /* UPDATE: Filter mask */
  UINT4 isend_max;                /* UPDATE: Maximum list size */
  SINT4 ilist_start;              /* List start file  TAP         */
  UINT4 iDevice;                  /* Output device #      POM     */

  /* The following fields are only used if the appropriate bit is set
   * in the mask.
   */
  UINT4 iptype;                   /* Product type     TAP POM     */
  char  spname[16];               /* Product name     TAP POM     */
  char  stname[16];               /* Task name            POM ISM */
  struct serv_ymds_time ing_time; /* Time (y,m,d only)TAP POM ISM */
  SINT4 ifrom_hour;               /* Hour to start    TAP POM ISM */
  SINT4 ito_hour;                 /* Hour to end      TAP POM ISM */
  UINT4 isite_num;                /* Site number      TAP POM ISM */
  UINT4 iscan;                    /* Scan type                ISM */
};
typedef struct server_filter SFLT;

/* Header structure used for communication with the iris client
 * interface.  One sent first before the task schedule, or the product
 * schedule.
 */ 
struct server_schedule_header
{
  SINT4 isend_max;		/* Maximum number of items that could be sent */
  SINT4 ilist_num;		/* Number of items in the schedule */
  SINT4 isend_num;		/* Number of items which are being sent */
  char  sched_name[16];		/* Name of schedule, null terminated */
  UINT4 isite_group_mask;	/* (Used only in the product schedule) */
  UINT4 lIngestPassive ;	/* (Used only in the task schedule) */
  char  ipad_end[12];
};
typedef struct server_schedule_header SSCH_HDR;

/* Used in command to set the overlay file name */
struct server_overlay_set
{
  UINT4 isite_num;
  char  soverlay[16];  /* null terminated string */
};

/* Used to list the overlays */
struct server_overlay_info
{
  char  soverlay[16];  /* null terminated string */
};

struct server_overlay_dir
{
  UINT4 ioverlay_count;
  struct server_overlay_info overlays[MAX_OVERLAYS];
  UINT4 ilayer_count;
  char slayers[32][20];
};

struct server_timelist
{
  struct serv_ymds_time Ymds;
  SINT4  iTimeOffset;      /* Minutes added to recorded times to make supplied time */
};

struct overlay_mask_names
{
  UINT4 imask;
  char  sname[20];  /* Unused if first character is a zero */
};

#define MAX_OVERLAY_MASKS (8)
struct overlay_mask_dir
{
  struct overlay_mask_names over_mask[MAX_OVERLAY_MASKS];
};

/* Available commands
 */
#define PROC_CMD_OFF (0)	/* Off, do nothing */
#define PROC_CMD_ON  (1)	/* On */

/* Available modes
 */
#define PROC_MODE_NULL     (0)	/* Not applicable */
#define PROC_MODE_STOPPED  (1)	/* Stopped */
#define PROC_MODE_IDLE     (2)	/* Between jobs  */
#define PROC_MODE_RUNNING  (3)	/* Running a job */
#define PROC_MODE_RESET    (4)	/* Resetting the device */
#define PROC_MODE_EXIT     (5)	/* Exit sequence */
#define PROC_MODE_INIT     (6)	/* Attempting to initialize */
#define PROC_MODE_BLOCKED  (7)	/* Blocked from running */
#define PROC_MODE_INVENTORY (8)	/* Scanning for archive inventory */
#define PROC_MODE_RECORD   (9)	/* In Record mode */
#define PROC_MODE_RETRIEVE (10)	/* In Retrieve mode */

struct one_process_info
{
  UINT4 icommand;
  UINT4 imode;
  UINT4 ipid;
};

struct process_info
{
  char srst_file[12];		/* Space terminated */

  /* Each of the following structures is used to control one of the
   * IRIS processes.  The slot number for a process is just a unique
   * number used for bit setting.
   */
#define INGEST_SLOT    (0)
  struct one_process_info ingest ;
#define INGFIO_SLOT    (1)
  struct one_process_info ingfio ;
#define PRODUCT_SLOT   (3)
  struct one_process_info product ;
#define WATCHDOG_SLOT  (4)
  struct one_process_info watchdog ;
#define REINGEST_SLOT  (5)
  struct one_process_info reingest ;
#define NETWORK_SLOT   (6)
  struct one_process_info network ;
#define NORDRAD_SLOT   (7)
  struct one_process_info nordrad ;
#define SERVER_SLOT    (8)
  struct one_process_info server ;
#define RIBBON_SLOT    (9)
  struct one_process_info ribbon ;
#define SSERVER_SLOT   (10)
  struct one_process_info sserver ;
#define OUTPUT_SLOT    (11)
#define INPUT_SLOT     (12)
  struct one_process_info output_master ;
  struct one_process_info output_list[MAX_OUT_DEVICES] ;

  /* The number of clients that are currently connected to the socket server
   */
  SINT4 iSocketClientCount;

  /* The last idle time of the product generator.  Used to detect it going
   * compute bound. This can be set and checked indivisibly, so no locking is needed.
   */
  UINT4 iLastIdleProductTime;
};
typedef struct process_info PINFO;

struct status_fault_summary
{
  /* Site number of lowest site which has a problem status product.
   * Set to FFFFFFF if none
   */
  UINT4 iSitenum;
  /* Type of fault on the above system, see product.h for choices.
   * Set to Ok if.
   */
  UINT4 iFaultType;
};

struct server_process_info
{
  /* Null terminated configuration file names */
  char srst_file[16];
  char stsc_file[16];
  char spsc_file[16];
  char spom_file[16];

  struct one_process_info ingest;
  struct one_process_info ingfio;
  struct one_process_info ipad_Unused;  /*Can remove when wanted */
  struct one_process_info output;     /* Output summary info */
  struct one_process_info product;
  struct one_process_info watchdog;
  struct one_process_info reingest;
  struct one_process_info network;
  struct one_process_info nordrad;
  struct one_process_info server;
  struct one_process_info ribbon;
  struct one_process_info sserver ;
  struct one_process_info Input;      /* Input summary info */

  /* ------- Network Receiver Related Information ------- */
  /* The number of network links from other IRISs which are currently alive: */
  SINT4 ilink_count;

  /* The number of client that are currently connected to the socket server */
  SINT4 iSocketClientCount;

  /* Index number of the last message in the message menu: */
  SINT4 imessage_count;

  /* Names of the currently active task and product, if any.  Null terminated */
  char sactive_tname[16];
  char sactive_pname[16];

  /* Copy of the header.lenabled value from the mode_switching_table */
  UINT4 lams_enabled;

  /* Summary of NST menu */
  struct status_fault_summary NStatus;

};
typedef struct server_process_info SPINFO;

struct server_antenna_info
{
  /* Current antenna position, in binary angles */
  UINT4 iazpos;
  UINT4 ielpos;

  /* Current antenna velocity, in binary angles/second * by 180/2**31 to go to deg/sec */
  UINT4 iazvel;
  UINT4 ielvel;

  /* Current antenna command bits */
  UINT4 icommand;
  UINT4 icommand_mask;

  /* Current antenna status bits */
  UINT4 istatus;
  UINT4 istatus_mask;
  UINT4 iStatusCritical;  /* Bits which can make critical faults */

  /* Current Bite flag, nonzero if there is a fault */
  UINT4 ibite_flag;
  SINT4 ibite_field;  /*Lowest field number generating the fault */
};
typedef struct server_antenna_info SAINFO;

#define AMS_REQUEST_NONE      (0)  /* No request is currently queued */
#define AMS_REQUEST_AUTOMATIC (1)  /* Auto switch, if there was a warning */
#define AMS_REQUEST_RST       (2)  /* Switch if there was no warning */
struct mode_switching_header
{
  SINT4 itable_length;               /* Number of entries in the following table */
  SINT4 ihold_time;                  /* Hysteresis time in seconds */
  UINT4 lenabled;                    /* Non-zero means switching is enabled */
  struct serv_ymds_time change_time; /* Time of last mode change */

  /* Mode switch requests are placed here, and are implemented by the watchdog.
   * Manual requests are always inserted, auto requests only inserted if the
   * current request is set to AMS_REQUEST_NONE.
   */
  UINT4 irequest;
  char  srequest_pname[20];          /* pname for automatic */
  char  srequest_rst[20];            /* RST name to switch to */

  /* For the following, a zero in the first character means there is no request */
  char  socket_request_rst[20];      /* Request coming in from a socket */
  char  sStatusRequestRst[20];       /* Request coming in from a status product */
  /* Changes to these two menus are done here, not by the server */
  char  smanual_request_tsc[20];     /* Task scheduler request from menus*/
  char  smanual_request_psc[20];     /* Product scheduler request from menus */
};

#define AMS_STATE_OFF     (0)  /* Switching disabled for this entry */
#define AMS_STATE_WARNING (1)  /* Switch if there was a warning */
#define AMS_STATE_CLEAR   (2)  /* Switch if there was no warning */
struct mode_switching_entry
{
  SINT4 index;                 /* Only used for client-->server */
  UINT4 istate;
  char  spname[20];            /* Null terminated */
  char  srst_name[20];         /* Null terminated */
};

/* The maximum number of runways we can handle */
#define MAX_RUNWAYS (8)

#define RUNWAY_UNUSED    0
#define RUNWAY_PRIMARY   1
#define RUNWAY_SECONDARY 2
#define RUNWAY_INACTIVE  3

/* Defines the direction of runways know.  All unused slots set to zero.
 * Each rayway stores both the active direction and the inactive direction.
 * This makes searching easier.
 */
struct runway_direction
{
  char  sPrimaryDirection[8];   /* Null terminated */
  char  sSecondaryDirection[8]; /* Null terminated */
  UINT4 iDirection;             /* Direction currently in effect */
};

#define MODE_SWITCHING_LENGTH (16)
struct mode_switching_table
{
  struct mode_switching_header header;
  struct mode_switching_entry  table[MODE_SWITCHING_LENGTH];
  struct runway_direction      Runways[MAX_RUNWAYS];
};

/* --------------- System Control And Status Variables ------------- */
struct system_status
{
  /* This holds the ID of the user and terminal which stopped the iris
   * system, Null terminated.
   */
  char squit_user[16];
  char squit_term[16];
  char start_user[16];
  char start_term[16];

  /* How iris was started, and number of times it has been restarted.
   */
#define IRIS_START_MANUAL    (1)
#define IRIS_START_AUTOMATIC (2)
  UINT2 istart_style, irestart ;

  /* Time iris was started.
   */
  struct full_time_spec StartTime;

  /* The following array is used to keep track of specific changes
   * that have been made to the share file variables.  This memory is
   * managed by routines in iris/share/event_flags_c.c
   */
  UINT2 imenu_mods[32];

  /* Overall system fault status.
   */
  UINT1 lFaultCritical ;
  UINT1 lFaultWarning ;

  /* Processes were started up in debug mode */
  UINT1 lDebugStartup;
  char  ipad_175x1;

  /* Variable to indicate IRIS's run level.  This is used to block multiple
   * conflicting operations, as well as mode switching.  Must lock 
   * MESSAGE_SEM before checking and changing from RUN_LEVEL_RUNNING.
   */
#define RUN_LEVEL_STARTING   0
#define RUN_LEVEL_RUNNING    1
#define RUN_LEVEL_RESTARTING 2
#define RUN_LEVEL_MODECHANGE 3
#define RUN_LEVEL_QUITING    4
  UINT2 iRunLevel;
  /* Force a new status product to be made very soon.  Must lock MESSAGE_SEM 
   * before checking and changing.  Also wakeup WATCHDOG_EF to make it go.
   */
  UINT1 lForceStatusProduct;
  /* System has been up long enough to timeout sites for which we
   * have not yet received a status product.
   */
  UINT1 lTimeoutStatusProducts;
};


/* --------------------------------------------------
 * Structures used by levelize
 */
#define MAXLSEAMS 256		/* Maximum number of levelizing seams */
struct byte_level {
  UINT1 imap[256] ;
} ;
struct short_level {
  SINT4 iseamcount ;		/* Number of active seams */
  UINT2 iseams[MAXLSEAMS] ;	/* Seam edges in data units */
  UINT1 ivalues[MAXLSEAMS+1] ;	/* Byte/Pixel value for each interval */
  char  ipad[3];
} ;
struct long_level {
  SINT4 iseamcount ;		/* Number of active seams */
  UINT4 iseams[MAXLSEAMS] ;	/* Seam edges in data units */
  UINT1 ivalues[MAXLSEAMS+1] ;	/* Byte/Pixel value for each interval */
  char  ipad[3];
 } ;
union level_control
{
  struct byte_level  level1 ;
  struct short_level level2 ;
  struct long_level  level4 ;
} ;

/* Structure used to define the color scale conversion */
struct color_scale_def
{
#define COLOR_SCALE_VARIABLE (0x0100)
#define COLOR_SCALE_OVERRIDE (0x0200)  /* Not in file */
#define COLOR_SCALE_TOP_SAT  (0x0400)  /* All values above top shown as top */
#define COLOR_SCALE_BOT_SAT  (0x0800)  /* All values below bottom shown as bottom */
  UINT4 iflags;
  SINT4 istart;
  SINT4 istep;
  SINT2 icolcnt;
  UINT2 iset_and_scale;   /* Set number in low byte, scale number in high */
  UINT2 ilevel_seams[16];

};

/* Structure used to define the color scale conversion */
struct server_color_scale_def
{
  SINT4 idevice_index;  /* Index and dtype not used in product configuration */
  UINT4 idtype;

  UINT4 iflags;
  SINT4 istart;
  SINT4 istep;
  SINT4 icolcnt;
  UINT4 iset_number;    /* Origin 1 */
  UINT4 ilevel_seams[16];  /* Not use in product configuration */
  UINT4 iscale_number;  /* Custom scale number, Origin 0 */
};

/* Used when a pipe program runs, and needs to produce 2 outputs.
 * This exit status means rerun the pipe to get the second output. */
#define EXIT_RERUN (2)

/* Used when a pipe program runs, and produces no output, but
 * there is no error.
 */
#define EXIT_NOTHING (3)

#ifdef __cplusplus
}
#endif
#endif /* #ifndef SIGMET_HEADERS_H */
