/* *********************************************************************
 * *                                                                   *
 * *     IRIS Antenna Driver and BITE Driver Internal Definitions      *
 * *                                                                   *
 * *********************************************************************
 * File: include/antenna_int.h
 *
 *  COPYRIGHT (c) 1991, 1992, 1994, 1996, 1997, 1999, 2001, 2002, 2003,
 *                              2004 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.
 */

/* Function prototypes for internal library and special application
 * routines that are not intended to be publicly visible.
 */
#ifdef __cplusplus
extern "C" {
#endif

/* Semaphore related definitions
 */
#define LIBS_ANTENNA_CLUSTER_NAME  "libs_antenna_cluster"

/* Semaphores to lock the antenna library's real time antenna models
 * for basic antenna position and extended shipboard parameters.
 */
#define ANTENNA_PEDX_MODEL_SEM    (LIBS_ANTENNA_CLUSTER + 0)
#define ANTENNA_SHIP_MODEL_SEM    (LIBS_ANTENNA_CLUSTER + 1)
#define ANTENNA_CMDHISTORY_SEM    (LIBS_ANTENNA_CLUSTER + 2)
#define ANTENNA_NETHOST_SEM       (LIBS_ANTENNA_CLUSTER + 3)
#define ANTENNA_EXPORT_EF0        (LIBS_ANTENNA_CLUSTER + 0)
#define ANTENNA_EXPORT_EF1        (LIBS_ANTENNA_CLUSTER + 1)
#define ANTENNA_EXPORT_EF2        (LIBS_ANTENNA_CLUSTER + 2)
#define ANTENNA_EXPORT_EF3        (LIBS_ANTENNA_CLUSTER + 3)
#define ANTENNA_EXPORT_EF4        (LIBS_ANTENNA_CLUSTER + 4)
#define ANTENNA_EXPORT_EF5        (LIBS_ANTENNA_CLUSTER + 5)
#define ANTENNA_EXPORT_EF6        (LIBS_ANTENNA_CLUSTER + 6)
#define ANTENNA_EXPORT_EF7        (LIBS_ANTENNA_CLUSTER + 7)

#define LIBS_ANTENNA_SEM_NUM   (4)
#define ANTENNA_EXPORT_NUM     (8)  /* Must not be made larger than 31 */
#define LIBS_ANTENNA_EF_NUM    ANTENNA_EXPORT_NUM

/* Sync code choices
 */
#define ANT_SYNC_ANT    (0x80)	/* ---- Antenna Packet ---- */
#define ANT_SYNC_QBITE  (0xAF)	/* ---- Q-BITE Packet ---- */
#define ANT_SYNC_TIME   (0xB0)	/* ---- Time Packet ---- */
#define ANT_SYNC_BITE   (0xC0)	/* ---- BITE Packet ---- */
#define ANT_SYNC_CHAT   (0xF1)	/* ---- Chat-Mode Packet ---- */
#define ANT_SYNC_ASCMD  (0xF2)	/* ---- ASCII Command String ---- */

#define ANT_SYNC_BITE_RQST  (0xC0)  /* ---- Request to BITE ---- */
#define ANT_SYNC_1BITE_RQST (0xC1)  /* ---- Request to a single BITE ---- */
#define ANT_SYNC_QBITE_RQST (0x90)  /* ---- Request to Q-BITE ---- */

#define ANT_SYNC_ENDREC  (0xFF)	/* ---- End-Of-Record ---- */

/* ---------------------------------------
 * Antenna & BITE Simulators
 */
MESSAGE antsim_close( void ) ;
void  antsim_get_activity( SINT4* incnt_a, SINT4* ioutcnt_a, SINT4* inerr_a,
			   SINT4* iouterr_a ) ;
void  antsim_get_az_cmd( UINT2* imode_a, BIN2* idaz_a, FLT4* fdazv_a ) ;
void  antsim_get_el_cmd( UINT2* imode_a, BIN2* idel_a, FLT4* fdelv_a ) ;
void  antsim_get_azel_pos( BIN2* iaz_a, BIN2* iel_a ) ;
void  antsim_get_azel_vel( FLT4* fazv_a, FLT4* felv_a ) ;

void  antsim_get_diagnostic
(UINT1* sbuffer_a, SINT4 ibuf_size_a, SINT4* ifill_size_a ) ;
void  antsim_get_odiagnostic
(UINT1* sbuffer_a, SINT4 ibuf_size_a, SINT4* ifill_size_a ) ;

void  antsim_get_elor( BIN2* ielor_a ) ;
void  antsim_get_heading( BIN2* iheading_a, FLT4* fheadingv_a ) ;
void  antsim_get_inu_pos(FLT4 fposition_a[3] ) ;
void  antsim_get_inu_vel( FLT4 fvelocity_a[3] ) ;

void  antsim_get_nst( UINT4 *bits_a ) ;

void  antsim_get_pedestal_vel( FLT4 fvelocity_a[3] ) ;
void  antsim_get_pids( UINT4 *ircv_pid_a, UINT4 *ixmt_pid_a ) ;
void  antsim_get_pitch( BIN2* ipitch_a, FLT4* fpitchv_a ) ;
void  antsim_get_roll( BIN2* iroll_a, FLT4* frollv_a ) ;
void  antsim_get_rstmode( UINT4 *imode_a ) ;
void  antsim_get_rstmode_cmd( UINT4 *imode_a ) ;
void  antsim_get_tror( BIN2* itror_a ) ;
MESSAGE antsim_global_init( UINT2* lcreated_a ) ;
void  antsim_set_deck_rock( FLT4 fvelocity_a[3] ) ;
void  antsim_set_deck_tilt( FLT4 fposition_a[3] ) ;
void  antsim_set_inu_vel( FLT4 fvelocity_a[3] ) ;
void  antsim_set_rstmode( UINT4 imode_a ) ;
void  antsim_set_status( UINT4* istatus_a ) ;

UINT4 iantsim_age( void ) ;
UINT4 iantsim_cmd( void ) ;
UINT4 iantsim_cmd_mask( void ) ;
UINT4 iantsim_pwbw( void ) ;
UINT4 iantsim_pwbw_cmd( void ) ;
MESSAGE iantsim_pwrp( void ) ;
MESSAGE iantsim_pwrp_opt( UINT2 lauto_a ) ;
SINT4 iantsim_siggen( void ) ;
SINT4 iantsim_siggen_cmd( void ) ;
UINT4 iantsim_stat( void ) ;
UINT4 iantsim_stat_mask( void ) ;

UINT2 lantsim_moving_platform( void ) ;
void antsim_set_drcp_mode( UINT2 iDrcpMode_a ) ;
void antsim_get_drcp( struct drcp_status *drcp_a ) ;

void  bitesim_fault( UINT1 iunit_a, UINT1 ibyte_a, UINT1 ibit_a ) ;
SINT4 bitesim_get_activity( SINT4 in_count_a[], SINT4 out_count_a[], 
			    SINT4 bite_count_a ) ;

/* ------------------------------
 * Private BITE interfaces used only by BITEX
 */
MESSAGE bite_load_def( void ) ;
MESSAGE bite_save_def( void ) ;

void bite_set_def( const struct bitex_setup *bitex_a ) ;

void  bite_set_one_def
( const struct bitex_field_def *pDefinition_a,
  SINT4 iField_a ) ;

/* ------------------------------
 * Function prototypes for functions only used locally within the
 * antenna driver package.  Externally referenced functions are
 * declared in the antenna_lib.h file.
 */
FLT4  fbound( FLT4 fmax_a, FLT4 fval_a ) ;

void velocity_matrix_compute
  (FLT4 fmatrix_a[3][3],
   FLT4 frotation_vel[3],  /* Order pitch, roll, heading */
   FLT4 frotation_pos[3],
   FLT4 fplatform_offset[3]
   ) ;
void position_matrix_compute
  (FLT4 fmatrix_a[3][3],
   FLT4 frotation_pos[3]
   ) ;
void  matrix_mul3
  (FLT4 fvelocity_a[3],     /* resulting velocity */
   FLT4 fmatrix_a[3][3],
   FLT4 fplatform_offset_a[3]
   ) ;

#ifdef INCLUDE_STDIO_PROTOTYPES
size_t WriteInt
( int iFD_a, const UINT1 *pData_a, size_t iSize_a, const char* sType_a,
  UINT4 iDestination_a ) ;

FILE *AntOpenLog( const char *sPrefix_a ) ;
#endif  /* #ifdef INCLUDE_STDIO_PROTOTYPES */

void get_more_chars
( int iFD_a, UINT1 str[], UINT4* iptr_a, UINT4* iend_a, SINT4 imaxch_a ) ;

UINT2 lcheck_packet( UINT1 str_a[], SINT4 ilength_a ) ;

UINT2 lcheck_packet_sa( UINT1 str_a[], SINT4 ilength_a ) ;

UINT4 iParseTimeStamp( const UINT1 *str_a, UINT2 iformat_a ) ;

MESSAGE iAntOpenSocket( int *pFD_a ) ;

  void  ant_set_pwbw( UINT2 ipwbw_a ) ;

  void AntRegisterNetHost( UINT4 iFromAddress_a );

  void AntPruneNetHost
  ( UINT4 iCurrentBTime_a );  /* The current time */


#ifdef __cplusplus
}
#endif
