threadedlib_h

/*
**	Copyright 2000-2015, Fermi Research Alliance, LLC.  All rights reserved.
*/
/******************************************************************************/
/* threadedlib.h
**
**	prototypes and defined constants for argument values for
**	ul_threaded library routines
**
*/
/******************************************************************************/

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

#include "cns_data_structs.h"

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

#define	TIMER_TYPE_DELAY	0	/* timer will expire after a requested number of milliseconds */
#define	TIMER_TYPE_ABSOLUTE	1	/* timer will expire at an absolute time */

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


//typedef void (*alarm_handler)(int device_index, int is_bad,
//			      unsigned int raw_data, char *alarm_text,
//			      unsigned int clinks,
//			      unsigned int nanoseconds,
//			      void *user_data);		/* alarm callback */

typedef void (*periodic_handler)(char const *handle, unsigned int period,
				 unsigned int periodic_count,
				 unsigned int clinks, unsigned int nanoseconds,
				 void *callback_data);		/* periodic callback */
typedef void (*timer_handler)(char const *handle, unsigned int clinks,
			      unsigned int nanoseconds,
			      void *callback_data);		/* timer callback */

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

#ifdef __cplusplus
extern "C" {
#endif

int event_callback_init_c(int event_number, int event_type,
			  clock_event_handler callback_func,
			  void *func_data, char *handle,
			  unsigned int options, int *callback_id);
int event_callback_term_c(int callback_id);
int periodic_callback_init_c(unsigned int period, int want_immediate,
			     periodic_handler callback_func, void *func_data,
			     char const *handle=(char const *) NULL,
			     unsigned int options=0,
			     int *callback_id=(int *) NULL);
int periodic_callback_term_c(int callback_id);
int timer_callback_request_c(int timer_type, unsigned int timer_value,
			     timer_handler callback_func, void *func_data,
			     char const *handle=(char const *) NULL,
			     unsigned int options=0);

#ifdef __cplusplus
}
#endif

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

#define	EVENT_CALLBACK_INIT_C		event_callback_init_c
#define	EVENT_CALLBACK_TERM_C		event_callback_term_c
#define	PERIODIC_CALLBACK_INIT_C	periodic_callback_init_c
#define	PERIODIC_CALLBACK_TERM_C	periodic_callback_term_c
#define	TIMER_CALLBACK_REQUEST_C	timer_callback_request_c

#endif