mecarlib_h

/*
**	Copyright 1995, Universities Research Association.  All rights reserved.
*/
/******************************************************************************/
/* mecarlib.h
**  
**	prototypes and defined constants for argument values for
**	ul_mecarlib library routines
**
*/
/******************************************************************************/

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

/******************************************************************************/
/* 
**	macros
*/
/******************************************************************************/

/******************************************************************************/
/* 
**	defined constants for argument values and structure definitions
*/
/******************************************************************************/

#define	MECAR_FIND_CRATE	-1		/* find the active MECAR crate */

#define	MECAR_CAPTURE_DEPOSIT	0		/* capture/deposit state */
#define	MECAR_ACCELERATION	1		/* acceleration state */
#define	MECAR_DECELERATION	-1		/* deceleration state */

#define	MECAR_MAX_RAMP_SLOTS	52		/* maximum number of ramp slots */

typedef struct MECAR_RAMP_SLOT_DATA		/* data structure for Mecar ramp table */
    {
    float	time;
    float	current;
    float	idot;
    float	iddot;
    float	idddot;
    } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ MECAR_RAMP_SLOT_DATA;

#define	MECAR_NUM_RAMP_PARAMETERS	35

typedef struct MECAR_RAMP_TABLE
    {
    float	num_slots;
    float	id[4];
    float	params[MECAR_NUM_RAMP_PARAMETERS];	/* buffer for parameters */
    MECAR_RAMP_SLOT_DATA	slot[MECAR_MAX_RAMP_SLOTS];
    } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ MECAR_RAMP_TABLE;


/******************************************************************************/
/*
**	function prototypes
*/
/******************************************************************************/
extern "C"
{
int mecar_get_crate(void);
int mecar_get_ramp(int cycle, int crate, MECAR_RAMP_TABLE *ramp_data);
int mecar_ramp_current_to_time(int max_times, int start_slot, float current, 
			       float *time, int *accel_state, int *slot,
			       MECAR_RAMP_TABLE *ramp_data);
int mecar_ramp_fit_current_to_time(float current, int accel_state,
				   float slot_length, float *time,
				   MECAR_RAMP_SLOT_DATA *slot_data);
int mecar_ramp_length(int cycle, int crate, float *ramp_length);
int mecar_ramp_time_to_current(float time, float *current, float *idot,
			       MECAR_RAMP_TABLE *ramp_data);
}
/******************************************************************************/
/*
**	equivalent name definitions
*/
/******************************************************************************/

#define	MECAR_GET_CRATE			mecar_get_crate
#define	MECAR_GET_RAMP			mecar_get_ramp
#define	MECAR_RAMP_CURRENT_TO_TIME	mecar_ramp_current_to_time
#define	MECAR_RAMP_FIT_CURRENT_TO_TIME	mecar_ramp_fit_current_to_time
#define	MECAR_RAMP_LENGTH		mecar_ramp_length
#define	MECAR_RAMP_TIME_TO_CURRENT	mecar_ramp_time_to_current

#endif