clockscope_h

/*
**	Copyright 1991-2016, Fermi Research Alliance, LLC.  All rights reserved.
*/
/******************************************************************************/
/* clockscope.h
**
**	Prototypes and defined constants for clockscope.c routines.
**	These depend on defs in cns_misc.h and cbslib.h
**
*/
/******************************************************************************/

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

#include "cnsparam.h"
#include "cns_misc.h"

#define MAX_CS_CYCLES	3			/* # of buffered cycles */
#define	MAX_CS_ENTRY	100			/* maximum allowed records */
#define	LEN_CS_TITLE	20			/* length of record title */
#define	MAX_CL_ENTRY	(60*24*14)		/* max record (~2 weeks) */
#define	LEN_CL_TITLE	24			/* length of record title */

typedef	struct CS_ENTRY_HEADER_T		/* entry header */
    {
    short		cs_key;			/* entry key or number */
    int			cs_date;		/* date (in clinks) written */
    char		cs_title[LEN_CS_TITLE];	/* user title */
    char		cs_author[PROCESS_NAME_LEN];	/* author's process name */
    short		cs_cns;			/* author console # */
    short		cs_slot;		/* author slot # */
    } __attribute__((packed)) cs_entry_header_t;

typedef	struct CS_ENTRY_T			/* one entry */
    {
    cs_entry_header_t	cs_head;		/* entry header */
    CLK_HISTORY2 	cs_hist;		/* event data */
    int			cs_spare;		/* for future use */
    } __attribute__((packed)) cs_entry_t;

typedef	struct CS_DIREC_T			/* header & directory */
    {
    short		direc_count;		/* # of entries */
    short		direc_last;		/* # of last entry */
    cs_entry_header_t	*direc_entry;		/* list of entry headers */
    } __attribute__((packed)) cs_direc_t;

typedef	struct CL_ENTRY_T			/* one entry */
    {
    short		cl_key;			/* entry key or number */
    CLK_HISTORY2 	cl_hist;		/* event data */
    } __attribute__((packed)) cl_entry_t;

typedef	struct CL_DIREC_T			/* header & directory */
    {
    short		direc_count;		/* # of entries */
    short		direc_last;		/* # of last entry */
    int			direc_date[MAX_CL_ENTRY];	/* date of entries */
    } __attribute__((packed)) cl_direc_t;

/******************************************************************************/
/*
**	function prototypes for clockscope functions in the
**	ul_cbsaux library
*/
/******************************************************************************/

#ifdef __cplusplus
extern "C" {
#endif

cs_entry_t *clockscope_directory(int tvrow, int tvcol);
int clockscope_directory_info(int *num_files, cs_entry_header_t **dir_info);
cs_entry_t *clockscope_recall(int key);
int clockscope_save(CLK_HISTORY2 *savdat, char *title, char *author);
int clockscope_file_init(void);
int clockscope_file_dump(void);

int clocklog_dates(int *num_files, unsigned int **dates,
		   int **file_keys=(int **) NULL);
cl_entry_t *clocklog_directory(int tvrow, int tvcol);
cl_entry_t *clocklog_recall(int key, int *numof);
int clocklog_save(CLK_HISTORY2 *savdat);
int clocklog_file_init(void);
int clocklog_file_dump(void);
int clock_history_get_event_counts_c(int event_type,
				     CLK_HISTORY2 const *event_data,
				     int *event_counts);
int clock_history_get_event_times_c(int event_number, int event_type,
				    CLK_HISTORY2 const *event_data,
				    int *num_times,
				    unsigned int **event_times=(unsigned int **) NULL);

#ifdef __cplusplus
}
#endif

#endif