/* **********************************************************************
 * *                                                                    *
 * *                INCLUDE Definitions for IRIS Ingest                 *
 * *                                                                    *
 * **********************************************************************
 * File: iris/ingest/ingest_h.h
 *
 * COPYRIGHT (c) 1989, 1993, 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.
 */
#ifdef INGEST_H_ALLOCATE
#define EXTERN
#else
#define EXTERN extern
#endif

#define     ANT_LOCAL       1
#define ING_ANT_LOCAL      (ING_FACILITY + ANT_LOCAL    )
#define     ANT_MORBID_AZ   2
#define ING_ANT_MORBID_AZ  (ING_FACILITY + ANT_MORBID_AZ)
#define     ANT_MORBID_EL   3
#define ING_ANT_MORBID_EL  (ING_FACILITY + ANT_MORBID_EL)
#define     ANT_MORBID_NO   4
#define ING_ANT_MORBID_NO  (ING_FACILITY + ANT_MORBID_NO)
#define     BAD_SCAN        5
#define ING_BAD_SCAN       (ING_FACILITY + BAD_SCAN     )
#define     BPHUNT_STARTED  6
#define ING_BPHUNT_STARTED (ING_FACILITY + BPHUNT_STARTED )
#define     CMAP_DFOPEN    11
#define ING_CMAP_DFOPEN    (ING_FACILITY + CMAP_DFOPEN  )
#define     CMAP_INREV     12
#define ING_CMAP_INREV     (ING_FACILITY + CMAP_INREV   )
#define     CMAP_NODBZ_F   13
#define ING_CMAP_NODBZ_F   (ING_FACILITY + CMAP_NODBZ_F )
#define     CMAP_NODBZ_T   14
#define ING_CMAP_NODBZ_T   (ING_FACILITY + CMAP_NODBZ_T )
#define     CMAP_NOTFND    15
#define ING_CMAP_NOTFND    (ING_FACILITY + CMAP_NOTFND  )
#define     CMAP_OUTSTEP   16
#define ING_CMAP_OUTSTEP   (ING_FACILITY + CMAP_OUTSTEP )
#define     CMAP_SCANTYPE  21
#define ING_CMAP_SCANTYPE  (ING_FACILITY + CMAP_SCANTYPE)
#define     CMAP_SUMOPEN   22
#define ING_CMAP_SUMOPEN   (ING_FACILITY + CMAP_SUMOPEN )
#define     DISQ_FULL      25
#define ING_DISQ_FULL      (ING_FACILITY + DISQ_FULL    )
#define     DSP_GPRM       31
#define ING_DSP_GPRM       (ING_FACILITY + DSP_GPRM     )
#define     DSP_NSE        32
#define ING_DSP_NSE        (ING_FACILITY + DSP_NSE      )
#define     DSP_PASSIVE    33
#define ING_DSP_PASSIVE    (ING_FACILITY + DSP_PASSIVE  )
#define     DSP_PWRP       34
#define ING_DSP_PWRP       (ING_FACILITY + DSP_PWRP     )
#define     DSP_PWRDN      35
#define ING_DSP_PWRDN      (ING_FACILITY + DSP_PWRDN    )
#define     DSP_RESET      36
#define ING_DSP_RESET      (ING_FACILITY + DSP_RESET    )
#define     DSP_UTC        37
#define ING_DSP_UTC        (ING_FACILITY + DSP_UTC      )
#define     DSP_UNGAIN     41
#define ING_DSP_UNGAIN     (ING_FACILITY + DSP_UNGAIN   )
#define     DSP_WBOUT      42
#define ING_DSP_WBOUT      (ING_FACILITY + DSP_WBOUT    )
#define     DSPB_OVF       43
#define ING_DSPB_OVF       (ING_FACILITY + DSPB_OVF     )
#define     DSPDO_ERR      44
#define ING_DSPDO_ERR      (ING_FACILITY + DSPDO_ERR    )
#define     DSPLOC_ERR     45
#define ING_DSPLOC_ERR     (ING_FACILITY + DSPLOC_ERR   )
#define     DSPWR_ERR      46
#define ING_DSPWR_ERR      (ING_FACILITY + DSPWR_ERR    )
#define     DSPRD_ERR      51
#define ING_DSPRD_ERR      (ING_FACILITY + DSPRD_ERR    )
#define     DSPRST_ERR     52
#define ING_DSPRST_ERR     (ING_FACILITY + DSPRST_ERR   )
#define     DSPWP_ERR      53
#define ING_DSPWP_ERR      (ING_FACILITY + DSPWP_ERR    )
#define     INV_CONFIG     54
#define ING_INV_CONFIG     (ING_FACILITY + INV_CONFIG   )
#define     MFCMODE        55
#define ING_MFCMODE        (ING_FACILITY + MFCMODE      )
#define     MISSES         56
#define ING_MISSES         (ING_FACILITY + MISSES       )
#define     EXEC_ERROR     59
#define ING_EXEC_ERROR     (ING_FACILITY + EXEC_ERROR   )
#define     EXEC_STOPPED   60
#define ING_EXEC_STOPPED   (ING_FACILITY + EXEC_STOPPED )
#define     NO_RADIATE     63
#define ING_NO_RADIATE     (ING_FACILITY + NO_RADIATE   )
#define     NOISE_SAMPLE   64
#define ING_NOISE_SAMPLE   (ING_FACILITY + NOISE_SAMPLE )
#define     NRAY_OVF       65
#define ING_NRAY_OVF       (ING_FACILITY + NRAY_OVF     )
#define     PASSIVE_SCAN   66
#define ING_PASSIVE_SCAN   (ING_FACILITY + PASSIVE_SCAN )
#define     PRM_OVF        71
#define ING_PRM_OVF        (ING_FACILITY + PRM_OVF      )
#define     RVP_DIAGERR    72
#define ING_RVP_DIAGERR    (ING_FACILITY + RVP_DIAGERR  )
#define     RVP_DSPCOUNT   73
#define ING_RVP_DSPCOUNT   (ING_FACILITY + RVP_DSPCOUNT )
#define     RVP_DNLINK     74
#define ING_RVP_DNLINK     (ING_FACILITY + RVP_DNLINK   )
#define     RVP_PLLCLK     75
#define ING_RVP_PLLCLK     (ING_FACILITY + RVP_PLLCLK   )
#define     RVP_SWITCH     76
#define ING_RVP_SWITCH     (ING_FACILITY + RVP_SWITCH   )
#define     RVP_SYLDERR    77
#define ING_RVP_SYLDERR    (ING_FACILITY + RVP_SYLDERR  )
#define     RVP_BPHFAIL    78
#define ING_RVP_BPHFAIL    (ING_FACILITY + RVP_BPHFAIL  )
#define     RVP_PHSEQGEN   79
#define ING_RVP_PHSEQGEN   (ING_FACILITY + RVP_PHSEQGEN )
#define     RVP_UPLINK     81
#define ING_RVP_UPLINK     (ING_FACILITY + RVP_UPLINK   )
#define     RVP_NOBURST    82
#define ING_RVP_NOBURST    (ING_FACILITY + RVP_NOBURST  )
#define     RVP_SLIPBURST  83
#define ING_RVP_SLIPBURST  (ING_FACILITY + RVP_SLIPBURST )
#define     SHMEM_MAP      84
#define ING_SHMEM_MAP      (ING_FACILITY + SHMEM_MAP    )
#define     SPAN_AZ        85
#define ING_SPAN_AZ        (ING_FACILITY + SPAN_AZ      )
#define     SPAN_EL        86
#define ING_SPAN_EL        (ING_FACILITY + SPAN_EL      )
#define     SWEEP_TIME     88
#define ING_SWEEP_TIME     (ING_FACILITY + SWEEP_TIME   )
#define     STC_CAL        91
#define ING_STC_CAL        (ING_FACILITY + STC_CAL      )
#define     SWEEP_STARTING 92
#define ING_SWEEP_STARTING (ING_FACILITY + SWEEP_STARTING )
#define     SWP_STOP       93
#define ING_SWP_STOP       (ING_FACILITY + SWP_STOP     )
#define     TASK_ALT       94
#define ING_TASK_ALT       (ING_FACILITY + TASK_ALT     )
#define     TASK_DATACOUNT 95
#define ING_TASK_DATACOUNT (ING_FACILITY + TASK_DATACOUNT)
#define     TASK_DSP_CANT  96
#define ING_TASK_DSP_CANT  (ING_FACILITY + TASK_DSP_CANT)
#define     TASK_MIXED     97
#define ING_TASK_MIXED     (ING_FACILITY + TASK_MIXED   )
#define     TASK_MODE_CANT 98
#define ING_TASK_MODE_CANT (ING_FACILITY + TASK_MODE_CANT)
#define     TIME_CHANGE    99
#define ING_TIME_CHANGE    (ING_FACILITY + TIME_CHANGE  )
#define     TIME_ERROR     100
#define ING_TIME_ERROR     (ING_FACILITY + TIME_ERROR   )
#define     TR_LOCAL       101
#define ING_TR_LOCAL       (ING_FACILITY + TR_LOCAL     )
#define     UNK_ANGF       102
#define ING_UNK_ANGF       (ING_FACILITY + UNK_ANGF     )
#define     UNK_RAYD       103
#define ING_UNK_RAYD       (ING_FACILITY + UNK_RAYD     )
#define     UNK_SUBR       104
#define ING_UNK_SUBR       (ING_FACILITY + UNK_SUBR     )
#define     USED_GLO       105
#define ING_USED_GLO       (ING_FACILITY + USED_GLO     )
#define     VC_NOVVP       106
#define ING_VC_NOVVP       (ING_FACILITY + VC_NOVVP     )
#define     VC_NOVEL       111
#define ING_VC_NOVEL       (ING_FACILITY + VC_NOVEL     )
#define     VSCAN_STARTING 112
#define ING_VSCAN_STARTING (ING_FACILITY + VSCAN_STARTING )
#define     ZC_NODBZ       113
#define ING_ZC_NODBZ       (ING_FACILITY + ZC_NODBZ     )
#define     RNG_INCONS     114
#define ING_RNG_INCONS     (ING_FACILITY + RNG_INCONS   )
#define     RVP_NTGPROC    115
#define ING_RVP_NTGPROC    (ING_FACILITY + RVP_NTGPROC  )
#define     RVP_PRFVARIED  116
#define ING_RVP_PRFVARIED  (ING_FACILITY + RVP_PRFVARIED )
#define     RVP_FIFOERROR  117
#define ING_RVP_FIFOERROR  (ING_FACILITY + RVP_FIFOERROR )
#define     RVP_RMASK      119
#define ING_RVP_RMASK      (ING_FACILITY + RVP_RMASK     )
#define     RVP_PHSEQMES   120
#define ING_RVP_PHSEQMES   (ING_FACILITY + RVP_PHSEQMES  )
#define     RVP_PMODERR    121
#define ING_RVP_PMODERR    (ING_FACILITY + RVP_PMODERR   )
#define     SIM_NO_MELT    122
#define ING_SIM_NO_MELT    (ING_FACILITY + SIM_NO_MELT   )
#define     RVP_TXCLK      123
#define ING_RVP_TXCLK      (ING_FACILITY + RVP_TXCLK     )
#define     RVP_MMTS       124
#define ING_RVP_MMTS       (ING_FACILITY + RVP_MMTS      )
#define     RVP_POLERROR   125
#define ING_RVP_POLERROR   (ING_FACILITY + RVP_POLERROR  )

#ifndef MESSAGE_ONLY

/* Upper bounds on Azimuth and Elevation hops during scans.  Make
 * sure these values match those in messages.msg for SPAN_AZ and
 * SPAN_EL.  These are 16-bit binary angles.
*/
#define MAX_AZ_SPAN (30*182)
#define MAX_EL_SPAN (15*182)

/* Maximum difference in PRF allowed in passive mode
 */
#define IPRF_TOLLERANCE (10)

/* ==============================
 * For each ray that is acquired by the DSP, there is a sequence of write
 * and read I/O operations that must be performed.  One such operation is
 * summarized by the following structure.
 */
#define MAX_DSP_DO_WR  (4)	/*Max # of words in a single write */

/* Definitions for dsp_do.iop
 */
#define DSP_OP_DONE    (0)	/* All Done */
#define DSP_OP_READ    (1)	/* Read from DSP */
#define DSP_OP_FAKE    (3)	/* Read fake values */
#define DSP_OP_SNOOZE  (4)	/* Snooze for selected time */

/* Snooze time in milliseconds for the case of DSP_DO_SNOOZE
 */
struct dsp_do_snooze
{
  SINT4 isnooze;
};

struct dsp_do
{
  struct dsp_do_snooze Snooze;
  UINT2 iop;			/* Operation */

  SINT2 iocnt;			/* Word count for read/write */
  char ipad_end[4];		/* Pad to multiple of 8 bytes */
};

#define ANGLE_HISTORY_SIZE (40)
struct angle_history
{
  BIN2  iEl;          /* Elevation angle, from tags */
  BIN2  iAz;          /* Azimuth angle, from tags */
  UINT4 iBTime;       /* Time ray was taken.  This time may be from another computer */
};

/* ------------------------------
 * This structure holds information some or all of which will be
 * used to assemble a ray header with the archived data.
 */
#ifdef SIGMET_DSP_H
#ifdef SIGMET_RVP8_H
struct ray_header_info
{
  BIN2 iaz[2];			/* Azimuth at begining and end of ray */
  BIN2 iel[2]; 
  BIN2 iAzMid;                  /* Average az/el */
  BIN2 iElMid;
  SINT4 iTagPrf;                /* Tag Measured PRF */
  SINT4 iTagPulses;             /* Tag number of pulses in the ray */
  SINT2 iTagPlaybackVersion;    /* Tag playback version */
  UINT2 iTagMismatchTS;         /* Tag Missmatched time series */
  struct rvp8TaskID TagTaskId;  /* Tag Task ID */
  struct ymds_time Ymds;        /* Time of ray */
  struct gparm Gparm;           /* Tag Gparm from the ray */

  /* All data below is derived from the serial line antenna
   * driver.  The information is read from the driver after the
   * ray is read from the signal processor.  This is to partly
   * compensate for the serial line delay.  Because of uncertain
   * buffering there is still a lot of uncertainty.
   */
  FLT4 fazv;
  FLT4 felv;
  FLT4 fpitchv;
  FLT4 frollv;
  FLT4 fheadingv;
  FLT4 finu_pos[3];
  FLT4 finu_vel[3];		/* Velocity of the inu */
  FLT4 fped_vel[3];
  SINT4 iage;                   /* Age in ms since last update */
  BIN2 iant_az;
  BIN2 iant_el;
  BIN2 itrain;
  BIN2 ielor;
  BIN2 ipitch;
  BIN2 iroll;
  BIN2 iheading;
  UINT2 inav_flag;
  SINT2 iPlatformVelCor1;      /* Platform motion correction 1-byte format */
  SINT2 iPlatformVelCor2;      /* Platform motion correction 2-byte format */
};
#endif  /* #ifdef SIGMET_RVP8_H */
#endif  /* #ifdef SIGMET_DSP_H */

/* Structure for simulating blobs of reflectivity
 */
struct blob {
  float xpos, ypos, zpos ;	     /* Position of center */
  float xscl, yscl, zscl ;	     /* Scaling terms (db/km) */
  float fang, fcos, fsin ;           /* XY Orientation angle & cosines */
  float s1cos, s1sin, s2cos, s2sin ; /* Shear line direction cosines */
  float peak ;                       /* Peak value in dBZ */
} ;

struct noise_state
{
  UINT4 ilast_btime;       /* Last time noise sampling sequence was triggered */
  UINT1 lforce_sample;     /* Force noise sequence next time. */
  SINT4 ilast_pw;          /* Pulse width of last noise sample, (1/100 of usec) */
  UINT1 lneeds_sample[4];  /* Sample required for each pulse width */
};
struct hybrid_state
{
  SINT2 imajor;         /* Major ID for the task (origin 1)*/
  SINT2 iminor;         /* Minor ID for the task (origin 1), zero means not in hybrid*/
  SINT4 itask_base;     /* Index of the base task for the hybrid (origin 1) */
};

/* *******************************
 * *                             *
 * * Shared Variable Definitions *
 * *                             *
 * *******************************
 */

EXTERN SINT2 iwritn_c ;		/* # rays written in so far */

/* The ray pointer tables are sorted either by Azimuth Angle,
 * Elevation Angle, or simply by order of arrival.  Order of
 * arrival can run in a continuous loop mode.
 */
EXTERN SINT4 iord_c ;
#define ORD_AZIMUTH     (1)
#define ORD_ELEVATION   (2)
#define ORD_OF_ARRIVAL  (3)
#define ORD_OF_AR_LOOP  (4)

EXTERN struct ingest_moment_info Moments_c[MAX_MOMENTS];

/* ----------------------------------------------------------------
 * This is the grandmother of the RVP6 DSP cal structures. 
 */
#ifdef SIGMET_SETUP_H
struct dsp_configuration
{
  struct dsp_stc_table    stc;
  struct dsp_agc_cal      agc;
};
#endif  /* #ifdef SIGMET_SETUP_H */

/* Summaries for above...
 */
EXTERN SINT2 iprms_c ;		/* # parameters being recorded */
EXTERN SINT4 imem_req_c ;	/* Total # bytes required */
EXTERN SINT4 idisplay_mem_req_c ; /* # bytes required for 1 ray, display processing */
EXTERN UINT1 *pdisplay_memory_c ; /* Pointer to that display memory */

EXTERN UINT2 l_16_bit_data_c ;	/* 16-bit data set chosen from DSP */

EXTERN struct data_convert convert_c ;

EXTERN FLT4 ffirst_c, flast_c, fstep_c ; /* First/Last bin range, & step in km */
EXTERN FLT4 ftrunc_c ;			 /* Truncation height in km */

/* ICALLS counts the number of times that DATALOOP was called,
 * and IMISSES counts the number of times that successive rays
 * were discarded by DATALOOP.  IMISSES is set to zero whenever
 * a ray is actually used.
 */
EXTERN SINT2 imisses_c ;	/* # successive discarded rays */
EXTERN SINT2 iel_misses_c ;	/* # successive rays out of el limit */
EXTERN SINT2 iaz_misses_c ;	/* # successive rays out of az limit */
EXTERN SINT4 icalls_c ;		/* # calls to DATALOOP */
EXTERN BIN2  iNomEl_c ;		/* Nominal elevation angle for this sweep */
EXTERN BIN2  iNomAz_c ;		/* Nominal azimuth angle for this sweep */

/* Variables related to the internal data simulation.
 */
EXTERN UINT2 lsim_first_param_c ;       /* This is the first simulated parameter */

/* Whenever a run of rays are not used, we keep track of the
 * total duration of the run so that a sweep can be terminated
 * early.
 */
EXTERN UINT4 ibtime_first_miss_c ;	/* Binary time of first miss, and */
EXTERN UINT4 ibtime_misses_c ;		/* last of run of misses */

/* The sequence of write and read operations necessary to bring in the
 * next ray from the DSP is given below.  Also given are operations to
 * wind up and wind down the procedure.
 */
#define DSP_DO_LIST_SIZE  (4)
EXTERN struct dsp_do do_ray_c  [ DSP_DO_LIST_SIZE ] ;
	
EXTERN SINT4 ido_bytes_used_c ;	/* Max # bytes used for any DO op */

/* The manner of obtaining angle information, and the format of same
 * is given by IANG_FORM.  The possible settings of this variable are
 * described under a DSP Setup variable of the same name in setup.h.
 */
EXTERN SINT2 iang_form_c ;	/* Format of angles */

EXTERN UINT4 ibins_c ;		/* Actual number of bins in this ray */

EXTERN SINT4 itask_c ;		/* Origin 1 task number we are running */
EXTERN FLT4  fprf_scale_c ;

EXTERN UINT2 lclutmap_used_c ;	/* Clutter mapping is in use */
EXTERN struct angle_history History_c[ANGLE_HISTORY_SIZE] ;
EXTERN UINT2 iHistoryCount_c ;	/* Number of entries in the history buffer */
EXTERN UINT2 iHistoryPointer_c ; /* Slot to fill in next in history buffer */

EXTERN UINT1 lFreeRunningBetweenTasks_c; /* Processor has been left in free running mode */
/* Keep DSP information pointer around
 */
#ifdef SIGMET_DSP_LIB_H
EXTERN Dsp* pdsp_c;
#endif  /* #ifdef SIGMET_DSP_LIB_H */

EXTERN UINT2 luse_dsp_c ;	/* DSP is being used */

EXTERN char singestenv_c[80] ;	/* Translation of IRIS_INGEST */
EXTERN char sconfigenv_c[80] ;	/* Translation of IRIS_CONFIG */

/* The following parameter sets the size of the statically
 * allocated DSP intermediate buffer.  This buffer must be large
 * enough to hold one complete ray cycle of DSP output.  For
 * example, if time series and Z-Only data were being recorded,
 * the buffer must be large enough to hold everything at once.
 *
 * It is sized for 2-byte data.
 */
#ifdef SIGMET_DSP_H
#ifdef SIGMET_INGEST_H
#define DSPB_SIZE  (DSP_HEADER_MAX_SIZE + (2 * MAX_BINS * MAX_MOMENTS) )

EXTERN UINT1 dspbyt_c[ DSPB_SIZE ];
#endif  /* #ifdef SIGMET_INGEST_H */
#endif  /* #ifdef SIGMET_DSP_H */

/* Shared pointers to interprocess shared memory.
 */
EXTERN volatile struct      task_schedule *ptsc_c ;

/* Stored locally */
EXTERN struct  dsp_configuration DspCf_c ;
EXTERN struct  dsp_gain_cal gaincal_c;

EXTERN volatile struct  rtdisp_control *pRtqGlobal_c;
/* ***********************
 * *                     *
 * * Function Prototypes *
 * *                     *
 * ***********************
 */
void ant_stop(void);		/* File: scans.c */

#ifdef SIGMET_INGEST_HEADER_DEFINED
void clutmap_initsweep		/* File: clutmap.c */
( const struct ingest_header *sum_a ) ;
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED */

#ifdef SIGMET_INGEST_HEADER_DEFINED
void ClutmapInitVolume          /* File: clutmap.C */
( struct ingest_header *pSmy_a, 
  SINT4*pLockedClutmap_a );
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED */

void clutmap_cleanup		/* File: clutmap.c */
( void ) ;

void clutmap_do_ray		/* File: clutmap.c */
( UINT1 sb_a[] ) ;

void CorrectionsDoRay           /* File: corrections.C */
( UINT1 sb_a[],
  const struct task_configuration *pTcf_a );

#ifdef SIGMET_INGEST_HEADER_DEFINED
void CorrectionsInitSweep       /* File: corrections.C */
(const struct ingest_header *smy_a );
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED */

#ifdef SIGMET_INGEST_HEADER_DEFINED
void CorrectionsInitVolume      /* File: corrections.C */
( struct ingest_header *pSmy,
  SINT4 *pLockedClutmap_a );           /* Fill in the clutter map index, if any */
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED */

#ifdef SIGMET_INGEST_HEADER_DEFINED
void data_loop                  /* File: data_loop.c */
(UINT1 sb_a[],
 const struct ingest_header *pIhd_a,
 volatile UINT2 *iflag_a,
 MESSAGE *pStatus_a );        /* Optionally filled in */
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED_H */

void define_simulation          /* File: simulator.c */
(const struct ymds_time *pYmds_a );  /* Time of the volume scan start */

#ifdef SIGMET_HEADERS_H
void display_loop		/* File: data_loop.c */
( volatile UINT2 *iflag_a,
  MESSAGE *pStatus_a,        /* Optionally filled in */
  const struct ingest_header *pIHdr_a,
  UINT2 lfirst_a );
#endif /* #ifdef SIGMET_HEADERS_H */

void DisplayQueueEnd            /* File: display.c */
( void );

#ifdef SIGMET_INGEST_HEADER_DEFINED
void DisplayQueueInit     	/* File: display.c */
(const struct ingest_header *ping_a,
 const struct ymds_time *pSweepTime_a );
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED */

#ifdef SIGMET_INGEST_H
void DisplayQueueRays		/* File: display.c */
(const UINT1 isb_a[]) ;		/* Address of current sweep buffer */
#endif /* #ifdef SIGMET_INGEST_H */

#ifdef SIGMET_INGEST_H
MESSAGE dp_data_init
(struct task_configuration *task_a,
 struct ingest_configuration *pIcf_a );  /* Ingest configuration is filled in some */
#endif /* #ifdef SIGMET_INGEST_H */

MESSAGE dsp_do_end              /* File: dspio.C */
( struct task_configuration *task_a,
  volatile UINT2 *iflag_a );

MESSAGE dsp_do_first            /* File: dspio.C */
( const struct task_configuration *pTask_a,
  volatile UINT2 *iflag_a );

MESSAGE dsp_do_list		/* File: dspio.c */
(const struct dsp_do list_a[],
 volatile UINT2 *iflag_a );	/* Flag may be set */

#ifdef SIGMET_TASK_H
FLT4 fingest_dsp_time		/* File: dspio.c */
(volatile const struct task_configuration *task_a );
#endif /* #ifdef SIGMET_TASK_H */

const struct ray_header_info *GetLastRayHeader( void ); /* File: data_loop.C */
void ClearLastRayHeader( void );                        /* File: data_loop.C */

const struct ingest_data_header *GetLastIngestDataHeader(void); /* File: scan.C */

#ifdef SIGMET_INGEST_HEADER_DEFINED
MESSAGE iclutmap_setup		/* File: clutmap.c */
( const struct ingest_header *sum_a,
  const volatile struct one_ingest_file *file_a ) ;
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED */

#ifdef SIGMET_INGEST_HEADER_DEFINED
SINT4 iclutmap_lookup		/* File: clutmap.c */
( const struct ingest_header *sum_a );
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED */

FLT4 ComputePositionDeviation   /* File: scan.C */
( UINT1 lAzAxis_a );

#ifdef SIGMET_INGEST_HEADER_DEFINED
MESSAGE icon_scan		/* File: scan.C */
(struct ingest_header *smy_a,
 UINT1 sb_a[],
 const char sname_a[12],
 volatile UINT2 *piflag_a );
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED */

#ifdef SIGMET_TASK_H
MESSAGE ExecScan
( volatile struct task_configuration *pExecTask_a );  /* Task to run */
#endif /* #ifdef SIGMET_TASK_H */

#ifdef SIGMET_TASK_H
UINT1 lContinueTask             /* File: scan.C */
( const struct task_configuration *pTask_a,
  UINT2 iflag_a ) ;
#endif /* #ifdef SIGMET_TASK_H */

#ifdef SIGMET_TASK_H
MESSAGE idp_dsp_init		/* File: dspio.c */
(const struct task_configuration *task_a );
#endif /* #ifdef SIGMET_TASK_H */

#define WAIT_FOR_AZIMUTH   1
#define WAIT_FOR_ELEVATION 2
#define WAIT_FOR_AZVEL     4

UINT4 imorbid_time       /* File: scan.C */
(FLT4 faz_error_a,
 FLT4 fel_error_a,
 UINT2 iaxis_a );

void ingestCheckGparm
( const struct gparm *pGparm_a );

void ingest_cvel_do_ray		/* File: subs.c */
( UINT1 sb_a[] ) ;

#ifdef SIGMET_INGEST_HEADER_DEFINED
MESSAGE IngestInitVolume        /* File: run_task.C */
( const struct ingest_header *pSmy_a );
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED */

SINT4 iIngestPointerFromAngle   /* File: data_loop.C */
( BIN2 iAngleMid_a,      /* Angle of mid point of ray */
  const struct ingest_configuration *pIcf_a );

#ifdef SIGMET_INGEST_HEADER_DEFINED
MESSAGE ippi_scan		/* File: scan.c */
(struct ingest_header *smy_a,
 UINT1 sb_a[],
 const char sname_a[12],
 volatile UINT2 *piflag_a );
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED */

#ifdef SIGMET_INGEST_HEADER_DEFINED
MESSAGE irhi_scan		/* File: scan.c */
(struct ingest_header *smy_a,
 UINT1 sb_a[],
 const char sname_a[12],
 volatile UINT2 *piflag_a );
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED */

#ifdef SIGMET_TASK_H
BIN2 iScanSpeed                 /* File: run_task.C */
( volatile const struct task_configuration *tcf_a );
#endif  /* #ifdef SIGMET_TASK_H */

#ifdef SIGMET_INGEST_HEADER_DEFINED 
#ifdef SIGMET_SETUP_H
MESSAGE isetup_dsp		/* File: dspio.c */
(const struct ingest_header *pIHdr_a,
 const struct dsp_gain_cal *gaincal_a );
#endif /* #ifdef SIGMET_SETUP_H */
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED  */

UINT1 lAdaquatePositionHistory(void); /* File: scan.C */

UINT1 lPassiveTaskRunning       /* File: ingest.C */
( const struct task_configuration *pTask_a );

#ifdef SIGMET_INGEST_HEADER_DEFINED
MESSAGE ManualScan		/* File: scan.c */
(struct ingest_header *smy_a,
 UINT1 sb_a[],
 const char sname_a[12],
 volatile UINT2 *piflag_a );
#endif /* #ifdef SIGMET_INGEST_HEADER_DEFINED */

/* Clear the saved version of the previous task. */
void PreviousTaskClear          /* File: run_task.C */
( void );

#ifdef SIGMET_TASK_H
void ProcessEndOfTask           /* File: scan.C */
(struct task_configuration *pTask_a );
#endif  /* #ifdef SIGMET_TASK_H */

#ifdef SIGMET_TASK_H
MESSAGE run_task                /* File: run_task.c */
(volatile struct task_configuration *ptask_a,
 const struct ymds_time *pStartYmds_a,  /* time on local computer task was started, NULL for passive*/
 struct noise_state *pnoise_a,
 struct hybrid_state *phybrid_a );
#endif  /* #ifdef SIGMET_TASK_H */

#ifdef SIGMET_HEADERS_H
void simulate_data		/* File: simulator.c */
(UINT4 idtype_a,
 union ray_data *pRay_a,		/* output array */
 FLT4 faz_a,
 FLT4 fel_a
 );
#endif /* #ifdef SIGMET_HEADERS_H */

/* Class of functions to store locked state */
class IngestLock
{
 public:
  IngestLock();  /* Constructor */

  void FileInit(void);
  void FileRelease(void);
  void FileLock(SINT4 iIngestIndex_a);

  void ClutmapInit(void);
  void ClutmapRelease(void);
  void ClutmapLock(SINT4 iIngestIndex_a);

 private:

  volatile struct one_ingest_file *pLockedIngest_c, *pLockedClutmap_c;
};

EXTERN class IngestLock ingestLock_c;

/* Class to store the sweep buffer pointer */
class SweepBuffer    /* File: run_task.C */
{
 public:
  SweepBuffer();  /* Constructor */
  MESSAGE MapMemory( SINT4 iSize_a, const char *sName_a, UINT2 *plCreated_a );
  UINT1*  GetPointer( void );
  void    UnMapMemory( void );

 private:
  UINT1 *iaddr;
  SINT4 isize, ichan;

};
      
EXTERN class SweepBuffer sweepBuffer_c;

#endif /* #ifndef MESSAGE_ONLY */
