bpmuti_h

/*
**	Copyright 1991-2017, Fermi Research Alliance, LLC.  All rights reserved.
*/
/******************************************************************************/
/* bpmuti.h
**  
**	function prototypes and defined constants for argument values for
**	BPM access routines
**
*/
/******************************************************************************/

#ifndef BPMUTI_DEFINED			/* do this only once */
#define	BPMUTI_DEFINED

#include "cnsparam.h"
#include "cns_data_structs.h"
#include "tclk_events.h"
#include "machine.h"

/******************************************************************************/
/* 
**	defined constants for argument values
*/
/******************************************************************************/

#define	BPM_PROFILE		0		/* profile frame */
#define	BPM_SNAPSHOT		1		/* snapshot frame */
#define	BPM_FAST_ABORT		1		/* fast abort buffer frame */
#define	BPM_DISPLAY_FRAME	2		/* display frame */
#define	BPM_FLASH		3		/* flash frame */
#define	BPM_RMS_FRAME		4		/* display RMS data frame */
#define	BPM_DISPLAY_RMS_FRAME	4		/* display RMS data frame */
#define	BPM_BACKGROUND_FLASH	5		/* background flash frame */
#define	BPM_DFG_FRAME		6		/* DFG breakpoint closed orbit */
#define	BPM_RF_TEST_FRAME	7		/* RF test frame */
#define	BPM_SNAPSHOT_RMS_FRAME	8		/* snapshot RMS data frame */
#define	BPM_PROFILE_RMS_FRAME	9		/* profile RMS data frame */
#define	BPM_TBT_DATA		10		/* turn by turn data */
#define	BPM_SLOW_ABORT		11		/* slow abort buffer frame */
#define	BPM_SLOW_SNAPSHOT	11		/* slow snapshot frame */
#define	BPM_INJECTION_FRAME	12		/* injection closed orbit frame */
#define	BPM_USER_FRAME		13		/* user triggered closed orbit frame */
#define	BPM_AVERAGED_FRAME	14		/* averaged data frame */
#define	BPM_CALIBRATION_DATA	15		/* calibration data */
#define	BPM_INTEGRATED_LOSS_FRAME	16	/* integrated loss data */

#define	BPM_DIFF_FRAME		0x80		/* difference frame */
#define	BPM_DIFF_MASK		0x7F		/* difference frame indicator mask */

#define	BPM_BLM_MODE_FAST	0		/* BLM fast mode */
#define	BPM_BLM_MODE_SLOW	1		/* BLM slow mode */
#define	BPM_BLM_MODE_VERY_SLOW	2		/* BLM very slow mode */
#define	BPM_BLM_MODE_INTEGRATED	2		/* BLM integrated mode */

#define	BLM_IMMEDIATE_LOSSES	0		/* immediate losses */
#define	BLM_FAST_LOSSES		1		/* fast losses */
#define	BLM_SLOW_LOSSES		2		/* slow losses */
#define	BLM_VERY_SLOW_LOSSES	3		/* very slow losses */
#define	BLM_INTEGRATED_LOSSES	3		/* integrated losses */

#define	BLM_ABORT_ENABLE	1		/* enable the corresponding BLM to generate aborts */
#define	BLM_ABORT_DISABLE	0		/* disable the corresponding BLM from generating aborts */

/* machine names */

#define	BPM_NULL_MACHINE	(-2)			/* null machine */
#define	BPM_ALL_MACHINES	(-1)			/* all machines */
#define	BPM_TEVATRON		0			/* Tevatron */
#define	BPM_SWYD		1			/* Switchyard */
#define	BPM_MAINRING		2			/* Main Ring */
#define	BPM_BOOSTER		3			/* Booster */
#define	BPM_PBAR		4			/* P-bar source */
#define	BPM_400_MEV		5			/* 400 MeV line */
#define	BPM_MAIN_INJECTOR	6			/* Main Injector */
#define	BPM_8_GEV_LINE		7			/* 8 GeV line */
#define	BPM_MI_ABORT_LINE	(MACHINE_MI_ABORT_LINE)	/* Main Injector abort line */
#define	BPM_RECYCLER		(MACHINE_RECYCLER)	/* Recycler */
#define	BPM_R20_LINE		(MACHINE_R20_LINE)	/* R20 line */
#define	BPM_R30_LINE		(MACHINE_R30_LINE)	/* R30 line */
#define	BPM_P1_LINE		100			/* P1 line */
#define	BPM_P2_LINE		101			/* P2 line */
#define	BPM_P3_LINE		(MACHINE_P3_LINE)	/* P3 line */
#define	BPM_A1_LINE		(MACHINE_A1_LINE)	/* A1 line */
#define	BPM_AP1_LINE		(MACHINE_AP1_LINE)	/* AP1 line */
#define	BPM_AP2_LINE		(MACHINE_AP2_LINE)	/* AP2 line */
#define	BPM_AP3_LINE		(MACHINE_AP3_LINE)	/* AP3 line */
#define	BPM_RR_ABORT_LINE	(MACHINE_RR_ABORT_LINE)	/* Recycler abort line */
#define	BPM_DEBUNCHER		(MACHINE_DEBUNCHER)	/* Debuncher */
#define	BPM_ACCUMULATOR		(MACHINE_ACCUMULATOR)	/* Accumulator */
#define	BPM_SWITCHYARD		(MACHINE_SWITCHYARD)	/* Switchyard */
#define	BPM_MINIBOONE		(MACHINE_MINIBOONE)	/* MiniBoone experiment */
#define	BPM_ELECTRON_COOLING	(MACHINE_ELECTRON_COOLING)	/* electron cooling */
#define	BPM_NUMI		(MACHINE_NUMI)		/* NUMI experiment */
#define	BPM_MESON_LINE		(MACHINE_MESON_LINE)	/* Meson line */
#define	BPM_SY_DUMP		(MACHINE_SY_DUMP)	/* SY dump */
#define	BPM_EC_DEVL		102			/* Electron Cooling (development system) */
#define	BPM_RECYCLER_BLT	(MACHINE_RECYCLER + 200)	/* Recycler BLT */
#define	BPM_MI_BLT		(MACHINE_MAIN_INJECTOR + 200)	/* Main Injector BLT */
#define	BPM_TEV_DEVL		(MACHINE_TEVATRON + 300)	/* Tevatron development */
#define	BPM_MI_DEVL		(MACHINE_MAIN_INJECTOR + 300)	/* Main Injector development */
#define	BPM_AP1_LINE_DEVL	(MACHINE_AP1_LINE + 300)	/* AP1 line development */
#define	BPM_CDF			(MACHINE_CDF)		/* CDF experiment */
#define	BPM_RR_DEVL		(MACHINE_RECYCLER + 300)	/* Recycler development */
#define	BPM_D_TO_A_LINE		(MACHINE_D_TO_A_LINE)	/* Pbar debuncher to accumulator line */
#define	BPM_MTA			(MACHINE_MTA)		/* MTA (Muon Test Area) */
#define	BPM_RR_TO_MI_LINE	(MACHINE_RR_TO_MI_LINE)	/* Recycler to Main Injector line */
#define	BPM_MUON_DEVL		(MACHINE_MUON + 300)	/* Muon development */
#define	BPM_DELIVERY_RING	(MACHINE_DELIVERY_RING)	/* Muon delivery ring */
#define	BPM_M1_LINE		(MACHINE_M1_LINE)	/* M1 line */
#define	BPM_M2_LINE		(MACHINE_M2_LINE)	/* M2 line */
#define	BPM_M3_LINE		(MACHINE_M3_LINE)	/* M3 line */
#define	BPM_M4_LINE		(MACHINE_M4_LINE)	/* M4 line */
#define	BPM_M5_LINE		(MACHINE_M5_LINE)	/* M5 line */
#define	BPM_DRING_DEVL		(MACHINE_DELIVERY_RING + 300)	/* Delivery Ring development */

#define	BPM_MODE_BUNCH		0		/* sample in bunch mode */
#define	BPM_MODE_BATCH		1		/* sample in batch mode */
#define	BPM_MODE_PROTON		0		/* sample protons */
#define	BPM_PROTON_DATA		0		/* sample protons */
#define	BPM_MODE_PBAR		1		/* sample p-bars */
#define	BPM_PBAR_DATA		1		/* sample p-bars */
#define	BPM_PLT_OPT_NO_LABELS	0		/* don't want labels */
#define	BPM_PLT_OPT_WANT_LIMITS	0		/* want limits */
#define	BPM_PLT_OPT_WANT_LABELS	1		/* want labels */
#define	BPM_PLT_OPT_SCALED_DATA	0		/* scaled data */
#define	BPM_PLT_OPT_CALIB_DATA	2		/* calibration data */
#define	BPM_PLT_OPT_RAW_DATA	2		/* raw data */
#define	BPM_MODE_NORMAL		0		/* normal plane */
#define	BPM_MODE_ORTHOGONAL	1		/* orthogonal plane */
#define	BPM_MODE_UNKNOWN	-1		/* unknown mode */
#define	BPM_MODE_CURRENT	-2		/* current mode */
#define	BPM_MODE_SLOW		0		/* slow sample */
#define	BPM_MODE_FAST		1		/* fast sample */
#define	BPM_MODE_NO_CALIBRATE	0		/* normal mode */
#define	BPM_MODE_CALIBRATE	1		/* calibration mode */

#define	BPM_HORZ_POS		1		/* horizontal position data */
#define	BPM_VERT_POS		2		/* vertical position data */
#define	BPM_HORZ_INT		3		/* horizontal intensity data */
#define	BPM_VERT_INT		4		/* vertical intensity data */
#define	BPM_LOSS_DATA		5		/* loss monitor data */
#define	BPM_PBAR_HORZ_POS	6		/* pbar horizontal position data */
#define	BPM_PBAR_VERT_POS	7		/* pbar vertical position data */
#define	BPM_PBAR_HORZ_INT	8		/* pbar horizontal intensity data */
#define	BPM_PBAR_VERT_INT	9		/* pbar vertical intensity data */

#define	BPM_NORMAL_TBT_DATA	1		/* normal TBT data */
#define	BPM_INJECTION_TBT_DATA	2		/* injection TBT data */
#define	BPM_ABORT_TBT_DATA	3		/* abort TBT data */

#define	BPM_FIX_THRESH		0		/* specify fixed target threshold */
#define	BPM_COLL_THRESH		1		/* specify collider threshold */
#define	BPM_HEP_THRESH		0		/* specify HEP threshold */
#define	BPM_STUDIES_THRESH	1		/* specify studies threshold */

#define	BPM_OK			0		/* detector status values */
#define	BPM_INVALID		1		/* reading is invalid (under threshold) */
#define	BPM_ABORT		2		/* reading above abort level */
#define	BPM_ALARM		3		/* reading above alarm level */
#define	BPM_ERROR		-1		/* error reading detector */
#define	BPM_UNEQUIPPED		-2		/* detector not equipped */
#define	BPM_SCALING_ERROR	-3		/* scaling error */
#define	BPM_NOT_IN_MODE		-4		/* system is not in the mode to read the requested data */
#define	BPM_NO_DATA		-5		/* requested value was not found */

#define	BPM_GOOD		0		/* detector condition values */
#define	BPM_OUT_OF_SERVICE	1

#define	BPM_HORZ		0		/* horizontal BPMs */
#define	BPM_VERT		1		/* vertical BPMs */

#define	BPM_ELECTRON_BEAM	1		/* electron beam */
#define	BPM_CIRCULATING_BEAM	2		/* circulating beam */

#define	BPM_TITLE_LEN		30		/* length of file titles */

#define	BPM_NO_PROTECT		0		/* file not protected */
#define	BPM_USER_PROTECT	1		/* user level protection */
#define	BPM_MCR_PROTECT		2		/* MCR level protection */

#define	BPM_NOT_REFERENCE	0		/* not a reference file */
#define	BPM_IS_REFERENCE	1		/* reference file */

#define	BPM_ALL_FILES		0		/* display all BPM files in menu */
#define	BPM_PROTECTED_FILES	1		/* display only protected BPM files in menu */
#define	BPM_REFERENCE_FILES	2		/* display only reference BPM files in menu */
#define	BPM_LINKED_FILES	4		/* display only linked BPM files in menu */

#define	BPM_OPT_NONE		0		/* no options selected */
#define	BPM_OPT_TIME_ORDER	2		/* arrange files in chronological order */
#define	BPM_OPT_FILE_TITLE	4		/* show the file name as the title */
#define	BPM_OPT_UNUSED_FILES	8		/* allow selecting unused files */
#define	BPM_OPT_BY_FILE_NUMBER	0x10		/* access files by file number */
#define	BPM_OPT_BEAM_ORDER	0x20		/* return values in beam order */
#define	BPM_OPT_LINKED		0x40		/* include linked files */
#define	BPM_OPT_PROTECTED	0x80		/* include protected files */

#define	BPM_FROM_DATAPOOL	0		/* get BPM data from datapool */
#define	BPM_FROM_SDA		1		/* get BPM data from SDA */
#define	BPM_FROM_JAVA		2		/* get BPM data from a Java OAC */
#define	BPM_FROM_SR		3		/* get BPM data from save/restore */

#define	BPM_PLOT_TYPE_BPM	0
#define	BPM_PLOT_TYPE_BLM	1
#define	BPM_PLOT_TYPE_INTENSITY	2

#define	BPM_VIEW_DEFAULT	0		/* default view (single machine) */
#define	BPM_VIEW_P1		1		/* data view - P1 Line */
#define	BPM_VIEW_P2		2		/* data view - P2 Line */
#define	BPM_VIEW_P3		4		/* data view - P3 Line */
#define	BPM_VIEW_AP1		8		/* data view - AP1 Line */
#define	BPM_VIEW_M1		8		/* data view - M1 Line */
#define	BPM_VIEW_AP2		0x10		/* data view - AP2 Line */
#define	BPM_VIEW_M3		0x10		/* data view - M3 Line */
#define	BPM_VIEW_AP3		0x20		/* data view - AP3 Line */
#define	BPM_VIEW_SY		0x40		/* data view - Switchyard */
#define	BPM_VIEW_P1_ONLY	0		/* data view - P1 Line only */
#define	BPM_VIEW_P2_ONLY	0		/* data view - P2 Line only */
#define	BPM_VIEW_P3_ONLY	0		/* data view - P3 Line only */
#define	BPM_VIEW_P1_P2		(BPM_VIEW_P1 | BPM_VIEW_P2)	/* data view - P1 and P2 lines */
#define	BPM_VIEW_P1_P2_P3	(BPM_VIEW_P1 | BPM_VIEW_P2 | \
				 BPM_VIEW_P3)	/* data view - P1, P2, and P3 lines */
#define	BPM_VIEW_P1_P2_P3_SY	(BPM_VIEW_P1 | BPM_VIEW_P2 | \
				 BPM_VIEW_P3 | BPM_VIEW_SY)	/* data view - P1, P2, and P3 lines and Switchyard */
#define	BPM_VIEW_P1_P2_AP1	(BPM_VIEW_P1 | BPM_VIEW_P2 | \
				 BPM_VIEW_AP1)	/* data view - P1 ,P2, and AP1 lines */
#define	BPM_VIEW_P1_P2_M1	(BPM_VIEW_P1 | BPM_VIEW_P2 | \
				 BPM_VIEW_M1)	/* data view - P1 ,P2, and M1 lines */
#define	BPM_VIEW_P1_P2_AP1_AP3	(BPM_VIEW_P1 | BPM_VIEW_P2 | \
				 BPM_VIEW_AP1 | BPM_VIEW_AP3)	/* data view - P1, P2, AP1, and AP3 lines */
#define	BPM_VIEW_P1_P2_M1_M3	(BPM_VIEW_P1 | BPM_VIEW_P2 | \
				 BPM_VIEW_M1 | BPM_VIEW_M3)	/* data view - P1, P2, M1, and M3 lines */
#define	BPM_VIEW_P1_P2_AP1_AP2	(BPM_VIEW_P1 | BPM_VIEW_P2 | \
				 BPM_VIEW_AP1 | BPM_VIEW_AP2)	/* data view - P1, P2, AP1, and AP2 lines */
#define	BPM_VIEW_AP1_ONLY	0		/* data view - AP1 line only */
#define	BPM_VIEW_AP1_AP2	(BPM_VIEW_AP1 | BPM_VIEW_AP2)	/* data view - AP1 and AP2 lines */
#define	BPM_VIEW_AP1_AP3	(BPM_VIEW_AP1 | BPM_VIEW_AP3)	/* data view - AP1 and AP3 lines */
#define	BPM_VIEW_M1_ONLY	0		/* data view - M1 Line only */
#define	BPM_VIEW_M3_ONLY	0		/* data view - M3 Line only */
#define	BPM_VIEW_M1_M3		(BPM_VIEW_M1 | BPM_VIEW_M3)	/* data view - M1 and M3 lines */
#define	BPM_VIEW_DELIVERY_RING_ONLY	0	/* data view - Delivery Ring only */
#define	BPM_VIEW_M5_ONLY	0		/* data view - M5 Line only */
#define	BPM_VIEW_MI8_TO_MI	0x80		/* data view - MI-8 line to Main Injector */
#define	BPM_VIEW_MI8_TO_RR	0x100		/* data view - MI-8 line to Recycler */
#define	BPM_VIEW_MI8_TO_DUMP	0x200		/* data view - MI-8 line to Booster dump */
#define	BPM_VIEW_P1_FROM_RR	0x400		/* data view - P1 line (from the Recycler) */
#define	BPM_VIEW_P1_P2_FROM_RR	(BPM_VIEW_P1_FROM_RR | BPM_VIEW_P2)	/* data view - P1 and P2 lines (from Recycler) */
#define	BPM_VIEW_P1_P2_M1_FROM_RR	(BPM_VIEW_P1_FROM_RR | BPM_VIEW_P2 | \
					 BPM_VIEW_M1)	/* data view - P1, P2, and M1 lines (from Recycler) */

#define	BPM_PLT_TYP_HV		0		/* Normal - HOR or VER frames */
#define	BPM_PLT_TYP_1P		1		/* 1-Plot - HOR or VER + data text */
#define	BPM_PLT_TYP_2P		2		/* 2-Plot - HOR and VER (Recycler only) */
#define	BPM_PLT_TYP_3P		2		/* 3-Plot - HOR/VER/(LOS/INT) */
#define	BPM_PLT_TYP_4P		3		/* 4-Plot - HOR/VER/RMS (Recycler only) */
#define	BPM_PLT_TYP_HV_DIFF	4		/* Difference - HOR or VER frames */
#define	BPM_PLT_TYP_1P_DIFF	5		/* 1-Plot - HOR or VER + data text */
#define	BPM_PLT_TYP_2P_DIFF	6		/* 2-Plot - HOR and VER (Recycler only) */
#define	BPM_PLT_TYP_3P_DIFF	7		/* 3-Plot - HOR/VER/(LOS/INT) */
#define	BPM_PLT_TYP_4P_DIFF	8		/* 4-Plot - HOR/VER/RMS (Recycler only) */
#define	BPM_PLT_PLN_HZ		0		/* Plot plane - HORZ */
#define	BPM_PLT_PLN_VT		1		/* Plot plane - VERT */
#define	BPM_PLT_PLN_BOTH	2		/* Plot plane - both */
#define	BPM_PLT_PLT_RG		0		/* Plot view - RING */
#define	BPM_PLT_PLT_B0		1		/* Plot view - B0 */
#define	BPM_PLT_PLT_D0		2		/* Plot view - D0 */
#define	BPM_PLT_PLT_LINE	0		/* Plot view - entire line */
#define	BPM_PLT_PLT_MI8_TO_MI	0		/* Plot view - entire MI-8 line to Main Injector */
#define	BPM_PLT_PLT_UPSTM	1		/* Plot view - upstream portion of line */
#define	BPM_PLT_PLT_MI8_TO_DUMP	1		/* Plot view - upstream portion of MI-8 line to the Booster dump */
#define	BPM_PLT_PLT_MI8_TO_RR	2		/* Plot view - entire MI-8 line to Recycler */
#define	BPM_PLT_PLT_P1		1		/* Plot view - P1 line */
#define	BPM_PLT_PLT_P2		2		/* Plot view - P2 line */
#define	BPM_PLT_PLT_P3		4		/* Plot view - P3 line */
#define	BPM_PLT_PLT_AP1		8		/* Plot view - AP1 line */
#define	BPM_PLT_PLT_M1		8		/* Plot view - M1 line */
#define	BPM_PLT_PLT_AP2		0x10		/* Plot view - AP2 line */
#define	BPM_PLT_PLT_M3		0x10		/* Plot view - M3 line */
#define	BPM_PLT_PLT_AP3		0x20		/* Plot view - AP3 line */
#define	BPM_PLT_PLT_SY		0x40		/* Plot view - Switchyard */
#define	BPM_PLT_PLT_SYDMP	0x80		/* Plot view - SY dump line */
#define	BPM_PLT_PLT_MESON	0x100		/* Plot view - Meson line */
#define	BPM_PLT_PLT_P1_ONLY	0		/* Plot view - P1 line only */
#define	BPM_PLT_PLT_P1_P2	(BPM_PLT_PLT_P1 | BPM_PLT_PLT_P2)	/* Plot view - P1 and P2 lines */
#define	BPM_PLT_PLT_P1_P2_P3	(BPM_PLT_PLT_P1 | BPM_PLT_PLT_P2 | \
				 BPM_PLT_PLT_P3)	/* Plot view - P1, P2, and P3 lines */
#define	BPM_PLT_PLT_P1_P2_AP1	(BPM_PLT_PLT_P1 | BPM_PLT_PLT_P2 | \
				 BPM_PLT_PLT_AP1)	/* Plot view - P1 ,P2, and AP1 lines */
#define	BPM_PLT_PLT_P1_P2_M1	(BPM_PLT_PLT_P1 | BPM_PLT_PLT_P2 | \
				 BPM_PLT_PLT_M1)	/* Plot view - P1 ,P2, and M1 lines */
#define	BPM_PLT_PLT_P1_P2_AP1_AP3	(BPM_PLT_PLT_P1 | BPM_PLT_PLT_P2 | \
					 BPM_PLT_PLT_AP1 | BPM_PLT_PLT_AP3)	/* Plot view - P1, P2, AP1, and AP3 lines */
#define	BPM_PLT_PLT_P1_P2_M1_M3	(BPM_PLT_PLT_P1 | BPM_PLT_PLT_P2 | \
				 BPM_PLT_PLT_M1 | BPM_PLT_PLT_M3)	/* Plot view - P1, P2, M1, and M3 lines */
#define	BPM_PLT_PLT_P1_P2_AP1_AP2	(BPM_PLT_PLT_P1 | BPM_PLT_PLT_P2 | \
					 BPM_PLT_PLT_AP1 | BPM_PLT_PLT_AP2)	/* Plot view - P1, P2, AP1, and AP2 lines */
#define	BPM_PLT_PLT_P1_P2_P3_SY	(BPM_PLT_PLT_P1 | BPM_PLT_PLT_P2 | \
				 BPM_PLT_PLT_P3 | BPM_PLT_PLT_SY)	/* Plot view - P1, P2, and P3 lines and SY */
#define	BPM_PLT_PLT_P1_P2_P3_SYDMP	(BPM_PLT_PLT_P1 | BPM_PLT_PLT_P2 | \
				 BPM_PLT_PLT_P3 | BPM_PLT_PLT_SY | \
				 BPM_PLT_PLT_SYDMP)	/* Plot view - P1, P2, and P3 lines and SY to the dump */
#define	BPM_PLT_PLT_P1_P2_P3_MESON	(BPM_PLT_PLT_P1 | BPM_PLT_PLT_P2 | \
				 BPM_PLT_PLT_P3 | BPM_PLT_PLT_SY | \
				 BPM_PLT_PLT_MESON)	/* Plot view - P1, P2, and P3 lines and SY to Meson */
#define	BPM_PLT_PLT_SY_SYDMP	(BPM_PLT_PLT_SY | BPM_PLT_PLT_SYDMP)	/* Plot view - SY to the dump */
#define	BPM_PLT_PLT_SY_MESON	(BPM_PLT_PLT_SY | BPM_PLT_PLT_MESON)	/* Plot view - SY to Meson */
#define	BPM_PLT_PLT_AP1_ONLY	0		/* Plot view - AP1 line only */
#define	BPM_PLT_PLT_AP1_AP2	(BPM_PLT_PLT_AP1 | BPM_PLT_PLT_AP2)	/* Plot view - AP1 and AP2 lines */
#define	BPM_PLT_PLT_AP1_AP3	(BPM_PLT_PLT_AP1 | BPM_PLT_PLT_AP3)	/* Plot view - AP1 and AP3 lines */
#define	BPM_PLT_PLT_M1_ONLY	0		/* Plot view - M1 line only */
#define	BPM_PLT_PLT_M1_M3	(BPM_PLT_PLT_M1 | BPM_PLT_PLT_M3)	/* Plot view - M1 and M3 lines */
#define	BPM_PLT_PLT_M3_ONLY	0		/* Plot view - M3 line only */
#define	BPM_PLT_PLT_RR_ALL	0		/* Plot view - all detectors (Recycler) */
#define	BPM_PLT_PLT_RR_PLANE	1		/* Plot view - detectors from one plane (Recycler) */
#define	BPM_PLT_PLT_EC_ELECTRON	1		/* Plot view - Electron Cooling electrons only */
#define	BPM_PLT_PLT_EC_CIRC	2		/* Plot view - Electron Cooling circulating beam only */
#define	BPM_PLT_PLT_EC_BOTH	(BPM_PLT_PLT_EC_ELECTRON | \
				 BPM_PLT_PLT_EC_CIRC)	/* Plot view - Electron Cooling both beams */
#define	BPM_PLT_PLT_EC_PULSE	4		/* Plot view - Electron Cooling electron pulse mode only */
#define	BPM_PLT_SCR_G1		0		/* Plot screen - GxP1 (LEX) */
#define	BPM_PLT_SCR_G2		1		/* Plot screen - GxP2 (614) */
#define	BPM_PLT_DSP_NM		0		/* Plot display - normal */
#define	BPM_PLT_DSP_CN		1		/* Plot display - connected */
#define	BPM_PLT_DSP_FL		2		/* Plot display - filled */
#define	BPM_PLT_DSP_NMC		3		/* Plot display - normal (continuous) */
#define	BPM_PLT_DSP_CNC		4		/* Plot display - connected (continuous) */
#define	BPM_PLT_DSP_FLC		5		/* Plot display - filled (continuous) */
#define	BPM_PLT_DSP_NMR		8		/* Plot display - normal (refreshing) */
#define	BPM_PLT_DSP_CNR		9		/* Plot display - connected (refreshing) */
#define	BPM_PLT_DSP_FLR		10		/* Plot display - filled (refreshing) */
#define	BPM_PLT_DSP_NMO		11		/* Plot display - normal (overlay) */
#define	BPM_PLT_DSP_CNO		12		/* Plot display - connected (overlay) */
#define	BPM_PLT_DSP_FLO		13		/* Plot display - filled (overlay) */

#define	BPM_PLT_AUX_LS		0		/* Plot aux type - loss */
#define	BPM_PLT_AUX_IN		1		/* Plot aux type - intensity */
#define	BPM_PLT_AUX_RMS		2		/* Plot aux type - RMS */

#define	BPM_MAX_TRACES_PER_WINDOW	2	/* maximum number of traces per plot window */

typedef struct BPM_PLOT_POINT_DATA
    {
    char	name[DEVICE_NAME_LEN+2];
    int		error;
    float	x_value;
    float	y_value;
    int		crate_number;
    int		channel_number;
    } BPM_PLOT_POINT_DATA;

typedef struct BPM_PLOT_WINDOW_DATA
    {
    int		window_id;
    int		screen;
    int		machine;
    int		frame_type;
    int		plot_type;
    int		data_type;
    int		particle_type;
    int		plane;
    int		plot_view;
    int		frame_number;
    int		num_machines;
    float	time_in_cycle;
    int		turn_number;
    unsigned int	timestamp;
    int		num_values[BPM_MAX_TRACES_PER_WINDOW];
    int		max_values[BPM_MAX_TRACES_PER_WINDOW];
    BPM_PLOT_POINT_DATA	*points[BPM_MAX_TRACES_PER_WINDOW];
    } BPM_PLOT_WINDOW_DATA;

/* measurement type definitions */
#define	BPM_MT_RR_BKGD_FLASH	0		/* Recycler background flash measurement */
#define	BPM_MT_RR_REPETITIVE	0		/* Recycler repetitive measurement */
#define	BPM_MT_RR_REPETITIVE_SINGLE	0	/* Recycler repetitive single gate measurement */
#define	BPM_MT_RR_TBT		1		/* Recycler one shot turn by turn measurement */
#define	BPM_MT_RR_ONESHOT_MULTIPLE	1	/* Recycler one shot multiple gate measurement */
#define	BPM_MT_RR_ONESHOT_SINGLE	2	/* Recycler one shot single gate measurement */
#define	BPM_MT_RR_PREARM	3		/* Recycler prearm measurement */
#define	BPM_MT_RR_TIMING_SCAN	4		/* Recycler timing scan measurement */
#define	BPM_MT_RR_PERIODIC_TBT	5		/* Recycler periodic turn by turn measurement */

/* beam mode definitions */
#define	BPM_BMD_RR_PBAR		0		/* Recycler pbar beam mode */
#define	BPM_BMD_RR_PROTON	1		/* Recycler proton beam mode */

/* beam type definitions */
#define	BPM_BT_RR_INJECT_EXTRACT	0	/* Recycler injection/extraction beam */
#define	BPM_BT_RR_HOT		1		/* Recycler hot beam */
#define	BPM_BT_RR_HOT_HEAD	2		/* Recycler hot head beam */
#define	BPM_BT_RR_HOT_TAIL	3		/* Recycler hot tail beam */
#define	BPM_BT_RR_COLD		4		/* Recycler cold beam */
#define	BPM_BT_RR_COLD_HEAD	5		/* Recycler cold head beam */
#define	BPM_BT_RR_COLD_TAIL	6		/* Recycler cold tail beam */

/* data type definitions */
#define	BPM_DT_RR_DEFAULT	0		/* Recycler default data */
#define	BPM_DT_RR_BUNCHED	0		/* Recycler bunched data */
#define	BPM_DT_RR_BUNCH_1	1		/* Recycler bunch 1 data */
#define	BPM_DT_RR_BUNCH_2	2		/* Recycler bunch 2 data */
#define	BPM_DT_RR_BUNCH_3	3		/* Recycler bunch 3 data */
#define	BPM_DT_RR_BUNCH_4	4		/* Recycler bunch 4 data */
#define	BPM_DT_RR_HOT		0		/* Recycler hot beam data */
#define	BPM_DT_RR_HOT_HEAD	0		/* Recycler hot head beam data */
#define	BPM_DT_RR_HOT_TAIL	0		/* Recycler hot tail beam data */
#define	BPM_DT_RR_COLD		0		/* Recycler cold beam data */
#define	BPM_DT_RR_COLD_HEAD	0		/* Recycler cold head beam data */
#define	BPM_DT_RR_COLD_TAIL	0		/* Recycler cold tail beam data */

#define	BPM_DT_NUMI_BATCH_AVG	0		/* NuMI batch average data */
#define	BPM_DT_NUMI_BATCH_1	1		/* NuMI batch 1 data */
#define	BPM_DT_NUMI_BATCH_2	2		/* NuMI batch 2 data */
#define	BPM_DT_NUMI_BATCH_3	3		/* NuMI batch 3 data */
#define	BPM_DT_NUMI_BATCH_4	4		/* NuMI batch 4 data */
#define	BPM_DT_NUMI_BATCH_5	5		/* NuMI batch 5 data */
#define	BPM_DT_NUMI_BATCH_6	6		/* NuMI batch 6 data */

#define	BPM_DT_EC_CIRCULATING	0		/* Electron Cooling circulating beam only */
#define	BPM_DT_EC_ELECTRON	1		/* Electron Cooling electron beam only */
#define	BPM_DT_EC_BOTH		2		/* Electron Cooling both circulating and electron beams */
#define	BPM_DT_EC_PULSE		3		/* Electron Cooling pulse data */

/* beam measurement definitions */
#define	BPM_BM_RR_2_5MHZ_BUNCH_ALL_WB	0	/* Recycler 2.5 MHz bunched beam (WB) */
#define	BPM_BM_RR_2_5MHZ_BUNCH_WB	1	/* Recycler 2.5 MHz single bunch (WB) */
#define	BPM_BM_RR_2_5MHZ_BUNCH_BY_BUNCH	1	/* Recycler 2.5 MHz single bunch (WB) */
#define	BPM_BM_RR_2_5MHZ_BUNCH_ALL_NB	2	/* Recycler 2.5 MHz bunched beam (NB) */
#define	BPM_BM_RR_UNBUNCHED_ALL_WB	3	/* Recycler unbunched beam (WB) */
#define	BPM_BM_RR_UNBUNCHED_WB	4		/* Recycler unbunched beam (WB) (head or tail) */
#define	BPM_BM_RR_UNBUNCHED_HEAD_TAIL	4	/* Recycler unbunched beam (WB) (head or tail) */
#define	BPM_BM_RR_UNBUNCHED_ALL_NB	5	/* Recycler unbunched beam (NB) */
#define	BPM_BM_RR_89_KHZ_NB	5		/* Recycler unbunched beam (NB) */
#define	BPM_BM_RR_COUNT		6		/* Recycler count */
#define	BPM_BM_RR_RAW		7		/* Recycler raw */
#define	BPM_BM_RR_RAW_LONG	8		/* Recycler raw long */

/* measurement mode definitions */
#define	BPM_MM_TEV_NORMAL	0		/* normal data acquisition mode */
#define	BPM_MM_TEV_CALIBRATION	1		/* calibration mode */
#define	BPM_MM_TEV_USER_DEFINED	2		/* user defined mode */

/* measurement resolution definitions */
#define	BPM_MR_EC_HIGH			0	/* Electron Cooling high resolution measurement */
#define	BPM_MR_EC_DONT_CARE		0	/* Electron Cooling no resolution specification */
#define	BPM_MR_EC_LOW			1	/* Electron Cooling low resolution measurement */

/* arm event definitions */
#define	BPM_ARM_EVENT_RR_INTERACTIVE	0x100	/* Recycler interactive arm event */
#define	BPM_ARM_EVENT_RR_AUTOMATIC	0x100	/* Recycler interactive arm event */
#define	BPM_ARM_EVENT_RR_PERIODIC	0x101	/* Recycler periodic arm event */

/* trigger event definitions */
#define	BPM_TRIG_EVENT_RR_PERIODIC	0x100	/* Recycler periodic trigger event */
#define	BPM_TRIG_EVENT_RR_EXTERNAL	0x101	/* Recycler external trigger event */

/* trigger delay definitions */
#define	BPM_MIN_TRIG_DELAY_RR	0		/* Recycler minimum trigger delay (turns) */
#define	BPM_MAX_TRIG_DELAY_RR	1023		/* Recycler maximum trigger delay (turns) */

/* bucket delay definitions */
#define	BPM_MIN_BUCKET_DELAY_RR	0		/* Recycler minimum RF bucket delay (buckets) */
#define	BPM_MAX_BUCKET_DELAY_RR	588		/* Recycler maximum RF bucket delay (buckets) */

/* timeout definitions */
#define	BPM_MIN_TIMEOUT_RR	0		/* Recycler minimum measurement timeout (seconds) */
#define	BPM_MAX_TIMEOUT_RR	300		/* Recycler maximum measurement timeour (seconds) */

/* event index definitions */
#define	BPM_EI_INTERACTIVE	0		/* interactive event index */
#define	BPM_EI_PERIODIC		1		/* periodic event index */
#define	BPM_EI_REPETITIVE	1		/* periodic event index */

#define	BPM_EI_MAX_NUM_ENTRIES	16		/* maximum number of event index entries per system */

/* Recycler, R20 line, R30 line */
#define	BPM_EI_INTERACTIVE_RR	0		/* Recycler interactive event index */
#define	BPM_EI_PERIODIC_RR	1		/* Recycler periodic event index */
#define	BPM_EI_REPETITIVE_RR	1		/* Recycler periodic event index */
#define	BPM_EI_MI_P_TO_RR_RR	2		/* Recycler MI protons to Recycler event index */
#define	BPM_EI_MI_PB_TO_RR_RR	3		/* Recycler MI pbars to Recycler event index */
#define	BPM_EI_RR_P_TO_MI_RR	4		/* Recycler protons to Main Injector event index */
#define	BPM_EI_RR_PB_TO_MI_RR	5		/* Recycler pbars to Main Injector event index */
#define	BPM_EI_RR_P_TO_ACC_RR	6		/* Recycler protons to Accumulator event index */
#define	BPM_EI_ACC_PB_TO_RR_RR	7		/* Accumulator pbars to Recycler event index */
#define	BPM_EI_USER_1_RR	8		/* user defined 1 event index */
#define	BPM_EI_USER_2_RR	9		/* user defined 2 event index */
#define	BPM_EI_USER_3_RR	10		/* user defined 3 event index */
#define	BPM_EI_USER_4_RR	11		/* user defined 4 event index */
#define	BPM_EI_USER_5_RR	12		/* user defined 5 event index */
#define	BPM_EI_USER_6_RR	13		/* user defined 6 event index */
#define	BPM_EI_USER_7_RR	14		/* user defined 7 event index */
#define	BPM_EI_USER_8_RR	15		/* user defined 8 event index */

#define	BPM_EI_MAX_RR		(BPM_EI_USER_8_RR)	/* maximum Recycler event index */

/* Recycler abort line */
#define	BPM_EI_INTERACTIVE_RRABRT	0	/* Recycler abort line interactive event index */
#define	BPM_EI_TEST_RRABRT		1	/* Recycler abort line test event index */
#define	BPM_EI_MOST_RECENT_RRABRT	16	/* Recycler abort line most recent good measurement event index */

#define	BPM_EI_MAX_RRABRT		(BPM_EI_TEST_RRABRT)	/* maximum Recycler abort line event index */

/* Recycler BLT */
#define	BPM_EI_INTERACTIVE_RRBLT	0	/* Recycler BLT interactive event index */
#define	BPM_EI_PERIODIC_RRBLT		1	/* Recycler BLT periodic event index */
#define	BPM_EI_REPETITIVE_RRBLT		1	/* Recycler BLT periodic event index */
#define	BPM_EI_MI_P_TO_RR_RRBLT		2	/* Recycler BLT MI protons to Recycler event index */
#define	BPM_EI_MI_PB_TO_RR_RRBLT	3	/* Recycler BLT MI pbars to Recycler event index */
#define	BPM_EI_RR_P_TO_MI_RRBLT		4	/* Recycler BLT protons to Main Injector event index */
#define	BPM_EI_RR_PB_TO_MI_RRBLT	5	/* Recycler BLT pbars to Main Injector event index */
#define	BPM_EI_RR_P_TO_ACC_RRBLT	6	/* Recycler BLT protons to Accumulator event index */
#define	BPM_EI_ACC_PB_TO_RR_RRBLT	7	/* Recycler BLT accumulator pbars to Recycler event index */

#define	BPM_EI_MAX_RRBLT	(BPM_EI_ACC_PB_TO_RR_RRBLT)	/* maximum Recycler BLT event index */

/* Main Injector BLT */
#define	BPM_EI_INTERACTIVE_MIBLT	0	/* MI BLT interactive event index */
#define	BPM_EI_PERIODIC_MIBLT		1	/* MI BLT periodic event index */
#define	BPM_EI_REPETITIVE_MIBLT		1	/* MI BLT periodic event index */
#define	BPM_EI_RR_P_TO_MI_MIBLT		2	/* MI BLT Recycler protons to Main Injector event index */
#define	BPM_EI_RR_PB_TO_MI_MIBLT	3	/* MI BLT Recycler pbars to Main Injector event index */
#define	BPM_EI_ACC_PB_TO_RR_MIBLT	4	/* MI BLT Accumulator pbars through Main Injector to Recycler event index */
#define	BPM_EI_ACC_PB_TO_TEV_MIBLT	5	/* MI BLT Accumulator pbars through Main Injector to Tevatron event index */
#define	BPM_EI_ACC_PB_TO_MI_PRE_MIBLT	15	/* MI BLT Accumulator pbars to Main Injector prearm event index */

#define	BPM_EI_MAX_MIBLT		(BPM_EI_ACC_PB_TO_MI_PRE_MIBLT)	/* maximum Main Injector BLT event index */

/* MI-8 Line */
#define	BPM_EI_BOOSTER_MI8		0	/* most recent or all Booster cycle event index */
#define	BPM_EI_RESET_13_MI8		1	/* reset event $13 event index */
#define	BPM_EI_RESET_14_MI8		2	/* reset event $14 event index */
#define	BPM_EI_RESET_15_MI8		3	/* reset event $15 event index */
#define	BPM_EI_RESET_16_MI8		4	/* reset event $16 event index */
#define	BPM_EI_RESET_17_MI8		5	/* reset event $17 event index */
#define	BPM_EI_RESET_19_MI8		6	/* reset event $19 event index */
#define	BPM_EI_RESET_1C_MI8		7	/* reset event $1C event index */
#define	BPM_EI_RESET_1D_MI8		8	/* reset event $1D event index */
#define	BPM_EI_RESERVED_MI8		9	/* reserved event index */

#define	BPM_EI_MAX_MI8		(BPM_EI_RESERVED_MI8)	/* maximum MI-8 Line event index */

/* P1 line */
#define	BPM_EI_INTERACTIVE_P1		0	/* P1 interactive event index */
#define	BPM_EI_TEST_P1			1	/* P1 test event index */
#define	BPM_EI_RR_TO_MUON_P1		2	/* P1 Recycler to Muon event index */
#define	BPM_EI_MI_8P_TO_ACC_P1		2	/* P1 MI 8 GeV protons to Accumulator event index */
#define	BPM_EI_ACC_8P_TO_MI_P1		3	/* P1 Accumulator 8 GeV protons to MI event index */
#define	BPM_EI_MI_120P_TO_TGT_P1	4	/* P1 MI 120 GeV protons to target event index */
#define	BPM_EI_MI_150P_TO_TEV_P1	5	/* P1 MI 150 GeV protons to Tevatron event index */
#define	BPM_EI_TEV_150P_TO_MI_P1	6	/* P1 Tevatron 150 GeV protons to MI event index */
#define	BPM_EI_MI_150PB_TO_TEV_P1	7	/* P1 MI 150 GeV pbars to Tevatron event index */
#define	BPM_EI_120_GEV_SWYD_P1		8	/* P1 120 GeV to Switchyard event index */

#define	BPM_EI_MAX_P1		(BPM_EI_120_GEV_SWYD_P1)	/* maximum P1 line event index */

/* P2 line */
#define	BPM_EI_INTERACTIVE_P2		0	/* P2 interactive event index */
#define	BPM_EI_TEST_P2			1	/* P2 test event index */
#define	BPM_EI_RR_TO_MUON_P2		2	/* P2 Recycler to Muon event index */
#define	BPM_EI_MI_8P_TO_ACC_P2		2	/* P2 MI 8 GeV protons to Accumulator event index */
#define	BPM_EI_ACC_8P_TO_MI_P2		3	/* P2 Accumulator 8 GeV protons to MI event index */
#define	BPM_EI_MI_120P_TO_TGT_P2	4	/* P2 MI 120 GeV protons to target event index */
#define	BPM_EI_MI_150P_TO_TEV_P2	5	/* P2 MI 150 GeV protons to Tevatron event index */
#define	BPM_EI_TEV_150P_TO_MI_P2	6	/* P2 Tevatron 150 GeV protons to MI event index */
#define	BPM_EI_MI_150PB_TO_TEV_P2	7	/* P2 MI 150 GeV pbars to Tevatron event index */
#define	BPM_EI_120_GEV_SWYD_P2		8	/* P2 120 GeV to Switchyard event index */

#define	BPM_EI_MAX_P2		(BPM_EI_120_GEV_SWYD_P2)	/* maximum P2 line event index */

/* A1 line */
#define	BPM_EI_INTERACTIVE_A1		0	/* A1 interactive event index */
#define	BPM_EI_TEST_A1			1	/* A1 test event index */
#define	BPM_EI_MI_8P_TO_ACC_A1		2	/* A1 MI 8 GeV protons to Accumulator event index */
#define	BPM_EI_ACC_8P_TO_MI_A1		3	/* A1 Accumulator 8 GeV protons to MI event index */
#define	BPM_EI_MI_120P_TO_TGT_A1	4	/* A1 MI 120 GeV protons to target event index */
#define	BPM_EI_MI_150P_TO_TEV_A1	5	/* A1 MI 150 GeV protons to Tevatron event index */
#define	BPM_EI_TEV_150P_TO_MI_A1	6	/* A1 Tevatron 150 GeV protons to MI event index */
#define	BPM_EI_MI_150PB_TO_TEV_A1	7	/* A1 MI 150 GeV pbars to Tevatron event index */

#define	BPM_EI_MAX_A1		(BPM_EI_MI_150PB_TO_TEV_A1)	/* maximum A1 line event index */

/* NuMI */
#define	BPM_EI_INTERACTIVE_NUMI		0	/* NuMI interactive event index */
#define	BPM_EI_PERIODIC_NUMI		1	/* NuMI periodic event index */
#define	BPM_EI_REPETITIVE_NUMI		1	/* NuMI periodic event index */
#define	BPM_EI_MI_P_TO_NUMI		2	/* NuMI MI protons to NuMI event index */

#define	BPM_EI_MAX_NUMI		(BPM_EI_MI_P_TO_NUMI)	/* maximum NuMI event index */

/* beamline */
#define	BPM_EI_INTERACTIVE_BL		0	/* beamline interactive event index */
#define	BPM_EI_PERIODIC_BL		1	/* beamline periodic event index */
#define	BPM_EI_REPETITIVE_BL		1	/* beamline periodic event index */
#define	BPM_EI_TEST_BL			1	/* beamline test event index */

#define	BPM_EI_MAX_BL		(BPM_EI_TEST_BL)	/* maximum beamline event index */

/* Main Injector abort line */
#define	BPM_EI_INTERACTIVE_MIABRT	0	/* MI abort line interactive event index */
#define	BPM_EI_TEST_MIABRT		1	/* MI abort line test event index */
#define	BPM_EI_MI_8P_TO_ACC_MIABRT	2	/* MI abort line MI 8 GeV protons to Accumulator event index */
#define	BPM_EI_ACC_8P_TO_MI_MIABRT	3	/* MI abort line Accumulator 8 GeV protons to MI event index */
#define	BPM_EI_MI_120P_TO_TGT_MIABRT	4	/* MI abort line MI 120 GeV protons to target event index */
#define	BPM_EI_MI_150P_TO_TEV_MIABRT	5	/* MI abort line MI 150 GeV protons to Tevatron event index */
#define	BPM_EI_TEV_150P_TO_MI_MIABRT	6	/* MI abort line Tevatron 150 GeV protons to MI event index */
#define	BPM_EI_MI_150PB_TO_TEV_MIABRT	7	/* MI abort line MI 150 GeV pbars to Tevatron event index */
#define	BPM_EI_MOST_RECENT_MIABRT	16	/* MI abort line most recent good measurement event index */

#define	BPM_EI_MAX_MIABRT		(BPM_EI_MI_150PB_TO_TEV_MIABRT)	/* maximum MI abort line event index */

/* AP1 line */
#define	BPM_EI_INTERACTIVE_AP1	0		/* AP1 interactive event index */
#define	BPM_EI_TEST_AP1		1		/* AP1 test event index */
#define	BPM_EI_MI_8P_TO_ACC_AP1	2		/* AP1 MI 8 GeV protons to Accumulator event index */
#define	BPM_EI_ACC_8P_TO_MI_AP1	3		/* AP1 Accumulator 8 GeV protons to MI event index */
#define	BPM_EI_MI_120P_TO_TGT_AP1	4	/* AP1 MI 120 GeV protons to target event index */
#define	BPM_EI_MI_150P_TO_TEV_AP1	5	/* AP1 MI 150 GeV protons to Tevatron event index */
#define	BPM_EI_TEV_150P_TO_MI_AP1	6	/* AP1 Tevatron 150 GeV protons to MI event index */
#define	BPM_EI_MI_150PB_TO_TEV_AP1	7	/* AP1 MI 150 GeV pbars to Tevatron event index */

#define	BPM_EI_MAX_AP1		(BPM_EI_MI_150PB_TO_TEV_AP1)	/* maximum AP1 line event index */

/* AP3 line */
#define	BPM_EI_INTERACTIVE_AP3	0		/* AP3 interactive event index */
#define	BPM_EI_TEST_AP3		1		/* AP3 test event index */
#define	BPM_EI_MI_8P_TO_ACC_AP3	2		/* AP3 MI 8 GeV protons to Accumulator event index */
#define	BPM_EI_ACC_8P_TO_MI_AP3	3		/* AP3 Accumulator 8 GeV protons to MI event index */
#define	BPM_EI_MI_120P_TO_TGT_AP3	4	/* AP3 MI 120 GeV protons to target event index */
#define	BPM_EI_MI_150P_TO_TEV_AP3	5	/* AP3 MI 150 GeV protons to Tevatron event index */
#define	BPM_EI_TEV_150P_TO_MI_AP3	6	/* AP3 Tevatron 150 GeV protons to MI event index */
#define	BPM_EI_MI_150PB_TO_TEV_AP3	7	/* AP3 MI 150 GeV pbars to Tevatron event index */

#define	BPM_EI_MAX_AP3		(BPM_EI_MI_150PB_TO_TEV_AP3)	/* maximum AP3 line event index */

/* Electron Cooling */
#define	BPM_EI_NONE_EC		0		/* null event index for Electron Cooling */

#define	BPM_EI_MAX_EC		(BPM_EI_NONE_EC)	/* maximum Electron Cooling event index */

/* M1 line */
#define	BPM_EI_INTERACTIVE_M1		0	/* M1 interactive event index */
#define	BPM_EI_TEST_M1			1	/* M1 test event index */
#define	BPM_EI_RR_TO_MUON_M1		2	/* M1 Recycler to Muon event index */

#define	BPM_EI_MAX_M1	(BPM_EI_RR_TO_MUON_M1)	/* maximum M1 Line event index */

/* M3 line */
#define	BPM_EI_INTERACTIVE_M3		0	/* M3 interactive event index */
#define	BPM_EI_TEST_M3			1	/* M3 test event index */
#define	BPM_EI_RR_TO_MUON_M3		2	/* M3 Recycler to Muon event index */

#define	BPM_EI_MAX_M3	(BPM_EI_RR_TO_MUON_M3)	/* maximum M3 Line event index */

#define	BPM_EI_MAX_DRING		15	/* maximum Delivery Ring event index */

/* calibration type definitions */
#define	BPM_CAL_RECYCLER	0		/* Recycler calibration type */
#define	BPM_CAL_BEAMLINE	0x10		/* beam line calibration type */
#define	BPM_CAL_EIGHT_GEV	0x10		/* MI-8 line calibration type */

/* calibration amplitude definitions */
#define	BPM_CALIBRATION_OFF_RR	0		/* Recycler calibration level off */
#define	BPM_CALIBRATION_LOW_RR	1		/* Recycler calibration level low (+/- 0.15 Vpp) */
#define	BPM_CALIBRATION_MEDIUM_RR	2	/* Recycler calibration level medium (+/- 0.38 Vpp) */
#define	BPM_CALIBRATION_HIGH_RR	1		/* Recycler calibration level high (+/- 0.75 Vpp) */

/* calibration waveform definitions */
#define	BPM_CAL_WF_BUNCHED_RR	0		/* Recycler bunched calibration waveform */
#define	BPM_CAL_WF_DEBUNCHED_RR	1		/* Recycler debunched calibration waveform */
#define	BPM_CAL_WF_BOTH_RR	2		/* Recycler bunched and debunched calibration waveforms */

/* calibration balance definitions */
#define	BPM_CAL_DISABLED_RR	0		/* Recycler calibration disabled */
#define	BPM_CAL_BALANCED_RR	1		/* Recycler balanced calibration */
#define	BPM_CAL_UNBALANCED_RR	2		/* Recycler unbalanced calibration */

/* calibration control definitions */
#define	BPM_CAL_DISABLED_NUMI	0		/* NuMI calibration disabled */
#define	BPM_CAL_A_ONLY_NUMI	1		/* NuMI calibration select A only */
#define	BPM_CAL_A_GT_B_NUMI	2		/* NuMI balance A>B */
#define	BPM_CAL_A_EQ_B_NUMI	3		/* NuMI balance A=B */
#define	BPM_CAL_A_LT_B_NUMI	4		/* NuMI balance A<B */
#define	BPM_CAL_B_ONLY_NUMI	5		/* NuMI calibration select B only */

/* calibration frequency definitions */
#define	BPM_CAL_53_NUMI		0		/* NuMI calibration 53 MHz */
#define	BPM_CAL_2_5_NUMI	1		/* NuMI calibration 2.5 MHz */

/* calibration control definitions */
#define	BPM_CAL_DISABLED_BL	0		/* beamline calibration disabled */
#define	BPM_CAL_A_GT_B_BL	1		/* beamline balance A>B */
#define	BPM_CAL_A_EQ_B_BL	2		/* beamline balance A=B */
#define	BPM_CAL_A_LT_B_BL	3		/* beamline balance A<B */
#define	BPM_CAL_DISABLED_MI8	0		/* beamline calibration disabled */
#define	BPM_CAL_A_GT_B_MI8	1		/* beamline balance A>B */
#define	BPM_CAL_A_EQ_B_MI8	2		/* beamline balance A=B */
#define	BPM_CAL_A_LT_B_MI8	3		/* beamline balance A<B */
#define	BPM_CAL_DISABLED_DRING	0		/* Delivery Ring calibration disabled */
#define	BPM_CAL_BALANCED_DRING	1		/* Delivery Ring calibration balanced */
#define	BPM_CAL_UNBALANCED_DRING	2	/* Delivery Ring calibration unbalanced */

/* calibration mode definitions */
#define	BPM_CAL_CONTINUOUS_BL	0		/* beamline continuous calibration */
#define	BPM_CAL_PULSE_BL	1		/* beamline pulse calibration */
#define	BPM_CAL_CONTINUOUS_MI8	0		/* beamline continuous calibration */
#define	BPM_CAL_PULSE_MI8	1		/* beamline pulse calibration */

/* calibration system type definitions */
#define	BPM_CAL_TYPE_RECYCLER	0		/* system type is Recycler */
#define	BPM_CAL_TYPE_NUMI	0x10		/* system type is NuMI */
#define	BPM_CAL_TYPE_BL		0x20		/* system type is beamline (rapid transfer) */
#define	BPM_CAL_TYPE_MI8	0x20		/* system type is MI-8 line */

#define	BPM_NEXT_HOUSE		0		/* access next house */
#define	BPM_PREVIOUS_HOUSE	1		/* access previous house */

#define	BPM_ALL_HOUSES		0		/* access all houses */
#define	BPM_BOOSTER_HOUSES	3		/* access Booster houses only */
#define	BPM_400_MEV_HOUSES	5		/* access 400 MeV line houses only */

#define	BPM_UNKNOWN_HOUSE	-1		/* unknown house type */

#define	BPM_MAX_CRATES		32		/* maximum number of BPM crates per system */

#define	BPM_DAWN_CRATE		1		/* BPM system is in Dawn crate */
#define	BPM_WIENER_CRATE	2		/* BPM system is in Wiener crate */

#define	BPM_DWNLD_FILE_LEN	23		/* length of a BPM download file name (not including '.dat') */

#define	BPM_CRATE_NAME_LEN	6		/* length of a crate name */

#define	BPM_TBT_NAME_LEN	4		/* number of characters in a turn by turn detector name */
#define	BPM_NUM_TBT_VALUES	1024		/* number of turn by turn data values */
#define	BPM_MAX_TBT_VALUES	8192		/* maximum number of turn by turn data values */

#define	BPM_MAX_TBT_TIMES	5		/* maximum number of global turn by turn timers */

#define	BPM_TBT_BAD_POSITION	(-1000.0)	/* indicator for bad turn by turn position data */
#define	BPM_TBT_BAD_INTENSITY	(-1000.0)	/* indicator for bad turn by turn intensity data */
#define	BPM_TBT_BAD_TIMESTAMP	(-1)		/* indicator for bad turn by turn timestamp data */

#define	BPM_TBT_TRIGGERED	0		/* turn by turn triggered mode */
#define	BPM_TBT_CIRCULAR_BUFFER	(-1)		/* turn by turn circular buffer mode */

#define	BLM_TBT_NAME_LEN	(DEVICE_NAME_LEN)	/* number of characters in a turn by turn BLM name */

#define	BPM_NUM_RAW_MODE_VALUES	2048		/* number of raw mode turn by turn data values */
#define	BPM_MAX_RAW_MODE_VALUES	2048		/* maximum number of raw mode turn by turn data values */
#define	BPM_RAW_MODE_BAD_TIMESTAMP	(-1)	/* indicator for bad raw mode turn by turn timestamp data */

#define	BPM_MAX_BPMS_PER_FRAME	422		/* maximum number of BPMs per frame */
#define	BPM_MAX_BLMS_PER_FRAME	300		/* maximum number of BLMs per frame */

#define	BPM_ENTRIES_PER_FILE	1000		/* maximum number of files per logical file */

#define	BPM_ENTIRE_DIRECTORY	(-1)		/* want entire directory */

#define	BPM_MASTER_FILE_NAME_LEN	80	/* maximum length of a BPM master file name */

#define	BPM_MAX_TIMING_PARAMS	6		/* maximum number of supported timing parameters */

#define	BPM_ATTR_CALIB_DATA	1		/* data is calibration data */

#define	BPM_EVENT_SPEC_NAME_LEN	32		/* length of an event specification name */

#define	BPM_FILTER_NAME_LEN	32		/* length of a filter name */

#define	BPM_MAX_NUM_FILTERS	30		/* maximum number of filters per system */

#define	BPM_MAP_TO_DETECTOR	0		/* return the data mapped to the corresponding BPM data location */
#define	BPM_MAP_SIMPLE		1		/* return data in simple linear mapping */

typedef struct BPM_SAVE_INFO			/* BPM save info structure */
    {
    char	title[BPM_TITLE_LEN];		/* ASCII file name */
    int		record;				/* record number to save data */
    int		data_type;			/* type of BPM data */
    int		particle_type;			/* type of particle */
    int		start_frame;			/* starting frame number */
    int		num_frames;			/* number of frames stored */
    unsigned int	timestamp;		/* time data was taken */
    int		lattice;			/* lattice in use when data was taken */
    int		protect;			/* file protection */
    int		bunch_batch;			/* bunch/batch mode */
    int		beam_event;			/* beam event on which data was taken */
    int		scaled_data;			/* scaled data flag */
    int		algorithm;			/* scaling algorithm */
    int		orthogonal_data;		/* orthogonal data included? */
    int		num_timing_params;		/* number of timing parameters */
    int		timing_params[BPM_MAX_TIMING_PARAMS];	/* timing parameters */
    } BPM_SAVE_INFO;

#define	BPM_PROTECTION_NAME_LEN	16

typedef struct BPM_DIR_ENTRY			/* BPM file directory entry info structure */
    {
    char	title[BPM_TITLE_LEN];		/* ASCII file name */
    unsigned int	timestamp;		/* time data was written */
    unsigned int	panum;			/* generic PA number of writing program */
    unsigned short	console;		/* writing console number */
    unsigned short	slot;			/* writing slot number */
    unsigned char	data_type;		/* type of BPM data */
    unsigned char	particle_type;		/* type of particle */
    unsigned short	num_frames;		/* number of frames stored */
    unsigned short	start_frame;		/* starting frame number */
    float		time_in_cycle;		/* time in cycle data was taken */
    unsigned short	lattice;		/* lattice in use when data was taken */
    int			protect;		/* file protection */
    unsigned char	horz_pos;		/* horizontal position data flag */
    unsigned char	horz_stat;		/* horizontal position data status flag */
    unsigned char	vert_pos;		/* vertical position data flag */
    unsigned char	vert_stat;		/* vertical position data status flag */
    unsigned char	losses;			/* beam loss data flag */
    unsigned char	loss_stat;		/* beam loss data status flag */
    unsigned char	horz_int;		/* horizontal intensity data flag */
    unsigned char	vert_int;		/* vertical intensity data flag */
    int			bunch_batch;		/* bunch/batch mode */
    unsigned char	horz_int_status;	/* horizontal intensity data status flag */
    unsigned char	vert_int_status;	/* vertical intensity data status flag */
    unsigned char	horz_rms;		/* horizontal RMS data flag */
    unsigned char	horz_rms_status;	/* horizontal RMS data status flag */
    unsigned char	vert_rms;		/* vertical RMS data flag */
    unsigned char	vert_rms_status;	/* vertical RMS data status flag */
    int			scaled_data;		/* TRUE -> data was scaled, FALSE -> raw/normalized data */
    int			algorithm;		/* scaling algorithm used */
    int			orthogonal_data;	/* flag indicating whether or not this is orthogonal data */
    int			reference_file;		/* flag indicating if this is a reference file */
    int			reference_event;	/* reference beam event(s) */
    int			cycle_number;		/* cycle number on which data was taken */
    int			turn_number;		/* turn number when data was taken */
    int			num_timing_params;	/* number of timing parameters */
    int			timing_params[BPM_MAX_TIMING_PARAMS];	/* timing parameters */
    int			num_links_to;		/* number of links to this file */
    int			related_file_id;	/* file linked to */
    int			related_file;		/* file number linked to */
    char		protection_name[BPM_PROTECTION_NAME_LEN];	/* protection name */
    int			file_number;		/* file number associated with this file */
    } __attribute__((packed)) BPM_DIR_ENTRY;

typedef struct BPM_SAVE_FILE_INFO
    {
    int			file_number;		/* file number */
    int			frame_type;		/* BPM frame type */
    unsigned int	timestamp;		/* time data was saved */
    float		time_in_cycle;		/* time in cycle data was taken */
    int			clock_event;		/* clock event (cycle) on which data was taken */
    char		title[BPM_TITLE_LEN];	/* ASCII save file name */
    } BPM_SAVE_FILE_INFO;

typedef struct BPM_PLT_OPT			/* BPM PLOT OPTIONS struct prototype */
    {
    int		bpm_frm;			/* BPM frame type */
    int		bpm_typ;			/* plot type (hor/ver,1-plt,3-plt) */
    int		bpm_pln;			/* plot plane (horz/vert) */
    int		bpm_nof;			/* number of frames */
    int		bpm_fno;			/* initial frame number */
    int		bpm_aux;			/* int/loss plot flag */
    int		bpm_plt;			/* BPM plot view (RING,B0,D0) */
    int		bpm_scr;			/* plot screen (GxPA1/GxPA2) */
    int		bpm_dsp;			/* display type (norm/conn/fill) */
    int		bpm_opt;			/* plot options */
    int		bpm_par;			/* particle type (prot/pbar) */
    int		bpm_sam;			/* sample mode (bunch/batch) */
    float	bpm_h_scl;			/* plot scale (HORZ) */
    float	bpm_v_scl;			/* plot scale (VERT) */
    float	bpm_l_scl;			/* plot scale (LOSS) */
    int		bpm_i1_scl;			/* plot scale (INT1 -> min) */
    int		bpm_i2_scl;			/* plot scale (INT2 -> max) */
    char	**frm_title;			/* ptrs to individual frame titles */
    BPM_SAVE_FILE_INFO	*save_file_info;	/* save file information */
    int		num_timing_params;		/* number of timing parameters */
    int		timing_params[BPM_MAX_TIMING_PARAMS];	/* timing parameters */
    } __attribute__((packed)) BPM_PLT_OPT;
/* pa1048 sends a BPM_PLT_OFT structure to sa1097 in the command buffer.
   It makes no sense however to the send the pointer data at the end of
   the structure. */
#define BPM_PLT_OPT_CMDBUF_LENGTH (sizeof(BPM_PLT_OPT)-4*(3+BPM_MAX_TIMING_PARAMS))

#define	BPM_UPDATE_CURSOR	1		/* normal update callback */
#define	BPM_UPDATE_LEAVE_WINDOW	2		/* leave window update callback */
#define	BPM_UPDATE_END		3		/* last update callback */

#define	BPM_DATA_TYPE_BPM	1
#define	BPM_DATA_TYPE_BLM	2
#define	BPM_DATA_TYPE_INTENSITY	4
#define	BPM_DATA_TYPE_RMS	8

typedef struct BPM_PLOT_UPDATE_DATA
    {
    int		update_type;			/* type of message (BPM_UPDATE(_CURSOR | _LEAVE_WINDOW | _END)) */
    int		machine;			/* machine associated with plot */
    int		frame_type;			/* type of data frame (flash, etc) */
    int		plot_type;			/* plot type (hor/ver,1-plt,3-plt) */
    int		data_type;			/* type of data (BPM, BLM, or intensity) */
    int		particle_type;			/* particle or plane (MI) type */
    int		plane;				/* plane (horizontal/vertical) */
    int		frame_number;			/* frame number */
    float	time_in_cycle;			/* time in cycle (seconds) */
    unsigned int	timestamp;		/* date that data was taken (in clinks) */
    int		error;				/* data point is in error (TRUE/FALSE) */
    float	x_value;			/* x position */
    float	y_value;			/* y position */
    char	label[DEVICE_NAME_LEN];		/* ASCII label for point */
    int		label_length;			/* length of ASCII label */
    int		crate_number;			/* crate number (0..n) */
    int		channel_number;			/* channel number */
    } BPM_PLOT_UPDATE_DATA;

typedef void (*bpm_plot_update_func)(BPM_PLOT_UPDATE_DATA *update_info,
				     int event_type);	/* plot update callback function */

typedef struct BPM_FILE_LINK_INFO
    {
    char	file_name[BPM_MASTER_FILE_NAME_LEN+2];	/* file name linked to */
    int		file_number;			/* file number linked to */
    int		machine_id;			/* BPM machine linked to */
    } BPM_FILE_LINK_INFO;

typedef struct BPM_TIMESTAMP
    {
    unsigned int	timestamp;		/* timestamp in seconds since Jan 1, 1970 */
    unsigned int	nanosecond_offset;	/* nanoseconds since the most recent second (0 if information not available) */
    } __attribute__((packed)) BPM_TIMESTAMP;

typedef struct BPM_BOOSTER_METADATA
    {
    int		reset_event;			/* reset clock event */
    } BPM_BOOSTER_METADATA;

typedef struct BPM_TEVATRON_ACQUISITION_SPEC
    {
    int		enable;				/* acquisition enabled flag */
    int		measurement_mode;		/* measurement mode (_MM_ constants) */
    int		arm_event;			/* acquisition arming event */
    int		trigger_event;			/* acquisition triggering event */
    } __attribute__((packed)) BPM_TEVATRON_ACQUISITION_SPEC;

typedef struct BPM_TEVATRON_READOUT_SPEC
    {
    int		particle_type;			/* BPM_MODE_PROTON -> proton, BPM_MODE_PBAR -> pbar */
    int		calib_data;			/* BPM_MODE_CALIBRATE -> calibration mode */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA */
    } BPM_TEVATRON_READOUT_SPEC;

typedef struct BLM_TEVATRON_READOUT_SPEC
    {
    int		state_number;			/* Tevatron BLM state */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA, BPM_ABORT_TBT_DATA */
    int		data_mode;			/* data acquisition mode - slow, fast, integrated */
    } BLM_TEVATRON_READOUT_SPEC;

typedef struct BPM_TEVATRON_METADATA
    {
    int		data_source;			/* 0 -> beam,
						   1 -> calibration system,
						   2 -> software diag,
						   3 -> hardware diag */
    int		particle_type;			/* 0 -> proton, 1 -> pbar */
    int		bunch_type;			/* 0 -> uncoalesced, 1 -> coalesced */
    int		scaled_data;			/* 0 -> raw data, n -> scaling algorithm */
    int		calibration_id;			/* calibration data ID number */
    int		machine_state;			/* value of V:CLDRST */
    int		helix_state;			/* value of V:HELIX */
    int		num_proton_bunches;		/* value of V:PBKTC */
    int		num_pbar_bunches;		/* value of V:ABKTC */
    int		bpm_state;			/* BPM state (not yet defined) */
    unsigned int	narrow_gate_mask;	/* narrow gate measurement mask */
    } BPM_TEVATRON_METADATA;

typedef struct BLM_TEVATRON_METADATA
    {
    int		state;				/* BLM state */
    int		abort_status;			/* abort status (undefined) */
    int		measure_divisor;		/* raw clock sample divisor */
    int		average_count;			/* number of raw measurements to average */
    int		event;				/* associated reset event */
    double	time_since_event;		/* time since the reset event */
    } BLM_TEVATRON_METADATA;

typedef struct BPM_PLATE_IQ_DATA
    {
    short	i;
    short	q;
    } BPM_PLATE_IQ_DATA;

typedef struct BPM_TEVATRON_IQ_DATA
    {
    BPM_PLATE_IQ_DATA	proton_a;
    BPM_PLATE_IQ_DATA	proton_b;
    BPM_PLATE_IQ_DATA	pbar_a;
    BPM_PLATE_IQ_DATA	pbar_b;
    } BPM_TEVATRON_IQ_DATA;

typedef struct BPM_TEVATRON_TBT_TRIGGER_INFO
    {
    short	event;				/* event to arm TBT data acquisition */
    } __attribute__((packed)) BPM_TEVATRON_TBT_TRIGGER_INFO;

#define	TEV_BLM_CHANNELS_PER_HOUSE	60

typedef struct BLM_TEVATRON_HOUSE_ABORT_CONFIG
    {
    int		type;			/* loss integration type */
    int		house_index;		/* house index */
    int		state;			/* state number */
    int		multiplicity;		/* abort multiplicity */
    short	masks[TEV_BLM_CHANNELS_PER_HOUSE];	/* channel abort masks (1 -> enabled) */
    float	thresholds[TEV_BLM_CHANNELS_PER_HOUSE];	/* channel abort thresholds */
    } __attribute__((packed)) BLM_TEVATRON_HOUSE_ABORT_CONFIG;

typedef struct BLM_TEVATRON_HOUSE_ABORT_INFO
    {
    int		house_index;		/* house index */
    unsigned int	timestamp;	/* timestamp of abort */
    unsigned int	microseconds;
    int		immediate_aborts[TEV_BLM_CHANNELS_PER_HOUSE];	/* immediate abort flags */
    int		fast_aborts[TEV_BLM_CHANNELS_PER_HOUSE];	/* fast abort flags */
    int		slow_aborts[TEV_BLM_CHANNELS_PER_HOUSE];	/* slow abort flags */
    int		very_slow_aborts[TEV_BLM_CHANNELS_PER_HOUSE];	/* very slow abort flags */
    int		type;			/* loss integration type */
    int		state;			/* state number */
    float	loss_values[TEV_BLM_CHANNELS_PER_HOUSE];		/* loss values */
    } __attribute__((packed)) BLM_TEVATRON_HOUSE_ABORT_INFO;

typedef struct BLM_CDF_READOUT_SPEC
    {
    int		state_number;			/* CDF BLM state */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA, BPM_ABORT_TBT_DATA */
    int		data_mode;			/* data acquisition mode - slow, fast, integrated */
    } BLM_CDF_READOUT_SPEC;

typedef struct BLM_CDF_METADATA
    {
    int		state;				/* BLM state */
    int		abort_status;			/* abort status (undefined) */
    int		measure_divisor;		/* raw clock sample divisor */
    int		average_count;			/* number of raw measurements to average */
    int		event;				/* associated reset event */
    double	time_since_event;		/* time since the reset event */
    } BLM_CDF_METADATA;

#define	CDF_BLM_CHANNELS_PER_HOUSE	60

typedef struct BLM_CDF_HOUSE_ABORT_CONFIG
    {
    int		type;			/* loss integration type */
    int		house_index;		/* house index */
    int		state;			/* state number */
    int		multiplicity;		/* abort multiplicity */
    short	masks[CDF_BLM_CHANNELS_PER_HOUSE];	/* channel abort masks (1 -> enabled) */
    float	thresholds[CDF_BLM_CHANNELS_PER_HOUSE];	/* channel abort thresholds */
    } __attribute__((packed)) BLM_CDF_HOUSE_ABORT_CONFIG;

typedef struct BLM_CDF_HOUSE_ABORT_INFO
    {
    int		house_index;		/* house index */
    unsigned int	timestamp;	/* timestamp of abort */
    unsigned int	microseconds;
    int		immediate_aborts[CDF_BLM_CHANNELS_PER_HOUSE];	/* immediate abort flags */
    int		fast_aborts[CDF_BLM_CHANNELS_PER_HOUSE];	/* fast abort flags */
    int		slow_aborts[CDF_BLM_CHANNELS_PER_HOUSE];	/* slow abort flags */
    int		integrated_aborts[CDF_BLM_CHANNELS_PER_HOUSE];	/* integrated abort flags */
    int		type;			/* loss integration type */
    int		state;			/* state number */
    float	loss_values[CDF_BLM_CHANNELS_PER_HOUSE];	/* loss values */
    } __attribute__((packed)) BLM_CDF_HOUSE_ABORT_INFO;

typedef struct BPM_MI_READOUT_SPEC
    {
    int		state_number;			/* Main Injector state */
    int		calib_data;			/* BPM_MODE_CALIBRATE -> calibration mode */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA */
    int		buffer_number;			/* buffer to retrieve */
    } BPM_MI_READOUT_SPEC;

typedef struct BLM_MI_READOUT_SPEC
    {
    int		state_number;			/* Main Injector state */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA, BPM_ABORT_TBT_DATA */
    int		data_mode;			/* data acquisition mode - slow, fast, integrated */
    } BLM_MI_READOUT_SPEC;

typedef struct BPM_MI_METADATA
    {
    int		data_source;			/* 0 -> beam,
						   1 -> calibration system,
						   2 -> software diag,
						   3 -> hardware diag */
    int		particle_type;			/* 0 -> proton, 1 -> pbar */
    int		scaled_data;			/* 0 -> raw data, n -> scaling algorithm */
    int		calibration_id;			/* calibration data ID number */
    int		reset_event;			/* reset clock event */
    int		machine_state;			/* machine state value */
    int		bpm_state;			/* BPM state (not yet defined) */
    } BPM_MI_METADATA;

typedef struct BLM_MI_METADATA
    {
    int		state;				/* BLM state */
    int		abort_status;			/* abort status (undefined) */
    int		measure_divisor;		/* raw clock sample divisor */
    int		average_count;			/* number of raw measurements to average */
    int		event;				/* associated reset event */
    double	time_since_event;		/* time since the reset event */
    } BLM_MI_METADATA;

typedef struct BPM_MI_IQ_DATA
    {
    BPM_PLATE_IQ_DATA	plate_a;
    BPM_PLATE_IQ_DATA	plate_b;
    } BPM_MI_IQ_DATA;

typedef struct BPM_MI_RAW_MODE_DATA
    {
    short	plate_a;
    short	plate_b;
    } BPM_MI_RAW_MODE_DATA;

typedef struct MI_TBT_TIMING_INFO
    {
    int		state_number;
    float	delay;
    } __attribute__((packed)) MI_TBT_TIMING_INFO;

typedef struct BPM_MI_TBT_TRIGGER_INFO
    {
    int		state_number;			/* Main Injector state */
    } __attribute__((packed)) BPM_MI_TBT_TRIGGER_INFO;

#define	MI_BLM_CHANNELS_PER_HOUSE	60

typedef struct BLM_MI_HOUSE_ABORT_CONFIG
    {
    int		type;			/* loss integration type */
    int		house_index;		/* house index */
    int		state;			/* state number */
    int		multiplicity;		/* abort multiplicity */
    short	masks[MI_BLM_CHANNELS_PER_HOUSE];	/* channel abort masks (1 -> enabled) */
    float	thresholds[MI_BLM_CHANNELS_PER_HOUSE];	/* channel abort thresholds */
    } __attribute__((packed)) BLM_MI_HOUSE_ABORT_CONFIG;

typedef struct BLM_MI_HOUSE_ABORT_INFO
    {
    int		house_index;		/* house index */
    unsigned int	timestamp;	/* timestamp of abort */
    unsigned int	microseconds;
    int		immediate_aborts[MI_BLM_CHANNELS_PER_HOUSE];	/* immediate abort flags */
    int		fast_aborts[MI_BLM_CHANNELS_PER_HOUSE];		/* fast abort flags */
    int		slow_aborts[MI_BLM_CHANNELS_PER_HOUSE];		/* slow abort flags */
    int		integrated_aborts[MI_BLM_CHANNELS_PER_HOUSE];	/* integrated abort flags */
    int		type;			/* loss integration type */
    int		state;			/* state number */
    float	loss_values[MI_BLM_CHANNELS_PER_HOUSE];		/* loss values */
    } __attribute__((packed)) BLM_MI_HOUSE_ABORT_INFO;

typedef struct BLM_MI_ABORT_READOUT_SPEC
    {
    int		state_number;			/* Main Injector abort line state */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA, BPM_ABORT_TBT_DATA */
    int		data_mode;			/* data acquisition mode - slow, fast, integrated */
    } BLM_MI_ABORT_READOUT_SPEC;

typedef struct BLM_MI_ABORT_METADATA
    {
    int		state;				/* BLM state */
    int		abort_status;			/* abort status (undefined) */
    int		measure_divisor;		/* raw clock sample divisor */
    int		average_count;			/* number of raw measurements to average */
    int		event;				/* associated reset event */
    double	time_since_event;		/* time since the reset event */
    } BLM_MI_ABORT_METADATA;

#define	MI_ABORT_BLM_CHANNELS_PER_HOUSE	60

typedef struct BLM_MI_ABORT_HOUSE_ABORT_CONFIG
    {
    int		type;			/* loss integration type */
    int		house_index;		/* house index */
    int		state;			/* state number */
    int		multiplicity;		/* abort multiplicity */
    short	masks[MI_ABORT_BLM_CHANNELS_PER_HOUSE];	/* channel abort masks (1 -> enabled) */
    float	thresholds[MI_ABORT_BLM_CHANNELS_PER_HOUSE];	/* channel abort thresholds */
    } __attribute__((packed)) BLM_MI_ABORT_HOUSE_ABORT_CONFIG;

typedef struct BLM_MI_ABORT_HOUSE_ABORT_INFO
    {
    int		house_index;		/* house index */
    unsigned int	timestamp;	/* timestamp of abort */
    unsigned int	microseconds;
    int		immediate_aborts[MI_ABORT_BLM_CHANNELS_PER_HOUSE];	/* immediate abort flags */
    int		fast_aborts[MI_ABORT_BLM_CHANNELS_PER_HOUSE];		/* fast abort flags */
    int		slow_aborts[MI_ABORT_BLM_CHANNELS_PER_HOUSE];		/* slow abort flags */
    int		integrated_aborts[MI_ABORT_BLM_CHANNELS_PER_HOUSE];	/* integrated abort flags */
    int		type;			/* loss integration type */
    int		state;			/* state number */
    float	loss_values[MI_ABORT_BLM_CHANNELS_PER_HOUSE];		/* loss values */
    } __attribute__((packed)) BLM_MI_ABORT_HOUSE_ABORT_INFO;

typedef struct RECYCLER_TBT_DETECTOR_SPEC
    {
    char	horz_detector[BPM_TBT_NAME_LEN];
    char	vert_detector[BPM_TBT_NAME_LEN];
    } __attribute__((packed)) RECYCLER_TBT_DETECTOR_SPEC;

#if COMMENTED_OUT
typedef struct RECYCLER_TBT_TIMING_INFO
    {
    short	mdat_frame;
    short	delay;
    int		start_turn;
    int		num_turns;
    int		num_houses;
    RECYCLER_TBT_DETECTOR_SPEC	detectors[1];
    } __attribute__((packed)) RECYCLER_TBT_TIMING_INFO;
#endif

typedef struct BPM_RECYCLER_ACQUISITION_SPEC
    {
    int		enable;				/* acquisition enabled flag */
    int		measurement_type;		/* type of measurement (_MT_ constants) */
    int		beam_mode;			/* pbar/proton beam mode (_BMD_ constants) */
    int		beam_type;			/* beam type (_BT_ constants) */
    int		beam_measurement;		/* beam measurement (_BM_ constants) */
    int		arm_event;			/* acquisition arming event */
    int		trigger_event;			/* acquisition triggering event */
    int		pretrigger_enable;		/* pretrigger enabled flag */
    unsigned int	trigger_delay;		/* trigger delay (turns) */
    unsigned int	bucket_delay;		/* bucket delay (buckets) */
    float	intensity_threshold;		/* intensity threshold */
    unsigned int	measurement_timeout;	/* measurement timeout (seconds) */
    } __attribute__((packed)) BPM_RECYCLER_ACQUISITION_SPEC;

#if COMMENTED_OUT
typedef struct BPM_RECYCLER_READOUT_SPEC
    {
    int		event_index;			/* event index (_EI_ constants) */
    int		data_type;			/* data type (_DT_ constants) */
    int		begin_turn;			/* starting turn number */
    int		num_turns;			/* number of turns */
    int		channel;			/* channel number */
    } __attribute__((packed)) BPM_RECYCLER_READOUT_SPEC;
#endif

typedef struct BPM_RECYCLER_READOUT_SPEC
    {
    int		state_number;			/* Recycler state */
    int		calib_data;			/* BPM_MODE_CALIBRATE -> calibration mode */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA */
    int		buffer_number;			/* buffer to retrieve */
    } BPM_RECYCLER_READOUT_SPEC;

typedef struct BLM_RECYCLER_READOUT_SPEC
    {
    int		state_number;			/* Recycler state */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA, BPM_ABORT_TBT_DATA */
    int		data_mode;			/* data acquisition mode - slow, fast, integrated */
    } BLM_RECYCLER_READOUT_SPEC;

typedef struct BPM_RECYCLER_CALIBRATION_SPEC
    {
    unsigned char	system_type;		/* calibration type (BPM_CAL_RECYCLER) */
    unsigned char	amplitude;		/* signal amplitude */
    unsigned char	waveform;		/* signal waveform */
    unsigned char	balance;		/* signal balance */
    } __attribute__((packed)) BPM_RECYCLER_CALIBRATION_SPEC;

typedef struct BPM_RECYCLER_DIAGNOSTIC_SPEC
    {
    unsigned char	channel_b;
    unsigned char	channel_a;
    unsigned short	enable;			/* enable flag (high bit) */
    } __attribute__((packed)) BPM_RECYCLER_DIAGNOSTIC_SPEC;

#if COMMENTED_OUT
typedef struct BPM_RECYCLER_METADATA
    {
    unsigned int	timestamp;		/* timestamp in seconds since Jan 1, 1970 (GMT) */
    unsigned int	nanosecond_offset;	/* nanoseconds since the most recent second */
    BPM_RECYCLER_ACQUISITION_SPEC	acquisition_spec;	/* data acquisition specification */
    BPM_RECYCLER_CALIBRATION_SPEC	calibration_spec;	/* calibration specification */
    int		mdat_delay;			/* trigger delay value received from MDAT */
    BPM_RECYCLER_READOUT_SPEC	readout_spec;	/* readout specification */
    } __attribute__((packed)) BPM_RECYCLER_METADATA;
#endif

typedef struct BPM_RECYCLER_METADATA
    {
    int		data_source;			/* 0 -> beam,
						   1 -> calibration system,
						   2 -> software diag,
						   3 -> hardware diag */
    int		particle_type;			/* 0 -> proton, 1 -> pbar */
    int		scaled_data;			/* 0 -> raw data, n -> scaling algorithm */
    int		calibration_id;			/* calibration data ID number */
    int		reset_event;			/* reset clock event */
    int		machine_state;			/* machine state value */
    int		bpm_state;			/* BPM state (not yet defined) */
    } BPM_RECYCLER_METADATA;

typedef struct BLM_RECYCLER_METADATA
    {
    int		state;				/* BLM state */
    int		abort_status;			/* abort status (undefined) */
    int		measure_divisor;		/* raw clock sample divisor */
    int		average_count;			/* number of raw measurements to average */
    int		event;				/* associated reset event */
    double	time_since_event;		/* time since the reset event */
    } BLM_RECYCLER_METADATA;

typedef struct BPM_RECYCLER_IQ_DATA
    {
    BPM_PLATE_IQ_DATA	plate_a;
    BPM_PLATE_IQ_DATA	plate_b;
    } BPM_RECYCLER_IQ_DATA;

typedef struct BPM_RECYCLER_RAW_MODE_DATA
    {
    short	plate_a;
    short	plate_b;
    } BPM_RECYCLER_RAW_MODE_DATA;

typedef struct RECYCLER_TBT_TIMING_INFO
    {
    int		state_number;
    float	delay;
    } __attribute__((packed)) RECYCLER_TBT_TIMING_INFO;

typedef struct BPM_RECYCLER_TBT_TRIGGER_INFO
    {
    int		state_number;			/* Recycler state */
    } __attribute__((packed)) BPM_RECYCLER_TBT_TRIGGER_INFO;

#define	RECYCLER_BLM_CHANNELS_PER_HOUSE	60

typedef struct BLM_RECYCLER_HOUSE_ABORT_CONFIG
    {
    int		type;			/* loss integration type */
    int		house_index;		/* house index */
    int		state;			/* state number */
    int		multiplicity;		/* abort multiplicity */
    short	masks[RECYCLER_BLM_CHANNELS_PER_HOUSE];		/* channel abort masks (1 -> enabled) */
    float	thresholds[RECYCLER_BLM_CHANNELS_PER_HOUSE];	/* channel abort thresholds */
    } __attribute__((packed)) BLM_RECYCLER_HOUSE_ABORT_CONFIG;

typedef struct BLM_RECYCLER_HOUSE_ABORT_INFO
    {
    int		house_index;		/* house index */
    unsigned int	timestamp;	/* timestamp of abort */
    unsigned int	microseconds;
    int		immediate_aborts[RECYCLER_BLM_CHANNELS_PER_HOUSE];	/* immediate abort flags */
    int		fast_aborts[RECYCLER_BLM_CHANNELS_PER_HOUSE];		/* fast abort flags */
    int		slow_aborts[RECYCLER_BLM_CHANNELS_PER_HOUSE];		/* slow abort flags */
    int		integrated_aborts[RECYCLER_BLM_CHANNELS_PER_HOUSE];	/* integrated abort flags */
    int		type;			/* loss integration type */
    int		state;			/* state number */
    float	loss_values[RECYCLER_BLM_CHANNELS_PER_HOUSE];		/* loss values */
    } __attribute__((packed)) BLM_RECYCLER_HOUSE_ABORT_INFO;

typedef struct BLM_RR_ABORT_READOUT_SPEC
    {
    int		state_number;			/* Recycler abort line state */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA, BPM_ABORT_TBT_DATA */
    int		data_mode;			/* data acquisition mode - slow, fast, integrated */
    } BLM_RR_ABORT_READOUT_SPEC;

typedef struct BLM_RR_ABORT_METADATA
    {
    int		state;				/* BLM state */
    int		abort_status;			/* abort status (undefined) */
    int		measure_divisor;		/* raw clock sample divisor */
    int		average_count;			/* number of raw measurements to average */
    int		event;				/* associated reset event */
    double	time_since_event;		/* time since the reset event */
    } BLM_RR_ABORT_METADATA;

#define	RR_ABORT_BLM_CHANNELS_PER_HOUSE	60

typedef struct BLM_RR_ABORT_HOUSE_ABORT_CONFIG
    {
    int		type;			/* loss integration type */
    int		house_index;		/* house index */
    int		state;			/* state number */
    int		multiplicity;		/* abort multiplicity */
    short	masks[RR_ABORT_BLM_CHANNELS_PER_HOUSE];	/* channel abort masks (1 -> enabled) */
    float	thresholds[RR_ABORT_BLM_CHANNELS_PER_HOUSE];	/* channel abort thresholds */
    } __attribute__((packed)) BLM_RR_ABORT_HOUSE_ABORT_CONFIG;

typedef struct BLM_RR_ABORT_HOUSE_ABORT_INFO
    {
    int		house_index;		/* house index */
    unsigned int	timestamp;	/* timestamp of abort */
    unsigned int	microseconds;
    int		immediate_aborts[RR_ABORT_BLM_CHANNELS_PER_HOUSE];	/* immediate abort flags */
    int		fast_aborts[RR_ABORT_BLM_CHANNELS_PER_HOUSE];		/* fast abort flags */
    int		slow_aborts[RR_ABORT_BLM_CHANNELS_PER_HOUSE];		/* slow abort flags */
    int		integrated_aborts[RR_ABORT_BLM_CHANNELS_PER_HOUSE];	/* integrated abort flags */
    int		type;			/* loss integration type */
    int		state;			/* state number */
    float	loss_values[RR_ABORT_BLM_CHANNELS_PER_HOUSE];		/* loss values */
    } __attribute__((packed)) BLM_RR_ABORT_HOUSE_ABORT_INFO;

typedef struct BPM_RECYCLER_BLT_ACQUISITION_SPEC
    {
    int		enable;				/* acquisition enabled flag */
    int		measurement_type;		/* type of measurement (_MT_ constants) */
    int		beam_mode;			/* pbar/proton beam mode (_BMD_ constants) */
    int		beam_type;			/* beam type (_BT_ constants) */
    int		beam_measurement;		/* beam measurement (_BM_ constants) */
    int		arm_event;			/* acquisition arming event */
    int		trigger_event;			/* acquisition triggering event */
    int		pretrigger_enable;		/* pretrigger enabled flag */
    unsigned int	trigger_delay;		/* trigger delay (turns) */
    unsigned int	bucket_delay;		/* bucket delay (buckets) */
    float	intensity_threshold;		/* intensity threshold */
    unsigned int	measurement_timeout;	/* measurement timeout (seconds) */
    } __attribute__((packed)) BPM_RECYCLER_BLT_ACQUISITION_SPEC;

typedef struct BPM_RECYCLER_BLT_READOUT_SPEC
    {
    int		event_index;			/* event index (_EI_ constants) */
    int		data_type;			/* data type (_DT_ constants) */
    int		begin_turn;			/* starting turn number */
    int		num_turns;			/* number of turns */
    int		channel;			/* channel number */
    } __attribute__((packed)) BPM_RECYCLER_BLT_READOUT_SPEC;

typedef struct BPM_RECYCLER_BLT_CALIBRATION_SPEC
    {
    unsigned char	system_type;		/* calibration type (BPM_CAL_RECYCLER) */
    unsigned char	amplitude;		/* signal amplitude */
    unsigned char	waveform;		/* signal waveform */
    unsigned char	balance;		/* signal balance */
    } __attribute__((packed)) BPM_RECYCLER_BLT_CALIBRATION_SPEC;

typedef struct BPM_RECYCLER_BLT_DIAGNOSTIC_SPEC
    {
    unsigned char	channel_b;
    unsigned char	channel_a;
    unsigned short	enable;			/* enable flag (high bit) */
    } __attribute__((packed)) BPM_RECYCLER_BLT_DIAGNOSTIC_SPEC;

typedef struct BPM_MI_BLT_ACQUISITION_SPEC
    {
    int		enable;				/* acquisition enabled flag */
    int		measurement_type;		/* type of measurement (_MT_ constants) */
    int		beam_mode;			/* pbar/proton beam mode (_BMD_ constants) */
    int		beam_type;			/* beam type (_BT_ constants) */
    int		beam_measurement;		/* beam measurement (_BM_ constants) */
    int		arm_event;			/* acquisition arming event */
    int		trigger_event;			/* acquisition triggering event */
    int		pretrigger_enable;		/* pretrigger enabled flag */
    unsigned int	trigger_delay;		/* trigger delay (turns) */
    unsigned int	bucket_delay;		/* bucket delay (buckets) */
    float	intensity_threshold;		/* intensity threshold */
    unsigned int	measurement_timeout;	/* measurement timeout (seconds) */
    } __attribute__((packed)) BPM_MI_BLT_ACQUISITION_SPEC;

typedef struct BPM_MI_BLT_READOUT_SPEC
    {
    int		event_index;			/* event index (_EI_ constants) */
    int		data_type;			/* data type (_DT_ constants) */
    int		begin_turn;			/* starting turn number */
    int		num_turns;			/* number of turns */
    int		channel;			/* channel number */
    } __attribute__((packed)) BPM_MI_BLT_READOUT_SPEC;

typedef struct BPM_MI_BLT_CALIBRATION_SPEC
    {
    unsigned char	system_type;		/* calibration type (BPM_CAL_RECYCLER) */
    unsigned char	amplitude;		/* signal amplitude */
    unsigned char	waveform;		/* signal waveform */
    unsigned char	balance;		/* signal balance */
    } __attribute__((packed)) BPM_MI_BLT_CALIBRATION_SPEC;

typedef struct BPM_MI_BLT_DIAGNOSTIC_SPEC
    {
    unsigned char	channel_b;
    unsigned char	channel_a;
    unsigned short	enable;			/* enable flag (high bit) */
    } __attribute__((packed)) BPM_MI_BLT_DIAGNOSTIC_SPEC;

typedef struct BLM_P1_LINE_READOUT_SPEC
    {
    int		state_number;			/* P1 Line state */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA, BPM_ABORT_TBT_DATA */
    int		data_mode;			/* data acquisition mode - slow, fast, integrated */
    } BLM_P1_LINE_READOUT_SPEC;

typedef struct BLM_P1_LINE_METADATA
    {
    int		state;				/* BLM state */
    int		abort_status;			/* abort status (undefined) */
    int		measure_divisor;		/* raw clock sample divisor */
    int		average_count;			/* number of raw measurements to average */
    int		event;				/* associated reset event */
    double	time_since_event;		/* time since the reset event */
    } BLM_P1_LINE_METADATA;

#define	P1_LINE_BLM_CHANNELS_PER_HOUSE	60

typedef struct BLM_P1_LINE_HOUSE_ABORT_CONFIG
    {
    int		type;			/* loss integration type */
    int		house_index;		/* house index */
    int		state;			/* state number */
    int		multiplicity;		/* abort multiplicity */
    short	masks[P1_LINE_BLM_CHANNELS_PER_HOUSE];		/* channel abort masks (1 -> enabled) */
    float	thresholds[P1_LINE_BLM_CHANNELS_PER_HOUSE];	/* channel abort thresholds */
    } __attribute__((packed)) BLM_P1_LINE_HOUSE_ABORT_CONFIG;

typedef struct BLM_P1_LINE_HOUSE_ABORT_INFO
    {
    int		house_index;		/* house index */
    unsigned int	timestamp;	/* timestamp of abort */
    unsigned int	microseconds;
    int		immediate_aborts[P1_LINE_BLM_CHANNELS_PER_HOUSE];	/* immediate abort flags */
    int		fast_aborts[P1_LINE_BLM_CHANNELS_PER_HOUSE];		/* fast abort flags */
    int		slow_aborts[P1_LINE_BLM_CHANNELS_PER_HOUSE];		/* slow abort flags */
    int		integrated_aborts[P1_LINE_BLM_CHANNELS_PER_HOUSE];	/* integrated abort flags */
    int		type;			/* loss integration type */
    int		state;			/* state number */
    float	loss_values[P1_LINE_BLM_CHANNELS_PER_HOUSE];		/* loss values */
    } __attribute__((packed)) BLM_P1_LINE_HOUSE_ABORT_INFO;

typedef struct BLM_P2_LINE_READOUT_SPEC
    {
    int		state_number;			/* P2 Line state */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA, BPM_ABORT_TBT_DATA */
    int		data_mode;			/* data acquisition mode - slow, fast, integrated */
    } BLM_P2_LINE_READOUT_SPEC;

typedef struct BLM_P2_LINE_METADATA
    {
    int		state;				/* BLM state */
    int		abort_status;			/* abort status (undefined) */
    int		measure_divisor;		/* raw clock sample divisor */
    int		average_count;			/* number of raw measurements to average */
    int		event;				/* associated reset event */
    double	time_since_event;		/* time since the reset event */
    } BLM_P2_LINE_METADATA;

#define	P2_LINE_BLM_CHANNELS_PER_HOUSE	60

typedef struct BLM_P2_LINE_HOUSE_ABORT_CONFIG
    {
    int		type;			/* loss integration type */
    int		house_index;		/* house index */
    int		state;			/* state number */
    int		multiplicity;		/* abort multiplicity */
    short	masks[P2_LINE_BLM_CHANNELS_PER_HOUSE];		/* channel abort masks (1 -> enabled) */
    float	thresholds[P2_LINE_BLM_CHANNELS_PER_HOUSE];	/* channel abort thresholds */
    } __attribute__((packed)) BLM_P2_LINE_HOUSE_ABORT_CONFIG;

typedef struct BLM_P2_LINE_HOUSE_ABORT_INFO
    {
    int		house_index;		/* house index */
    unsigned int	timestamp;	/* timestamp of abort */
    unsigned int	microseconds;
    int		immediate_aborts[P2_LINE_BLM_CHANNELS_PER_HOUSE];	/* immediate abort flags */
    int		fast_aborts[P2_LINE_BLM_CHANNELS_PER_HOUSE];		/* fast abort flags */
    int		slow_aborts[P2_LINE_BLM_CHANNELS_PER_HOUSE];		/* slow abort flags */
    int		integrated_aborts[P2_LINE_BLM_CHANNELS_PER_HOUSE];	/* integrated abort flags */
    int		type;			/* loss integration type */
    int		state;			/* state number */
    float	loss_values[P2_LINE_BLM_CHANNELS_PER_HOUSE];		/* loss values */
    } __attribute__((packed)) BLM_P2_LINE_HOUSE_ABORT_INFO;

typedef struct BLM_P3_LINE_READOUT_SPEC
    {
    int		state_number;			/* P3 Line state */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA, BPM_ABORT_TBT_DATA */
    int		data_mode;			/* data acquisition mode - slow, fast, integrated */
    } BLM_P3_LINE_READOUT_SPEC;

typedef struct BLM_P3_LINE_METADATA
    {
    int		state;				/* BLM state */
    int		abort_status;			/* abort status (undefined) */
    int		measure_divisor;		/* raw clock sample divisor */
    int		average_count;			/* number of raw measurements to average */
    int		event;				/* associated reset event */
    double	time_since_event;		/* time since the reset event */
    } BLM_P3_LINE_METADATA;

#define	P3_LINE_BLM_CHANNELS_PER_HOUSE	60

typedef struct BLM_P3_LINE_HOUSE_ABORT_CONFIG
    {
    int		type;			/* loss integration type */
    int		house_index;		/* house index */
    int		state;			/* state number */
    int		multiplicity;		/* abort multiplicity */
    short	masks[P3_LINE_BLM_CHANNELS_PER_HOUSE];		/* channel abort masks (1 -> enabled) */
    float	thresholds[P3_LINE_BLM_CHANNELS_PER_HOUSE];	/* channel abort thresholds */
    } __attribute__((packed)) BLM_P3_LINE_HOUSE_ABORT_CONFIG;

typedef struct BLM_P3_LINE_HOUSE_ABORT_INFO
    {
    int		house_index;		/* house index */
    unsigned int	timestamp;	/* timestamp of abort */
    unsigned int	microseconds;
    int		immediate_aborts[P3_LINE_BLM_CHANNELS_PER_HOUSE];	/* immediate abort flags */
    int		fast_aborts[P3_LINE_BLM_CHANNELS_PER_HOUSE];		/* fast abort flags */
    int		slow_aborts[P3_LINE_BLM_CHANNELS_PER_HOUSE];		/* slow abort flags */
    int		integrated_aborts[P3_LINE_BLM_CHANNELS_PER_HOUSE];	/* integrated abort flags */
    int		type;			/* loss integration type */
    int		state;			/* state number */
    float	loss_values[P3_LINE_BLM_CHANNELS_PER_HOUSE];		/* loss values */
    } __attribute__((packed)) BLM_P3_LINE_HOUSE_ABORT_INFO;

typedef struct BLM_M1_LINE_READOUT_SPEC
    {
    int		state_number;			/* M1 Line state */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA, BPM_ABORT_TBT_DATA */
    int		data_mode;			/* data acquisition mode - slow, fast, integrated */
    } BLM_M1_LINE_READOUT_SPEC;

typedef struct BLM_M1_LINE_METADATA
    {
    int		state;				/* BLM state */
    int		abort_status;			/* abort status (undefined) */
    int		measure_divisor;		/* raw clock sample divisor */
    int		average_count;			/* number of raw measurements to average */
    int		event;				/* associated reset event */
    double	time_since_event;		/* time since the reset event */
    } BLM_M1_LINE_METADATA;

#define	M1_LINE_BLM_CHANNELS_PER_HOUSE	60

typedef struct BLM_M1_LINE_HOUSE_ABORT_CONFIG
    {
    int		type;			/* loss integration type */
    int		house_index;		/* house index */
    int		state;			/* state number */
    int		multiplicity;		/* abort multiplicity */
    short	masks[M1_LINE_BLM_CHANNELS_PER_HOUSE];		/* channel abort masks (1 -> enabled) */
    float	thresholds[M1_LINE_BLM_CHANNELS_PER_HOUSE];	/* channel abort thresholds */
    } __attribute__((packed)) BLM_M1_LINE_HOUSE_ABORT_CONFIG;

typedef struct BLM_M1_LINE_HOUSE_ABORT_INFO
    {
    int		house_index;		/* house index */
    unsigned int	timestamp;	/* timestamp of abort */
    unsigned int	microseconds;
    int		immediate_aborts[M1_LINE_BLM_CHANNELS_PER_HOUSE];	/* immediate abort flags */
    int		fast_aborts[M1_LINE_BLM_CHANNELS_PER_HOUSE];		/* fast abort flags */
    int		slow_aborts[M1_LINE_BLM_CHANNELS_PER_HOUSE];		/* slow abort flags */
    int		integrated_aborts[M1_LINE_BLM_CHANNELS_PER_HOUSE];	/* integrated abort flags */
    int		type;			/* loss integration type */
    int		state;			/* state number */
    float	loss_values[M1_LINE_BLM_CHANNELS_PER_HOUSE];		/* loss values */
    } __attribute__((packed)) BLM_M1_LINE_HOUSE_ABORT_INFO;

typedef struct BLM_M3_LINE_READOUT_SPEC
    {
    int		state_number;			/* M3 Line state */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA, BPM_ABORT_TBT_DATA */
    int		data_mode;			/* data acquisition mode - slow, fast, integrated */
    } BLM_M3_LINE_READOUT_SPEC;

typedef struct BLM_M3_LINE_METADATA
    {
    int		state;				/* BLM state */
    int		abort_status;			/* abort status (undefined) */
    int		measure_divisor;		/* raw clock sample divisor */
    int		average_count;			/* number of raw measurements to average */
    int		event;				/* associated reset event */
    double	time_since_event;		/* time since the reset event */
    } BLM_M3_LINE_METADATA;

#define	M3_LINE_BLM_CHANNELS_PER_HOUSE	60

typedef struct BLM_M3_LINE_HOUSE_ABORT_CONFIG
    {
    int		type;			/* loss integration type */
    int		house_index;		/* house index */
    int		state;			/* state number */
    int		multiplicity;		/* abort multiplicity */
    short	masks[M3_LINE_BLM_CHANNELS_PER_HOUSE];		/* channel abort masks (1 -> enabled) */
    float	thresholds[M3_LINE_BLM_CHANNELS_PER_HOUSE];	/* channel abort thresholds */
    } __attribute__((packed)) BLM_M3_LINE_HOUSE_ABORT_CONFIG;

typedef struct BLM_M3_LINE_HOUSE_ABORT_INFO
    {
    int		house_index;		/* house index */
    unsigned int	timestamp;	/* timestamp of abort */
    unsigned int	microseconds;
    int		immediate_aborts[M3_LINE_BLM_CHANNELS_PER_HOUSE];	/* immediate abort flags */
    int		fast_aborts[M3_LINE_BLM_CHANNELS_PER_HOUSE];		/* fast abort flags */
    int		slow_aborts[M3_LINE_BLM_CHANNELS_PER_HOUSE];		/* slow abort flags */
    int		integrated_aborts[M3_LINE_BLM_CHANNELS_PER_HOUSE];	/* integrated abort flags */
    int		type;			/* loss integration type */
    int		state;			/* state number */
    float	loss_values[M3_LINE_BLM_CHANNELS_PER_HOUSE];		/* loss values */
    } __attribute__((packed)) BLM_M3_LINE_HOUSE_ABORT_INFO;

typedef struct BPM_DELIVERY_RING_ACQUISITION_SPEC
    {
    int		enable;				/* acquisition enabled flag */
    int		measurement_type;		/* type of measurement (_MT_ constants) */
    int		beam_mode;			/* pbar/proton beam mode (_BMD_ constants) */
    int		beam_type;			/* beam type (_BT_ constants) */
    int		beam_measurement;		/* beam measurement (_BM_ constants) */
    int		arm_event;			/* acquisition arming event */
    int		trigger_event;			/* acquisition triggering event */
    int		pretrigger_enable;		/* pretrigger enabled flag */
    unsigned int	trigger_delay;		/* trigger delay (turns) */
    unsigned int	bucket_delay;		/* bucket delay (buckets) */
    float	intensity_threshold;		/* intensity threshold */
    unsigned int	measurement_timeout;	/* measurement timeout (seconds) */
    } __attribute__((packed)) BPM_DELIVERY_RING_ACQUISITION_SPEC;

typedef struct BPM_DELIVERY_RING_CALIBRATION_SPEC
    {
    unsigned char	system_type;		/* calibration type (BPM_CAL_DELIVERY_RING) */
    unsigned char	amplitude;		/* signal amplitude */
    unsigned char	waveform;		/* signal waveform */
    unsigned char	balance;		/* signal balance */
    } __attribute__((packed)) BPM_DELIVERY_RING_CALIBRATION_SPEC;

typedef struct BPM_DELIVERY_RING_READOUT_SPEC
    {
    int		event_index;			/* event index (_EI_ constants) */
    int		data_type;			/* data type (_DT_ constants) */
    int		begin_turn;			/* starting turn number */
    int		num_turns;			/* number of turns */
    int		channel;			/* channel number */
    } __attribute__((packed)) BPM_DELIVERY_RING_READOUT_SPEC;

typedef struct BPM_DELIVERY_RING_DIAGNOSTIC_SPEC
    {
    unsigned char	channel_b;
    unsigned char	channel_a;
    unsigned short	enable;			/* enable flag (high bit) */
    } __attribute__((packed)) BPM_DELIVERY_RING_DIAGNOSTIC_SPEC;

typedef struct BPM_DELIVERY_RING_METADATA
    {
    unsigned int	timestamp;		/* timestamp in seconds since Jan 1, 1970 (GMT) */
    unsigned int	nanosecond_offset;	/* nanoseconds since the most recent second */
    BPM_DELIVERY_RING_ACQUISITION_SPEC	acquisition_spec;	/* data acquisition specification */
    BPM_DELIVERY_RING_CALIBRATION_SPEC	calibration_spec;	/* calibration specification */
    int		mdat_delay;			/* trigger delay value received from MDAT */
    BPM_DELIVERY_RING_READOUT_SPEC	readout_spec;	/* readout specification */
    } __attribute__((packed)) BPM_DELIVERY_RING_METADATA;

typedef struct BLM_DELIVERY_RING_READOUT_SPEC
    {
    int		state_number;			/* Delivery Ring state */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA, BPM_ABORT_TBT_DATA */
    int		data_mode;			/* data acquisition mode - slow, fast, integrated */
    } BLM_DELIVERY_RING_READOUT_SPEC;

typedef struct BLM_DELIVERY_RING_METADATA
    {
    int		state;				/* BLM state */
    int		abort_status;			/* abort status (undefined) */
    int		measure_divisor;		/* raw clock sample divisor */
    int		average_count;			/* number of raw measurements to average */
    int		event;				/* associated reset event */
    double	time_since_event;		/* time since the reset event */
    } BLM_DELIVERY_RING_METADATA;

#define	DELIVERY_RING_BLM_CHANNELS_PER_HOUSE	60

typedef struct BLM_DELIVERY_RING_HOUSE_ABORT_CONFIG
    {
    int		type;			/* loss integration type */
    int		house_index;		/* house index */
    int		state;			/* state number */
    int		multiplicity;		/* abort multiplicity */
    short	masks[DELIVERY_RING_BLM_CHANNELS_PER_HOUSE];		/* channel abort masks (1 -> enabled) */
    float	thresholds[DELIVERY_RING_BLM_CHANNELS_PER_HOUSE];	/* channel abort thresholds */
    } __attribute__((packed)) BLM_DELIVERY_RING_HOUSE_ABORT_CONFIG;

typedef struct BLM_DELIVERY_RING_HOUSE_ABORT_INFO
    {
    int		house_index;		/* house index */
    unsigned int	timestamp;	/* timestamp of abort */
    unsigned int	microseconds;
    int		immediate_aborts[DELIVERY_RING_BLM_CHANNELS_PER_HOUSE];	/* immediate abort flags */
    int		fast_aborts[DELIVERY_RING_BLM_CHANNELS_PER_HOUSE];	/* fast abort flags */
    int		slow_aborts[DELIVERY_RING_BLM_CHANNELS_PER_HOUSE];	/* slow abort flags */
    int		integrated_aborts[DELIVERY_RING_BLM_CHANNELS_PER_HOUSE];	/* integrated abort flags */
    int		type;			/* loss integration type */
    int		state;			/* state number */
    float	loss_values[DELIVERY_RING_BLM_CHANNELS_PER_HOUSE];	/* loss values */
    } __attribute__((packed)) BLM_DELIVERY_RING_HOUSE_ABORT_INFO;

typedef struct BLM_M5_LINE_READOUT_SPEC
    {
    int		state_number;			/* M5 Line state */
    int		data_type;			/* BPM_NORMAL_TBT_DATA, BPM_INJECTION_TBT_DATA, BPM_ABORT_TBT_DATA */
    int		data_mode;			/* data acquisition mode - slow, fast, integrated */
    } BLM_M5_LINE_READOUT_SPEC;

typedef struct BLM_M5_LINE_METADATA
    {
    int		state;				/* BLM state */
    int		abort_status;			/* abort status (undefined) */
    int		measure_divisor;		/* raw clock sample divisor */
    int		average_count;			/* number of raw measurements to average */
    int		event;				/* associated reset event */
    double	time_since_event;		/* time since the reset event */
    } BLM_M5_LINE_METADATA;

#define	M5_LINE_BLM_CHANNELS_PER_HOUSE	60

typedef struct BLM_M5_LINE_HOUSE_ABORT_CONFIG
    {
    int		type;			/* loss integration type */
    int		house_index;		/* house index */
    int		state;			/* state number */
    int		multiplicity;		/* abort multiplicity */
    short	masks[M5_LINE_BLM_CHANNELS_PER_HOUSE];		/* channel abort masks (1 -> enabled) */
    float	thresholds[M5_LINE_BLM_CHANNELS_PER_HOUSE];	/* channel abort thresholds */
    } __attribute__((packed)) BLM_M5_LINE_HOUSE_ABORT_CONFIG;

typedef struct BLM_M5_LINE_HOUSE_ABORT_INFO
    {
    int		house_index;		/* house index */
    unsigned int	timestamp;	/* timestamp of abort */
    unsigned int	microseconds;
    int		immediate_aborts[M5_LINE_BLM_CHANNELS_PER_HOUSE];	/* immediate abort flags */
    int		fast_aborts[M5_LINE_BLM_CHANNELS_PER_HOUSE];		/* fast abort flags */
    int		slow_aborts[M5_LINE_BLM_CHANNELS_PER_HOUSE];		/* slow abort flags */
    int		integrated_aborts[M5_LINE_BLM_CHANNELS_PER_HOUSE];	/* integrated abort flags */
    int		type;			/* loss integration type */
    int		state;			/* state number */
    float	loss_values[M5_LINE_BLM_CHANNELS_PER_HOUSE];		/* loss values */
    } __attribute__((packed)) BLM_M5_LINE_HOUSE_ABORT_INFO;

typedef struct BPM_NUMI_ACQUISITION_SPEC
    {
    int		enable;				/* acquisition enabled flag */
    int		measurement_type;		/* type of measurement (_MT_ constants) */
    int		beam_mode;			/* pbar/proton beam mode (_BMD_ constants) */
    int		beam_type;			/* beam type (_BT_ constants) */
    int		beam_measurement;		/* beam measurement (_BM_ constants) */
    int		arm_event;			/* acquisition arming event */
    int		trigger_event;			/* acquisition triggering event */
    int		pretrigger_enable;		/* pretrigger enabled flag */
    unsigned int	trigger_delay;		/* trigger delay (turns) */
    unsigned int	bucket_delay;		/* bucket delay (buckets) */
    float	intensity_threshold;		/* intensity threshold */
    unsigned int	measurement_timeout;	/* measurement timeout (seconds) */
    } __attribute__((packed)) BPM_NUMI_ACQUISITION_SPEC;

typedef struct BPM_NUMI_READOUT_SPEC
    {
    int		event_index;			/* event index (_EI_ constants) */
    int		data_type;			/* data type (_DT_ constants) */
    int		begin_turn;			/* starting turn number */
    int		num_turns;			/* number of turns */
    int		channel;			/* channel number */
    } __attribute__((packed)) BPM_NUMI_READOUT_SPEC;

typedef struct BPM_NUMI_CALIBRATION_SPEC
    {
    unsigned char	control;		/* signal control */
    unsigned char	frequency;		/* signal frequency */
    unsigned char	zero;			/* must be zero */
    unsigned char	system_type;		/* calibration type (BPM_CAL_BEAMLINE) */
    } __attribute__((packed)) BPM_NUMI_CALIBRATION_SPEC;

typedef struct BPM_NUMI_DIAGNOSTIC_SPEC
    {
    unsigned char	channel_b;
    unsigned char	channel_a;
    unsigned short	enable;			/* enable flag (high bit) */
    } __attribute__((packed)) BPM_NUMI_DIAGNOSTIC_SPEC;

typedef struct BPM_BEAMLINE_ACQUISITION_SPEC
    {
    int		enable;				/* acquisition enabled flag */
    int		measurement_type;		/* type of measurement (_MT_ constants) */
    int		beam_mode;			/* pbar/proton beam mode (_BMD_ constants) */
    int		beam_type;			/* beam type (_BT_ constants) */
    int		beam_measurement;		/* beam measurement (_BM_ constants) */
    int		arm_event;			/* acquisition arming event */
    int		trigger_event;			/* acquisition triggering event */
    int		pretrigger_enable;		/* pretrigger enabled flag */
    unsigned int	trigger_delay;		/* trigger delay (turns) */
    unsigned int	bucket_delay;		/* bucket delay (buckets) */
    float	intensity_threshold;		/* intensity threshold */
    unsigned int	measurement_timeout;	/* measurement timeout (seconds) */
    } __attribute__((packed)) BPM_BEAMLINE_ACQUISITION_SPEC;

typedef struct BPM_BEAMLINE_READOUT_SPEC
    {
    int		event_index;			/* event index (_EI_ constants) */
    int		data_type;			/* data type (_DT_ constants) */
    int		begin_turn;			/* starting turn number */
    int		num_turns;			/* number of turns */
    int		channel;			/* channel number */
    } __attribute__((packed)) BPM_BEAMLINE_READOUT_SPEC;

typedef struct BPM_BEAMLINE_CALIBRATION_SPEC
    {
    unsigned char	control;		/* signal control */
    unsigned char	mode;			/* calibration mode */
    unsigned char	zero;			/* must be zero */
    unsigned char	system_type;		/* calibration system type (BPM_CAL_TYPE_BL) */
    } __attribute__((packed)) BPM_BEAMLINE_CALIBRATION_SPEC;

typedef struct BPM_BEAMLINE_DIAGNOSTIC_SPEC
    {
    unsigned char	channel_b;
    unsigned char	channel_a;
    unsigned short	enable;			/* enable flag (high bit) */
    } __attribute__((packed)) BPM_BEAMLINE_DIAGNOSTIC_SPEC;

typedef struct BPM_EIGHT_GEV_ACQUISITION_SPEC
    {
    int		enable;				/* acquisition enabled flag */
    int		measurement_type;		/* type of measurement (_MT_ constants) */
    int		beam_mode;			/* pbar/proton beam mode (_BMD_ constants) */
    int		beam_type;			/* beam type (_BT_ constants) */
    int		beam_measurement;		/* beam measurement (_BM_ constants) */
    int		arm_event;			/* acquisition arming event */
    int		trigger_event;			/* acquisition triggering event */
    int		pretrigger_enable;		/* pretrigger enabled flag */
    unsigned int	trigger_delay;		/* trigger delay (turns) */
    unsigned int	bucket_delay;		/* bucket delay (buckets) */
    float	intensity_threshold;		/* intensity threshold */
    unsigned int	measurement_timeout;	/* measurement timeout (seconds) */
    } __attribute__((packed)) BPM_EIGHT_GEV_ACQUISITION_SPEC;

typedef struct BPM_EIGHT_GEV_READOUT_SPEC
    {
    int		event_index;			/* event index (_EI_ constants) */
    int		data_type;			/* data type (_DT_ constants) */
    int		begin_turn;			/* starting turn number */
    int		num_turns;			/* number of turns */
    int		channel;			/* channel number */
    } __attribute__((packed)) BPM_EIGHT_GEV_READOUT_SPEC;

typedef struct BPM_EIGHT_GEV_AND_MI_READOUT_SPEC
    {
    BPM_EIGHT_GEV_READOUT_SPEC	eg_readout_spec;	/* 8 GeV line readout spec */
    int		mi_state_number;		/* Main Injector state */
    } __attribute__((packed)) BPM_EIGHT_GEV_AND_MI_READOUT_SPEC;

typedef struct BPM_EIGHT_GEV_AND_RR_READOUT_SPEC
    {
    BPM_EIGHT_GEV_READOUT_SPEC	eg_readout_spec;	/* 8 GeV line readout spec */
    int		rr_state_number;		/* Recycler state */
    } __attribute__((packed)) BPM_EIGHT_GEV_AND_RR_READOUT_SPEC;

typedef struct BPM_EIGHT_GEV_CALIBRATION_SPEC
    {
    unsigned char	control;		/* signal control */
    unsigned char	mode;			/* calibration mode */
    unsigned char	zero;			/* must be zero */
    unsigned char	system_type;		/* calibration system type (BPM_CAL_TYPE_MI8) */
    } __attribute__((packed)) BPM_EIGHT_GEV_CALIBRATION_SPEC;

typedef struct BPM_EIGHT_GEV_DIAGNOSTIC_SPEC
    {
    unsigned char	channel_b;
    unsigned char	channel_a;
    unsigned short	enable;			/* enable flag (high bit) */
    } __attribute__((packed)) BPM_EIGHT_GEV_DIAGNOSTIC_SPEC;

typedef struct BPM_EIGHT_GEV_METADATA
    {
    unsigned int	timestamp;		/* timestamp in seconds since Jan 1, 1970 (GMT) */
    unsigned int	nanosecond_offset;	/* nanoseconds since the most recent second */
    BPM_EIGHT_GEV_ACQUISITION_SPEC	acquisition_spec;	/* data acquisition specification */
    BPM_EIGHT_GEV_CALIBRATION_SPEC	calibration_spec;	/* calibration specification */
    int		mdat_delay;			/* trigger delay value received from MDAT */
    BPM_EIGHT_GEV_READOUT_SPEC	readout_spec;	/* readout specification */
    BPM_TIMESTAMP	supercycle_time;	/* time since the start of the most recent supercycle */
    unsigned int	supercycle_reset;	/* last supercycle reset */
    unsigned int	last_mi_reset;		/* last Main Injector reset event */
    unsigned int	last_booster_reset;	/* last Booster reset event */
    } __attribute__((packed)) BPM_EIGHT_GEV_METADATA;

typedef struct BPM_EC_ACQUISITION_SPEC
    {
    int		data_type;			/* data type (_DT_ definitions) */
    int		resolution_or_freq;		/* measurement resolution (_MR_ definitions) or switch frequency */
    } __attribute__((packed)) BPM_EC_ACQUISITION_SPEC;

typedef struct BPM_SAVED_POSITION
    {
    int		file_number;
    int		frame_number;
    unsigned int	timestamp;
    float	time_in_cycle;			/* time in cycle data was taken */
    int		frame_type;			/* BPM frame type */
    float	value;
    short	status;
    } __attribute__((packed)) BPM_SAVED_POSITION;

typedef struct BPM_SEARCH_DATA
    {
    int		machine;			/* machine detector belongs to */
    int		plane;				/* BPM plane (BPM_HORZ or BPM_VERT) */
    int		order_number;			/* order number */
    int		crate_number;			/* crate number */
    int		channel_number;			/* channel number */
    float	bpm_offset;
    float	survey_offset;
    float	orbit_offset;
    float	electrical_offset;
    float	relative_position;		/* detector location */
    int		detector_status;		/* detector status */
    int		detector_id;			/* detector ID */
    } __attribute__((packed)) BPM_SEARCH_DATA;

typedef struct BLM_SEARCH_DATA
    {
    int		machine;			/* machine detector belongs to */
    int		order_number;			/* order number */
    int		crate_number;			/* crate number */
    int		channel_number;			/* channel number */
    float	relative_position;		/* detector location */
    int		detector_status;		/* detector status */
    int		detector_id;			/* detector ID */
    } __attribute__((packed)) BLM_SEARCH_DATA;


/******************************************************************************/
/*
**	function prototypes for BPM routines
*/
/******************************************************************************/

#ifdef __cplusplus
extern "C" {
#endif

int blm_abort_map_select_c(int top_row, int left_column, int *abort_states);
int blm_detector_name_search(char const *name, int *num_returned,
			     BLM_SEARCH_DATA **blm_info=(BLM_SEARCH_DATA **) NULL);
int blm_get_abort_info_c(int start_house, int num_houses, int type,
			 void *abort_info, short *errors,
			 int *num_ret_houses);
int blm_get_abort_map(int *abort_states, int *num_states);
int blm_get_abort_status_c(int start_house, int num_houses,
			   int *abort_status, short *errors,
			   int *num_ret_houses);
int blm_get_crates_and_channels_c(int *crates, int *channels,
				  unsigned int data_view=BPM_VIEW_DEFAULT,
				  int *machines=(int *) NULL);
int blm_get_data_c(int type, int frame, int num_frame, float *losses,
		   char *stat=(char *) NULL,
		   unsigned int *timestamp=(unsigned int *) NULL,
		   char **bpm_title=(char **) NULL,
		   float *time_in_cycle=(float *) NULL,
		   int *frames_ret=(int *) NULL,
		   int *returned_type=(int *) NULL,
		   unsigned int data_view=BPM_VIEW_DEFAULT,
		   unsigned int *timestamps=(unsigned int *) NULL,
		   unsigned int *nano_offsets=(unsigned int *) NULL,
		   void *readout_spec=(void *) NULL,
		   void *metadata=(void *) NULL);
int blm_get_file_frame_data_c(int file, char *detector, int start_frame,
			      int max_frames, void *readout_spec,
			      float *losses, char *loss_status,
			      int *num_frames=(int *) NULL,
			      int *frame_type=(int *) NULL,
			      unsigned int *timestamps=(unsigned int *) NULL,
			      unsigned int *nanoseconds=(unsigned int *) NULL,
			      char **file_title=(char **) NULL,
			      void *metadata=(void *) NULL);
int blm_get_frame_data_c(char *detector, int type, int start_frame,
			 int max_frames, void *readout_spec, float *losses,
			 char *loss_status, int *num_frames=(int *) NULL,
			 unsigned int *timestamp=(unsigned int *) NULL,
			 unsigned int *nanoseconds=(unsigned int *) NULL,
			 void *metadata=(void *) NULL);
int blm_get_frame_list_data_c(int num_detectors, char *detectors, int type,
			      int start_frame, int max_frames,
			      void *readout_spec, float *losses,
			      int *num_frames, unsigned int *times,
			      void *metadata, short *errors);
int blm_get_house_abort_config_c(int start_house, int num_houses, int state,
				 int type, void *config_data, short *errors,
				 int *num_ret_houses);
int blm_get_house_names_c(char *house, int max_return, int *num_names,
			  char *names, unsigned int options);
int blm_get_locations(float *locations,
		      unsigned int data_view=BPM_VIEW_DEFAULT);
int blm_get_names(char *passed_names,
		  unsigned int data_view=BPM_VIEW_DEFAULT,
		  int *machines=(int *) NULL);
int blm_get_system_sample_data(int *sample_event,
			       double *sample_delay=(double *) NULL);
int blm_get_tbt_data_c(char *detector, int max_turns, int filter_data,
		       void *readout_spec, float *losses,
		       unsigned int *timestamps, int *num_turns,
		       unsigned int *time, void *metadata);
int blm_get_tbt_list_data_c(int num_detectors, char *detectors, int max_turns,
			    int filter_data, void *readout_spec, float *losses,
			    unsigned int *timestamps, int *num_turns,
			    unsigned int *times, void *metadata, short *errors);
int blm_interrogate_plot(bpm_plot_update_func update_func, int screen);
int blm_last_error(void);
int blm_name_to_index_c(char *name, unsigned int data_view, int *index);
int blm_num_abort_states(int *num_states);
int blm_num_machine_states(int *num_states);
int blm_plot_data(BPM_PLT_OPT *plot_options, unsigned int *timestamp,
		  float *loss_data, char *loss_stat,
		  float *time_in_cycle, char *blm_title,
		  int cycle, int *turn_numbers, unsigned int *timestamps,
		  unsigned int *nano_offsets, int *colors,
		  void *metadata);
int blm_query(int *num_monitors, unsigned int data_view=BPM_VIEW_DEFAULT);
int blm_set_abort_map_c(int start_state, int num_states, int *abort_states);
int blm_set_abort_mask_c(int num_blms, char *names, int state, int type,
			 short *masks, short *errors);
int blm_set_abort_mask_by_address_c(int num_blms, int *houses, int *channels,
				    int state, int type, short *masks,
				    short *errors);
int blm_set_abort_multiplicity_c(int start_house, int num_houses, int state,
				 int type, int multiplicity, short *errors);
int blm_set_abort_threshold_c(int num_blms, char *names, int state,
			      int type, float *thresholds, short *errors);
int blm_set_abort_threshold_by_address_c(int num_blms, int *houses,
					 int *channels, int state, int type,
					 float *thresholds, short *errors);
int blm_set_system_sample_data_c(int sample_event, double sample_delay=0.0);
int blm_state_menu_c(int top_row, int left_column, int *state);
int blm_to_crate_and_channel_c(char *detector, char *crate_name,
			       int *crate_number, int *channel_number);
int bpm_beam_cycle_info(int *beam_event, int *cycle_num=(int *) NULL,
			int *turn_num=(int *) NULL);
int bpm_calculate_rms_dpoverp_c(unsigned int data_view, int num_frames,
				float *horz_pos, char *horz_status,
				float *vert_pos, char *vert_status,
				float *horz_rms, float *vert_rms,
				float *dpoverp);
int bpm_check_for_data_c(int type, void *readout_spec,
			 int start_house, int num_houses,
			 int *house_status, int *num_ret_houses,
			 BPM_TIMESTAMP *times=(BPM_TIMESTAMP *) NULL);
int bpm_crate_and_channel_to_name_c(int crate_number, int channel_number,
				    char *name, int ortho_plane=FALSE);
int bpm_crate_info_c(char *crate_names, int *num_crates,
		     int *max_name_length, int max_return,
		     char *alt_crate_names=(char *) NULL,
		     int *max_alt_name_length=(int *) NULL,
		     int *num_horz_bpms=(int *) NULL,
		     int *num_vert_bpms=(int *) NULL,
		     int *num_blms=(int *) NULL);
int bpm_crate_name_to_index(char *crate_name, int *index);
int bpm_data_source_c(int source, int info1=0,
		      int info2=SDA_DEFAULT_CASE_NUMBER,
		      int info3=SDA_DEFAULT_SUBCASE_NUMBER,
		      void *info4=(void *) NULL);
int bpm_detector_name_search(char const *name, int *num_returned,
			     BPM_SEARCH_DATA **bpm_info=(BPM_SEARCH_DATA **) NULL);
int bpm_get_database_system_id(int *system_id);
int bpm_default_data_event(char *data_event);
int bpm_directory_info(BPM_DIR_ENTRY *directory=(BPM_DIR_ENTRY *) NULL,
		       int entry=BPM_ENTIRE_DIRECTORY,
		       unsigned int options=BPM_OPT_NONE,
		       int *file_range=(int *) NULL);
int bpm_enable_tbt_trigger_c(int enable, char *house=(char *) NULL,
			     void *enable_info=(void *) NULL);
int bpm_file_link_info_c(int file_number, BPM_FILE_LINK_INFO *linked_to,
			 int *num_linked, BPM_FILE_LINK_INFO *linked_by);
int bpm_find_oldest_file_number_c(int *file_number,
				  unsigned int options=BPM_OPT_NONE);
int bpm_file_menu_c(int top_row, int left_column, int filter=BPM_ALL_FILES,
		    unsigned int options=BPM_OPT_NONE,
		    int *file_range=(int *) NULL);
int bpm_frame_file_menu_c(int top_row, int left_column, int filter,
			  int *file_range, unsigned int options);
char *bpm_frame_type_to_string_c(int frame_type);
int bpm_get_acquisition_spec_c(int start_house, int num_houses,
			       int max_specs, void *acquisition_specs,
			       int *num_ret_houses, int *num_ret_specs);
int bpm_get_calculation_masks_c(unsigned int data_view, int *num_horz_masks,
				int *horz_masks, int *num_vert_masks,
				int *vert_masks);
int bpm_get_calibration_spec_c(int start_house, int num_houses,
			       void *calibration_specs,
			       int *num_ret_houses);
int bpm_get_crates_and_channels(int *horz_crates, int *horz_channels,
				int *vert_crates, int *vert_channels,
				unsigned int data_view=BPM_VIEW_DEFAULT,
				int *horz_machines=(int *) NULL,
				int *vert_machines=(int *) NULL);
int bpm_get_data_c(int type, int frame, int num_frame,
		   float *horz_pos=(float *) NULL,
		   float *vert_pos=(float *) NULL,
		   char *horz_status=(char *) NULL,
		   char *vert_status=(char *) NULL,
		   unsigned int *timestamp=(unsigned int *) NULL,
		   char **file_title=(char **) NULL,
		   float *time_in_cycle=(float *) NULL,
		   int *frames_ret=(int *) NULL, int scale_it=TRUE,
		   int *returned_type=(int *) NULL,
		   unsigned int data_view=BPM_VIEW_DEFAULT,
		   int *turn_numbers=(int *) NULL, int *cycle=(int *) NULL,
		   int *num_timing=(int *) NULL,
		   int *timing_params=(int *) NULL,
		   unsigned int *timestamps=(unsigned int *) NULL,
		   unsigned int *nano_offsets=(unsigned int *) NULL,
		   void *readout_spec=(void *) NULL,
		   unsigned int *attributes=(unsigned int *) NULL,
		   void *metadata=(void *) NULL);
int bpm_get_default_save_file(char *file_name);
int bpm_get_detector_status(int *horz_status, int *vert_status,
			    unsigned int data_view=BPM_VIEW_DEFAULT);
int bpm_get_diagnostic_spec_c(int start_house, int num_houses,
			      void *diagnostic_specs, int *num_ret_houses);
int bpm_get_event_spec_text_c(int max_entries, int *num_entries,
			      char *text);
int bpm_get_file_frame_data_c(int file, char *detector, int start_frame,
			      int max_frames, void *readout_spec,
			      float *positions, char *pos_status,
			      float *intensities, char *int_status,
			      int *num_frames, int *frame_type=(int *) NULL,
			      unsigned int *timestamps=(unsigned int *) NULL,
			      unsigned int *nanoseconds=(unsigned int *) NULL,
			      char **file_title=(char **) NULL,
			      void *metadata=(void *) NULL);
int bpm_get_filter_text_c(int max_entries, int *num_entries, char *text);
int bpm_get_frame_data_c(char *detector, int type, int start_frame,
			 int max_frames, void *readout_spec,
			 float *positions, float *intensities,
			 char *detector_status, int *num_frames,
			 unsigned int *timestamps,
			 unsigned int *nanoseconds,
			 void *metadata);
int bpm_get_frame_save_file(char *file_name);
int bpm_get_global_tbt_timing_c(int max_events, int *events,
				int *num_events=(int *) NULL, int max_delays=0,
				double *delays=(double *) NULL,
				int *num_delays=(int *) NULL);
int bpm_get_house_names_c(char *house, int max_return, int *num_names,
			  char *names, int *channels=(int *) NULL);
int bpm_get_intensity_c(int frame, int num_frame,
			float *horz_int=(float *) NULL,
			float *vert_int=(float *) NULL,
			char *horz_status=(char *) NULL,
			char *vert_status=(char *) NULL,
			unsigned int *timestamp=(unsigned int *) NULL,
			char **file_title=(char **) NULL,
			float *time_in_cycle=(float *) NULL,
			int *frames_ret=(int *) NULL,
			unsigned int data_view=BPM_VIEW_DEFAULT,
			int type=BPM_FLASH, int scale_it=TRUE,
			void *readout_spec=(void *) NULL,
			unsigned int *attributes=(unsigned int *) NULL,
			void *metadata=(void *) NULL);
int bpm_get_intensity_locations(float *h_loc, float *v_loc=(float *) NULL);
int bpm_get_intensity_names(char *horz_names, int *num_horizontal,
			    char *vert_names=(char *) NULL,
			    int *num_vertical=(int *) NULL,
			    int ortho_plane=BPM_MODE_NORMAL,
			    unsigned int data_view=BPM_VIEW_DEFAULT);
int bpm_get_last_microp_status_c(int max_return, int *num_status,
				 int *status_values);
int bpm_get_locations(float *horz_locations,
		      float *vert_locations=(float *) NULL,
		      unsigned int data_view=BPM_VIEW_DEFAULT);
int bpm_get_microp_times_c(unsigned int *timestamps,
			   unsigned int *nanoseconds, int *num_timestamps,
			   int max_return, int *cycle_ids=(int *) NULL);
int bpm_get_names(char *horz_names, char *vert_names=(char *) NULL,
		  int ortho_plane=BPM_MODE_NORMAL,
		  unsigned int data_view=BPM_VIEW_DEFAULT,
		  int *horz_machines=(int *) NULL,
		  int *vert_machines=(int *) NULL);
int bpm_get_offsets(float *h_off, float *v_off=(float *) NULL);
int bpm_get_plot_window_info_c(int screen, int plot_type, int plane,
			       unsigned int options, int *num_windows,
			       BPM_PLOT_WINDOW_DATA **window_info);
int bpm_get_raw_data_c(int type, int frame, int num_frames,
		       void *readout_spec, unsigned int data_view,
		       void *horz_data, char *horz_status, void *vert_data,
		       char *vert_status, unsigned int *timestamps,
		       unsigned int *nano_offsets, float *time_in_cycle,
		       int *turn_numbers, int *cycle, int *num_timing,
		       int *timing_params, void *metadata,
		       int *frames_ret, int *returned_type);
int bpm_get_raw_mode_data_c(char *detector, int max_turns, void *data,
			    unsigned int *timestamps, int *num_turns,
			    unsigned int *time, void *readout_spec,
			    void *metadata);
int bpm_get_raw_tbt_data_c(char *detector, int max_turns, void *data,
			   unsigned int *timestamps, int *num_turns,
			   int filter_data, unsigned int *time,
			   void *readout_spec, void *metadata);
int bpm_get_sample_mode(int *particle_type, int *sample_type,
			char *house=(char *) NULL);
int bpm_get_save_file(char *file_name);
int bpm_get_saved_position_c(char *detector, char *file_name,
			     int start_file, int num_files,
			     int start_frame, int num_frames,
			     int frame_type, int *num_values,
			     BPM_SAVED_POSITION *position_data);
int bpm_get_tbt_crates_and_channels(int *crates, int *channels);
int bpm_get_tbt_data_c(char *detector, float *positions,
		       unsigned int *timestamps, int *num_turns,
		       int filter_data, unsigned int *time,
		       float *intensities=(float *) NULL,
		       int scale_it=TRUE, void *readout_spec=(void *) NULL,
		       unsigned int *attributes=(unsigned int *) NULL,
		       void *metadata=(void *) NULL,
		       int max_turns=BPM_NUM_TBT_VALUES);
int bpm_get_tbt_intensity_c(char *house, float *intensities,
			    unsigned int *timestamps, int *num_turns,
			    int filter_data, unsigned int *time);
int bpm_get_tbt_names(char *tbt_names, int *num_tbt);
int bpm_get_tbt_timing_c(char *house, int *events,
			 float *delays, int num_times);
int bpm_get_threshold_c(int machine_state, float *threshold);
int bpm_house_info(char *houses,
		   unsigned short *nodes=(unsigned short *) NULL,
		   int *types=(int *) NULL, char *prefixes=(char *) NULL,
		   char *dwnload_files=(char *) NULL);
int bpm_house_menu_c(int top_row, int left_column, char *house_name,
		     int *house_index=(int *) NULL,
		     int house_type=BPM_ALL_HOUSES);
int bpm_house_select_delete_c(short window_id);
int bpm_house_select_init_c(short window_id, int row, int left_column,
			    char *initial_house,
			    int house_type=BPM_ALL_HOUSES);
int bpm_house_select_set_c(short window_id, char *new_house);
int bpm_house_select_update_c(short window_id, char *ret_house,
			      int *house_type=(int *) NULL);
int bpm_interrogate_plot(bpm_plot_update_func update_func,
			 int screen=(int) CLIB_DEFAULT_ARG);
int bpm_is_tbt_trigger_enabled(char *house=(char *) NULL,
			       void *enable_info=(void *) NULL);
int bpm_link_file_c(int file_number, BPM_FILE_LINK_INFO *link_to);
int bpm_lock_tbt_buffer_c(char *house, int lock_it);
int bpm_machine_c(int machine);
char *bpm_machine_to_string_c(int machine);
int bpm_map_from_model_c(int type, float *input_buffer,
			 float *output_buffer);
int bpm_map_from_tevconfig_c(int type, float *input_buffer,
			     float *output_buffer);
int bpm_master_file_menu_c(int top_row, int left_column, int machine,
			   unsigned int options, char *file_name,
			   int *is_default_file);
int bpm_name_to_index_c(char *names, int plane, unsigned int data_view,
			int *index);
int bpm_next_house_c(char *house, char *next_house,
		     int direction=BPM_NEXT_HOUSE,
		     int *house_index=(int *) NULL,
		     int house_type=BPM_ALL_HOUSES);
int bpm_next_unlinked_file_c(int file_number, int *next_file);
int bpm_num_machine_states(int *num_states);
int bpm_plot_data(BPM_PLT_OPT *plot_options, float *horz_pos=(float *) NULL,
		  float *vert_pos=(float *) NULL,
		  char *horz_status=(char *) NULL,
		  char *vert_status=(char *) NULL,
		  unsigned int *timestamp=(unsigned int *) NULL,
		  float *loss_data=(float *) NULL,
		  char *loss_status=(char *) NULL,
		  float *horz_int=(float *) NULL,
		  float *vert_int=(float *) NULL,
		  float *time_in_cycle=(float *) NULL,
		  char *bpm_title=(char *) NULL,
		  char *horz_int_status=(char *) NULL,
		  char *vert_int_status=(char *) NULL,
		  int cycle=EVENT_NULL, float *user_horz_pos=(float *) NULL,
		  float *user_vert_pos=(float *) NULL,
		  int *turn_numbers=(int *) NULL,
		  unsigned int *timestamps=(unsigned int *) NULL,
		  unsigned int *nano_offsets=(unsigned int *) NULL,
		  int *colors=(int *) NULL, void *metadata=(void *) NULL);
int bpm_protect_file_c(int file_number, int protection);
int bpm_query(int *num_horz, int *num_vert=(int *) NULL,
	      int ortho_plane=BPM_MODE_NORMAL,
	      unsigned int data_view=BPM_VIEW_DEFAULT);
int bpm_read_file_range_data_c(char *detector_name, int data_type,
			       int particle_type, int frame_type,
			       int frame_number, unsigned int options,
			       void *start_value, void *end_value,
			       int *num_values, int **file_numbers,
			       float **values, char **status_values,
			       unsigned int **timestamps,
			       unsigned int **nanoseconds);
int bpm_read_frame_file_data_c(char *detector_name, int data_type,
			       int particle_type, int file_number,
			       int start_frame, int max_frames,
			       int *num_frames, float *values,
			       char *status_values,
			       unsigned int *timestamps,
			       unsigned int *nanoseconds,
			       float *time_in_cycle,
			       int *turn_numbers, int *frame_type,
			       void *metadata);
int bpm_read_frame_file_info_c(int file_number, int max_return,
			       int *num_detectors, char *detector_names,
			       int *max_frames);
int bpm_read_tbt_buffer_lock_c(char *house, int max_return,
			       int *locked, int *num_returned);
int bpm_read_tbt_mode_c(char *house, int max_return,
			int *mode, int *num_returned);
int bpm_rename_file_c(int file_number, char *title);
int bpm_request_data_c(int event_index, void *acquisition_spec,
		       int start_house, int num_houses);
int bpm_save_data(BPM_SAVE_INFO *save_info, float *time_in_cycle,
		  float *horz_pos=(float *) NULL,
		  char *horz_status=(char *) NULL,
		  float *vert_pos=(float *) NULL,
		  char *vert_status=(char *) NULL,
		  float *losses=(float *) NULL,
		  char *loss_status=(char *) NULL,
		  float *horz_int=(float *) NULL,
		  float *vert_int=(float *) NULL,
		  int *turn_numbers=(int *) NULL,
		  unsigned int *timestamps=(unsigned int *) NULL,
		  unsigned int *nano_offsets=(unsigned int *) NULL);
int bpm_save_frame_data_c(char *detector_name, int data_type, int new_file,
			  BPM_SAVE_INFO *save_info, float *values,
			  char *status_values, unsigned int *timestamps,
			  unsigned int *nanoseconds, float *time_in_cycle,
			  int *turn_numbers);
int bpm_set_calculation_masks_c(unsigned int data_view, int horz_mask_index,
				int num_horz_masks, int *horz_masks,
				int vert_mask_index, int num_vert_masks,
				int *vert_masks);
int bpm_set_calibration_spec_c(void *calibration_spec,
			       int start_house, int num_houses);
int bpm_set_detector_status_c(char *detector, int plane,
			      int detector_status);
int bpm_set_diagnostic_spec_c(void *diagnostic_spec,
			      int start_house, int num_houses);
int bpm_set_frame_save_file(char *file_name);
int bpm_set_global_tbt_timing_c(int num_events, int *events,
				int num_delays=0,
				double *delays=(double *) NULL,
				void *machine_data=(void *) NULL);
int bpm_set_intensity_mapping_c(int mode);
int bpm_set_readout_spec_c(int type, void *readout_spec);
int bpm_set_reference_file_c(int file_number, int reference);
int bpm_set_sample_mode_c(int particle_plane, int bunch_or_batch,
			  char *house=(char *) NULL);
int bpm_set_save_file(char *file_name);
int bpm_set_tbt_mode_c(char *house, int mode);
int bpm_set_tbt_timing_c(char *house, int *events,
			 float *delays, int num_times,
			 void *machine_data=(void *) NULL);
int bpm_set_tbt_timing_params(void *machine_data);
int bpm_set_threshold_c(int machine_state, float threshold);
int bpm_state_menu_c(int top_row, int left_column, int *state);
char *bpm_status_to_string_c(int bpm_status, int want_symbolic=FALSE);
int bpm_string_to_frame_type(char *string, int *frame_type);
int bpm_string_to_machine(char *string, int *machine);
int bpm_to_crate_and_channel_c(char *detector, char *crate_name,
			       int *crate_number, int *channel_number);
int bpm_unlink_file_c(int file_number);
int bpm_use_buffered_data_c(int use_buffered);
int bpm_verify_house_c(char *house, int *house_index=(int *) NULL,
		       int house_type=BPM_ALL_HOUSES);

#ifdef __cplusplus
}
#endif


/******************************************************************************/
/*
**	equivalent name definitions
*/
/******************************************************************************/

#define	BLM_ABORT_MAP_SELECT_C		blm_abort_map_select_c
#define	BLM_DETECTOR_NAME_SEARCH	blm_detector_name_search
#define	BLM_GET_ABORT_INFO_C		blm_get_abort_info_c
#define	BLM_GET_ABORT_MAP		blm_get_abort_map
#define	BLM_GET_ABORT_STATUS_C		blm_get_abort_status_c
#define	BLM_GET_CRATES_AND_CHANNELS	blm_get_crates_and_channels
#define	BLM_GET_DATA_C			blm_get_data_c
#define	BLM_GET_FILE_FRAME_DATA_C	blm_get_file_frame_data_c
#define	BLM_GET_FRAME_DATA_C		blm_get_frame_data_c
#define	BLM_GET_FRAME_LIST_DATA_C	blm_get_frame_list_data_c
#define	BLM_GET_HOUSE_ABORT_CONFIG_C	blm_get_house_abort_config_c
#define	BLM_GET_HOUSE_NAMES_C		blm_get_house_names_c
#define	BLM_GET_LOCATIONS		blm_get_locations
#define	BLM_GET_NAMES			blm_get_names
#define	BLM_GET_SYSTEM_SAMPLE_DATA	blm_get_system_sample_data
#define	BLM_GET_TBT_DATA_C		blm_get_tbt_data_c
#define	BLM_GET_TBT_LIST_DATA_C		blm_get_tbt_list_data_c
#define	BLM_INTERROGATE_PLOT		blm_interrogate_plot
#define	BLM_LAST_ERROR			blm_last_error
#define	BLM_NAME_TO_INDEX_C		blm_name_to_index_c
#define	BLM_NUM_ABORT_STATES		blm_num_abort_states
#define	BLM_NUM_MACHINE_STATES		blm_num_machine_states
#define	BLM_PLOT_DATA			blm_plot_data
#define	BLM_QUERY			blm_query
#define	BLM_SET_ABORT_MAP_C		blm_set_abort_map_c
#define	BLM_SET_ABORT_MASK_C		blm_set_abort_mask_c
#define	BLM_SET_ABORT_MASK_BY_ADDRESS_C	blm_set_abort_mask_by_address_c
#define	BLM_SET_ABORT_MULTIPLICITY_C	blm_set_abort_multiplicity_c
#define	BLM_SET_ABORT_THRESHOLD_C	blm_set_abort_threshold_c
#define	BLM_SET_ABORT_THRESHOLD_BY_ADDRESS_C	blm_set_abort_threshold_by_address_c
#define	BLM_SET_SYSTEM_SAMPLE_DATA_C	blm_set_system_sample_data_c
#define	BLM_STATE_MENU_C		blm_state_menu_c
#define	BLM_TO_CRATE_AND_CHANNEL_C	blm_to_crate_and_channel_c
#define	BPM_BEAM_CYCLE_INFO		bpm_beam_cycle_info
#define	BPM_CALCULATE_RMS_DPOVERP_C	bpm_calculate_rms_dpoverp_c
#define	BPM_CHECK_FOR_DATA_C		bpm_check_for_data_c
#define	BPM_CRATE_AND_CHANNEL_TO_NAME_C	bpm_crate_and_channel_to_name_c
#define	BPM_CRATE_INFO_C		bpm_crate_info_c
#define	BPM_CRATE_NAME_TO_INDEX		bpm_crate_name_to_index
#define	BPM_DATA_SOURCE_C		bpm_data_source_c
#define	BPM_DETECTOR_NAME_SEARCH	bpm_detector_name_search
#define	BPM_GET_DATABASE_SYSTEM_ID	bpm_get_database_system_id
#define	BPM_DEFAULT_DATA_EVENT		bpm_default_data_event
#define	BPM_DIRECTORY_INFO		bpm_directory_info
#define	BPM_ENABLE_TBT_TRIGGER_C	bpm_enable_tbt_trigger_c
#define	BPM_FILE_LINK_INFO_C		bpm_file_link_info_c
#define	BPM_FILE_MENU_C			bpm_file_menu_c
#define	BPM_FIND_OLDEST_FILE_NUMBER_C	bpm_find_oldest_file_number_c
#define	BPM_FRAME_FILE_MENU_C		bpm_frame_file_menu_c
#define	BPM_FRAME_TYPE_TO_STRING_C	bpm_frame_type_to_string_c
#define	BPM_GET_CALCULATION_MASKS_C	bpm_get_calculation_masks_c
#define	BPM_GET_CALIBRATION_SPEC_C	bpm_get_calibration_spec_c
#define	BPM_GET_CRATES_AND_CHANNELS	bpm_get_crates_and_channels
#define	BPM_GET_DATA_C			bpm_get_data_c
#define	BPM_GET_DEFAULT_SAVE_FILE	bpm_get_default_save_file
#define	BPM_GET_DETECTOR_STATUS		bpm_get_detector_status
#define	BPM_GET_EVENT_SPEC_TEXT_C	bpm_get_event_spec_text_c
#define	BPM_GET_FILE_FRAME_DATA_C	bpm_get_file_frame_data_c
#define	BPM_GET_FILTER_TEXT_C		bpm_get_filter_text_c
#define	BPM_GET_FRAME_DATA_C		bpm_get_frame_data_c
#define	BPM_GET_FRAME_SAVE_FILE		bpm_get_frame_save_file
#define	BPM_GET_GLOBAL_TBT_TIMING_C	bpm_get_global_tbt_timing_c
#define	BPM_GET_HOUSE_NAMES_C		bpm_get_house_names_c
#define	BPM_GET_INTENSITY_C		bpm_get_intensity_c
#define	BPM_GET_INTENSITY_LOCATIONS	bpm_get_intensity_locations
#define	BPM_GET_INTENSITY_NAMES		bpm_get_intensity_names
#define	BPM_GET_LAST_MICROP_STATUS_C	bpm_get_last_microp_status_c
#define	BPM_GET_LOCATIONS		bpm_get_locations
#define	BPM_GET_MICROP_TIMES_C		bpm_get_microp_times_c
#define	BPM_GET_NAMES			bpm_get_names
#define	BPM_GET_OFFSETS			bpm_get_offsets
#define	BPM_GET_PLOT_WINDOW_INFO_C	bpm_get_plot_window_info_c
#define	BPM_GET_RAW_DATA_C		bpm_get_raw_data_c
#define	BPM_GET_RAW_MODE_DATA_C		bpm_get_raw_mode_data_c
#define	BPM_GET_RAW_TBT_DATA_C		bpm_get_raw_tbt_data_c
#define	BPM_GET_SAMPLE_MODE		bpm_get_sample_mode
#define	BPM_GET_SAVE_FILE		bpm_get_save_file
#define	BPM_GET_SAVED_POSITION_C	bpm_get_saved_position_c
#define	BPM_GET_TBT_CRATES_AND_CHANNELS	bpm_get_tbt_crates_and_channels
#define	BPM_GET_TBT_DATA_C		bpm_get_tbt_data_c
#define	BPM_GET_TBT_INTENSITY_C		bpm_get_tbt_intensity_c
#define	BPM_GET_TBT_NAMES		bpm_get_tbt_names
#define	BPM_GET_TBT_TIMING_C		bpm_get_tbt_timing_c
#define	BPM_GET_THRESHOLD_C		bpm_get_threshold_c
#define	BPM_HOUSE_INFO			bpm_house_info
#define	BPM_HOUSE_MENU_C		bpm_house_menu_c
#define	BPM_HOUSE_SELECT_DELETE_C	bpm_house_select_delete_c
#define	BPM_HOUSE_SELECT_INIT_C		bpm_house_select_init_c
#define	BPM_HOUSE_SELECT_SET_C		bpm_house_select_set_c
#define	BPM_HOUSE_SELECT_UPDATE_C	bpm_house_select_update_c
#define	BPM_INTERROGATE_PLOT		bpm_interrogate_plot
#define	BPM_IS_TBT_TRIGGER_ENABLED	bpm_is_tbt_trigger_enabled
#define	BPM_LINK_FILE_C			bpm_link_file_c
#define	BPM_LOCK_TBT_BUFFER_C		bpm_lock_tbt_buffer_c
#define	BPM_MACHINE_C			bpm_machine_c
#define	BPM_MACHINE_TO_STRING_C		bpm_machine_to_string_c
#define	BPM_MAP_FROM_MODEL_C		bpm_map_from_model_c
/* #define	BPM_MAP_FROM_TEVCONFIG_C	bpm_map_from_tevconfig_c */
#define	BPM_MASTER_FILE_MENU_C		bpm_master_file_menu_c
#define	BPM_NAME_TO_INDEX_C		bpm_name_to_index_c
#define	BPM_NEXT_HOUSE_C		bpm_next_house_c
#define	BPM_NEXT_UNLINKED_FILE_C	bpm_next_unlinked_file_c
#define	BPM_NUM_MACHINE_STATES		bpm_num_machine_states
#define	BPM_PLOT_DATA			bpm_plot_data
#define	BPM_PROTECT_FILE_C		bpm_protect_file_c
#define	BPM_QUERY			bpm_query
#define	BPM_READ_FILE_RANGE_DATA_C	bpm_read_file_range_data_c
#define	BPM_READ_FRAME_FILE_DATA_C	bpm_read_frame_file_data_c
#define	BPM_READ_FRAME_FILE_INFO_C	bpm_read_frame_file_info_c
#define	BPM_READ_TBT_BUFFER_LOCK_C	bpm_read_tbt_buffer_lock_c
#define	BPM_READ_TBT_MODE_C		bpm_read_tbt_mode_c
#define	BPM_RENAME_FILE_C		bpm_rename_file_c
#define	BPM_REQUEST_DATA_C		bpm_request_data_c
#define	BPM_SAVE_DATA			bpm_save_data
#define	BPM_SAVE_FRAME_DATA_C		bpm_save_frame_data_c
#define	BPM_SET_CALCULATION_MASKS_C	bpm_set_calculation_masks_c
#define	BPM_SET_CALIBRATION_SPEC_C	bpm_set_calibration_spec_c
#define	BPM_SET_DETECTOR_STATUS_C	bpm_set_detector_status_c
#define	BPM_SET_FRAME_SAVE_FILE		bpm_set_frame_save_file
#define	BPM_SET_GLOBAL_TBT_TIMING_C	bpm_set_global_tbt_timing_c
#define	BPM_SET_INTENSITY_MAPPING_C	bpm_set_intensity_mapping_c
#define	BPM_SET_READOUT_SPEC_C		bpm_set_readout_spec_c
#define	BPM_SET_REFERENCE_FILE_C	bpm_set_reference_file_c
#define	BPM_SET_SAMPLE_MODE_C		bpm_set_sample_mode_c
#define	BPM_SET_SAVE_FILE		bpm_set_save_file
#define	BPM_SET_TBT_MODE_C		bpm_set_tbt_mode_c
#define	BPM_SET_TBT_TIMING_C		bpm_set_tbt_timing_c
#define	BPM_SET_TBT_TIMING_PARAMS	bpm_set_tbt_timing_params
#define	BPM_SET_THRESHOLD_C		bpm_set_threshold_c
#define	BPM_STATE_MENU_C		bpm_state_menu_c
#define	BPM_STATUS_TO_STRING_C		bpm_status_to_string_c
#define	BPM_STRING_TO_FRAME_TYPE	bpm_string_to_frame_type
#define	BPM_STRING_TO_MACHINE		bpm_string_to_machine
#define	BPM_TO_CRATE_AND_CHANNEL_C	bpm_to_crate_and_channel_c
#define	BPM_UNLINK_FILE_C		bpm_unlink_file_c
#define	BPM_USE_BUFFERED_DATA_C		bpm_use_buffered_data_c
#define	BPM_VERIFY_HOUSE_C		bpm_verify_house_c

#endif