 /*===========================================================================*/
 /*                                                                           */
 /*      **CMS**=C_INC                                                        */
 /*                                                                           */
 /* Abs:  Klystron (SBST, KLYS, DKLY) HSTA, STAT, and SWRD bit definitions.   */
 /*                                                                           */
 /* Name: slctxt:klystatus.hc                                                 */
 /*                                                                           */
 /* Prev: None.                                                               */
 /*                                                                           */
 /* Auth: ??-???-1983, R. Keith Jobe (RKJ)                                    */
 /* Revw:                                                                     */
 /*                                                                           */
 /*---------------------------------------------------------------------------*/
 /*                                                                           */
 /* Mod:  09-May-1993, Tony Gromme (TEG):                                     */
 /*           Made KLYSTATUS.HC from Vax FORTRAN KLYSTATUS.TXT;  eliminated   */
 /*           .H and antecedent .SDL.                                         */
 /*       15-Apr-1992, Keith Jobe                                             */
 /*           Added HSTA_1BEAM for HSTA=200, removed HSTA_MK2.                */
 /*       18-Jan-1991, R. Hall (RDH):                                         */
 /*           Added comment definitions of bits SWRD_LOST_ACC and             */
 /*           SWRD_PHASE_MEAN for use in the display status bits facility.    */
 /*       09-Jan-1990, R. Hall (RDH):                                         */
 /*           Incorporate the contents of files KLYS_HSTA.TXT for use in the  */
 /*           new display status bits facility.                               */
 /*       22-Sep-1989, M. Flores (MICK):                                      */
 /*           Add SWRD_LOST_ACC bit.                                          */
 /*       12-May-1989, R. Hall (RDH):                                         */
 /*           Removed includes of KLYS_HSTA.TXT and KLYS_HDSC.TXT.            */
 /*       13-Apr-1989, R. Hall (RDH):                                         */
 /*           Added bits STAT_PHAS_DRIFT, STAT_AMPL_DRIFT, STAT_AJTN_DRIFT,   */
 /*           and STAT_PJTN to match those added to the micro include file    */
 /*           KLYSTATUS.INC.                                                  */
 /*                                                                           */
 /*===========================================================================*/



 /*  Formatted bit decoding for anyone interested:                        */
 /*                                                                       */
 /* BIT   HSTA(Hdwe Status)    STAT(Status)        SWRD(PIOP Status) BIT  */
 /*                                                                       */
 /* 0001  Hsta online          STAT_okok           BAD CABLE Status  0001 */
 /* 0002  Hsta maintenance     Stat_Maintenance    MKSU Protect      0002 */
 /* 0004  Hsta offline         Stat_Unit Offline   NO Triggers       0004 */
 /* 0008                       Stat_Out of Tol     MODulator Fault   0008 */
 /* 0010  TimingFxup Disabld   Stat_Bad Camac      Lost Acc Triggers 0010 */
 /* 0020  Sled Tune Request    Stat_SWRD Error     LOW RF Power      0020 */
 /* 0040  Pulsed Drive Atten   Dead Man Timeout    AMPL Mean         0040 */
 /* 0080  Pulsed Phase Shftr   Fox Phase Home Err  AMPL Jitter       0080 */
 /* 0100  Equipped with PAD                        LOST Phase        0100 */
 /* 0200  Single Beam Database Phase Mean Out Tol  PHASE Mean        0200 */
 /* 0400  Equipped with MKSU                       PHASE Jitter      0400 */
 /* 0800  ProcessMode Enabld                                         0800 */
 /* 1000  Sled Cavity Presnt   Stat_IPL Required                     1000 */
 /* 2000  Electromagnet Klys                                         2000 */
 /* 4000  Solid State SBST     Stat_Update Req                       4000 */
 /* 8000  AutoSaturateDisabl                       NO AccelerateRate 8000 */
 /*END                                                                    */



#ifndef KLYSTATUS_HC


 /* Hardware Status (HSTA) definitions (for          */
 /* primaries SBST, KLYS, and DKLY):                 */

#define HSTA_NOAUTO_RETIME 0x0010   /* Automatic re-timing is disabled.             */
#define HSTA_SLED_TUNE     0x0020
#define HSTA_PAMPL         0x0040   /* The amplitude is pulsed by a PAU.            */
#define HSTA_PPHAS         0x0080   /* The phase shifter is pulsed by a PAU.        */

#define HSTA_PAD           0x0100   /* There is a phase and amplitude detector.     */
#define HSTA_1BEAM         0x0200   /* Data for database is limited to 1 beam code. */
#define HSTA_MKSU          0x0400
#define HSTA_PROCESS_MODE  0x0800   /* The PIOP will treat every fault as serious.  */

#define HSTA_SLEDED        0x1000   /* There is a SLED cavity for this klystron.    */
#define HSTA_ELECTROMAG    0x2000   /* There is an electromagnet for this klystron. */
#define HSTA_SS_SB         0x4000   /* Solid state subbooster. */
#define HSTA_NOSATURATE    0x8000   /* The ACCEPT PEAK DRIVE function is disabled.  */



 /* Supertype 3 STAT definitions:                    */
 /* STAT bits 0-2 are echoed from HSTA.  STAT bit 3  */
 /* (STAT_SICK) is generated by the micro.  Bits 4-7 */
 /* tell where the source of bit 3 is.               */

#define STAT_BADCAMAC    0x0010
#define STAT_SWRDBITS    0x0020
#define STAT_DMTO        0x0040
#define STAT_BADFOX      0x0080
#define STAT_PHASE_MEAN  0x0200
#define STAT_PHAS_DRIFT  0x0400
#define STAT_AMPL_DRIFT  0x0800
#define STAT_IPL         0x1000
#define STAT_AJTN_DRIFT  0x2000
#define STAT_UPDATE      0x4000
#define STAT_PJTN_DRIFT  0x8000
#define STAT_MASK        0x5000


 /* Status bits for PIOP status word:                */
 /* Note: The following codes are burned into the    */
 /* heart of the PIOP and are not freely changeable; */
 /* they live also in the file SLCPIOP:PIOPSWRD.PNC. */


#define SWRD_SWRD_MASK    0xFFFF

#define SWRD_BADCABLE     0x0001
#define SWRD_MKSU_PROTECT 0x0002
#define SWRD_NOTRIG       0x0004
#define SWRD_MOD_FAULT    0x0008

#define SWRD_LOST_ACC     0x0010
#define SWRD_LOW_RF       0x0020
#define SWRD_AMP_MEAN     0x0040      /* Excessive RF amplitude drift.  */
#define SWRD_AMP_JITT     0x0080      /* Excessive RF amplitude jitter. */

#define SWRD_LOST_PHASE   0x0100
#define SWRD_PHASE_MEAN   0x0200      /* Excessive phase drift.         */
#define SWRD_PHASE_JITT   0x0400      /* Excessive phase jitter.        */

#define SWRD_NO_SAMPLE    0x4000
#define SWRD_STANDBY      0x8000
#define SWRD_SICK_MASK    0x7DFF      /* (Turn "standby" green.)        */
#define SWRD_GOOD_MASK    0x8000

#define KLYSTATUS_HC
#endif


