scopelib_h

/*
**	Copyright 2015-2016, Fermi Research Alliance, LLC.  All rights reserved.
*/
/******************************************************************************/
/* scopelib.h
**
**	This header file contains definitions for accessing scope information.
**
*/
/******************************************************************************/

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

#include "ul_vxi11/scope.h"

#define	SCOPE_ALL_CHANNELS		(-1)	/* specify all scope channels */

#define	SCOPE_IP_NAME_LEN		128	/* scope IP name length */

#define	SCOPE_MANUFACTURER_NAME_LEN	64	/* manufacturer name length */

#define	SCOPE_MODEL_NAME_LEN		64	/* model name length */

#define	SCOPE_INTERFACE_NAME_LEN	64	/* interface name length */

#define	SCOPE_USAGE_LEN			254	/* usage length */

#define	SCOPE_LOCATION_LEN		64	/* location length */

#define	SCOPE_MANUFACTURER_TEXTRONIX	1	/* Tektronix */
#define	SCOPE_MANUFACTURER_LECROY	2	/* Lecroy */

#define	SCOPE_MODEL_TDS7154		1	/* Tektronix TDS7154 */
#define	SCOPE_MODEL_LT224		2	/* Lecroy LT224 */
#define	SCOPE_MODEL_TDS7404		3	/* Tektronix TDS7404 */
#define	SCOPE_MODEL_DPO7254		4	/* Tektronix DPO7254 */
#define	SCOPE_MODEL_RTD720		5	/* Tektronix RTD720 */

#define	SCOPE_TRIGGER_UNKNOWN		(-1)
#define	SCOPE_TRIGGER_A			0
#define	SCOPE_TRIGGER_B			1

#define	SCOPE_TRIGGER_TYPE_UNKNOWN	(-1)
#define	SCOPE_TRIGGER_TYPE_EDGE		0
#define	SCOPE_TRIGGER_TYPE_PULSE	1
#define	SCOPE_TRIGGER_TYPE_LOGIC	2
#define	SCOPE_TRIGGER_TYPE_COMM		3
#define	SCOPE_TRIGGER_TYPE_SERIAL	4

#define	SCOPE_NUM_TRIGGER_TYPES		5

#define	SCOPE_TRIGGER_MODE_UNKNOWN	(-1)
#define	SCOPE_TRIGGER_MODE_NORMAL	0
#define	SCOPE_TRIGGER_MODE_AUTO		1

#define	SCOPE_NUM_TRIGGER_MODES		2

#define	SCOPE_TRIGGER_SOURCE_UNKNOWN		(-2)
#define	SCOPE_TRIGGER_SOURCE_LINE		(-1)
#define	SCOPE_TRIGGER_SOURCE_AUXILIARY		0
#define	SCOPE_TRIGGER_SOURCE_EXTERNAL		0
#define	SCOPE_TRIGGER_SOURCE_CH1		1
#define	SCOPE_TRIGGER_SOURCE_CH2		2
#define	SCOPE_TRIGGER_SOURCE_CH3		3
#define	SCOPE_TRIGGER_SOURCE_CH4		4

#define	SCOPE_NUM_TRIGGER_SOURCES		6

#define	SCOPE_TRIGGER_COUPLING_UNKNOWN		(-1)
#define	SCOPE_TRIGGER_COUPLING_DC		0
#define	SCOPE_TRIGGER_COUPLING_AC		1
#define	SCOPE_TRIGGER_COUPLING_HF_REJECT	2
#define	SCOPE_TRIGGER_COUPLING_LF_REJECT	3
#define	SCOPE_TRIGGER_COUPLING_NOISE_REJECT	4

#define	SCOPE_NUM_TRIGGER_COUPLINGS		5

#define	SCOPE_TRIGGER_SLOPE_UNKNOWN	(-1)
#define	SCOPE_TRIGGER_SLOPE_RISING	0
#define	SCOPE_TRIGGER_SLOPE_FALLING	1

#define	TDS7000_NUM_TRIGGER_SLOPES	2

typedef struct SCOPE_INFO_DATA
    {
    char	manufacturer_name[SCOPE_MANUFACTURER_NAME_LEN+2];
    int		manufacturer_id;
    char	model_name[SCOPE_MODEL_NAME_LEN+2];
    int		model_id;
    char	interface_name[SCOPE_INTERFACE_NAME_LEN+2];
    int		interface_id;
    int		node;
    char	fe_interface_name[SCOPE_INTERFACE_NAME_LEN+2];
    int		fe_interface_id;
    int		address;
    char	usage[SCOPE_USAGE_LEN+2];
    char	location[SCOPE_LOCATION_LEN+2];
    char	keeper_name[USER_NAME_LEN+2];
    int		keeper_id;
    char	backup_keeper_name[USER_NAME_LEN+2];
    int		backup_keeper_id;
    char	create_date[DATE_STRING_LEN];
    char	modify_date[DATE_STRING_LEN];
    } __attribute__((packed)) SCOPE_INFO_DATA;

#define	SCOPE_ID_STRING		"scope"

#define	SCOPE_CONNECT_SIMPLE	0
#define	SCOPE_CONNECT_VXI11	1

typedef struct SCOPE_SIMPLE_CONNECTION_DATA
    {
    int		node;
    int		address;
    } __attribute__((packed)) SIMPLE_SCOPE_CONNECTION_DATA;

typedef struct SCOPE_VXI11_CONNECTION_DATA
    {
    scope_t	*connection_data;
    } __attribute__((packed)) SCOPE_VXI11_CONNECTION_DATA;

typedef struct SCOPE_CONNECTION_DATA
    {
    char	id_string[sizeof(SCOPE_ID_STRING)];
    char	ip_name[SCOPE_IP_NAME_LEN+2];
    char	manufacturer_name[SCOPE_MANUFACTURER_NAME_LEN+2];
    int		manufacturer_id;
    char	model_name[SCOPE_MODEL_NAME_LEN+2];
    int		model_id;
    char	interface_name[SCOPE_INTERFACE_NAME_LEN+2];
    int		interface_id;
    int		connect_type;
    union
	{
	SCOPE_SIMPLE_CONNECTION_DATA	simple;
	SCOPE_VXI11_CONNECTION_DATA	vxi11;
	} data;
    } __attribute__((packed)) SCOPE_CONNECTION_DATA;

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

#ifdef __cplusplus
extern "C" {
#endif

int scope_command_trace_off(void);
int scope_command_trace_on(void);
int scope_connect(char const *ip_name, void **connect_info);
int scope_connection_is_valid(void const *connect_info);
int scope_disconnect(void **connect_info);
int scope_enable_channel_c(void *connect_info, int channel);
int scope_error_to_acnet_error_c(int scope_error);
int scope_get_config_info(void *connect_info, void *config_data);
int scope_get_edge_trigger_config_info_c(void *connect_info,
					 int trigger, void *config_data);
int scope_get_id_string_c(void *connect_info, int max_return,
			  char *id_string);
int scope_get_last_scope_error(void);
int scope_get_module_id(void *passed_connect_info, int *module_id);
int scope_get_string_c(void *connect_info, char const *command_string,
		       int max_return, char *data_string);
int scope_get_trigger_config_info_c(void *connect_info, int trigger,
				    void *config_data);
int scope_get_trigger_coupling_convert_id(void *connect_info, int *convert_id);
int scope_get_trigger_mode_convert_id(void *connect_info, int *convert_id);
int scope_get_trigger_slope_convert_id(void *connect_info, int *convert_id);
int scope_get_trigger_source_convert_id(void *connect_info, int *convert_id);
int scope_get_trigger_type_convert_id(void *connect_info, int *convert_id);
int scope_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,
			 void *config_data=(void *) NULL,
			 void *measure_data=(void *) NULL);
int scope_info(char const *ip_name, SCOPE_INFO_DATA *info);
int scope_is_busy(void *connect_info, int *is_busy);
int scope_make_command_trace_entry(char const *command_string, int status=0,
				   int error=0);
int scope_request_measurement(void *connect_info);
int scope_reset(void *connect_info);
int scope_set_display_position_c(void *connect_info, int position);
int scope_set_edge_trigger_params_c(void *connect_info, int trigger,
				    int source=CLIB_DEFAULT_ARG,
				    int coupling=CLIB_DEFAULT_ARG,
				    int slope=CLIB_DEFAULT_ARG);
int scope_set_last_scope_error_c(int scope_error);
int scope_set_num_traces_c(void *connect_info, int num_traces);
int scope_set_offset_c(void *connect_info, int channel, double offset);
int scope_set_range_c(void *connect_info, int channel, double range);
int scope_set_sample_rate_c(void *connect_info, double sample_rate);
int scope_set_trace_length_c(void *connect_info, int trace_length);
int scope_set_trigger_level_c(void *connect_info, int trigger,
			      double level);
int scope_set_trigger_type_c(void *passed_connect_info, int trigger,
			     int type=CLIB_DEFAULT_ARG,
			     int mode=CLIB_DEFAULT_ARG);

#ifdef __cplusplus
}
#endif

#endif