/**C*
 *
 * Vaisala software source code file
 *
 * Copyright (c) Vaisala Oyj 1991, 1992, 1994, 1996, 1997, 1999, 2001, 2002,
 * 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012.
 * All rights reserved.
 *
 * $URL: https://subversion.vaisala.com/svn/repos/sigmet/wr_iris_rda/branches/release8.13.5/base/antenna_lib/antenna_lib.h $
 *
 * $Id: antenna_lib.h 27860 2012-02-17 16:09:40Z jho $
 *
 **C*/
/* *********************************************************************
 * *                                                                   *
 * *       Vaisala Antenna and BITE Library Public Definitions         *
 * *                                                                   *
 * *********************************************************************
 */
#ifndef SIGMET_ANTENNA_LIB_H
#define SIGMET_ANTENNA_LIB_H 1

/* This collection of library routines provides a uniform interface to
 * the external radar and antenna.  A variety of serial interfaces and
 * protocols can be used.  All library source files are located in the
 * libs/antenna directory.  The statically linked antenna library
 * itself is libs/lib/libantenna.a.
 */
#ifdef __cplusplus
extern "C" {
#endif

#if 0
}  /* Prevent indentation */
#endif

/* Messages supported within the library.
 */
#define ANT_ANTINTERNERR      (ANT_FACILITY + 1)
#define ANT_BAD_CONTROL       (ANT_FACILITY + 2)
#define ANT_BAD_DEVICE        (ANT_FACILITY + 3)
#define ANT_BAD_LOGFILE       (ANT_FACILITY + 4)
#define ANT_BAD_STATUS        (ANT_FACILITY + 5)
#define ANT_BAD_TIMESPAN      (ANT_FACILITY + 11)
#define ANT_BITE_STATUS_UNIT  (ANT_FACILITY + 12)
#define ANT_BITE_STATUS_SIZE  (ANT_FACILITY + 13)
#define ANT_BITE_STATUS_BUSY  (ANT_FACILITY + 14)
#define ANT_BITE_FILE         (ANT_FACILITY + 15)
#define ANT_CLIENT_CHANGED    (ANT_FACILITY + 21)
#define ANT_CLIENT_INVALID    (ANT_FACILITY + 22)
#define ANT_ERR_NETRCV        (ANT_FACILITY + 23)
#define ANT_ERR_RCV           (ANT_FACILITY + 24)
#define ANT_ERR_XMT           (ANT_FACILITY + 25)
#define ANT_INU_ANGLE_SKIPPED (ANT_FACILITY + 31)
#define ANT_INU_ANGLE_OK      (ANT_FACILITY + 32)
#define ANT_IS_RUNNING        (ANT_FACILITY + 33)
#define ANT_LAUNCH_ERROR      (ANT_FACILITY + 34)
#define ANT_LIB_SHUTDOWN      (ANT_FACILITY + 35)
#define ANT_NO_ANTENNA        (ANT_FACILITY + 36)
#define ANT_NOT_RUNNING       (ANT_FACILITY + 37)
#define ANT_PED_ANGLE_SKIPPED (ANT_FACILITY + 38)
#define ANT_PED_ANGLE_OK      (ANT_FACILITY + 41)
#define ANT_REMOTE_CHATTER    (ANT_FACILITY + 42)
#define ANT_REMOTEPWRUP       (ANT_FACILITY + 43)
#define ANT_REMOTEPROTO       (ANT_FACILITY + 44)
#define ANT_REMOTEREJECT      (ANT_FACILITY + 45)
#define ANT_SETUP_CHANGED     (ANT_FACILITY + 51)
#define ANT_SETUP_FILE        (ANT_FACILITY + 52)
#define ANT_SETUP_SIZE        (ANT_FACILITY + 53)
#define ANT_SETSTRING         (ANT_FACILITY + 54)
#define ANT_SIM_STARTFIRST    (ANT_FACILITY + 55)
#define ANT_TWO_RCV           (ANT_FACILITY + 62)
#define ANT_TWO_SIM_RCV       (ANT_FACILITY + 63)
#define ANT_TWO_SIM_XMT       (ANT_FACILITY + 64)
#define ANT_TWO_XMT           (ANT_FACILITY + 65)
#define ANT_TWO_LOG           (ANT_FACILITY + 71)
#define ANT_TWO_CHATTER       (ANT_FACILITY + 72)
#define ANT_WRONG_CHATTER     (ANT_FACILITY + 73)
#define ANT_XH_INIT_FAILED    (ANT_FACILITY + 74)
#define ANT_XH_INIT_OK        (ANT_FACILITY + 75)

/* ***************************
 * *                         *
 * * ANTENNA_INFO Structures *
 * *    and Definitions      *
 * *                         *
 * ***************************
 */

/* Types of interfaces to the RCP hardware
 */
#define ANTIFACE_SERIAL    (0)
#define ANTIFACE_NONE      (1)
#define ANTIFACE_ANTEXPORT (2)
#define ANTIFACE_NETWORK   (3)

/* Types of serial formats
 */
#define ANTFMT_XMTVOID (0)      /* No antenna available*/
#define ANTFMT_XMT02   (2)      /* Enhanced RCP */
#define ANTFMT_XMT01   (3)      /* Original RCP */
#define ANTFMT_XMT04   (4)      /* (Same as XMT02, preserve for compatability)*/
#define ANTFMT_XMTSA   (5)      /* Scientific Atlanta series 3860 controller */
#define ANTFMT_XMT05   (6)      /* Expanded XMT02 */
#define ANTFMT_XMTLIMITHI (6)

#define ANTFMT_RCVVOID (0)      /* No antenna available*/
#define ANTFMT_RCV03   (1)      /* Shipboard    */
#define ANTFMT_RCV02   (2)      /* Enhanced RCP */
#define ANTFMT_RCV01   (3)      /* Original RCP */
#define ANTFMT_RCV04   (4)      /* (Same as RCV02, preserve for compatability)*/
#define ANTFMT_RCVSA   (5)      /* Scientific Atlanta series 3860 controller */
#define ANTFMT_RCV05   (6)      /* Expanded RCV02 */
#define ANTFMT_RCVLIMITHI (6)

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - */

/* Structure defining the RCP bits
 */
struct rcp_bit_def     /* Definitions for rcp control bit */
{
    uint8_t lenabled;
    uint8_t lhigh;
    uint8_t linitial_high;
    char  pad3x1[1] ;
};
struct rcp_status_def  /* Definitions for rcp status bit */
{
    uint8_t lenabled;
    uint8_t lhigh;
    uint8_t lCritical;     /* Fault is critical */
    char  pad3x1[1] ;
};

/* =======================================================================
 *                        Antenna Configuration
 * =======================================================================
 * This holds configuration information about the antenna(s).  This does
 * not include geometric information that is used for calibration, such as
 * beam width.  
 */
enum ant_scan_geometry {
    ANTGEOM_TRADITIONAL = 0,
    ANTGEOM_AIR_TAIL   = 1
};

struct ant_manual_setup
{
    char sVersion[8] ;          /* IRIS version when saved */

    uint8_t lAntAvailable;      /* Flag indicates that system has an antenna */
    uint8_t iInterfaceType;     /* Interface type (ANTIFACE_* ) */
    uint8_t lControllingHost;   /* This is a controlling host */

    uint8_t lLogToFile ;        /* Antenna driver makes log files */
    uint8_t lLogPacketsAnt ;    /*   Log incoming antenna packets */
    uint8_t lLogPacketsBITE ;   /*   Log incoming BITE packets */
    uint8_t lLogPacketsTime ;   /*   Log incoming TIME packets */
    uint8_t lLogPacketsErr ;    /*   Log incoming unrecognized packets */
    uint8_t lLogDataAnt ;       /*   Log AZ/EL data insertions */
    uint8_t lLogDataINU ;       /*   Log INU data insertions */
    char pad18x6[6] ;

    /* Storage for AntExport info only
     */
    uint32_t iAntExportPortNum;    /* Socket port number on remote machine */
    char  sAntExportHost[40] ;     /*   IP address / Node name */


    uint8_t bExtendedCntPackets;   /* Allow extended control packets */

    /* Antenna is located on a moving platform.  This means that we will
     * enable the INU config questions, and enable the platform motion
     * velocity correction button in the data, and force on the platform
     * motion  velocity correction in the rtdisp. */
    uint8_t bMovingPlatform;

/* Antenna scanning geometry */
#define ANTGEOM_TRADITIONAL  (0)
#define ANTGEOM_AIR_TAIL     (1)
    enum ant_scan_geometry iScanGeometry;

    /* This antenna can scan continuously in elevation.  So no limits
     * are applicable.
     */
    uint8_t bElevationFull;
    /* The mimimum and maximum elevation angles allowed, in binary angles
     */ 
    int16_t ielmin;  /* Signed number to make setup_limits work */
    BIN2  ielmax;  /* Unsigned number to make setup_limits work */

    /*The maximum velocity in azimuth and elevation, degrees/second
     */
    float fazvelmax, felvelmax;

    /* The latitude and longitude of the antenna itself, as 32-bit binary
     * angle.
     */
    uint32_t ilat, ilon;

    /* Height of ground relative to sea level in meters and height of
     * antenna platform above the ground in meters.
     */
    int16_t ignd_hgt;
    int16_t irad_hgt;

    /* Format of antenna control interface, see antenna_lib.h for options
     */
    uint16_t icontrol_format;

    /* Format of antenna status interface, see antenna_lib.h for options
     */
    uint16_t istatus_format;

    /* How long to continue to toggle the Radiate if it does not work,
     * in seconds.
     */
    uint32_t itoggle_time;

    /* How long the radiate is off when we toggle.
     */
    float fRadiateTogglePeriod;

    /* Offset between the INU reported altitude, and its actual altitude
     * in cm.  This is used for systems which do not report altitude.
     */
    int32_t inu_height_offset;

    /* Distance in cm between the INU location and the antenna.  This is
     * only used for moving platforms, and the three directions are
     * forward, to port, and up.
     */
    int32_t iplatform_offset[3];

    /* Time radar requires noise source on
     */
    float fnoise_toggle_time;

    /* The maximum value available from the signal generator in dBm.
     * This value corresponds to a zero in the data format.
     */
    int32_t isiggen_max;

    /* The minimum value available from the signal generator in dBm
     */
    int32_t isiggen_min;

    /* Time required to warm up the signal generator after it is turned
     * on.
     */
    float fsiggen_warmup;

    /* Time required after signal generator value is changed before
     * level OK
     */
    float fsiggen_settle;

    uint32_t iazmode_initial;       /* Initial azimuth mode */
    uint32_t ielmode_initial;       /* Initial elevation mode */

    uint16_t iazpos_initial;        /* Initial azimuth position */
    uint16_t ielpos_initial;        /* Initial elevation position */

    float fazv_initial;             /* Initial azimuth velocity */
    float felv_initial;             /* Initial elevation velocity */

    int32_t isiggen_value_initial;  /* Initial signal generator value */

    /* Sub Process Priorities
     */
    int16_t ipri_antrcv, ipri_antxmt ;

    /* Second process formats
     */
    uint16_t icontrol2_format;
    uint16_t istatus2_format;

    /* Device names and TTY parameters for the two channels.
     */
    char schannel1[PATHNAME_SIZE]; /* Serial device, or network IP address */
    char schannel2[PATHNAME_SIZE];
    char sNetInterface1[16];       /* Network interface used for channel 1 */
    int32_t iBaudRate1, iBaudRate2 ; /* Numerical baud rate or port number */
    uint8_t iParity1  , iParity2   ; /* One of TTYPARITY_xxx */
    uint16_t iNetDelayMs;            /* Average network delay in ms */

    uint8_t lStartSimulator;       /*Automatically start simulator at init time */

    uint8_t lUseTimeStamp ;        /* Use time stamps on received data */

    uint8_t iAngleSource ;         /* Where antenna angles come from */
#define ANTANGSRC_NORMAL    0        /*   Standard ANT_RCV interface */
#define ANTANGSRC_RCP       1        /*   Embedded RCP */
#define ANTANGSRC_RVP       2        /*   Embedded RVP */

    uint8_t iInuSource ;           /* Where INU angles come from */
#define ANTINUSRC_NORMAL      0      /*   Standard INU RCP8 interface */
#define ANTINUSRC_EXT_HEADER  1      /*   Extended header */

/* -------------------------------------------------- */

    /* Servo power control
     */
    struct rcp_bit_def cont_servo_power;

    /* T/R power control
     */
    struct rcp_bit_def cont_tr_power;

    /* Radiate control
     */
    struct rcp_bit_def cont_radiate;

    /* Reset antenna controller
     */
    struct rcp_bit_def cont_reset;

    /* Control the noise source
     */
    struct rcp_bit_def cont_noise;

    /* Control the signal generator
     */
    struct rcp_bit_def cont_siggen;

    /* Control whether the signal generator is in pulse or CW mode
     */
    struct rcp_bit_def cont_sigcw;
 
    /* Control the pulse width, only valid field used
     */
    struct rcp_bit_def cont_pwbw;
 
    /* Control the pulse width unchanged bit
     */
    struct rcp_bit_def cont_pw_unset;
 
    /* Control the polarization, only valid field used
     */
    struct rcp_bit_def cont_polar;
 
    /* Report the network status to the RCP
     */
    struct rcp_bit_def cont_nst;

    /* -------------------------------------------------- */

    /* Low airflow sensor
     */
    struct rcp_status_def status_low_airflow;

    /* Low waveguide pressure sensor
     */
    struct rcp_status_def status_low_wgp;

    /* Interlock open sensor
     */
    struct rcp_status_def status_interlock_open;

    /* Standby mode sensor
     */
    struct rcp_status_def status_standby;

    /* Radiate sensor
     */
    struct rcp_status_def status_radiate;

    /* Bad magnitron current sensor
     */
    struct rcp_status_def status_mag_current;

    /* RCP is in local mode
     */
    struct rcp_status_def status_local;

    /* T/R is in local mode
     */
    struct rcp_status_def status_trlocal;

    /* Antenna controller shutdown detection
     */
    struct rcp_status_def status_shutdown;

    /* T/R Power sensor
     */
    struct rcp_status_def status_tr_power;

    /* Servo Power sensor
     */
    struct rcp_status_def status_servo_power;

    /* Signal generator ON sensor
     */
    struct rcp_status_def status_siggen;

    /* Signal generator CW mode sensor
     */
    struct rcp_status_def status_sigcw;

    /* Pulse width can be sensed, only valid field used
     */
    struct rcp_status_def status_pwbw;

    /* Polarization can be sensed, only valid field used
     */
    struct rcp_status_def status_polar;

    /* Signal generator fault
     */
    struct rcp_status_def status_sigfault;

    /* Azimuth encoder calibrated
     */
    struct rcp_status_def status_calib_az;

    /* Elevation encoder calibrated
     */
    struct rcp_status_def status_calib_el;

    /* -------------------------------------------------- */

    /* RST names for the 8 possible modes.  Note that mode zero is
     * reported for unrecognized names, so it is not used at this point.
     * Similarly, incomming mode zero means turn on auto switching, and
     * do not control mode.
     */
    char sreport_mode[8][16];

    /* Site codes for the 4 possible sites to be reported to the RCP.
     */
    char sreport_sites[4][4];

    /* Delay in seconds applied before and after the mode is reported to
     * the RCP
     */
    float freport_mode_delay;

    /* This is the mode to request (temporarilly) when the RCP goes
     * dead.
     */
    uint16_t iDeadModeReq ;

    /* Time packets are in UTC, otherwise in the local time on the
     * computer
     */
    uint8_t lTimePacketUtc;
    char ipad795x1[1];

    /* Custom header name, blank string for none */
    char  sCustomRayHeader[16];

};

#define ANTRCV_MAX_LENGTH (60)  /* Sizes of the largest receive and transmit */
#define ANTXMT_MAX_LENGTH (80)  /*  serial packets from/to an external RCP. */

/* Control flag definitions
 */
#define ACF_SERVO      (0x00010000) /* Turn on servo power */
#define ACF_RADIATE    (0x00020000) /* Turn on transmitter */
#define ACF_TRPOWER    (0x00040000) /* Turn on power to Tx/Rx rack */
#define ACF_IRIS       (0x00080000) /* IRIS Control mode */
#define ACF_RESET      (0x00100000) /* Reset pulse */
#define ACF_AUTO_RAD   (0x00200000) /* IRIS Will automatically control radiate */
#define ACF_NOISE      (0x00400000) /* Turn on noise source */
#define ACF_SIGGEN     (0x00800000) /* Turn on signal generator */
#define ACF_SIGCW      (0x01000000) /* Signal generator set to CW */
#define ACF_PWBW       (0x02000000) /* Pulse width controlled from antenna */
#define ACF_NST        (0x04000000) /* NST reports sent to RCP */
#define ACF_POLAR      (0x08000000) /* Polarization control available */
#define ACF_ANTENNA    (0x10000000) /* Antenna control available */
#define ACF_PW_UNSET   (0x20000000) /* Pulse width unchanged control available */

/* Status flag definitions
 */
#define ASF_LOCAL      (0x00000001) /* Antenna Local Mode */
#define ASF_TRLOCAL    (0x00000002) /* T/R Local Mode */
#define ASF_LOWAIRFLOW (0x00000004) /* Low Air Flow */
#define ASF_LOW_WGP    (0x00000008) /* Low waveguide pressure */
#define ASF_INTERLOCK  (0x00000010) /* Interlock open */
#define ASF_STANDBY    (0x00000020) /* Radar is in Standby mode */
#define ASF_MAGTFLT    (0x00000040) /* Magnatron/Klystron fault */
#define ASF_SHUTDOWN   (0x00000080) /* Controller has shutdown */
#define ASF_SIGFAULT   (0x00000100) /* Signal generator fault */
#define ASF_CALIB_AZ   (0x00000200) /* Azimuth encoder calibrated */
#define ASF_CALIB_EL   (0x00000400) /* Elevation encoder calibrated */
#define ASF_MOVING_PLT (0x00000800) /* Antenna is on a moving platform */
#define ASF_AIR_TAIL   (0x00001000) /* Antenna is an aircraft tail system */

#define ASF_SERVO      (0x00010000) /* Servo is ON */
#define ASF_RADIATE    (0x00020000) /* Transmitter is ON */
#define ASF_TRPOWER    (0x00040000) /* TX/RX Power is ON */
#define ASF_SIGGEN     (0x00800000) /* Signal generator is ON */
#define ASF_SIGCW      (0x01000000) /* Signal generator is set to CW */
#define ASF_PWBW       (0x02000000) /* Pulse width/band width sense available */
#define ASF_POLAR      (0x08000000) /* Polarization sense available */

/* Mask containing all the status bits which can be faulted
 */
#define ASFLAGS_FAULTABLE                                               \
    (ASF_LOWAIRFLOW | ASF_LOW_WGP | ASF_INTERLOCK | ASF_MAGTFLT | ASF_SHUTDOWN)

/* ------------------------------
 * Dual RCP System Structures.  Use 4-byte entities here to increase
 * portability in the IRIS Server.
 */
struct drcp_unitinfo {          /* Information about each unit */
    uint32_t lKnown ;           /* Information is known about this unit */
    uint32_t lDisabled ;        /* This unit is disabled by a KILL switch */
    uint32_t lOkay ;            /* This unit passes all internal checks */
    uint32_t lRelinquish ;      /* This unit is offering to relinquish control*/
    uint32_t lWouldUse ;        /* This unit would be used if available */
    uint32_t iActivity ;        /* Activity code for this unit */
} ;

#define DRCP_ACT_INACTIVE 0       /* Activity codes */
#define DRCP_ACT_WARMUP   1
#define DRCP_ACT_ACTIVE   2

struct drcp_status {            /* Status returned by each RCP */
    uint32_t lSetupDual ;       /* This unit is setup as a dual system */
    uint32_t lRunningDual ;     /* This unit is actually running as a dual system */
    uint32_t lUnitA ;           /* This unit is the "A" unit */
    uint32_t lFlipAllowed ;     /* This unit allows voluntary flipping of control */
    uint32_t lPreferredA ;      /* Unit "A" is the preferred unit */
    uint32_t iDrcpMode ;        /* Mutually agreed mode of the dual system */

    struct drcp_unitinfo sysA;  /* Information about the "A" system */
    struct drcp_unitinfo sysB;  /* Information about the "B" system */
} ;

#define DRCP_MODE_VOID    0      /* In a dual system, the host computer will */
#define DRCP_MODE_A       1      /*   select one of these modes to either    */
#define DRCP_MODE_B       2      /*   force the A or B channel active, or to */
#define DRCP_MODE_AUTO    3      /*   allow them to swap on failures.        */

/* ------------------------------
 * Realtime history structure for the basic pedestal info.
 */
#define ANTPEDX_SLOTS   200      /* Number of realtime slots \ Minimum 4-sec */
#define ANTPEDX_WIDTH    20      /* Minimum slot width in ms /   of history */
#define ANTPEDX_TERMS     6      /* Number of terms in struct rtpedx */
struct rtpedx {                  /* Position vector contents */
    double faz, fel ;            /* Angles in degrees (Earth relative) */
    double fazv, felv ;          /* Velocities in degrees/second (Earth relative)*/
    double fPedAz ;              /* Azimuth of the radar pedestal */
    double fPedEl ;              /* Elevation of radar pedestal */
} ;
#define ANTPEDX_MODS             /* Data modulos for each term */        \
    RTVEC_MOD_UBIN, RTVEC_MOD_EBIN, RTVEC_MOD_NONE, RTVEC_MOD_NONE,     \
        RTVEC_MOD_UBIN, RTVEC_MOD_EBIN, /* pedestal Azimuth and elevation */ 
  
/* Realtime history structure for the shipboard info.
 */
#define ANTSHIP_SLOTS   200      /* Number of realtime slots \ Minimum 4-sec */
#define ANTSHIP_WIDTH    20      /* Minimum slot width in ms /   of history */
#define ANTSHIP_TERMS    12      /* Number of terms in struct rtship */
struct rtship {                  /* Position vector contents */
    double fpitch  , fpitchv ;   /* Pitch angle and rate, degrees and deg/sec */
    double froll   , frollv ;    /*   Roll angle and rate */
    double fheading, fheadingv;  /*   Heading angle and rate */

    double flatitude ;           /*   Position of the platform */
    double flongitude ;          /*   Degrees */
    double faltitude ;           /*   Altitude in meters */

    double fvel_east ;           /*   Motion of the platform, m/s */
    double fvel_north ;
    double fvel_up ;
} ;
#define ANTSHIP_MODS                /* Data modulos for each term */        \
    RTVEC_MOD_SBIN, RTVEC_MOD_NONE, /* Pitch angle and rate */          \
        RTVEC_MOD_SBIN, RTVEC_MOD_NONE, /* Roll angle and rate */       \
        RTVEC_MOD_UBIN, RTVEC_MOD_NONE, /* Heading angle and rate */    \
        RTVEC_MOD_SBIN, RTVEC_MOD_SBIN, /* Lat, Lon */                  \
        RTVEC_MOD_NONE, RTVEC_MOD_NONE, /* Altitude, East vel */        \
        RTVEC_MOD_NONE, RTVEC_MOD_NONE  /* North vel, Up vel */

/* Structure holding information about what network RCP8 hosts we have
 * detected out there.
 */
struct ant_nethost_info
{
    uint32_t iAddress;   /* IP V4 address in network byte order */
    uint32_t iBTime;     /* Binary time we last received data from it */
};
/* ***********************************
 * *                                 *
 * * BITE Structures and Definitions *
 * *                                 *
 * ***********************************
 */
#define BITE_MAX_UNITS       16 /* Max number of BITE units */
#define BITE_MAX_LENGTH     128 /* Max length of a BITE packet */
#define BITE_NUM_FIELD_DEFS 256 /* Number of field definitions in library */
                                /*   (must be a multiple of 32) */
#define BITE_MASK_SIZE (BITE_NUM_FIELD_DEFS/32)

#define BITE_BIT_MINVAL   1
#define BITE_BIT_LOW       1    /* Constants used to represent bits   */
#define BITE_BIT_HIGH      2    /*  that are LOW, HIGH, or DONT-CARE. */
#define BITE_BIT_NONE      3
#define BITE_BIT_MAXVAL   3

#define BITE_COLOR_MINVAL 0
#define BITE_COLOR_NONE    0    /* Constants representing optional colors   */
#define BITE_COLOR_RED     1    /*  that might be used for buttons or field */
#define BITE_COLOR_YELLOW  2    /*  name backgrounds. */
#define BITE_COLOR_GREEN   3
#define BITE_COLOR_MAXVAL 3

#define BITE_SF_CRITICAL (0x01) /* Fault is critical */

/* ------------------------------
 * Status information structure
 */
struct bitex_status_info
{
    char low_text[10] ;         /* Text to represent LOW state */
    char high_text[10] ;        /* Text to represent HIGH state */

    uint8_t flag_state ;        /* Fault generation, set to BITE_BIT_XXX */
    uint8_t iFlags ;            /* Flag bits, see BITE_SF* parameters */
    uint16_t disable_field ;    /* Disabling field, Origin 0, (BITEX displays org 1) */
    uint8_t disable_state ;     /* Disable fault condition, set to BITE_BIT_XXX */
    char  pad_end[3] ;
} ;

/* ------------------------------
 * Q-BITE Status information structure
 */
struct qbite_status_info
{
    char sUnitsText[8] ;        /* Text to represent HIGH state */

    float  fCalSlope ;
    float  fCalOffset ;

    float  fFaultThreshold ;
    float  fCriticalThreshold ;
    uint8_t iFormatLeft ;       /* Characters to the left of . */
    uint8_t iFormatRight ;      /* Characters to the right of . */
    uint8_t lSigned ;           /* Value is signed */
#define QBITE_FAULT    (0x01)     /*   Fault enabled */
#define QBITE_CRITICAL (0x02)     /*   Critical enabled */
#define QBITE_LESSTHAN (0x04)     /*   Fault if less than threshold */
    uint8_t iFaultMask ;
    uint16_t disable_field ;    /* Disabling field, Origin 0, (BITEX displays org 1) */
    uint8_t disable_state ;     /* Disable fault condition, set to BITE_BIT_XXX */
    char  pad_end[1] ;
} ;

/* ------------------------------
 * Control information structure
 */
struct bitex_control_info
{
    char out_text[10] ;         /* Button text when OUT */
    char in_text[10] ;          /* Button text when IN */

    uint8_t lbutton_in_high ;   /* Button pressed --> HIGH control bit */

    uint8_t button_flags ;      /* How the button works */
#define BITE_BUTTON_PULSE  0x01    /*   Momentary pushbutton, else toggle */
#define BITE_BUTTON_DFLTIN 0x02    /*   Default state is IN (else OUT) */

    /* The following three variables allow the color of the field
     * name to be controlled by some other field.
     */
    uint16_t fcolor_fieldnum ;  /* Field doing the control */
    uint8_t fcolor_state ;      /* One of BITE_BIT_XXX */
    uint8_t fcolor_color ;      /* One of BITE_COLOR_XXX */

    /* The following two variables set the color of the control
     * pushbutton itself.
     */
    uint8_t button_in_color ;   /* One of BITE_COLOR_XXX */
    uint8_t button_out_color ;

    uint8_t liris_flag ;        /* Flag IRIS when button is activated */
    char  pad_end[3] ;
} ;

/* ------------------------------
 * Individual field definition structure
 */
union bitex_cs_union            /* Shared storage for control or status BITEs */
{
    struct bitex_status_info  sts ;
    struct bitex_control_info cnt ;
    struct qbite_status_info  Q_Sts ;
} ;

struct bitex_field_def
{
    uint8_t __lcontrol_unit ;   /* Used only by bitex_limits() */
    uint8_t __lQBite ;          /* Used only by bitex_limits() */
    uint8_t ldisabled ;         /* Field is disabled */

    uint8_t iunit ;             /* BITE Unit number, origin 0, (BITEX displays org 1) */
    uint8_t ibyte ;             /* Byte in packet, origin 0, (BITEX displays org 1) */
    uint8_t ibit ;              /* Bit in byte, origin 0, (#bytes for Q-bite) */

    char name_text[20] ;        /* Name of this field */

    char pad26x2[2] ;
    union bitex_cs_union cs ;
} ;

/* ------------------------------
 * Definition of each byte unit
 */
struct bitex_unit_info
{
    uint8_t lcontrol_unit ;     /* Control BITE unit (else status unit) */
    uint8_t iunit_length ;      /* Number of bytes in each BITE packet */
    uint8_t iunit_id ;          /* BITE ID character in packet */
    uint8_t lQBite ;            /*   Unit is Q-bite */
    char  sName[20] ;           /*   Nice name to use for this BITE unit */
} ;

/* ------------------------------
 * Top level definition structure
 */
struct bitex_setup
{
    char sVersion[8] ;          /* IRIS version when saved */

    uint16_t ifield_cnt ;       /* Number of fields (max BITE_NUM_FIELD_DEFS) */
    uint8_t iunit_cnt ;         /* Number of units, (max BITE_MAX_UNITS) */
    uint8_t lDisplayIO ;        /* Display the I/O summary on the main screen */
    struct bitex_unit_info  units[BITE_MAX_UNITS] ;
    struct bitex_field_def fields[BITE_NUM_FIELD_DEFS] ;
} ;

/* ------------------------------
 * Summary structure of present state of a field.  This is all of
 * the temporal information that BITEX needs to know so that, in
 * conjunction with the BITEX_FIELD_DEF structure, the field can
 * be fully displayed on the top maintenance panel. Some of the
 * structure elements are redundant if the BITEX_FIELD_DEF
 * structure is already known, but it is handy to have them
 * called out here as well.
 */
#define BITE_LABEL_TEXT_SIZE (19)
struct bite_field_state
{
    float  fQBiteValue ;        /* Value of Q-bite number */
    uint8_t ldata ;             /* Bit value */
    uint8_t lCriticalFault ;    /* Critical fault is detected */
    uint8_t lfault ;            /* Non-disabled fault is detected */
    uint8_t button_color ;      /* Color of button (one of BITE_COLOR_XXX) */
    uint8_t lQBite ;            /* Field is Q-bite */
    uint8_t lcontrol ;          /* Control field (else status) */
    uint8_t lbutton_in ;        /* Control button is pressed IN */
    uint8_t liris_flag ;        /* IRIS flag request */
    uint8_t label_color ;       /* Label color (one of BITE_COLOR_XXX) */
    char  label_text[BITE_LABEL_TEXT_SIZE] ;    /* Label text */
} ;

/* ------------------------------
 * Dialog and Window state for BITEX2
 */
#define BITEX_MAX_PANEL_DIAGS 50

struct bitexWgt_StatContDef {
    uint32_t iPanelNum ;
    uint32_t iX ;
    uint32_t iY ;
} ;

#define BITEX_PANEL_TITLE_SIZE (32)
struct bitexWgt_Panel {
    uint16_t lAlloced ;
    uint16_t iPanelNum ;
    uint32_t iX ;
    uint32_t iY ;
    uint32_t iNewPanelNum ;
    uint32_t iNewPanelX ;
    uint32_t iNewPanelY ;
    uint32_t iNewPanelWidth ;
    uint32_t iNewPanelHeight ;
    char  sNewPanelTitle[BITEX_PANEL_TITLE_SIZE] ;
    char  sNewPanelGIFFile[20] ;
} ;

struct bitexWgt_setup {
    char sVersion[8] ;          /* IRIS version when saved */
    struct bitexWgt_StatContDef statCont[BITE_NUM_FIELD_DEFS] ;
    struct bitexWgt_Panel       panels  [BITEX_MAX_PANEL_DIAGS] ;
} ;

/* ------------------------------
 * Identification byte for special BITE packets
 */
#define BITE_INTERROGATE   (0x4d)
#define BITE_SET_VALUES    (0x46)
#define BITE_SIGGEN_OFF    (0x45) /* (Obsolete 8/2002) */
#define BITE_TAKE_SAMPLE   (0x44)
#define BITE_RESET         (0x43)

/* ------------------------------
 * Key names for the BITE field name.  Used to form a generic
 * interface to extract bits having a certain meaning regardless
 * of where they fall within the packets.
 */
/* |----19 char max ---| */
#define BITE_KEY_HPOSREDUCED       "Reduced Hor Pos/Vel"
#define BITE_KEY_HPOSINVALID       "Invalid Hor Pos/Vel"
#define BITE_KEY_VPOSREDUCED       "Reduced Vrt Pos/Vel"
#define BITE_KEY_VPOSINVALID       "Invalid Vrt Pos/Vel"
#define BITE_KEY_ROLLREDUCED       "Reduced Roll/Pitch"
#define BITE_KEY_ROLLINVALID       "Invalid Roll/Pitch"
#define BITE_KEY_HEADREDUCED       "Reduced Heading"
#define BITE_KEY_HEADINVALID       "Invalid Heading"
#define BITE_KEY_INUNODATA         "No INU/MRU Data"

#define BITE_KEY_FULL_LIST {                                            \
        BITE_KEY_HPOSREDUCED, BITE_KEY_HPOSINVALID, BITE_KEY_VPOSREDUCED, \
            BITE_KEY_VPOSINVALID, BITE_KEY_ROLLREDUCED, BITE_KEY_ROLLINVALID, \
            BITE_KEY_HEADREDUCED, BITE_KEY_HEADINVALID, BITE_KEY_INUNODATA \
            }

/* ********************************************
 * *                                          *
 * * Function Prototypes for Library Routines *
 * *                                          *
 * ********************************************
 */

/* ---------------------------------------------------------------
 * ----------------- Open/Close/Powerup Routines -----------------
 * ---------------------------------------------------------------
 */
/* AntPowerUpMain() initializes internal shared memory for subsequent
 * calls to the library.  Any additional processes needed to
 * run the antenna are also created by this function.  The additional
 * process names are, for example, ANT_XMTD and ANT_RCVD.
 */
enum ant_powerup_options {
    ANT_OPTIONS_NONE = 0,
    ANT_OPTIONS_AUTO = 0x0001  /* Automatic startup */
};


enum ant_client_type {
    ANT_IAM_CLIENT    = 0,   /* Normal client */
    ANT_IAM_ANT_XMT0  = 1,   /* Serial XMT process */
    ANT_IAM_ANT_RCV0  = 2,   /* Serial RCV process */
    ANT_IAM_ANT_XMT1  = 3,   /* Serial XMT process */
    ANT_IAM_ANT_RCV1  = 4,   /* Serial RCV process */
    ANT_IAM_SIM_XMT   = 5,   /* Antenna simulator XMT */
    ANT_IAM_SIM_RCV   = 6,   /* Antenna simulator RCV */
    ANT_IAM_RCP       = 7,   /* The external RCP */
    ANT_IAM_RVP       = 8,   /* The external RVP */
    ANT_IAM_STOPPER   = 9,   /* The stop_antennad program */
    ANT_IAM_EXPORT   = 10,   /* The AntExport program */
    ANT_IAM_CHATTER  = 11,   /* Client wanting to chat, not available via AntExport */
    ANT_IAM_LOGGER   = 12,   /* Antenna logging process */
    ANT_IAM_STARTER  = 13    /* The start_antennad program */
};

MESSAGE AntPowerUpMain( enum ant_client_type iClientType);

/* Called by the start_antennad program only */
MESSAGE AntPowerUpFirst(enum ant_powerup_options iOptions_a);

/* UnMap the shared memory, and disconnect this process from the
 * antenna library.  Use this when you no longer need the antenna
 * library.  For multi-threaded programs, call this after all threads
 * are closed, for example in the exit handler.
 */
MESSAGE ant_close( void ) ;

/* Get the process IDs for the Main/Aux serial receive and serial
 * transmit processes.  A returned ID of zero means that the process
 * has exited (or was never started).
 */
void ant_get_pids( uint32_t ircv_pids_a[2], uint32_t ixmt_pids_a[2],
                   uint32_t *iLogPID_a ) ;

/* Return flag indicating that the antlib is shutting down.
 * This will allow application programs to exit, if they want.
 */
uint8_t lAntLibShutDown(void);

/* Return flag indicating that we are the controlling host.
 */
uint8_t lAntControllingHost(void);

/* Returns a pointer to the antenna setup structure.  Use with
 * Care.
 */
#ifdef SIGMET_SETUP_H
const struct ant_manual_setup *AntGetSetupPointer( void );
#endif  /* #ifdef SIGMET_SETUP_H */

const char *sAntClientType( int32_t iClientType_a ) ;

/* -------------------------------------------------------------
 * -------------------- Serial I/O Activity --------------------
 * -------------------------------------------------------------
 */
/* These routines return the input and output serial byte activity
 * counts for channels #1 (main) and #2 (aux) of the antenna library.
 */
void ant_get_activity
( int32_t* incnt_a,             /* Number of characters received */
  int32_t* ioutcnt_a,           /* Number of characters sent */
  int32_t* inerr_a,             /* Number of bad characters received */
  int32_t* iouterr_a ) ;        /* Number of bad characters sent */

void  ant_get_activity2
( int32_t* incnt_a, int32_t* ioutcnt_a, int32_t* inerr_a, int32_t* iouterr_a ) ;

void  AntGetNetActivity
( struct ant_nethost_info *pNetHost_a,  /* Table to hold net host info */
  int32_t iSize_a ) ;                   /* Size of the supplied table */

/* Returns the number of milliseconds since the last valid antenna
 * information was received by the library.  If several streams
 * of data are expected, returns the maximum.
 */
uint32_t iAntAgeSummary( void ) ;

/* Gets the ages in milliseconds since the last valid antenna
 * packet, angle report, and shipboard INU report.
 * Returns a mask of which ages are applicable to this system.
 */
#define ANT_EXPECT_PKT    (0x01)   /* Antenna status packet */
#define ANT_EXPECT_ANG    (0x02)   /* Antenna angle info*/
#define ANT_EXPECT_INU    (0x04)   /* INU info */
#define ANT_TIMEOUT_MS    (5000)   /* Timeout value for antenna info */
uint8_t AntGetAges
( uint32_t *pAgePkt_a,
  uint32_t *pAgeAng_a,
  uint32_t *pAgeInu_a );

/* BITE_GET_AGE() returns the number of milliseconds since a valid BITE
 * packet was received for each of the BITE units.  The unit count is
 * limited to BITE_MAX_UNITS.  BITE_GET_ACTIVITY() returns the actual
 * character counts for serial input and output from each BITE unit.
 * It returns the number of configured BITE units.
 */
void bite_get_age( int32_t age_a[], int32_t bite_count_a ) ;

int32_t bite_get_activity
( int32_t in_count_a[], int32_t out_count_a[], int32_t bite_count_a ) ;

/* Get the I/O diagnostic buffer containing the last received packet
 * that started with a 0x80.
 *   Entry parameters:
 *     ibuf_size_a - The size of the buffer in bytes
 *   Exit parameters:
 *     sbuffer_a    - Buffer with stuff in it
 *     ifill_size_a - Number of characters placed in the buffer
 */
void  ant_get_diagnostic
( uint8_t* sbuffer_a, int32_t ibuf_size_a, int32_t* ifill_size_a ) ;

/* Get the I/O diagnostic buffer containing the largest received error
 * packet starting with a character other than the known characters
 * 0x80, 0xAF, 0xB0, or 0xC0.
 */
void  ant_get_odiagnostic
( uint8_t* sbuffer_a, int32_t ibuf_size_a, int32_t* ifill_size_a ) ;

/* Get the diagnostic buffer containing the last received packet that
 * started with a 0xC0.
 */
void  bite_get_diagnostic
( uint8_t* sbuffer_a, int32_t ibuf_size_a, int32_t* ifill_size_a ) ;

/* -----------------------------------------------------------------
 * ----------------- Get AZ/EL Position & Velocity -----------------
 * -----------------------------------------------------------------
 */
/* Get AZ and EL positions and velocities, either for the current
 * time, or for the indicated BTIME in miliseconds.  The RTVEC
 * modeling package is used to extrapolate the current values based on
 * the antenna's recent history.
 */
void  ant_get_azel_pos( volatile BIN2* iaz_a , volatile BIN2* iel_a  ) ;
void  ant_get_azel_vel( volatile float* fazv_a, volatile float* felv_a ) ;

void  ant_get_azel_pos_btime
( volatile BIN2* iaz_a , volatile BIN2* iel_a , uint32_t iBtime_a ) ;

void  ant_get_azel_vel_btime
( volatile float* fazv_a, volatile float* felv_a, uint32_t iBtime_a ) ;

/* Get AZ and EL position error, i.e., the difference between the
 * actual and desired antenna positions.  If a position servo is not
 * being implemented then the position error is zero.
 */
void  ant_get_azel_err( volatile BIN2* iazerr_a, volatile BIN2* ielerr_a ) ;

/* This is the fundamental routine to extract the antenna parameters
 * for a given binary time.  It is called internally by all of the
 * other "get" routines.  Returns the age of the last antenna 
 * position packet in ms.
 */
uint32_t ant_get_rtpedx( struct rtpedx *rtpedx_a, uint32_t iBtime_a ) ;

#define ANT_MAXEXTRAPMS  1000   /* Max extrapolate time (ms) */

/* -----------------------------------------------------------------
 * ----------------- Set AZ/EL Position & Velocity -----------------
 * -----------------------------------------------------------------
 */
/* Sets up a position servo to move the antenna to the desired AZ/EL
 * position.  Argument is a 16-bit binary angle.
 */
void  ant_set_az_pos( BIN2 iangle_a ) ;
void  ant_set_el_pos( BIN2 iangle_a ) ;

/* Sets up a velocity servo to move the antenna at a specified speed
 * in AZ/EL.  Velocity argument is signed, with positive indicating
 * clockwise/upward movement.  Units are degrees/second.
 */
void  ant_set_az_vel( float fspeed_a ) ;
void  ant_set_el_vel( float fspeed_a ) ;

/* Returns the Min/Max AZ/EL velocities in degrees/second, and the
 * Min/Max EL positions in signed degrees.  pb360 is set to TRUE if
 * the antenna can scan a full 360 degrees in elevation, in which
 * case the fpos_limits[] should be ignored.
 */
void  ant_get_az_limits( float fvel_limits_a[2] ) ;
void  ant_get_el_limits( float fvel_limits_a[2], float fpos_limits_a[2], uint8_t *pb360_a ) ;

/* Returns the current AZ/EL axis control requests for the antenna.
 * The returned MODE will be one of ANTMODE_xxx.  The desired angle
 * will be filled in for ANTMODE_POS, and the desired velocity will be
 * returned for ANTMODE_VEL.
 */
void  ant_get_az_cmd
( volatile uint16_t* imode_a, volatile BIN2* idaz_a, volatile float* fdazv_a ) ;

void  ant_get_el_cmd
( volatile uint16_t* imode_a, volatile BIN2* idel_a, volatile float* fdelv_a ) ;

/* Servo modes for each axis
 */
#define ANTMODE_STOP    (0)     /* Stopped (tolerates user interventions) */
#define ANTMODE_VEL     (1)     /* Velocity Servo */
#define ANTMODE_POS     (2)     /* Position Servo */

/* Places the AZ/EL axis into "stop mode".  Stop mode stops the
 * antenna gracefully and without long term drift; yet still allows
 * the antenna to be moved in local mode.
 */
void  ant_stop_az( void ) ;
void  ant_stop_el( void ) ;

/* ------------------------------------------------------------
 * ------------------- Logging and History --------------------
 * ------------------------------------------------------------
 */
#define ANTLOGCOL_MAX    180    /* Maximum length of log line entries */

#define ANTLOGMAXFILES    40    /* Maximum number of kept log files */

/* Write a text string to the common log file.  Prefix the current
 * time and other information to help identify who made this entry.
 * This routine may be called from client applications outside the
 * antenna driver to insert log messages where needed/desired.
 */
void antWriteLog( const char *sLogText_a ) ;

/* Routine to log an array of bytes in human readable format.  This
 * is typically used to make a record of I/O packets.
 */
void antWriteLogBinary
( const char *sPrefix_a, const uint8_t *str_a, int32_t iLength_a ) ;

/* Return the time of the most recent entry in the log file.
 */
void antGetLatestLogTime( volatile struct ymds_time *pTime_a ) ;

/* Prepare for extracting information from the antenna log files right
 * at this moment.  Subsequent analysis routines will only see those
 * entries that presently exist, even if some of the log files change
 * thereafter.  A fresh look is obtained by releasing this snapshot
 * and then acquiring another.
 */
struct antHistInfo ;            /* Opaque outside of the antenna library */

struct antHistInfo *antHistPrepare( MESSAGE *iStatus_a ) ; 
MESSAGE antHistRelease( const struct antHistInfo *pInfo_a ) ;

/* Given a BITE unit ID and bit offset within the BITE records, fill
 * in a multi-state array representing the activity of that bit over a
 * specified time interval.  The ANTHISTBITE_xxx bits can be examined
 * directly, or the ANTHISTPLOT_xxx plotting macros can be applied to
 * each output slot to determine whether to draw a Hi/Lo data point,
 * or a Hi/Lo fine connecting line, or a fine vertical line.
 */
MESSAGE antHistGetBITE
( const struct antHistInfo *pInfo_a, uint8_t iID_a, int32_t iByte_a, int32_t iBit_a,
  const struct ymds_time *pBegin_a, const struct ymds_time *pEnd_a,
  uint8_t *pOut_a, int32_t nOutPoints_a, int32_t iExtrapMS_a ) ;

#define ANTHISTBITE_LOW    0x01     /* These bits will be set whenever either */
#define ANTHISTBITE_HIGH   0x02     /*   logic level was placed in this slot. */
#define ANTHISTBITE_LAST   0x04     /* Most recent level written to this slot */
#define ANTHISTBITE_XLEVEL 0x10     /* Logic level extrapolated forward */
#define ANTHISTBITE_XVALID 0x20     /* Extrapolated logic level is valid */

#define ANTHISTPLOT_LOPOINT(X) (((X) & ANTHISTBITE_LOW ) != 0)
#define ANTHISTPLOT_HIPOINT(X) (((X) & ANTHISTBITE_HIGH) != 0)
#define ANTHISTPLOT_LOLINE(X)  (((X) &                                  \
                                 (ANTHISTBITE_XVALID | ANTHISTBITE_XLEVEL | ANTHISTBITE_HIGH | ANTHISTBITE_LOW)) == \
                                (ANTHISTBITE_XVALID                                                          ) )
#define ANTHISTPLOT_HILINE(X)  (((X) &                                  \
                                 (ANTHISTBITE_XVALID | ANTHISTBITE_XLEVEL | ANTHISTBITE_HIGH | ANTHISTBITE_LOW)) == \
                                (ANTHISTBITE_XVALID | ANTHISTBITE_XLEVEL                                     ) )
#define ANTHISTPLOT_VLINE(X) (                                          \
        (((X) &                                                         \
          (ANTHISTBITE_XVALID | ANTHISTBITE_XLEVEL | ANTHISTBITE_HIGH | ANTHISTBITE_LOW)) == \
         (ANTHISTBITE_XVALID                      | ANTHISTBITE_HIGH                  ) ) || \
        (((X) &                                                         \
          (ANTHISTBITE_XVALID | ANTHISTBITE_XLEVEL | ANTHISTBITE_HIGH | ANTHISTBITE_LOW)) == \
         (ANTHISTBITE_XVALID | ANTHISTBITE_XLEVEL                    | ANTHISTBITE_LOW) ) )

/* Given a QBITE unit ID, byte offset and field length within the
 * QBITE records, and slope/offset conversion parameters, create an
 * output array representing the activity of that field over a given
 * time interval.
 */
struct antHistQBITE {           /* Return values for antHistGetQBITE() */
    double fMeanVal ;           /*   Mean value within this slot */
    float fLoVal, fHiVal ;      /*   Low/High values within this slot */
    int32_t nValues ;           /*   Number of values deposited here */
} ;
MESSAGE antHistGetQBITE
( const struct antHistInfo *pInfo_a, uint8_t iID_a, int32_t iByte_a, int32_t nBytes_a,
  const struct ymds_time *pBegin_a, const struct ymds_time *pEnd_a,
  float fCalSlope_a, float fCalOffset_a, uint8_t lSigned_a,
  struct antHistQBITE *pOut_a, int32_t nOutPoints_a ) ;

/* ------------------------------------------------------------
 * -------------------- Interfaces to IRIS --------------------
 * ------------------------------------------------------------
 */
/* Tells the antenna library whether it is being controlled exclusively
 * by IRIS, or whether it can be controlled by other APPs.
 */
void  ant_set_iris( uint16_t lon_a ) ;

/* ANT_GET_NST_CMD() gets the NST fault report information for all
 * four sites, along with their site codes.  ANT_SET_NST() sets the
 * NST report information for one site to be reported to the RCP.
 */
void  ant_get_nst_cmd
( char snst_sites_a[4][4], uint32_t* lfaults_a ) ;

void  ant_set_nst( const char* snst_site_a, uint16_t lfault_a ) ;

/* Set/Get timeout settings for network status updates.  A site will
 * be considered faulted if its status has not been updated for longer
 * than the indicated times in miliseconds.
 */
void  ant_set_nst_timeout( uint32_t imilisec_a ) ;
uint32_t ant_get_nst_timeout( void ) ;

/* Gets the Radar Status menu mode that is being received from the
 * external RCP.  SRST_NAME_A is the name of a Radar Status menu
 * configuration; INAME_SIZE_A is the maximum length of the name;
 * IMODE_A is a number from 1 to 7 associated with the configuration.
 * A mode of 0 indicates that automatic mode switching is enabled.
 */
void ant_get_rstmode
( char* srst_name_a, int32_t iname_size_a, uint32_t *imode_a ) ;

/* Gets the Radar Status menu mode that is being sent from IRIS to the
 * RCP.  Whenever the mode changes, IRIS reports the change back to
 * the RCP.  A mode value of 0 indicates an unrecognized
 * configuration.
 */
void ant_get_rstmode_cmd
( char* srst_name_a, int32_t iname_size_a, uint32_t *imode_a ) ;

/* Sets the Radar Status menu mode to be sent to the RCP.
 */
void ant_set_rstmode
( const char* srst_name_a, uint16_t lwait_a ) ;

/* --------------------------------------------------------------
 * ------------------ Moving Platform Routines ------------------
 * --------------------------------------------------------------
 */
/* Returns TRUE if moving platform parameters are included in the data
 * being received from the external RCP.
 */
uint16_t lant_moving_platform( void ) ;

/* The INU position vector consists of longitude (degrees, -180 to
 * +180), latitude (degrees, -90 to +90) and altitude (meters above
 * sea level).
 */
void ant_get_inu_pos( double fposition_a[3] ) ;

/* The INU velocity vector consists of velocity East, North, and Up,
 * all in meters/second.
 */
void ant_get_inu_vel( float fvelocity_a[3] ) ;

/* The pedestal offset vector is the distance between the antenna
 * pedestal and the INU sensor itself.  Distances in meters are
 * antenna position forward, to port side, and above the INU.
 */
void ant_get_pedestal_off( float foffset_a[3] ) ;

/* The pedestal velocity vector has the same interpretation as the INU
 * velocity vector (see above), except that the rotational dynamics of
 * the ship are also taken into account.  As the ship rotates along
 * its three axes, there is a component of translational motion at the
 * antenna.
 */
void ant_get_pedestal_vel
( double fvelocity_a[3], const struct rtship *rtship_a ) ;

/* This is the fundamental routine to extract the shipboard parameters
 * for a given binary time.  It is called internally by all of the
 * other "get" routines.  Returns the age of the last ship report.
 */
uint32_t ant_get_rtship( struct rtship *rtship_a, uint32_t iBtime_a ) ;

/* Returns the fault bits reported from the INU.
 */
#define ANT_INU_INVHORZ 0x02        /* Invalid lat/long pos/vel */
#define ANT_INU_INVVERT 0x08        /* Invalid vertical pos/vel */
#define ANT_INU_INVROLL 0x20        /* Invalid roll/pitch angle/vel */
#define ANT_INU_INVHEAD 0x80        /* Invalid heading angle/vel */
uint32_t AntGetInuFaults( void );

/* ---------------------------------------------------------------
 * -------------------- Time Get/Set Routines --------------------
 * ---------------------------------------------------------------
 */
/* Returns the time of day information, along with supporting info,
 * from the most recent time record that has been received from the
 * RCP.
 */
void  ant_get_time
( struct ymds_time* time,       /* Time stamped into packet */
  char  sTZName[TZNAME_SIZE],   /* Assumed time zone of time in packet */
  uint32_t* iage,               /* How long ago the packet was received (ms) */
  int32_t* idiff,               /* Time error (OS - RCP) (ms) */
  uint16_t* lflag ) ;           /* NZ if a time packet has been received */

/* Set the system time clock.  A request is made to the antenna
 * transmit process to actually do the work.  This is necessary
 * because the calling process probably does not have the required
 * priveleges to actually set the system time.
 */
void ant_set_time( void ) ;

/* LANT_OKAY_TO_SET_TIME() returns TRUE if the system time could be
 * set from the time information that we currently have from the RCP.
 */
uint16_t lant_okay_to_set_time( void ) ;

/* LANT_SET_TIME_WAIT() returns TRUE if the system time currently has
 * a pending time set request.  PLASTCHANGE_A will hold the binary
 * time at which the last change was made, and is valid only if the
 * function returns FALSE.
 */
uint32_t lant_set_time_wait( int32_t *pLastChange_a ) ;

/* ----------------------------------------------------------------
 * -------------------- Radar Tx/Rx Interfaces --------------------
 * ----------------------------------------------------------------
 */
/* ANT_SET_AUTO() sets the IRIS automatic radiate flag in the antenna
 * library.  IRIS will automatically request that the transmitter
 * radiate in time to start each task when call with TRUE arg.
 * Otherwise, radiate is not affected by IRIS tasks starting and
 * stopping.  ANT_SET_RADIATE() turns the transmitter On/Off right
 * away as requested.
 */
void  ant_set_auto( uint16_t lon_a ) ;

void  ant_set_radiate( uint16_t lon_a ) ;

/* ant_toggle_radiate implements the radiate toggle feature.  This
 * is an attempt to turn radiate on if it has faulted off.
 */
void  ant_toggle_radiate(int32_t iWarmTimeMs_a);

/* Wait until radiate has been on the required time.
 */
void  ant_wait_for_radiate(int32_t iWarmTimeMs_a);

/* ant_set_pw_prf() tells the library to send a command to the RCP to set
 * the 2-bit transmit pulsewidth.  iant_pw_prf_cmd() returns that very
 * same request, and iant_pwbw() returns the actual pulsewidth being
 * reported back from the RCP.
 *
 * void  ant_set_pw_prf( ... ) ; Do not call from applications! 
 */
#define ANT_PWBW_MASK       (0x03)
#define ANT_PWBW_UNCHANGED  (0x04)

uint32_t iant_pw_prf_cmd( float* fpw_a, float* fprf_a ) ;
uint32_t iant_pwbw( void ) ;

/* ANT_SET_POLAR() tells the library to send a command to the RCP to
 * set the transmit polarization.  Argument is one of the POL_xxx
 * parameters that are defined in dsp.h.  IANT_POLAR_CMD() returns
 * that very same request, and IANT_POLAR() returns the actual
 * polarization being reported back from the RCP.
 */
void  ant_set_polar( uint16_t iPolar_a ) ;
uint16_t iant_polar_cmd( void ) ;
uint16_t iant_polar( uint8_t *lOK_a ) ;

/* Turn On/Off the power supplies to the transmitter.
 */
void  ant_set_trpower( uint16_t lon_a ) ;

/* --------------------------------------------------------------
 * ------------------ Antenna Status & Control ------------------
 * --------------------------------------------------------------
 */
/* Reset the remote RCP from any shutdown or fault state that it may
 * be in right now.
 */
void  ant_set_reset( void ) ;

/* Turn On/Off the pedestal servo amplifiers
 */
void  ant_set_servo( uint16_t lon_a ) ;

/* Fills in the antenna status as a string that can be displayed.
 * Possible returns are "Shutdown", "Local", "IRIS", "Computer".  The
 * function's return value is one of DEV_xxx parameters from ingest.h.
 */
uint32_t AntGetStateString( char sName_a[16] ) ;

/* IANT_CMD() returns a summary of the control bits being sent to the
 * remote RCP.  The bit mask is a combination of the ACF_xxx macros
 * that are defined earlier in this file.  IANT_CMD_MASK() returns the
 * mask of which control bits are actually being used by the RCP.
 */
uint32_t iant_cmd( void ) ;
uint32_t iant_cmd_mask( void ) ;

/* IANT_STAT() returns a summary of the status bits being received by
 * the remote RCP.  The bit mask is a combination of the ASF_xxx
 * macros that are defined earlier in this file.  IANT_STAT_MASK()
 * returns the mask of which status bits are actually being used by
 * the RCP.  IANT_STAT_CRITICAL() returns a mask of status bits which
 * result in a critical system fault whenever any of them are set.
 */
uint32_t iant_stat( void ) ;
uint32_t iant_stat_mask( void ) ;
uint32_t iant_stat_critical( void ) ;

/* Returns the height of the ground at the antenna site, in meters.
 */
float  fant_ground_height( void ) ;

enum ant_scan_geometry AntGetScanGeometry( void );

/* --------------------------------------------------------------
 * ------------------ Signal Generator Control ------------------
 * --------------------------------------------------------------
 */
/* ANT_SET_SIGGEN() turns the RF signal generator (if any) On/Off.  A
 * CW waveform will be output if ANT_SET_SIGCW() is called with a TRUE
 * arg, else a pulse waveform will be produced.
 */
void ant_set_siggen( uint16_t lon_a, uint8_t lwait_a ) ;
void ant_set_sigcw( uint16_t lon_a ) ;

/* The actual power output level is set by ANT_SET_SIGGEN_VALUE(),
 * which can optionally wait a predetermined settling time (from
 * SETUP) before returning.  IANT_SIGGEN_CMD() returns the level that
 * is being requested, and IANT_SIGGEN() returns the actual setting of
 * the signal generator as reported back from the RCP.
 */
void  ant_set_siggen_value
( const int32_t ivalue_a, const uint16_t lwait_a ) ;

int32_t iant_siggen_cmd( void ) ;
int32_t iant_siggen( void ) ;

/* Gets the minimum and maximum signal generator values in dBm.
 */
void  ant_get_siggen_limits( int32_t ilimits_a[2] ) ;

/* ANT_SET_NOISE() turns the noise souce (if any) On/Off.  The noise
 * source can also be toggled On-->Wait-->Off for a predetermined time
 * (from SETUP) using ANT_TOGGLE_NOISE().
 */
void  ant_set_noise( uint16_t lon_a ) ;
void  ant_toggle_noise( void ) ;

/* ---------------------------------------------------------------
 * -------------------- Dual Redundant System --------------------
 * ---------------------------------------------------------------
 */
/* The operating mode of a dual-redundant system is set to either "A",
 * "B", or "Auto" using ANT_SET_DRCP_MODE().  Arg is one of the macros
 * DRCP_MODE_xxx, whose meaning can be translated to text form using
 * DRCP_MODE_TEXT().
 */
void ant_set_drcp_mode( uint16_t iDrcpMode_a ) ;
const char *AntGetDrcpModeString( uint16_t iDrcpMode_a ) ;

/* The complete status of a dual-redundant system, as reported back
 * from whichever RCP(s) is/are actually up and running, is available
 * here.
 */
void ant_get_drcp( struct drcp_status *drcp_a ) ;

/* When a dual-redundant RCP system would be used by some application,
 * this is indicated by calling ANT_SET_DRCP_WOULDUSE() with a TRUE
 * arg.  Then, while the RCP is being used by a given APP, it can be
 * momentarily given up by calling ANT_SET_DRCP_RELINQUISH().  Both of
 * these routines define switchover barriers which guide the RCP's
 * decisions about when to change control between the "A" and "B"
 * systems.
 */
void ant_set_drcp_wouldUse( uint16_t lWouldUse_a ) ;
void ant_set_drcp_relinquish( uint16_t lRelinquish_a ) ;

/* ---------------------------------------------------------------
 * -------------------- Extended Header System -------------------
 * ---------------------------------------------------------------
 */
/* Get the size of the extended header in bytes.
 */
uint32_t AntGetXhSize( void ) ;

/* Get the extended header data.
 */
void AntGetXhData( uint8_t *pData_a ) ;

/* Get the extended header name.
 */
void AntGetXhName( char *sName_a, uint32_t iMaxSize_a ) ;

/* --------------------------------------------------------------
 * -------------------- BITE Suport Routines --------------------
 * --------------------------------------------------------------
 */
/* Get a copy of the complete bitex definition structures from the
 * library.  Returns TRUE if a fresh copy has been written to BITEX_A,
 * i.e., if either the definitions have changed since the last
 * time that this routine was called, or LFORCE_GET_A was TRUE on
 * entry.  BITEX_A can be NULL if you are only interested in the
 * return value.
 */
uint16_t lbite_get_def
( struct bitex_setup *bitex_a, uint16_t lforce_get_a ) ;

/* BITE_GET_ONE_DEF() gets a copy of the fixed definition of a single
 * field of the BITE system.  BITE_GET_FIELD_STATE() returns all of
 * the temporal (changing with time) information about a given field.
 * See the structure definitions for a description of the information
 * passed by these routines.
 */
void bite_get_one_def
( struct bitex_field_def *definition_a,
  int32_t ifield_a ) ;

void bite_get_field_state
( struct bite_field_state *fstate_a, int32_t ifield_a ) ;

/* Check whether there is a BITE field with a particular (reserved)
 * text name, and if so, return the state of that bit.
 */
uint16_t bite_check_keyname( const char *keyname_a ) ;
#define BITE_CHKEY_UNDEF  0        /* Key is undefined */
#define BITE_CHKEY_FALSE  1        /* Key is FALSE */
#define BITE_CHKEY_TRUE   2        /* Key is TRUE  */

/* The summary status of all possible BITE faults is obtained using
 * BITE_GET_FLAG(), which returns the type of fault, and the field (if
 * any) that is causing it.
 */
void  bite_get_flag
( uint32_t* flag_a, int32_t *ifield_a ) ;
#define BITE_FLAG_OK       (0)
#define BITE_FLAG_FAULT    (1)
#define BITE_FLAG_CRITICAL (2)

/* Get the button presses flagged for IRIS.  The flags are cleared, so
 * we only see presses since the last call.
 */
void  bite_get_iris_flags
( uint32_t mask_a[BITE_MASK_SIZE] ) ;

/* Get the current mask of one bit for each defined field.  There is a
 * maximum of BITE_NUM_FIELD_DEFS bits returned.
 */
void  BiteGetMasks
( uint32_t iData_a[BITE_MASK_SIZE], 
  uint32_t iFaults_a[BITE_MASK_SIZE],
  uint32_t iCriticals_a[BITE_MASK_SIZE] ) ;

/* Sets the state of a BITE bit. 
 */
void bite_set_button( uint16_t lbutton_in_a, int32_t ifield_a ) ;

/* Sends one of the following commands, either to all BITE units, or
 * to a specified BITE units:
 *
 *   BITE_INTERROGATE: Request a new BITE packet transmission from the RCP
 *   BITE_SET_VALUES:  Request that RCP send commands to external units
 *   BITE_TAKE_SAMPLE: Request that RCP sample data from external units
 *   BITE_RESET:       Reset the hardware associated with this BITE unit
 */
void bite_send_command( uint8_t icommand_a ) ;
void bite_send_unit_command( uint8_t icommand_a, uint8_t iUnitId_a ) ;

/* Request that a client send a BITE status packet.  The full packet
 * is provided, and some error checking is done.  Returns message on
 * error, and the packet is not sent.
 */
MESSAGE bite_send_client_status
( int32_t iUnit_a,            /* Packet unit number, origin 0 */
  const uint8_t iPacket_a[],  /* Packet to send */
  int32_t iPacketLength_a );  /* Number of bytes in packet */

/* ----------------------------------------------------------------
 * ------------------- Measured Angle Insertion -------------------
 * ----------------------------------------------------------------
 */
/* Function to process an antenna packet in any of the RCVxx formats,
 * once we know that it is formatted correctly.  The contents are
 * inserted into the antenna information database.
 */
void AntInsertPacket
( const uint8_t str_a[],        /* Array of data received */
  uint32_t iread_time_a,        /* Binary time of packet arrival */
  uint32_t iformat_a,           /* One of ANTFMT_RCVxxx */
  int32_t iLength_a ) ;         /* Total length of the packet */

/* Returns TRUE if this client (the process that opened this version
 * of the antenna library) is allowed to insert measured antenna
 * angles.
 */
uint8_t lAntCanInsertAngles( void ) ;

/* Insert into the library a measured angle AZ/EL pair that was sampled
 * at a particular time.  Use the PosAndVel routine if the velocity is
 * known; otherwise just insert the positions and the library will take
 * care of computing velocities as needed.
 */
uint8_t AntInsertPosition
(BIN2 iEarthAzPos_a, BIN2 iEarthElPos_a,
 BIN2 iPedAzPos_a,   BIN2 iPedElPos_a,
 BIN2 iPedAzJump_a,  BIN2 iPedElJump_a, /* Position jumps due to encoder cal */
  uint32_t iBtime_a ) ;

uint8_t AntInsertPosAndVel
(BIN2 iEarthAzPos_a, BIN2 iEarthElPos_a,
 BIN2 iPedAzPos_a, BIN2 iPedElPos_a,
 BIN2 iPedAzJump_a,  BIN2 iPedElJump_a, /* Position jumps due to encoder cal */
  float fAzVel_a, float fElVel_a, uint32_t iBtime_a ) ;

uint8_t AntInsertRtship
( const struct rtship *pRtship_a, uint32_t iBtime_a ) ;

/* ----------------------------------------------------------------
 * ------------------- Antenna Motion Modelling -------------------
 * ----------------------------------------------------------------
 */
struct antAxisModel {           /* Simple antenna model state on one axis */
    BIN4  iPos32 ;              /*   Current position (32-bit binang) */
    int32_t iVel32 ;            /*   Current velocity (32-bit binang/sec)*/
    uint8_t iAntMode ;          /*   Servo type, one of ANTMODE_xxx  */
    uint8_t lUseLimits ;        /*   Enforce lower/upper limits of travel */
    uint8_t lOverTheTop ;       /*   Don't cross -90, else take shortest path */
    uint8_t lHysteresisInner ;  /*   Flag for inner position hysteresis zone */
    char  pad12x2[2] ;
    BIN2  iRequestedPos ;       /*   Requested position (binang), or */
    int16_t iRequestedVel ;     /*     requested velocity (binang/sec). */
    int16_t iVelLimit ;         /*   Upper bound on velocity (binang/sec) */
    BIN2  iPosLimits[2] ;       /*   Optional lower/upper position limits */
} ;

/* Maximum acceleration in degrees/sec^2, and velocity servo gain term
 * having units of acceleration per degree/sec of velocity error.
 */
#define ANTMOD_MAXACCEL   20.0
#define ANTMOD_ACCELGAIN   8.0

/* Position feedback term is dimensionless because the feedback is
 * nonlinear.  However, making this number bigger makes the position
 * servos 'tighter'.
 */
#define ANTMOD_POSGAIN    30.0

/* Routine to update one axis of a modelled antenna, simulating the
 * passage of FTICK seconds since the last call.
 */
void antAxisModelUpdate
( volatile struct antAxisModel *pModel_a, float fTick_a ) ;

/* ----------------------------------------------------------------
 * ------------------- Miscellaneous Interfaces -------------------
 * ----------------------------------------------------------------
 */
/* Get/Put a chat-mode character.  The PUT routine will sleep until
 * there is room in the outgoing chat FIFO.  Since chat packets can be
 * sent whenever any data are ready, any sleeps that might happen will
 * always be very short.  A return value of -1 from the GET routine
 * indicates that no characters were available to be read.  The GET
 * routine will never sleep.
 */
int32_t iant_get_chat( void ) ;
void  ant_put_chat( uint8_t ichar_a ) ;
void AntSetChatDestination
( uint32_t iDestination_a );  /* Destination in network byte order */

/* Write the packet to the network with the appropriate header for an
 * antenna packet.  The type string should be chosen from the list of
 * well known types.
 */
int32_t AntWriteNetwork
( int iFD_a,
  const uint8_t *pData_a, 
  int32_t iSize_a,
  const char *sType_a,
  uint32_t iDestination_a );  /* Destination address in network order */

#define ANT_PKT_TYPE_XMT01      "XMT01"    /* Standard antenna XMTnn packets */
#define ANT_PKT_TYPE_XMT02      "XMT02"
#define ANT_PKT_TYPE_XMT05      "XMT05"
#define ANT_PKT_TYPE_RCV01      "RCV01"    /* Standard antenna RCVnn packets */
#define ANT_PKT_TYPE_RCV02      "RCV02"
#define ANT_PKT_TYPE_RCV03      "RCV03"
#define ANT_PKT_TYPE_RCV05      "RCV05"
#define ANT_PKT_TYPE_XMTSA      "XMTSA"    /* Scientific Atlanta controller */
#define ANT_PKT_TYPE_RCVSA      "RCVSA"
#define ANT_PKT_TYPE_XMTCHAT    "XCHAT"    /* Chat mode packet */
#define ANT_PKT_TYPE_RCVCHAT    "RCHAT"
#define ANT_PKT_TYPE_RCVTIME    "RTIME"    /* Time packet */
#define ANT_PKT_TYPE_XMTBITEC   "XBITEC"   /* BITE control/status packet */
#define ANT_PKT_TYPE_RCVBITES   "RBITES"
#define ANT_PKT_TYPE_XMTBINTROG "XBINTROG" /* BITE 'Interrogate' packet */
#define ANT_PKT_TYPE_RCVBINTROG "RBINTROG"
#define ANT_PKT_TYPE_XMTBSAMPLE "XBSAMPLE" /* BITE 'Take Sample' packet */
#define ANT_PKT_TYPE_RCVBSAMPLE "RBSAMPLE"
#define ANT_PKT_TYPE_XMTBSETVAL "XBSETVAL" /* BITE 'Set Values' packet */
#define ANT_PKT_TYPE_RCVBSETVAL "RBSETVAL"
#define ANT_PKT_TYPE_XMTBRESET  "XBRESET"  /* BITE 'Reset' packet */
#define ANT_PKT_TYPE_RCVBRESET  "RBRESET"

/* Create a running subprocess that is connected to the calling parent
 * process via a single readable file descriptor.  The child process
 * ID is also returned so that it can be cleaned up later.  The parent
 * must put a kill of this PID in it's exit handler.  Returns -1 on error,
 * else a file descriptor
 */
struct ant_net_spec
{
    char *sAddress;    /* Network address, can be "0.0.0.0" for any */
    uint16_t iPort;
    uint16_t iFlags;
#define ANTNET_FLG_RCV  (0x0001)
#define ANTNET_FLG_XMT  (0x0002)
    char *sInterface;
};

int AntNetRcvOpen
( const struct ant_net_spec *pSpec_a, int32_t *pPID_a ) ;

/* The antenna network receive process reads incoming network packets
 * and produces a virtual serial antenna/BITE stream on the requested
 * file descriptor.  It runs until getting an external request to
 * quit, or encountering a fatal internal error.
 */
MESSAGE AntNetRcvProcess
( const struct ant_net_spec *pSpec_a,
  int iFD_a,
  volatile const uint8_t *lQuitFlag_a,
  void (*AntLock_a)(int) ) ; /* Optional antenna library lock function */

/* ----------------------------------------------------------------
 * ------------------- Common Control Interface -------------------
 * ----------------------------------------------------------------
 */
/* Common interface function to handle all control requests from the
 * antenna library API calls.  Having this single interface allows a
 * history of all control requests to be maintained for exporting to
 * other systems.
 */
#define ANTSET_AZCMD      "AZCMD"
#define ANTSET_ELCMD      "ELCMD"
#define ANTSET_AUTORAD    "AUTORAD"
#define ANTSET_IRISMODE   "IRISMODE"
#define ANTSET_NOISEGEN   "NOISEGEN"
#define ANTSET_NOISETOG   "NOISETOG"
#define ANTSET_NSTOUT     "NSTOUT"
#define ANTSET_NSTFLT     "NSTFLT"
#define ANTSET_RSTMODE    "RSTMODE"
#define ANTSET_SERVO      "SERVO"
#define ANTSET_RADIATE    "RADIATE"
#define ANTSET_TOGGLE     "TOGGLE"
#define ANTSET_WAITRAD    "WAITRAD"
#define ANTSET_SIGGENCW   "SIGGENCW"
#define ANTSET_SIGGENOUT  "SIGGENOUT"
#define ANTSET_SIGGENVAL  "SIGGENVAL"
#define ANTSET_TRPOWER    "TRPOWER"
#define ANTSET_RESET      "RESET"
#define ANTSET_PWBW       "PWBW"
#define ANTSET_POLAR      "POLAR"
#define ANTSET_TIME       "TIME"
#define ANTSET_CHAT       "CHAT"
#define ANTSET_DRCPMODE   "DRCPMODE"
#define ANTSET_DRCPRLNQ   "DRCPRLNQ"
#define ANTSET_DRCPWUSE   "DRCPWUSE"
#define ANTSET_BITEBUTN   "BITEBUTN"
#define ANTSET_BITESCMD   "BITESCMD"
#define ANTSET_BITEUCMD   "BITEUCMD"
#define ANTSET_NUMCOMMANDS  (28)
#define ANTSETCMDLEN       (120)

/* NOTE: The number of commands should match the above list, so that
 * the history table will have a slot for each one.  Max command
 * length must be less than 128 so that the length can be coded into a
 * 7-bit packet value (MSB clear).
 */
void AntSet
( const char *pStr_a ) ;

/* Handy invocations, passing an opcode and numeric arg(s).
 */
void AntSetArg ( const char *pOpStr_a, double fValue_a ) ;
void AntSetArg2( const char *pOpStr_a, double fVal1_a, double fVal2_a ) ;
void AntSetArg3( const char *pOpStr_a, double fVal1_a, double fVal2_a,
                 double fVal3_a) ;

void antenna_lib_nls_init(void);  /* File: antenna_lib_message_init.c */
#define ANTENNA_LIB_INIT antenna_lib_nls_init()

/* Return a string of packets containing the data and command updates
 * that have been entered into the library and have not yet been sent
 * to the specified client.
 * Return value is the length of the data string, which must
 * be free'd when you're done with it.  The contents of the string can
 * be exported directly to update a remote antenna receive process.
 */
int32_t iAntGetUpdatePackets
( uint32_t iClientMask_a, /* Mask of which client we are */
  uint8_t iGet_a,        /* Type of get to do */
  char **pData_a );     /* Data returned here */

#define ANTGET_RCV_MASK (0x80000000)  /* Mask for the ant_rcv process */

#define ANTGET_ALL      0        /* Get all packets, regardless of time/purpose */
#define ANTGET_EXPORT   1        /* Get unsent packets needing to be exported */
#define ANTGET_RETURN   2        /* Get unsent packets to return to real antenna */
/* Return orientation angle to the sun.
 */
void sun_position 
(int32_t iyear_a,          /* Current year */
 int32_t iyday_a,          /* Current day in the year */
 int32_t idsec_a,          /* Current second in the day */
 double  fposition_a[2],   /* Longitude and latitude of your position in degrees */
 double  *pfAzimuth_a,     /* Azimuth in radians */
 double  *pfElevation_a ); /* Elevation in radians */

/* Does not require an initialized antenna */
double ant_compute_vel_correction
( double faz_a,  /* Az and el in radians */
  double fel_a,
  double froll_a, double fpitch_a, double fheading_a,  /* RPH in radians */
  const double fmotion_a[3],   /* Motion (East, North, Up in m/s */
  enum ant_scan_geometry iScanGeometry_a );       /* Type of antenna */

#ifdef __cplusplus
}
#endif

#endif /* #ifndef SIGMET_ANTENNA_LIB_H */
