/* **********************************************************************
 * *                                                                    *
 * *   Parameters For Ribbon Display Library Processes and Routines     * 
 * *                                                                    *
 * ********************************************************************** 
 * File: libs/ribbon/rib_global.h
 *
 *                  COPYRIGHT (c) 1999, 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. 
 */    

/* Possible error values: 
 */
  
#define        BAD_DEVICE     1
#define RIBLIB_BAD_DEVICE     (RIBLIB_FACILITY + BAD_DEVICE)
#define        ERR_RCV        2
#define RIBLIB_ERR_RCV        (RIBLIB_FACILITY + ERR_RCV)
#define        ERR_XMT        3
#define RIBLIB_ERR_XMT        (RIBLIB_FACILITY + ERR_XMT)
#define        INVALID_CLIENT 4
#define RIBLIB_INVALID_CLIENT (RIBLIB_FACILITY + INVALID_CLIENT)
#define        MANY_DISPLAYS  5
#define RIBLIB_MANY_DISPLAYS  (RIBLIB_FACILITY + MANY_DISPLAYS)
#define        PROC_RCV       6
#define RIBLIB_PROC_RCV       (RIBLIB_FACILITY + PROC_RCV)
#define        PROC_XMT       7
#define RIBLIB_PROC_XMT       (RIBLIB_FACILITY + PROC_XMT)
#define        TWO_BUILDERS   8
#define RIBLIB_TWO_BUILDERS   (RIBLIB_FACILITY + TWO_BUILDERS)
#define        TWO_SERIALRCV  9
#define RIBLIB_TWO_SERIALRCV  (RIBLIB_FACILITY + TWO_SERIALRCV)
#define        TWO_SERIALXMT  10
#define RIBLIB_TWO_SERIALXMT  (RIBLIB_FACILITY + TWO_SERIALXMT)
#define        TWO_SETUPS     11
#define RIBLIB_TWO_SETUPS     (RIBLIB_FACILITY + TWO_SETUPS)

#ifndef MESSAGE_ONLY


#ifdef RIBBON_GLOBAL_ALLOCATE
#define EXTERN
#else
#define EXTERN extern
#endif

/* -----------------------------------------------------------
 * Semaphore to lock the ribbon shared memory.
 */
#define IRIS_RIBBON_CLUSTER_NAME   "iris_ribbon_cluster"
#define RIBBON_SEM   (IRIS_RIBBON_CLUSTER + 0)

#define IRIS_RIBBON_SEM_NUM   (1)

/* The following event flags are available for waking up processes
 * which may have to output to a ribbon display when a change is made.
 */
#define RIBBON_XMT_EF     (IRIS_RIBBON_CLUSTER +  1)
#define RIBBON_DIS1_EF    (IRIS_RIBBON_CLUSTER +  2)
#define RIBBON_DIS2_EF    (IRIS_RIBBON_CLUSTER +  3)
#define RIBBON_DIS3_EF    (IRIS_RIBBON_CLUSTER +  4)
#define RIBBON_DIS4_EF    (IRIS_RIBBON_CLUSTER +  5)
#define RIBBON_DIS5_EF    (IRIS_RIBBON_CLUSTER +  6)

#define RIB_MAX_VDISPLAYS (5)   /* Maximum number of X virtual displays */
#define IRIS_RIBBON_EF_NUM (1+RIB_MAX_VDISPLAYS)


/* Priority */
#define RIBBON_SERIAL_PRIORITY (-10)

/*================= Structure for Holding Ribbon Display Info ==================*/

struct out_information
{
  UINT4 ixmt_pid;               /* Process IDs for the two processes */

  MESSAGE ixmt_status;          /* Status for xmt process  */

  SINT4 iout_cnt[RIB_MAX_DISPLAYS]; /* Output Operation count */
  SINT4 iout_ercnt;                 /* Output Error count */
};

struct in_information
{
  UINT4 ircv_pid;

  MESSAGE ircv_status;          /* status for rcv process  */

  SINT4 iin_cnt[RIB_MAX_DISPLAYS];  /* Input Operation count */
  SINT4 iin_ercnt;                  /* Input Error count */
  UINT4 ibtime[RIB_MAX_DISPLAYS];   /* binary time of last status byte from each display */
};

struct ribbon_info
{
  struct ribbon_display_contents Display[RIB_MAX_DISPLAYS];
  struct out_information out;
  struct in_information in;

  UINT2 lBuilderActive;
  UINT2 lSetupActive;
  UINT2 lSerialXmtActive;
  UINT2 lSerialRcvActive;
  UINT2 lVDisplayActive[RIB_MAX_VDISPLAYS];
  UINT2 lSerialChange;    /* Change needs update on serial line */
  UINT2 lDisableAutoTime; /* Do not Automatically write time on the bottom line */
};


struct ribbon_global
{
  /* Current information for the ribbon display
   */
  struct ribbon_info info;

  /* Setup information for the ribbon display
   */
  struct ribbon_setup setup;
  
};


EXTERN volatile struct ribbon_global *pRibbon_c;
EXTERN SINT4 iRibbonSize_c;
EXTERN SINT4 iRibbonId_c;


/* Function prototypes for functions only used locally within the antenna
 * driver package.  Externally referenced functions are declared in the
 * antenna_lib.h file
 */

/* Not in the actual library, but instead located in ant_iosubs.c
 */
size_t fwrite_int               /* File: ant_iosubs.c */
( const UINT1 *pData_a,
  size_t iSize_a,
  size_t iItems_a,
  FILE *pStream_a );

#undef EXTERN

#endif  /* #ifndef MESSAGE_ONLY */
