/* **********************************************************************
 * *                                                                    *
 * *            Support Routines for DSP Configuration Files            *
 * *                                                                    *
 * **********************************************************************
 * File: libs/config/dsp_limits.c
 *
 *                     COPYRIGHT (c) 2001, 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.
 */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include "sigtypes.h"
#include "sigversion.h"
#include "dsp.h"
#include "rvp8.h"
#include "user_lib.h"
#include "dsp_lib.h"
#include "pcicards_lib.h"
#include "rdasubs_lib.h"

#define LIM_DEFINITIONS
#define LIM_KERNEL dsp_limits_kernel
#include "config_lib.h"

static MESSAGE LIM_KERNEL
( const char *sname_a,		/* Name of structure */
  void *item_a,			/* Pointer to structure */
  SINT4 ioper_a,		/* Operation to perform */
  const char *spath_a,		/* Full path name of fields */
  void *ioarg_a ) ;		/* Diagnostic messages, or NULL */

MESSAGE dsp_limits
( const char *sname_a,		/* Name of structure */
  volatile void *item_a,	/* Pointer to structure */
  SINT4 ioper_a,		/* Operation to perform */
  void *file_a )		/* Diagnostic messages, or NULL */
{
  return( lim_toplevel( sname_a, item_a, ioper_a, file_a, LIM_KERNEL ) ) ;
}

/* ======================================================================
 * Internal routine to recursively descend the DSP structures.
 */
static MESSAGE LIM_KERNEL
( const char *sname_a,		/* Name of structure */
  void *item_a,			/* Pointer to structure */
  SINT4 ioper_a,		/* Operation to perform */
  const char *spath_a,		/* Full path name of fields */
  void *ioarg_a )		/* Diagnostic messages, or NULL */
{
  char spath[PATHNAME_SIZE], *sItem ; struct lim_inLine **pLine ;
  SINT4 idim1=0, idim2=0 ; MESSAGE istatus = SS_NORMAL ;

  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  if( 0 == strcmp( "dspPhysTargSim", sname_a ) ) {
    struct dspPhysTargSim *item = item_a ;

    SCALAR   (          iFlags,         0x00,          0xFF,             0 ) ;
    SCALAR   (      iStartKM10,            0,         10000,             0 ) ;
    SCALAR   (     iLengthKM10,            0,         10000,             0 ) ;
    SCALAR   (      iPowerDB10,        -1000,           100,             0 ) ;
    SCALAR   (  iPowerSpanDB10,         -500,           500,             0 ) ;
    SCALAR   (      iDopplerHZ,        -2000,          2000,             0 ) ;
    SCALAR   (  iDopplerSpanHZ,        -2000,          2000,             0 ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "opprm", sname_a ) ) {
    struct opprm *item = item_a ;

    SCALAR   (           isamp,RVP8MINPULSES, RVP8MAXPULSES,            25 ) ;

    SCALAR   (          iflags,       0x0000,        0xFFFF,
	       OPF_RNV|OPF_DSR|OPF_LSR|OPF_END|OPF_FROM_POL(POL_HORIZ_FIX) ) ;

    SCALAR   (        iz_slope,            0,   0x7FFF,(int)(4096.0*0.480) ) ;
    SCALAR   (        izns_thr,            0,        0x7FFF,             8 ) ;
    SCALAR   (        iccr_thr,      -0x8000,        0x7FFF,      -25 * 16 ) ;
    SCALAR   (        isqi_thr,            0,        0x0100,           128 ) ;
    SCALAR   (        isig_thr,            0,        0x7FFF,       10 * 16 ) ;
    SCALAR   (        iz_calib,      -0x8000,        0x7FFF,      -22 * 16 ) ;
    SCALAR   (         flg_agc,            0,        0xFFFF,             0 ) ;
    SCALAR   (          filter,            0,        0xFFFF,OPFLT_RESET+11 ) ;
    SCALAR   (         dbt_tcf,            0,        0xFFFF, TCF_LOG       ) ;
    SCALAR   (         dbz_tcf,            0,       0xFFFF,TCF_LOG&TCF_CSR ) ;
    SCALAR   (         vel_tcf,            0,       0xFFFF,TCF_SQI&TCF_CSR ) ;
    SCALAR   (         wid_tcf,            0,0xFFFF,TCF_SQI&TCF_CSR&TCF_WSP ) ;
    SCALAR   (       iAzOffset,            0,        0xFFFF,             0 ) ;
    SCALAR   (       iElOffset,            0,        0xFFFF,             0 ) ;
    SCALAR   (       gas_atten,            0,        0x7FFF,             0 ) ;
    SCALAR   (         zdr_tcf,            0,        0xFFFF,   TCF_LOG     ) ;
    SCALAR   (      zdr_offset,      -0x8000,        0x7FFF,             0 ) ;
    SCALAR   (      wavelength,            0,        0xFFFF,          5000 ) ;
    SCALAR   (      ldr_offset,      -0x8000,        0x7FFF,             0 ) ;
    SCALAR   (     ibin_smooth,            0,  DSP_MAXAVG-1,             0 ) ;
    SCALAR   (    iPtCltDetect,            0,        0xFFFF,             0 ) ;
    SCALAR   (    iPtCltCensor,            0,        0xFFFF,             0 ) ;
    SCALAR   ( iMismatchTSIgnore,          0,        0xFFFF,             0 ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "rvp8BatchSetup", sname_a ) ) {
    struct rvp8BatchSetup *item = item_a ;

    SCALAR   (      lAvailable,            0,             1,         FALSE ) ;
    SCALAR   (       fLoPrfScl,         -1.0,           1.0,           0.0 ) ;
    SCALAR   (       fLoPrfOff, DSP_RVP8_MINPRF, DSP_RVP8_MAXPRF,    250.0 ) ;
    SCALAR   (       fSampsScl,         -1.0,           1.0,           0.0 ) ;
    SCALAR   (       fSampsOff,          1.0, RVP8MAXPULSES,           6.0 ) ;
    SCALAR   (    fMaxUnfoldKM,          0.0,        1000.0,         600.0 ) ;
    SCALAR   (   iLoPrfAvgSide,            0,            15,             2 ) ;
    SCALAR   (     fdBOverRefl,          0.0,          25.0,           5.0 ) ;
    SCALAR   (      fdBOverVel,          0.0,          25.0,           8.0 ) ;
    SCALAR   (      fdBOverWid,          0.0,          25.0,          12.0 ) ;
    SCALAR   (    fdBAddNseThr,          0.0,           5.0,           0.0 ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "rvp8Tgline", sname_a ) ) {
    struct rvp8Tgline *item = item_a ;

    SCALAR   (          fStart,      -TGDLIM,        TGDLIM,           0.0 ) ;
    SCALAR   (       fStartPRT,         -1.0,           1.0,           0.0 ) ;
    SCALAR   (          fWidth,          0.0,        TGDLIM,           1.0 ) ;
    SCALAR   (          tgtype,   0x00000000,    0xFFFFFFFF,   TGTYPE_RISE ) ;

    RALACS   (       fStartPRT,         -1.0,           1.0,       0.0,  fStartPRTs[0] ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "rvp8Pwdef", sname_a ) ) {
    struct rvp8Pwdef *item = item_a ;

    SUBSTRUCTURE_1D( rvp8Tgline, trigs, NTRIGS ) ;

    SCALAR   (         fminprf, DSP_RVP8_MINPRF, DSP_RVP8_MAXPRF, DSP_RVP8_MINPRF ) ;
    SCALAR   (         fmaxprf, DSP_RVP8_MINPRF, DSP_RVP8_MAXPRF,    500.0 ) ;
    SCALAR   (     fMaxInstPrf, DSP_RVP8_MINPRF, DSP_RVP8_MAXPRF,    500.0 ) ;
    SCALAR   (       fextdelay, MINFEXTDELAY,  MAXFEXTDELAY,          10.0 ) ;
    SCALAR_1D(     fpol_switch,      -TGDLIM,        TGDLIM,           0.0, NPOLARS ) ;
    SCALAR   (         ipwcode,          0x0,           0xF,           0x1 ) ;
    SCALAR   (   fRangeMaskRes,         15.0,         625.0,         125.0 ) ;
    SCALAR   (       implength, MINIMPLENGTH,  DIMIMPLENGTH,            48 ) ;
    SCALAR   (        firwidth,  MINFIRWIDTH,   MAXFIRWIDTH,         0.503 ) ;
    SCALAR   (    fPriNoiseDbm,       -110.0,          10.0,         -75.0 ) ;
    SCALAR   (    fSecNoiseDbm,       -110.0,          10.0,         -75.0 ) ;
    SCALAR   (      ibfelength, MINIMPLENGTH,  DIMIMPLENGTH,            48 ) ;
    SCALAR   (       ibfestart,            0,  DIMIMPLENGTH,             0 ) ;
    SCALAR   (     fphase_load,      -TGDLIM,        TGDLIM,          -1.0 ) ;
    SUBSTRUCTURE( rvp8TxWaveSpecs, txSpecs ) ;

    SCALAR_1D( fTxZeroOffsUSec,       -100.0,      100.0,     0.0, 2 ) ;
    RALACS   ( fTxZeroOffsUSec[0],    -100.0,      100.0,     0.0, fTxZeroOffUSec ) ;
    RALACS   ( fTxZeroOffsUSec[1],    -100.0,      100.0,     0.0, fTxZeroOffUSec ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "rvp8SpecFilt", sname_a ) ) {
    struct rvp8SpecFilt *item = item_a ;

    SCALAR   (           iType,          0, SPFILT_NUMCODES-1,SPFILT_FIXED ) ;
    SCALAR   (       iMinWidth,          1,    SPFILTMAXPTS/2,           2 ) ;
    SCALAR   (       iSlopePts,          0,    SPFILTMAXPTS/2,           2 ) ;
    SCALAR   (        iEdgePts,          1,                15,           3 ) ;
    SCALAR   (    fClutWidthMS,        0.0,               5.0,        0.30 ) ;
    SCALAR   (        iWinType,          0,          MAXUINT4,           0 ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "rvp8SectorBlank", sname_a ) ) {
    struct rvp8SectorBlank *item = item_a ;

    SCALAR   (          lInUse,            0,             1,         FALSE ) ;
    SCALAR   (      lPedAngles,            0,             1,         FALSE ) ;
    SCALAR   (           fAzLo,          0.0,         360.0,           0.0 ) ;
    SCALAR   (           fAzHi,          0.0,         360.0,           0.0 ) ;
    SCALAR   (           fElLo,        -90.0,         270.0,           0.0 ) ;
    SCALAR   (           fElHi,        -90.0,         270.0,           0.0 ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "rvp8tsConfig", sname_a ) ) {
    struct rvp8tsConfig *item = item_a ;

    STRING(           sVersion, IRIS_VERSION ) ;

    SCALAR(     iDesWrMainUnit, RVP8TS_CLIENT_VOID, RVP8TS_MAX_CLIENTS-1,
	    RVP8TS_CLIENT_RVP8MAIN ) ;

    SCALAR(     iDesWrApp0Unit, RVP8TS_CLIENT_VOID, RVP8TS_MAX_CLIENTS-1, 
		RVP8TS_CLIENT_VOID ) ;
    SCALAR(     iDesWrApp1Unit, RVP8TS_CLIENT_VOID, RVP8TS_MAX_CLIENTS-1, 
		RVP8TS_CLIENT_VOID ) ;

    SCALAR(           nIQDVecs,             100000,             20000000,
		  RVP8IQDVECS_DFLT ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "rvp8TxChanSetup", sname_a ) ) {
    struct rvp8TxChanSetup *item = item_a ;

    SCALAR   (           iMode,            0,TXCSMODE_NUM-1,TXCSMODE_UNUSED ) ;    
    SCALAR   (        fFreqMHz,          0.0, TX8MAXFREQMHZ,          60.0 ) ;    
    SCALAR   (       lPhaseMod,            0,             1,         FALSE ) ;    
    SCALAR   (       fPhaseDeg,       -360.0,         360.0,           0.0 ) ;    
    SCALAR   (       lAbruptPH,            0,             1,         FALSE ) ;    
    SCALAR   (       fPowerdBm, TX8MINPOWDBM,  TX8MAXPOWDBM,           0.0 ) ;    
    SCALAR   (      lPeakPower,            0,             1,          TRUE ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "rvp8TxWaveSpecs", sname_a ) ) {
    struct rvp8TxWaveSpecs *item = item_a ;

    SCALAR   (       iWaveType,             0, WAVETYPE_NUMWAVES-1,  WAVETYPE_CWPULSE ) ;
    SCALAR   (   fPulseLenUSec,          0.20,         100.0,           2.0 ) ;
    SCALAR   (   fBandWidthMHz,   MINFIRWIDTH,   MAXFIRWIDTH,           0.5 ) ;
    SCALAR_1D(          fTunes, TXWAVEMINTUNE, TXWAVEMAXTUNE,     0.0, TXWAVETUNES ) ;
    SCALAR_1D(       fMinTunes, TXWAVEMINTUNE, TXWAVEMAXTUNE,     0.0, TXWAVETUNES ) ;
    SCALAR_1D(       fMaxTunes, TXWAVEMINTUNE, TXWAVEMAXTUNE,     1.0, TXWAVETUNES ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "rvp8NV", sname_a ) ) {
    struct rvp8NV *item = item_a ;

    STRING   (        sVersion, IRIS_VERSION ) ;

    SCALAR   (         version,            0,            99,             0 ) ;
    SCALAR   (         minorev,            0,            99,             0 ) ;

    SCALAR   (       iIo62Card,           -1,IO62MAXUNITS-1,             0 ) ;
    SCALAR   (     iRvp8RxCard,           -1, RX8MAXUNITS-1,             0 ) ;
    SCALAR   (     iRvp8TxCard,           -1, TX8MAXUNITS-1,            -1 ) ;

    SCALAR   (  lIo62LineDiags,            0,             1,         FALSE ) ;
    SCALAR   ( lPCIResetOnShutdown,        0,             1,          TRUE ) ;

    SCALAR   (  lRpcIrisServer,            0,             1,         FALSE ) ;

    SCALAR_1D(   iRxRS422Funcs,           -1,           499, RX_PIN_NOFUNCTION, 4 ) ;

    SCALAR   (       __iRxMode,            0, RXM_NUMMODES-1, RXM_NORMSING ) ;

    SCALAR   (          fSyClk,        33.33,         76.00,       71.9502 ) ;
    RALACS   (          fSyClk,        33.33,         76.00,       71.9502, fAqClk ) ;
    RALACS   (          fSyClk,        33.33,         76.00,       71.9502, faqclk ) ;

    SCALAR   (         ifdconf,   0x00000000,    0xFFFFFFFF,  
		                          IFDCONF_AFCMFC | IFDCONF_AFCXMIT ) ;

    SCALAR   (    fDitherPower,       -120.0,           0.0,         -57.0 ) ;

    SCALAR   (       iPllNumer,            1,  IFDMAXNUMDEN,             1 ) ;
    SCALAR   (       iPllDenom,            1,  IFDMAXNUMDEN,             1 ) ;
    SCALAR   (  lPllPosFreqDev,            0,             1,          TRUE ) ;

    SCALAR   ( iwaveguide_length,          0,          1000,             0 ) ;

    SCALAR   (       iIFDAuxMode,          0,             1, IFDAUXM_UNUSED ) ;
    SCALAR   (     iIFDAuxClkDiv, IFDAUX_MINDIV, IFDAUX_MAXDIV,           6 ) ;

    SCALAR   (         iPhLock,            0,             2,   BPLOCK_AUTO ) ;
    RALACS   (         iPhLock,            0,             1,          TRUE, lphlock ) ;

    SCALAR   (     lampc_inuse,            0,             1,         FALSE ) ;
    SCALAR   (  iampc_expulses,           10,           500,            70 ) ;
    SCALAR   (         fdbhead,          0.0,           5.0,           4.0 ) ;

    SCALAR   (  fWideChanSepDB,          0.0,          40.0,          20.0 ) ;
    SCALAR   ( fWideChanSepDeg,       -180.0,         180.0,           0.0 ) ;
    SCALAR   (  fWideChanErrDB,          0.0,           5.0,           0.5 ) ;
    SCALAR   ( fWideChanErrDeg,          0.0,          90.0,           5.0 ) ;
    SCALAR   (  fWideOverlapDB,          0.0,          60.0,          30.0 ) ;

    SCALAR   (       pwinfo_ok,            0,             1,         FALSE ) ;
    SCALAR   (       trigwf_ok,            0,             1,         FALSE ) ;

    SCALAR   (          nTrigs,            1,        NTRIGS,             6 ) ;
    SCALAR   (         nPolars,            0,       NPOLARS,             0 ) ;
    SCALAR   (        nPWidths,            1,    RVP8NPWIDS,             4 ) ;

    SUBSTRUCTURE_1D( rvp8Pwdef, pwdefs, RVP8NPWIDS ) ;

    SCALAR   (         lextrig,            0,             1,         FALSE ) ;
    SCALAR   (  lextrig_rising,            0,             1,          TRUE ) ;
    SCALAR   (   lextrig_synch,            0,             1,         FALSE ) ;
    SCALAR   (   lextrig_xmits,            0,             1,         FALSE ) ;

    SCALAR   (            fprf, DSP_RVP8_MINPRF, DSP_RVP8_MAXPRF,    500.0 ) ;
    SCALAR   (         ipwidth,            0,  RVP8NPWIDS-1,             0 ) ;
    SCALAR_1D(      lpol_vhigh,            0,             1,          TRUE, 2 ) ;
    SCALAR   (    iPrtQuantMpy,            1,         10000,             1 ) ;
    SCALAR   (    iPrtQuantOff,            0,         10000,             0 ) ;

    SCALAR   (          tblank,   0x00000000,    0xFFFFFFFF, BIT(NTRIGS)-1 ) ;

    SUBSTRUCTURE_1D( rvp8SectorBlank, sectorBlanks, RVP8SECTORBLANKS ) ;

    SCALAR   (        iRxTrigs,   0x00000000,    0xFFFFFFFF,             0 ) ;

    SCALAR   (      lTrigMerge,            0,             1,         FALSE ) ;
    SCALAR_1D(     iTrigMerges,   0x00000000,    0xFFFFFFFF,             0, NTRIGS ) ;

    SCALAR   (          fifreq,          6.0,          90.0,          30.0 ) ;
    SCALAR   (      fifreq_drx,          6.0,          90.0,          24.0 ) ;
    SCALAR   (         lifsign,            0,             1,          TRUE ) ;

    SCALAR   (   iburst_window,            0,             2,   WIN_HAMMING ) ;
    SCALAR   (   fburst_minpwr,        -60.0,          10.0,         -15.0 ) ;
    SCALAR   (   fburst_settle,          0.1,         120.0,           5.0 ) ;

    SCALAR   (      lEnableBPT,            0,             1,          TRUE ) ;

    SCALAR   (   lBpHuntEnable,            0,             1,         FALSE ) ;
    SCALAR   (    iBpHuntFreqs,            0,            50,             5 ) ;
    SCALAR   (   fBpHuntSettle,          0.0,           5.0,          0.25 ) ;
    SCALAR   (lBpHuntAutoEnable,           0,             1,         FALSE ) ;
    SCALAR   (fBpHuntAutoPeriod,         5.0,        3600.0,          60.0 ) ;

    SCALAR   (       lsimburst,            0,             1,         FALSE ) ;
    SCALAR   (      fafc_simlo,         10.0,          70.0,          27.0 ) ;
    SCALAR   (      fafc_simhi,         10.0,          70.0,          32.0 ) ;

    SCALAR   (   iAfcServoType,            0,             1,AFCSERVOTYPE_DC ) ;
    SCALAR   (      fafc_hist0,          0.0,        1000.0,           5.0 ) ;
    SCALAR   (      fafc_hist1,          0.0,        4000.0,          15.0 ) ;
    SCALAR   (      fafc_fwide,          0.0,        4000.0,          50.0 ) ;
    SCALAR   (    fafc_maxslew,          0.0,        1000.0,           0.5 ) ;
    SCALAR   (      fafc_slope,          0.0,         100.0,          0.01 ) ;
    SCALAR   (     fafc_warmup,          0.0,         300.0,          10.0 ) ;
    SCALAR   (    lafc_freqinc,            0,             1,          TRUE ) ;
    SCALAR   (    fafc_minslew,          0.0,        1000.0,           0.0 ) ;
    SCALAR   (     iafc_format,            0,             2, AFCFMT_BINARY ) ;
    SCALAR   (    iafc_lolimit,  -0x00800000,    0x00FFFFFF,   -0x00008000 ) ;
    SCALAR   (    iafc_hilimit,  -0x00800000,    0x00FFFFFF,    0x00007FFF ) ;

    SCALAR   (          fTxClk,         30.0, TX8MAXFREQMHZ,      80.94375 ) ;
    SCALAR   (      lTxClkLock,            0,             1,          TRUE ) ;
    SCALAR   (        iTxNumer,            1,  TX8MAXNUMDEN,            12 ) ;
    SCALAR   (        iTxDenom,            2,  TX8MAXNUMDEN,            27 ) ;
    SCALAR   (    iTxPllSource,            0,             1, TX8PLLSRC_IFD ) ;
    SCALAR   (      iTxModeBNC,            0,             4,TX8BNCMODE_IN50Z ) ;
    SCALAR   (    iTxClkDivBNC,            1,  TX8BNCMAXDIV,             1 ) ;
    SCALAR   (     fTxOpAmpFix,        -10.0,          10.0,           0.0 ) ;

    SUBSTRUCTURE_1D( rvp8TxChanSetup, txChans, 2 ) ;

    SCALAR   (   lphcode_inuse,            0,             1,         FALSE ) ;
    SCALAR   (   iphcode_nbits,            1,  RX8PHASEBITS,  RX8PHASEBITS ) ;
    SCALAR   (    fphcode_idle,          0.0,         360.0,           0.0 ) ;
    SCALAR   (     iphcode_seq,            0,             3,   PHSEQ_FIXED ) ;

    SUBSTRUCTURE( opprm, opprm ) ;

    SCALAR   (  iMinRayHoldoff,            0,           100,            50 ) ;

    SCALAR   ( fCltSigSlope[0],          0.0,           2.0,          0.15 ) ;
    SCALAR   ( fCltSigSlope[1],          0.0,           2.0,          1.00 ) ;

    SCALAR   ( fCltSigBegDB[0],          0.0,          80.0,         10.00 ) ;
    SCALAR   ( fCltSigBegDB[1],          0.0,          80.0,         50.00 ) ;

    SCALAR   (    force_window,            0,             3,             0 ) ;
    SCALAR   (        force_r2,            0,             2,             1 ) ;
    SCALAR   (    force_avgcth,            0,             2,             1 ) ;
    SCALAR   (   force_ctrigok,            0,             2,             1 ) ;
    SCALAR   (   force_unfdiff,            0,             2,             1 ) ;
    SCALAR   (    force_2Dpass,            0,             2,             1 ) ;

    SUBSTRUCTURE_1D( rvp8SpecFilt, spfilts, NFILTS ) ;
    SCALAR   (    lAnySizeSpec,            0,             1,          TRUE ) ;

    SCALAR   (      fnoise_sim,       -100.0,           0.0,         -50.0 ) ;

    SCALAR   (      fnoise_prf, DSP_RVP8_MINPRF, DSP_RVP8_MAXPRF,    250.0 ) ;
    SCALAR   (    fnoise_range,          0.0,        1000.0,         525.0 ) ;

    SCALAR   (    lIQPackHiSNR,            0,             1,          TRUE ) ;

    SCALAR   (         iIntFlt,            0,     INTFLTNUM,             0 ) ;
    SCALAR   (       fIntFltP1,          0.0,          50.0,          10.0 ) ;
    SCALAR   (       fIntFltP2,          0.0,          50.0,          12.0 ) ;

    SCALAR   (  fwht_sqi_slope,          0.0,           2.0,          0.50 ) ;
    SCALAR   ( fwht_sqi_offset,         -2.0,           1.0,         -0.05 ) ;

    SCALAR   ( fwht_szFlatness,          0.0,          20.0,           4.0 ) ;
    SCALAR   (fwht_szHiPowReject,        0.0,          20.0,           8.0 ) ;
    SCALAR   (fwht_szMaxPhaseErr,        0.0,         180.0,          12.0 ) ;
    SCALAR   (   lwht_revertSZ,            0,             1,         FALSE ) ;

    SUBSTRUCTURE( rvp8BatchSetup, batch ) ;
    SCALAR   (   lNonFilteredPPP,          0,             1,         FALSE ) ;

    SCALAR   (       isr_inuse,            0,             1,             0 ) ;
    SCALAR   (    isr_startbin,            0,   RVP8MAXBINS,            10 ) ;
    SCALAR   (       isr_width,            0,   RVP8MAXBINS,            10 ) ;
    SCALAR   (       isr_count,            1,   RVP8MAXBINS,            15 ) ;
    SCALAR   (   isr_datastart,       0x0000,        0xFFFF,            16 ) ;
    SCALAR   (    isr_rangeinc,       0x0001,        0xFFFF,            16 ) ;

    SCALAR   (    lForcePhysTargSim,       0,             1,         FALSE ) ;
    SUBSTRUCTURE_1D( dspPhysTargSim, physTargSims, DSPPHYSTARGSIMCOUNT ) ;

    SCALAR   (   llogvid_inuse,            0,             1,         FALSE ) ;
    SCALAR   ( flogvid_dbmspan,         20.0,         120.0,         100.0 ) ;
    SCALAR   ( flogvid_dacpcnt,         10.0,         100.0,          85.0 ) ;
    SCALAR   (   llogvid_rxsec,            0,             1,         FALSE ) ;

    SCALAR   (       lrtm_enab,            0,             1,         FALSE ) ;    
    STRING   (       srtm_device, "/dev/ttyS0" ) ;
    SCALAR   (       irtm_baud,          300,         38400,          9600 ) ;
    SCALAR   (       frtm_rate,          0.1,          10.0,           1.0 ) ;    
    SCALAR   (       irtm_msgs,   0x00000000,    0xFFFFFFFF,    0x00000000 ) ;    

    SCALAR   (     ibplt_amplz,            1,           128,             1 ) ;
    SCALAR   (     ibplt_tspan,            1,     BMAXTSPAN,             5 ) ;
    SCALAR   (     ibplt_pcode,            0,  BPLCODE_NCODES-1, BPLCODE_SAMPLES ) ;

    SCALAR   (      ibspc_navg,            1,           100,             3 ) ;
    SCALAR   (   ibspc_dbscale,          -30,            50,            10 ) ;
    SCALAR   (     ibspc_pcode,            0,  BSPCODE_NCODES-1, BSPCODE_BOTH ) ;

    SCALAR   (     irplt_amplz,            1,           128,             1 ) ;
    SCALAR   (      irplt_navg,            1,           100,             3 ) ;
    SCALAR   (     frplt_start,          0.0,         500.0,           0.0 ) ;
    SCALAR   (     irplt_tspan,            1,     RMAXTSPAN,             5 ) ;
    SCALAR   (     irplt_pcode,            0,  RPLCODE_NCODES-1, RPLCODE_SAMPLES ) ;

    SCALAR   (     iaplt_dopHz,            0,       100000,              0 ) ;
    SCALAR   (    iaplt_peakDB,          -60,           10,              0 ) ;
    SCALAR   (     iaplt_ptune,            0,  TXWAVETUNES-1,            0 ) ;
    SCALAR   (     iaplt_pcode,            0,  APLCODE_NCODES-1, APLCODE_RANGAMB ) ;

    SCALAR   (lplt_secondary_if,           0,             1,         FALSE ) ;

    SCALAR   ( iFPDDeciDigitsAZ,           0,             2,             1 ) ;
    SCALAR   ( iFPDDeciDigitsEL,           0,             2,             2 ) ;

    SCALAR   (      iDfltAngSrc,      0, RVPANGSRC_NCODES-1,RVPANGSRC_TAGS ) ;

    SCALAR   (  iSynchroFreqHZ,           20,            80,            60 ) ;

    SCALAR   (        tinvert0,       0x0000,        0xFFFF,        0x0000 ) ;
    SCALAR   (        tinvert1,       0x0000,        0xFFFF,        0x0000 ) ;

    SCALAR   (        iOffPre0,       0x0000,        0xFFFF,        0x0000 ) ;
    SCALAR   (        iOffPre1,       0x0000,        0xFFFF,        0x0000 ) ;

    SCALAR   (        fMpyAng0,       -128.0,         128.0,           1.0 ) ;
    SCALAR   (        fMpyAng1,       -128.0,         128.0,           1.0 ) ;

    SCALAR   (        toffang0,       0x0000,        0xFFFF,             0 ) ;
    SCALAR   (        toffang1,       0x0000,        0xFFFF,             0 ) ;

    SCALAR   (   lCoPolOnPriRx,            0,             1,         FALSE ) ;

    SCALAR   (     fkdp_length,          0.0,          15.0,           5.0 ) ;
    SCALAR   (   fphidp_offset,       -180.0,         180.0,          90.0 ) ;

    SCALAR   (       iPolFlags,   0x00000000,    0xFFFFFFFF, POLFLAG_TX_H |
	       POLFLAG_TX_V   | POLFLAG_RX_CO |   POLFLAG_CNOISE | POLFLAG_FILTER ) ;

    SCALAR_1D(    iOrdaTPoints,            0,            15,             0, 2 ) ;

    SCALAR   (        faultpin,            0, FAULTPIN_MAXVAL,           0 ) ;
    SCALAR_1D(          pinmap,            0,            31,             0, 25 ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else
    istatus = iMessageMod_va( CONFIG_LIM_BADSTRUCT, 1, sname_a ) ;

  return( istatus ) ;
}

/* ------------------------------
 * These routines load/save new values to the RVP8 signal processor
 * config file.
 */
MESSAGE rvp8_load_conf
( const char *sRemoteHostname_a, volatile struct rvp8NV *pRvp8NV_a )
{
  memset( (void *)pRvp8NV_a, 0, sizeof(struct rvp8NV) ) ;

  return( lim_loadFile( sRemoteHostname_a, "rvp8.conf", "rvp8NV",
			pRvp8NV_a, dsp_limits ) ) ;
}
MESSAGE rvp8_save_conf
( const char *sRemoteHostname_a, volatile const struct rvp8NV *pRvp8NV_a )
{
  struct rvp8NV Rvp8NV = *pRvp8NV_a ;

  strncpy( Rvp8NV.sVersion, IRIS_VERSION, 8 ) ; Rvp8NV.sVersion[7] = '\0' ;

  return( lim_saveFile( sRemoteHostname_a, "rvp8.conf", "rvp8NV",
			&Rvp8NV, dsp_limits ) ) ;
}

/* ------------------------------
 * These routines load/save new values to the Timeseries API config
 * file.
 */
MESSAGE rvp8ts_load_conf
( const char *sRemoteHostname_a, volatile struct rvp8tsConfig *pConfig_a )
{
  memset( (void *)pConfig_a, 0, sizeof(struct rvp8tsConfig) ) ;

  return( lim_loadFile( sRemoteHostname_a, "rvp8ts.conf", "rvp8tsConfig",
			pConfig_a, dsp_limits ) ) ;
}
MESSAGE rvp8ts_save_conf
( const char *sRemoteHostname_a, volatile const struct rvp8tsConfig *pConfig_a )
{
  struct rvp8tsConfig config = *pConfig_a ;

  strncpy( config.sVersion, IRIS_VERSION, 8 ) ; config.sVersion[7] = '\0' ;

  return( lim_saveFile( sRemoteHostname_a, "rvp8ts.conf", "rvp8tsConfig",
			&config, dsp_limits ) ) ;
}
