lecroydefs_h

/*
**	Copyright 2015, Fermi Research Alliance, LLC.  All rights reserved.
*/
/******************************************************************************/
/* lecroydefs.h
**
**	This header file contains definitions for waverunner_xxx routines.
**
**  MODIFICATION HISTORY:
**
**      R Joshel 	27-Jul-15	Created
**	[@tbs@]...
**
*/
/******************************************************************************/

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

#include "acnet_callbacks.h"

#define	WAVERUNNER_NUM_TRACES		4
#define	WAVERUNNER_NUM_TRACES_USED	2
#define	WAVERUNNER_NUM_CHANNELS		4
#define	WAVERUNNER_NUM_CHANNELS_USED	2

typedef struct WAVERUNNER_CONFIG_CHANNEL_DATA
    {
    int		state;
    double	offset;
    double	range;
    double	vscale;
    } __attribute__((packed)) WAVERUNNER_CONFIG_CHANNEL_DATA;

#define	WAVERUNNER_TRIGGER_TYPE_LEN	6
#define	WAVERUNNER_TRIGGER_MODE_LEN	6
#define	WAVERUNNER_TRIGGER_SOURCE_LEN	9
#define	WAVERUNNER_TRIGGER_COUPLING_LEN	8
#define	WAVERUNNER_TRIGGER_SLOPE_LEN	4

#define	WAVERUNNER_TRIGGER_UNKNOWN	(-1)
#define	WAVERUNNER_TRIGGER_A		0
#define	WAVERUNNER_TRIGGER_B		1

#define	WAVERUNNER_TRIGGER_TYPE_UNKNOWN		(-1)
#define	WAVERUNNER_TRIGGER_TYPE_EDGE		0
#define	WAVERUNNER_TRIGGER_TYPE_DROPOUT		5
#define	WAVERUNNER_TRIGGER_TYPE_GLITCH		6
#define	WAVERUNNER_TRIGGER_TYPE_INTERVAL	7
#define	WAVERUNNER_TRIGGER_TYPE_STD		8
#define	WAVERUNNER_TRIGGER_TYPE_SNG		9
#define	WAVERUNNER_TRIGGER_TYPE_SQ		10
#define	WAVERUNNER_TRIGGER_TYPE_TEQ		11

#define	WAVERUNNER_NUM_TRIGGER_TYPES		8

#define	WAVERUNNER_TRIGGER_MODE_UNKNOWN	(-1)
#define	WAVERUNNER_TRIGGER_MODE_NORMAL	0
#define	WAVERUNNER_TRIGGER_MODE_AUTO	1
#define	WAVERUNNER_TRIGGER_MODE_SINGLE	2
#define	WAVERUNNER_TRIGGER_MODE_STOP	3

#define	WAVERUNNER_NUM_TRIGGER_MODES	4

#define	WAVERUNNER_TRIGGER_SOURCE_UNKNOWN	(-2)
#define	WAVERUNNER_TRIGGER_SOURCE_LINE		(-1)
#define	WAVERUNNER_TRIGGER_SOURCE_AUXILIARY	0
#define	WAVERUNNER_TRIGGER_SOURCE_EXTERNAL	0
#define	WAVERUNNER_TRIGGER_SOURCE_CH1		1
#define	WAVERUNNER_TRIGGER_SOURCE_CH2		2
#define	WAVERUNNER_TRIGGER_SOURCE_CH3		3
#define	WAVERUNNER_TRIGGER_SOURCE_CH4		4
#define	WAVERUNNER_TRIGGER_SOURCE_EXTERNAL_10	5
#define	WAVERUNNER_TRIGGER_SOURCE_ETM_10	6
#define	WAVERUNNER_TRIGGER_SOURCE_PA		7

#define	WAVERUNNER_NUM_TRIGGER_SOURCES		9

#define	WAVERUNNER_TRIGGER_COUPLING_UNKNOWN	(-1)
#define	WAVERUNNER_TRIGGER_COUPLING_DC		0
#define	WAVERUNNER_TRIGGER_COUPLING_AC		1
#define	WAVERUNNER_TRIGGER_COUPLING_GROUND	5
#define	WAVERUNNER_TRIGGER_COUPLING_DC50	6
#define	WAVERUNNER_TRIGGER_COUPLING_DC1M	7
#define	WAVERUNNER_TRIGGER_COUPLING_AC1M	8

#define	WAVERUNNER_NUM_TRIGGER_COUPLINGS	6

#define	WAVERUNNER_TRIGGER_SLOPE_UNKNOWN	(-1)
#define	WAVERUNNER_TRIGGER_SLOPE_RISING		0
#define	WAVERUNNER_TRIGGER_SLOPE_FALLING	1

#define	WAVERUNNER_NUM_TRIGGER_SLOPES		2

#define	WAVERUNNER_PULSE_TRIGGER_CLASS_UNKNOWN	(-1)
#define	WAVERUNNER_PULSE_TRIGGER_CLASS_GLITCH	0
#define	WAVERUNNER_PULSE_TRIGGER_CLASS_RUNT	1
#define	WAVERUNNER_PULSE_TRIGGER_CLASS_WIDTH	2
#define	WAVERUNNER_PULSE_TRIGGER_CLASS_TRANSITION	3
#define	WAVERUNNER_PULSE_TRIGGER_CLASS_TIMEOUT	4

typedef struct WAVERUNNER_CONFIG_DATA		/* configuration data from Waverunner scope */
    {
    WAVERUNNER_CONFIG_CHANNEL_DATA	channel_data[WAVERUNNER_NUM_CHANNELS];
    int		trace_length;
    int		num_traces;
    double	horz_increment;
    int		display_position;
    } __attribute__((packed)) WAVERUNNER_CONFIG_DATA;

typedef struct WAVERUNNER_MEASUREMENT_DATA	/* measurement data from Waverunner scope */
    {
    double	time_last_measure;		/* time of last trigger - t0 (sec) */
    double	trigger_11th;			/* time at the 11th trigger */
    } __attribute__((packed)) WAVERUNNER_MEASUREMENT_DATA;

typedef struct WAVERUNNER_TRIGGER_CONFIG_DATA	/* trigger configuration data from Waverunner scope */
    {
    int		trigger_type;
    int		trigger_source;
    int		trigger_mode;
    double	trigger_level;
    } __attribute__((packed)) WAVERUNNER_TRIGGER_CONFIG_DATA;

typedef struct WAVERUNNER_EDGE_TRIGGER_CONFIG_DATA	/* edge trigger configuration data from Waverunner scope */
    {
    int		trigger_source;
    int		trigger_coupling;
    int		trigger_slope;
    } __attribute__((packed)) WAVERUNNER_EDGE_TRIGGER_CONFIG_DATA;

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

extern "C" {
int waverunner_enable_channel_c(void *connect_info, int channel);
int waverunner_get_config_info(void *connect_info,
			       WAVERUNNER_CONFIG_DATA *config_data);
int waverunner_get_id_string_c(void *connect_info, int max_return,
			       char *id_string);
int waverunner_get_string_c(void *connect_info, char const *command_string,
			    int max_return, char *data_string);
int waverunner_get_trigger_config_info_c(void *connect_info,
					 WAVERUNNER_TRIGGER_CONFIG_DATA *config_data);
int waverunner_get_trigger_coupling_convert_id(int *convert_id);
int waverunner_get_trigger_mode_convert_id(int *convert_id);
int waverunner_get_trigger_slope_convert_id(int *convert_id);
int waverunner_get_trigger_source_convert_id(int *convert_id);
int waverunner_get_trigger_type_convert_id(int *convert_id);
int waverunner_get_waveform_c(void *connect_info,
			      double *horz_increment,
			      int max_traces, int mpnts_per_trace,
			      int *num_traces, int *pnts_per_trace,
			      double **chan_1=(double **) NULL,
			      double **chan_2=(double **) NULL,
			      double **chan_3=(double **) NULL,
			      double **chan_4=(double **) NULL,
			      unsigned int **timestamps=(unsigned int **) NULL,
			      WAVERUNNER_CONFIG_DATA *config_data=(WAVERUNNER_CONFIG_DATA *) NULL,
			      WAVERUNNER_MEASUREMENT_DATA *measure_data=(WAVERUNNER_MEASUREMENT_DATA *) NULL);
int waverunner_request_measurement(void *connect_info);
int waverunner_reset_scope(void *connect_info);
int waverunner_set_edge_trigger_params_c(void *connect_info,
					 int source=CLIB_DEFAULT_ARG,
					 int coupling=CLIB_DEFAULT_ARG,
					 int slope=CLIB_DEFAULT_ARG);
int waverunner_set_num_traces_c(void *connect_info, int num_traces);
int waverunner_set_offset_c(void *connect_info, int channel, double offset);
int waverunner_set_range_c(void *connect_info, int channel, double range);
int waverunner_set_trace_length_c(void *connect_info, int trace_length);
void lecroyuti_clear_statistics(void);
void lecroyuti_get_acb_statistics(SCOPE_ACB_REPLY *reply);

}

#endif