calclib_h

/*
**	Copyright 2014-2015, Fermi Research Alliance, LLC.  All rights reserved.
*/
/******************************************************************************/
/* calclib.h
**
**	function prototypes and defined constants for argument values for
**	calculated device data routines
**
**	V0.1	Yu Ivanov / Accelerator Controls		19-May-2014
**
**	V0.2	Yu Ivanov / Accelerator Controls		08-Feb-2016
**		DIO_INTEGRAL_RMS, DIO_CALC_TYPE_INTEGRAL_RMS,
**		DIO_RMS, DIO_CALC_TYPE_RMS - added
*/
/******************************************************************************/

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

    #define DIO_SIMPLE_AVERAGE		1	/* arithmetic average, =DIO_COMMON  */
    #define DIO_PRIMARY_SIMPLE_AVERAGE	0	/* arithmetic average (primary value),
    						 = DIO_PRIMARY */
    #define DIO_INTEGRAL_AVERAGE	11	/* integral average		*/
    #define DIO_INTEGRAL		12	/* integral value of F(x)	*/
    #define DIO_INTEGRAL_ABSOLUTE	13	/* integral value of abs(F(x))	*/
    #define DIO_STANDARD_DEVIATION	14	/* standard deviation		*/
    #define DIO_SPEED_IN_PERCENTS	15	/* speed in percents		*/
    #define DIO_RMS			16	/* Root Mean Square		*/
    #define DIO_INTEGRAL_RMS		17	/* Integral Root Mean Square	*/

#define	DIO_CALC_TYPE_NONE		(-1)	/* no calculation type specified */
#define	DIO_CALC_TYPE_SIMPLE_AVERAGE	(DIO_SIMPLE_AVERAGE)	/* arithmetic average */
#define	DIO_CALC_TYPE_PRIMARY_SIMPLE_AVERAGE	(DIO_PRIMARY_SIMPLE_AVERAGE)	/* arithmetic average (primary value) */
#define	DIO_CALC_TYPE_INTEGRAL_AVERAGE	(DIO_INTEGRAL_AVERAGE)	/* integral average */
#define	DIO_CALC_TYPE_INTEGRAL		(DIO_INTEGRAL)		/* integral value of F(x) */
#define	DIO_CALC_TYPE_INTEGRAL_ABSOLUTE	(DIO_INTEGRAL_ABSOLUTE)	/* integral value of abs(F(x)) */
#define	DIO_CALC_TYPE_STANDARD_DEVIATION	(DIO_STANDARD_DEVIATION)	/* standard deviation */
#define	DIO_CALC_TYPE_SPEED_IN_PERCENT	(DIO_SPEED_IN_PERCENTS)	/* speed in percent */
#define	DIO_CALC_TYPE_RMS		(DIO_RMS)	/* Root Mean Square */
#define	DIO_CALC_TYPE_INTEGRAL_RMS	(DIO_INTEGRAL_RMS) /* Integral Root Mean Square */


/******************************************************************************/
/*
**	function prototypes
*/
/******************************************************************************/

#ifdef __cplusplus
extern "C" {
#endif

    int dio_bld_calc_buffer_list_c(int *list_id, int numdev,
				   int *di, short *pi, unsigned int *ai,
				   short cvt_type, short *errors,
				   char const *passed_des=(char const *) NULL,
				   unsigned int start_time=0,
				   unsigned int options=0);
    int dio_can_calc_buffer_device_c(int device_index, short property,
				     unsigned int array_index, short cnv_type,
				     char const *passed_des=(char const *) NULL,
				     unsigned int start_time=0,
				     unsigned int options=0);
    int dio_can_calc_buffer_list_c(int *listid);
    int dio_cancel_all_calc_devices(void);
    int dio_get_calc_buffer_device_c(int device_index, short property,
				     unsigned int array_index, short cnv_type,
				     unsigned int start_time_interval,
				     unsigned int end_time_interval,
				     double *value,
				     char const *passed_des=(char const *) NULL,
				     unsigned int options=0);
    int dio_get_calc_buffer_list_c(int *listid, unsigned int start_time,
				   unsigned int end_time,
				   double *values, short *err_val);
    int dio_get_calc_value_c(int device_index, short property,
			     unsigned int array_index,
			     short node, DATA_EVENT_DATA const *ded, 
			     unsigned int start_time, unsigned int end_time,
			     short convert_type, double *value);
    int dio_make_calc_buffers_c(int list_id);

#ifdef __cplusplus
}
#endif

#endif