lextuti_h

/*
**	Copyright 1993-2016, Fermi Research Alliance, LLC.  All rights reserved.
*/
/******************************************************************************/
/* lextuti.h
**  
**	prototypes and defined constants for argument values for
**	Lextools support routines
**
*/
/******************************************************************************/

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

#include "clib.h"
#include "cbslib.h"
#include "acl.h"

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

#define	LEXT_BUILD_TEXT_ARG(strng,value)	memcpy((void *) &value,(void *) strng,sizeof(short));

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

/* Lex Draw object type codes */

#define	LEXT_LD_EOF		-1		/* end of file object */
#define	LEXT_LD_EOR		-2		/* end of record object */
#define	LEXT_LD_NOOP		-3		/* noop filler object */
#define	LEXT_LD_LINE		1		/* line object */
#define	LEXT_LD_BOX		2		/* box object */
#define	LEXT_LD_CIRCLE		3		/* circle object */
#define	LEXT_LD_TRIANGLE	4		/* triangle object */
#define	LEXT_LD_TEXT		5		/* text object */
#define	LEXT_LD_POINT		6		/* point object */
#define	LEXT_LD_ARC		7		/* arc object */
#define	LEXT_LD_POLYGON		8		/* polygon object */
#define	LEXT_LD_IRRPOLYGON	9		/* irregular polygon object */
#define	LEXT_LD_CHAINVECTOR	10		/* chained vector object */
#define	LEXT_LD_ELLIPSE		11		/* ellipse object */
#define	LEXT_LD_LINEPLUS	12		/* line+ object */
#define	LEXT_LD_RECTANGLE	13		/* rectangle object */
#define	LEXT_LD_LOGO		14		/* Fermi logo object */
#define	LEXT_LD_IRRPOLYGON2	15		/* filled irregular polygon object */
#define	LEXT_LD_ICON		16		/* icon object */
#define	LEXT_LD_PARAGRAPH	17		/* paragraph pseudo object */
#define	LEXT_LD_SCREENSIZE	17		/* screen size object */
#define	LEXT_LD_IMAGE		18		/* embedded image object */

/* Lex Object object type codes */

#define	LEXT_LO_EOF		-1		/* end of file object */
#define	LEXT_LO_NOOP		-3		/* noop filler object */
#define	LEXT_LO_LINE		1		/* line object */
#define	LEXT_LO_RECTANGLE	2		/* rectangle object */
#define	LEXT_LO_CIRCLE		3		/* circle object */
#define	LEXT_LO_TEXTO		4		/* text object */
#define	LEXT_LO_ARC		5		/* arc object */
#define	LEXT_LO_IRRPOLYGON	6		/* irregular polygon object */
#define	LEXT_LO_CHAINVECTOR	7		/* chained vector object */
#define	LEXT_LO_IRRPOLYGON2	8		/* filled irregular polygon object */
#define	LEXT_LO_ICON		9		/* icon object */
#define	LEXT_LO_IMAGE		10		/* embedded image object */

/* Lex Prog object type codes */

#define	LEXT_LP_EOF		-1		/* end of file object */
#define	LEXT_LP_EOR		-2		/* end of record object */
#define	LEXT_LP_NOOP		-3		/* noop filler object */
#define	LEXT_LP_LEXDRAW		1		/* Lex Draw image object */
#define	LEXT_LP_TIME		2		/* date and time object */
#define	LEXT_LP_ANALOG		3		/* analog device object */
#define	LEXT_LP_DIGITAL		4		/* digital status object */
#define	LEXT_LP_CLOCK		5		/* clock event object */
#define	LEXT_LP_POSITION	6		/* positional object */
#define	LEXT_LP_CALLABLE	7		/* callable object */
#define	LEXT_LP_ERROR_DISPLAY	8		/* error display object */
#define	LEXT_LP_NEW_IMAGE_BUTTON	9	/* new image button object */
#define	LEXT_LP_URL		10		/* URL object */
#define	LEXT_LP_START_PROGRAM	11		/* start program object */
#define	LEXT_LP_STATE		12		/* state object */
#define	LEXT_LP_DEVICE_VIEWER	13		/* device viewer object */
#define	LEXT_LP_SCRIPT		14		/* script object */
#define	LEXT_LP_EXPRESSION	15		/* expression object */
#define	LEXT_LP_CUSTOM_SCALED	16		/* custom scaled object */
#define	LEXT_LP_DIGITAL_MASK	17		/* digital mask object */
#define	LEXT_LP_NUMERIC_LABEL	18		/* numeric label object */
#define	LEXT_LP_TIMER_EVENTS	19		/* timer events object */
#define	LEXT_LP_TEXT		20		/* text object */
#define	LEXT_LP_IMAGE		21		/* embedded image object */
#define	LEXT_LP_SCREEN_SIZE	22		/* screen size object */
#define	LEXT_LP_PLOT		23		/* plot object */
#define	LEXT_LP_LINE		24		/* line object */
#define	LEXT_LP_BOX		25		/* box object */
#define	LEXT_LP_CIRCLE		26		/* circle object */
#define	LEXT_LP_TRIANGLE	27		/* triangle object */
#define	LEXT_LP_LEX_OBJECT	28		/* Lex Object object */
#define	LEXT_LP_ARRAY_PLOT	29		/* array plot object */
#define	LEXT_LP_STRIP_CHART	30		/* strip chart object */

#define	LEXT_SA_NAMLEN		8		/* length of a Lex SA name */
#define	LEXT_CALLABLE_NAMLEN	12		/* length of a callable Lex object's name */

#define	LEXT_ENTER_HELP		1		/* enter new help */
#define	LEXT_DISPLAY_HELP	2		/* display help */

#define	LEXT_LO_NAMLEN		8		/* length of a Lex Object name */

#define	LEXT_LO_TEMPSAVE	1		/* include temporary save Lex Object in menu */
#define	LEXT_LO_TEXT		2		/* include text pseudo Lex Object in menu */
#define	LEXT_LO_BUTTON		3		/* include button pseudo Lex Object in menu */

#define	LEXT_NUM_USER_ARGS	6		/* number of user arguments passed to a Lex Object */

#define	LEXT_PASSWORD_LEN	10		/* length of Lex Object edit password */

#define	LEXT_UNUSED_ARG		0		/* Lex Object unused argument */
#define	LEXT_COLOR_ARG		1		/* Lex Object color argument */
#define	LEXT_SIZE_ARG		2		/* Lex Object size argument */
#define	LEXT_WIDTH_ARG		3		/* Lex Object width argument */
#define	LEXT_ROTATION_ARG	4		/* Lex Object rotation argument */
#define	LEXT_TEXT_ARG		5		/* Lex Object text argument */

#define	LEXT_LD_NAMLEN		8		/* length of a Lex Draw file name */

#define	LEXT_MIN_IMAGE		1		/* minimum Lex Draw image number */
#define	LEXT_MAX_IMAGE		5000		/* maximum Lex Draw image number */

#define	LEXT_LD_RECORD_SIZE	2048		/* size of a Lex Draw data record in bytes */
#define	LEXT_LO_RECORD_SIZE	2048		/* size of a Lex Object data record in bytes */
#define	LEXT_LP_RECORD_SIZE	2048		/* size of a Lex Prog data record in bytes */

#define	LEXT_LD_RECORDS_PER_IMAGE	4	/* number of records in a Lex Draw image */

#define	LEXT_ACTIVE_NORMAL	0		/* normal program execution */
#define	LEXT_ACTIVE_COPY_IMAGE	1		/* copy image and terminate */

#define	LEXT_IMAGE_SIZE		(LEXT_LD_RECORD_SIZE * LEXT_LD_RECORDS_PER_IMAGE)	/* size of a Lex Draw image */

#define	LEXT_DATESTRING_LEN	18		/* length of date and time string */

#define	LEXT_CLOCK_MAX_EVENTS	4		/* maximum number of events for a clock event object */

#define	LEXT_DEFAULT_ERROR_LEN	40		/* default length of error display field */

#define	LEXT_LD_MAX_TEXT_LEN	60		/* longest text string object */

#define	LEXT_LD_MAX_IMAGE_NAMLEN	59	/* maximum length of an embedded image's file name */

#define	LEXT_IMAGE_BUTTON_TEXT_LEN	11	/* length of an image button text string */

#define	LEXT_URL_LABEL_TEXT_LEN	23		/* length of a URL button text string */
#define	LEXT_URL_LEN		79		/* length of a URL text string */

#define	LEXT_START_PROGRAM_TEXT_LEN	23	/* length of a start program button text string */
#define	LEXT_START_PROGRAM_BUFFER_LEN	80	/* length of a start program command buffer */

#define	LEXT_LEX_SA_PROGRAM	"SA1082"	/* Lex SA program name */
#define	LEXT_LEX_SA_COMPANION	"PA1650"	/* Lex SA companion program name */
#define	LEXT_LEX_SA_COMPANION_PANUM	1650	/* Lex SA companion program PA number */

#define	LEXT_STATE_MAX_STATES		6	/* maximum number of states in a state object */

#define	LEXT_SCRIPT_NAME_LEN	(ACL_DB_FILE_NAME_LEN)	/* maximum length of a script file name */
#define	LEXT_SCRIPT_LABEL_TEXT_LEN	24	/* maximum length of a script button text string */
#define	LEXT_SCRIPT_SUBST_STRING_LEN	32	/* maximum length of a substitute string for a script */

#define	LEXT_EXPRESSION_LEN		100	/* maximum length of an expression object's expression string */

#define	LEXT_SCALING_THIS_DEVICE	0	/* use scaling for this device */
#define	LEXT_SCALING_OTHER_DEVICE	1	/* use scaling for another device */
#define	LEXT_SCALING_CUSTOM		2	/* use custom built scaling information */

#define	LEXT_DIGITAL_MASK_TEXT_LEN	16	/* maximum length of a digital mask text string */

#define	LEXT_DISPLAY_MASK_OBJECT	0	/* display digital mask as Lex Object */
#define	LEXT_DISPLAY_MASK_TEXT		1	/* display digital mask as text */

#define	LEXT_LP_MAX_TEXT_LEN		90	/* longest Lex Prog text string object */

#define	LEXT_MAX_LP_IMAGE_NAMLEN	79	/* maximum length of a Lex Prog embedded image's file name */

#define	LEXT_PLOT_MAX_TRACES		4	/* maximum number of traces in a plot object */
#define	LEXT_ARRAY_PLOT_MAX_TRACES	4	/* maximum number of traces in an array plot object */
#define	LEXT_SC_MAX_TRACES		4	/* maximum number of traces in a strip chart object */

#define	LEXT_ATTR_ANALOG_ALARM		1	/* use analog alarms */
#define	LEXT_ATTR_SCRIPT_ENABLED	2	/* script enabled */
#define	LEXT_ATTR_DISPLAY_SCRIPT_ENABLED	2	/* display script enabled */
#define	LEXT_ATTR_SHOW_POLARITY		2	/* show polarity status */
#define	LEXT_ATTR_USE_DESIRED_VALUE	2	/* use desired (nominal) value */
#define	LEXT_ATTR_ACTION_SCRIPT_ENABLED	4	/* action script enabled */
#define	LEXT_ATTR_SHOW_RAMP_DC		4	/* show ramp/DC status */
#define	LEXT_ATTR_SHOW_STATE_TEXT	4	/* show state text (state objects) */
#define	LEXT_ATTR_DISPLAY_SWITCH	8	/* display as a switch */
#define	LEXT_ATTR_USE_FULL_NAME		8	/* use full device names */
#define	LEXT_ATTR_ERASE_BEFORE_DRAWING	0x10	/* erase old object before drawing a new one */
#define	LEXT_ATTR_WANT_ALARM		0x20	/* want to use object alarm limits */
#define	LEXT_ATTR_WANT_WARNING		0x40	/* want to use object warning limits */
#define	LEXT_ATTR_LOG_SCALING		0x80	/* want to use logarithmic scaling */
#define	LEXT_ATTR_FULL_COLOR_MODE	0x80	/* display using full color mode */
#define	LEXT_ATTR_PROGRAMMABLE_MINIMUM	0x100	/* minimum display value is programmable */
#define	LEXT_ATTR_PROGRAMMABLE_MAXIMUM	0x200	/* maximum display value is programmable */
#define	LEXT_ATTR_PERSISTENT_PLOT	0x400	/* want persistent plot display */
#define	LEXT_ATTR_SUBSTITUTE_STRING	0x400	/* substitute string is present for script */
#define	LEXT_ATTR_INVERT_RAW_DATA	0x800	/* invert raw data before scaling */
#define	LEXT_ATTR_LONG_DISPLAY		0x1000	/* use long display */
#define	LEXT_ATTR_IGNORE_FAULT_IF_OFF	0x1000	/* display off status even if the device is faulted */
#define	LEXT_ATTR_SHOW_TIME		0x2000	/* display time */
#define	LEXT_ATTR_HONOR_FAULT_STATUS	0x2000	/* display fault status even if the device is on */
#define	LEXT_ATTR_FLAT_FILE_SCRIPT	0x2000	/* script is a flat file (as opposed to the database) */
#define	LEXT_ATTR_PROTECTED_SETTING	0x4000	/* protected setting (for action scripts) */
#define	LEXT_ATTR_DISPLAY_VALUE		0x8000	/* display value */
#define	LEXT_ATTR_FIT_WINDOW		0x8000	/* fit window to object */

#define	LEXT_PLOT_ATTR_SCIENTIFIC	1	/* use scientific notation for plot labels */
#define	LEXT_PLOT_ATTR_NOT_CONNECTED	2	/* don't connect plotted points */
#define	LEXT_PLOT_ATTR_LOG_PLOT		0x80	/* do semilog plot */

#define	LEXT_PLOT_TYPE_FTP		0	/* do fast time plot */
#define	LEXT_PLOT_TYPE_CONTINUOUS	1	/* do continuous plot */
#define	LEXT_PLOT_TYPE_SCROLLING	2	/* do scrolling plot */
#define	LEXT_PLOT_TYPE_SNAP_NO_ERASE	3	/* do snapshot plot without erase */
#define	LEXT_PLOT_TYPE_SNAP_ERASE	4	/* do snap shot plot with erase */

#define	LEXT_ARRAY_PLOT_TYPE_VECTOR	0	/* vector array plot */
#define	LEXT_ARRAY_PLOT_TYPE_POINTS	1	/* individual points plot */
#define	LEXT_ARRAY_PLOT_TYPE_HISTOGRAM	2	/* histogram array plot */
#define	LEXT_ARRAY_PLOT_TYPE_BIHISTOGRAM	3	/* bidirectional histogram array plot */

#define	LEXT_FILE_FSHARE		1	/* filesharing */
#define	LEXT_FILE_DB			2	/* database */
#define	LEXT_FILE_BOTH			3	/* both */

#define	LEXT_READ_DEFAULT		LEXT_FILE_DB
#define	LEXT_WRITE_DEFAULT		LEXT_FILE_DB

#define	LEXT_SOLID_PATTERN		0

#define	LEXT_LP_NO_ARROW_ENDS		0
#define	LEXT_LP_RIGHT_ARROW_END		1
#define	LEXT_LP_BOTH_ARROW_ENDS		2
#define	LEXT_LP_LEFT_ARROW_END		3

#define	LEXT_IMAGE_TYPE_LXI		1	/* LXI image */
#define	LEXT_IMAGE_TYPE_GIF		2	/* GIF image */


/******************************************************************************/
/* 
**	data structures
*/
/******************************************************************************/

typedef struct LEXT_OBJECT_HEADER		/* Lex Object information structure */
    {
    int		key;				/* object key */
    char	name[LEXT_OBJECT_NAMLEN];	/* ASCII name of object */
    int		spare;
    short	version;			/* software version */
    short	num_component;			/* number of component objects */
    short	length;				/* length of object data minus header info in words */
    char	arg_names[LEXT_NUM_USER_ARGS][2];	/* argument descriptor text */
    short	x_ref;				/* x reference coordinate */
    short	y_ref;				/* y reference coordinate */
    char	password[LEXT_PASSWORD_LEN];	/* edit password */
    } __attribute__((packed)) LEXT_OBJECT_HEADER;

typedef struct LEXT_SELECTED_OBJECT_DATA		/* selected Lex object data */
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];
    int		device_index;
    int		array_index;
    short	property;
    int		object_type;
    char	display_object[LEXT_OBJECT_NAMLEN];
    int		x_pos;
    int		y_pos;
    int		rotation;
    } __attribute__((packed)) LEXT_SELECTED_OBJECT_DATA;

#define	LEXT_SA_TC_START_DISPLAY	0	/* start new display */
#define	LEXT_SA_TC_ENABLE_MONITOR	2	/* enable device monitoring/control */
#define	LEXT_SA_TC_DISABLE_MONITOR	3	/* disable device monitoring/control */
#define	LEXT_SA_TC_READ_FILE		4	/* return current graphics file name */
#define	LEXT_SA_TC_GRAB_FOCUS		5	/* tell SA to grab focus */
#define	LEXT_SA_TC_IMAGE_CHANGED	6	/* notify connected tasks that the graphics file has changed */

#define	LEXT_SA_TCSUB_DEVICE_CONTROL	1	/* change device control setting */
#define	LEXT_SA_TCSUB_DEVICE_MONITOR	2	/* change device monitor setting */

#define	LEXT_SA_FLAG_SUBSTITUTE_DEVICE	1	/* substitute device name passed */
#define	LEXT_SA_FLAG_CALLER_LIMITS	2	/* caller-supplied limits passed */

#define	LEXT_SA_REQUEST_MAX_LIMITS	6	/* maximum number of caller-supplied limits */

#define	LEXT_SA_REQUEST_FILLER	(LEN_CHGBUFF-LEXT_SA_NAMLEN-6*(sizeof(int))-\
				 PROCESS_NAME_LEN-DEVICE_TERSE_NAME_LEN-\
				 LEXT_SA_REQUEST_MAX_LIMITS*(sizeof(float)))

typedef struct LEXT_SA_REQUEST
    {
    char	file_name[LEXT_SA_NAMLEN];
    int		mode;
    int		type_code;
    int		subtype;
    unsigned int	request_flags;
    int		node;
    char	process_name[PROCESS_NAME_LEN];
    char	substitute_device[DEVICE_TERSE_NAME_LEN];
    int		num_limits;
    float	caller_limits[LEXT_SA_REQUEST_MAX_LIMITS];
    char	unused[LEXT_SA_REQUEST_FILLER];
    } __attribute__((packed)) LEXT_SA_REQUEST;

typedef struct LEXT_SA_SIMPLE_REPLY
    {
    int		node;
    char	process_name[PROC_NAMLEN];
    char	file_name[LEXT_SA_NAMLEN];
    int		type_code;
    int		status;
    } __attribute__((packed)) LEXT_SA_SIMPLE_REPLY;

typedef struct LEXT_SA_MONITOR_REPLY
    {
    int		node;
    char	process_name[PROC_NAMLEN];
    int		type;
    LEXT_SELECTED_OBJECT_DATA	object_data;
    int		event_type;
    } __attribute__((packed)) LEXT_SA_MONITOR_REPLY;

typedef struct LEXT_SA_NEW_IMAGE_REPLY
    {
    int		node;
    char	process_name[PROC_NAMLEN];
    int		type;
    char	file_name[LEXT_SA_NAMLEN];
    } __attribute__((packed)) LEXT_SA_NEW_IMAGE_REPLY;

typedef struct LEXT_LD_SCREENSIZE_DATA		/* Lex Draw screen size object data structure */
    {
    int		width;
    int		height;
    } LEXT_LD_SCREENSIZE_DATA;

typedef struct LEXT_LD_LINE_DATA		/* Lex Draw line object data structure */
    {
    int		x1_pos;
    int		y1_pos;
    int		x2_pos;
    int		y2_pos;
    int		vector_width;
    int		color;
    } LEXT_LD_LINE_DATA;

typedef struct LEXT_LD_BOX_DATA			/* Lex Draw box object data structure */
    {
    int		x1_pos;
    int		y1_pos;
    int		x2_pos;
    int		y2_pos;
    int		border_width;
    int		color;
    } LEXT_LD_BOX_DATA;

typedef struct LEXT_LD_CIRCLE_DATA		/* Lex Draw circle object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		radius;
    int		border_width;
    int		color;
    } LEXT_LD_CIRCLE_DATA;

typedef struct LEXT_LD_TRIANGLE_DATA		/* Lex Draw triangle object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		size;
    int		border_width;
    int		color;
    } LEXT_LD_TRIANGLE_DATA;

typedef struct LEXT_LD_TEXT_DATA		/* Lex Draw text object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    char	*text;
    int		text_length;
    int		text_size;
    int		text_mode;
    int		color;
    } LEXT_LD_TEXT_DATA;

typedef struct LEXT_LD_POINT_DATA		/* Lex Draw point object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		color;
    } LEXT_LD_POINT_DATA;

typedef struct LEXT_LD_ARC_DATA			/* Lex Draw arc object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		radius;
    int		arc_length;
    int		border_width;
    int		color;
    } LEXT_LD_ARC_DATA;

typedef struct LEXT_LD_POLYGON_DATA		/* Lex Draw regular polygon object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		size;
    int		num_sides;
    int		border_width;
    int		color;
    } LEXT_LD_POLYGON_DATA;

typedef struct LEXT_LD_VERTEX_DATA
    {
    int		x_pos;
    int		y_pos;
    } LEXT_LD_VERTEX_DATA;

typedef struct LEXT_LD_IRRPOLYGON_DATA		/* Lex Draw irregular polygon object data structure */
    {
    LEXT_LD_VERTEX_DATA	*vertices;
    int		num_vertices;
    int		rotation;
    int		vector_width;
    int		color;
    } LEXT_LD_IRRPOLYGON_DATA;

typedef struct LEXT_LD_CHAINVECTOR_DATA		/* Lex Draw chained vector object data structure */
    {
    LEXT_LD_VERTEX_DATA	*vertices;
    int		num_vertices;
    int		rotation;
    int		vector_width;
    int		color;
    } LEXT_LD_CHAINVECTOR_DATA;

typedef struct LEXT_LD_ELLIPSE_DATA		/* Lex Draw ellipse object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		semi_major_axis;
    int		eccentricity;			/* times 100 */
    int		border_width;
    int		color;
    } LEXT_LD_ELLIPSE_DATA;

typedef struct LEXT_LD_LINEPLUS_DATA		/* Lex Draw line plus object data structure */
    {
    int		x_center_pos;
    int		y_center_pos;
    int		rotation;
    int		length;
    int		vector_width;
    unsigned short	vector_pattern;
    int		arrow_ends;
    int		color;
    } LEXT_LD_LINEPLUS_DATA;

typedef struct LEXT_LD_RECTANGLE_DATA		/* Lex Draw rectangle object data structure */
    {
    int		x_center_pos;
    int		y_center_pos;
    int		rotation;
    int		width;
    int		height;
    int		border_width;
    unsigned short	vector_pattern;
    int		color;
    } LEXT_LD_RECTANGLE_DATA;

typedef struct LEXT_LD_LOGO_DATA		/* Lex Draw Fermi logo object data structure */
    {
    int		x_center_pos;
    int		y_center_pos;
    int		size;
    int		color;
    } LEXT_LD_LOGO_DATA;

typedef struct LEXT_LD_ICON_DATA		/* Lex Draw icon object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		size;
    unsigned short	icon_data[32];
    int		color;
    } LEXT_LD_ICON_DATA;

typedef struct LEXT_LD_EMBEDDED_IMAGE_DATA	/* Lex Draw embedded image object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		height;
    int		width;
    char	*file_name;
    int		color_map;
    } LEXT_LD_EMBEDDED_IMAGE_DATA;

typedef struct LEXT_LP_EOF_DATA			/* Lex Prog end of file object data structure */
    {
    } LEXT_LP_EOF_DATA;

typedef struct LEXT_LP_LEXDRAW_DATA		/* Lex Prog image object data structure */
    {
    char	image_file[LEXT_IMAGE_NAMLEN];
    int		image_number;
    int		display_mode;
    } LEXT_LP_LEXDRAW_DATA;

typedef struct LEXT_LP_TIME_DATA		/* Lex Prog date and time object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		color;
    int		display_format;
    unsigned short	attributes;
    } LEXT_LP_TIME_DATA;

typedef struct LEXT_LP_ANALOG_DATA		/* Lex Prog analog object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    char	display_object[LEXT_OBJECT_NAMLEN];
    int		display_size;
    int		color;
    int		device_index;
    short	property;
    short	ftd;
    int		min_value;
    int		max_value_or_text_size;
    int		alarm_limit;
    int		alarm_color;
    int		min_value_index;
    int		max_value_index;
    int		alarm_limit_index;
    unsigned short	attributes;
    } LEXT_LP_ANALOG_DATA;

typedef struct LEXT_LP_DIGITAL_DATA		/* Lex Prog digital object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    char	display_object[LEXT_OBJECT_NAMLEN];
    int		on_color;
    int		off_color;
    int		ready_color;
    int		fault_color;
    int		remote_color;
    int		local_color;
    int		positive_color;
    int		negative_color;
    int		ramp_color;
    int		dc_color;
    int		device_index;
    short	ftd;
    int		selected_attribute;
    unsigned short	attributes;
    } LEXT_LP_DIGITAL_DATA;

typedef struct LEXT_LP_CLOCK_DATA
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		on_color;
    int		off_color;
    unsigned char	events[LEXT_CLOCK_MAX_EVENTS];
    char	display_object[LEXT_OBJECT_NAMLEN];
    int		size;
    int		display_time;
    unsigned short	attributes;
    } LEXT_LP_CLOCK_DATA;

typedef struct LEXT_LP_POSITIONAL_DATA
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		color;
    char	display_object[LEXT_OBJECT_NAMLEN];
    int		x_size;
    int		y_size;
    int		x_device_index;
    short	x_property;
    int		y_device_index;
    short	y_property;
    short	ftd;
    float	x_min_value;
    float	x_max_value;
    float	y_min_value;
    float	y_max_value;
    unsigned short	attributes;
    } LEXT_LP_POSITIONAL_DATA;

typedef struct LEXT_LP_CALLABLE_DATA			/* Lex Prog callable object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    char	display_object[LEXT_OBJECT_NAMLEN];
    char	name[LEXT_CALLABLE_NAMLEN];
    int		color;
    } LEXT_LP_CALLABLE_DATA;

typedef struct LEXT_LP_ERROR_DISPLAY_DATA		/* Lex Prog error display object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		field_length;
    int		text_size;
    } LEXT_LP_ERROR_DISPLAY_DATA;

typedef struct LEXT_LP_NEW_IMAGE_BUTTON_DATA
    {
    int		x_pos;
    int		y_pos;
    int		height;
    int		width;
    int		shape;
    int		color;
    char	command_file[LEXT_SA_NAMLEN];
    int		mode;
    int		display_mode;
    char	text[LEXT_IMAGE_BUTTON_TEXT_LEN+1];
    unsigned short	attributes;
    int		state_device;
    int		state_value;
    int		state_operator;
    int		state_delay;
    int		console_number;
    int		slot;
    } LEXT_LP_NEW_IMAGE_BUTTON_DATA;

typedef struct LEXT_LP_URL_DATA
    {
    int		x_pos;
    int		y_pos;
    int		height;
    int		width;
    int		rotation;
    int		shape;
    int		color;
    int		text_size;
    char	text[LEXT_URL_LABEL_TEXT_LEN+1];
    char	url[LEXT_URL_LEN+1];
    } LEXT_LP_URL_DATA;

typedef struct LEXT_LP_START_PROGRAM_DATA
    {
    int		x_pos;
    int		y_pos;
    int		height;
    int		width;
    int		rotation;
    int		shape;
    int		color;
    int		console_number;
    int		slot;
    int		flags;
    int		text_size;
    char	process_name[PROCESS_NAME_LEN];
    char	text[LEXT_START_PROGRAM_TEXT_LEN+1];
    char	command_buffer[LEXT_START_PROGRAM_BUFFER_LEN];
    int		command_buffer_length;
    } LEXT_LP_START_PROGRAM_DATA;

typedef struct LEXT_LP_STATE_DESCR
    {
    short	min_state_value;
    short	max_state_value;
    int		color;
    char	display_object[LEXT_OBJECT_NAMLEN];
    } LEXT_LP_STATE_DESCR;

typedef struct LEXT_LP_STATE_DATA
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		height;
    int		width;
    int		color;
    unsigned short	attributes;
    int		device_index;
    int		property;
    int		ftd;
    int		text_size;
    int		script_type;
    char	script_file[LEXT_SCRIPT_NAME_LEN];
    int		default_state;
    unsigned short	state_attributes;
    int		num_states;
    LEXT_LP_STATE_DESCR	states[LEXT_STATE_MAX_STATES];
    } LEXT_LP_STATE_DATA;

typedef struct LEXT_LP_DEVICE_VIEWER_DATA		/* Lex Prog device viewer object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		color;
    int		border_color;
    int		text_size;
    unsigned short	attributes;
    int		spare;
    } LEXT_LP_DEVICE_VIEWER_DATA;

typedef struct LEXT_LP_SCRIPT_DATA
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		action_x_pos;
    int		action_y_pos;
    int		height;
    int		width;
    int		color;
    char	display_object_or_text[LEXT_SCRIPT_LABEL_TEXT_LEN];
    int		text_size;
    int		display_size;
    float	min_value;
    float	max_value;
    float	alarm_limit;
    int		alarm_color;
    unsigned short	attributes;
    int		script_type;
    int		device_index;
    short	property;
    short	ftd;
    char	display_script_file[LEXT_SCRIPT_NAME_LEN];
    char	action_script_file[LEXT_SCRIPT_NAME_LEN];
    char	substitute_string[LEXT_SCRIPT_SUBST_STRING_LEN];
    } LEXT_LP_SCRIPT_DATA;

typedef struct LEXT_LP_EXPRESSION_DATA
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    char	display_object[LEXT_OBJECT_NAMLEN];
    int		display_size;
    int		color;
    int		device_index;
    short	property;
    short	ftd;
    float	min_value;
    float	max_value_or_text_size;
    float	alarm_limit;
    int		alarm_color;
    unsigned short	attributes;
    char	expression[LEXT_EXPRESSION_LEN];
    } LEXT_LP_EXPRESSION_DATA;

typedef struct LEXT_SCALING_INFO
    {
    int		scaling_length;
    unsigned short	scaling_attributes;
    int		primary_transform;
    int		common_transform;
    char	units_text[LEN_DEV_UNITS];
    int		num_constants;
    double	constants[DIO_PDB_MAX_CONSTANTS];
    } LEXT_SCALING_INFO;

typedef struct LEXT_LP_CUSTOM_SCALED_DATA
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    char	display_object[LEXT_OBJECT_NAMLEN];
    int		display_size;
    int		color;
    int		device_index;
    short	property;
    short	ftd;
    int		length;
    int		offset;
    float	min_value;
    float	max_value_or_text_size;
    float	warning_minimum;
    float	warning_maximum;
    int		warning_color;
    float	alarm_minimum;
    float	alarm_maximum;
    int		alarm_color;
    unsigned short	attributes;
    int		display_format;
    int		scaling_type;
    int		scaling_key;
    short	scaling_property;
    LEXT_SCALING_INFO	scaling_info;
    } LEXT_LP_CUSTOM_SCALED_DATA;

typedef struct LEXT_LP_DIGITAL_MASK_DATA
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    char	on_display_object[LEXT_DIGITAL_MASK_TEXT_LEN];
    int		on_color;
    char	off_display_object[LEXT_DIGITAL_MASK_TEXT_LEN];
    int		off_color;
    int		device_index;
    short	property;
    short	ftd;
    int		length;
    int		offset;
    unsigned int	mask;
    unsigned int	desired_value;
    int		text_size;
    int		text_length;
    int		display_format;
    unsigned short	attributes;
    } LEXT_LP_DIGITAL_MASK_DATA;

typedef struct LEXT_LP_NUMERIC_LABEL_DATA
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		color;
    int		display_format;
    int		justify;
    int		text_length;
    int		text_size;
    float	default_value;
    int		value_index;
    int		draw_mode;
    unsigned short	attributes;
    } LEXT_LP_NUMERIC_LABEL_DATA;

typedef struct LEXT_LP_TIMER_EVENTS_DATA
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		color;
    int		hilite_color;
    int		border_color;
    int		device_index;
    short	ftd;
    int		num_events;
    int		display_format;
    int		text_size;
    int		draw_mode;
    int		separator;
    int		want_border;
    unsigned int	attributes;
    } LEXT_LP_TIMER_EVENTS_DATA;

typedef struct LEXT_LP_TEXT_DATA		/* Lex Prog text object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    char	*text;
    int		text_length;
    int		text_size;
    int		text_mode;
    int		inverse_mode;
    int		color;
    int		pad_length;
    short	pad_character;
    unsigned int	attributes;
    } LEXT_LP_TEXT_DATA;

typedef struct LEXT_LP_IMAGE_DATA		/* Lex Prog embedded image object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		height;
    int		width;
    int		color_map;
    int		image_type;
    int		display_parameters[2];
    char	*file_name;
    unsigned int	attributes;
    } LEXT_LP_IMAGE_DATA;

typedef struct LEXT_LP_SCREEN_SIZE_DATA		/* Lex Prog screen size object data structure */
    {
    int		width;
    int		height;
    int		color_depth;
    } LEXT_LP_SCREEN_SIZE_DATA;

typedef struct LEXT_LP_PLOT_TRACE_INFO
    {
    int		device_index;			/* device index */
    short	property;			/* property index */
    unsigned int	array_index;		/* array index */
    int		rate;
    int		color;
    int		label_length;
    int		label_type;
    float	minimum;
    float	maximum;
    } LEXT_LP_PLOT_TRACE_INFO;

#define	LEXT_NUM_PLOT_EVENTS	8

typedef struct LEXT_LP_PLOT_DATA
    {
    int		x_pos;
    int		y_pos;
    int		height;
    int		width;
    int		rotation;
    int		color;
    int		plot_type;
    int		events[LEXT_NUM_PLOT_EVENTS];
    float	delay;
    float	x_range;
    int		x_label_length;
    int		x_units;
    int		x_num_grids;
    int		y_num_grids;
    int		text_size;
    unsigned short	plot_attributes;
    unsigned int	attributes;
    int		num_devices;
    LEXT_LP_PLOT_TRACE_INFO	devices[LEXT_PLOT_MAX_TRACES];
    } LEXT_LP_PLOT_DATA;

typedef struct LEXT_LP_ARRAY_PLOT_TRACE_INFO
    {
    int		device_index;			/* device index */
    short	property;			/* property index */
    unsigned int	array_index;		/* array index */
    int		num_elements;
    int		color;
    int		label_length;
    int		label_type;
    float	minimum;
    float	maximum;
    } __attribute__((packed)) LEXT_LP_ARRAY_PLOT_TRACE_INFO;

#define	LEXT_ARRAY_PLOT_DATA_EVENT_LEN	24	/* length of an array plot data event string */

typedef struct LEXT_LP_ARRAY_PLOT_DATA
    {
    int		color;
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		height;
    int		width;
    int		plot_type;
    int		x_label_color;
    int		x_label_length;
    int		x_units;
    int		x_num_grids;
    int		x_num_minor_grids;
    int		y_num_grids;
    int		y_num_minor_grids;
    int		text_size;
    unsigned short	plot_attributes;
    unsigned int	attributes;
    float	delay;
    char	data_event[LEXT_ARRAY_PLOT_DATA_EVENT_LEN];
    int		num_devices;
    LEXT_LP_ARRAY_PLOT_TRACE_INFO	devices[LEXT_ARRAY_PLOT_MAX_TRACES];
    } __attribute__((packed)) LEXT_LP_ARRAY_PLOT_DATA;

typedef struct LEXT_LP_STRIP_CHART_DATA
    {
    int		x_pos;
    int		y_pos;
    int		height;
    int		width;
    int		rotation;
    int		color;
    float	x_range;
    int		x_label_length;
    int		x_units;
    int		x_num_grids;
    int		y_num_grids;
    int		text_size;
    unsigned short	plot_attributes;
    unsigned int	attributes;
    int		num_devices;
    LEXT_LP_PLOT_TRACE_INFO	devices[LEXT_SC_MAX_TRACES];
    } LEXT_LP_STRIP_CHART_DATA;

typedef struct LEXT_LP_LINE_DATA		/* Lex Prog line object data structure */
    {
    int		x1_pos;
    int		y1_pos;
    int		x2_pos;
    int		y2_pos;
    int		vector_width;
    int		color;
    int		vector_pattern;
    int		pattern_size;
    int		arrow_ends;
    } LEXT_LP_LINE_DATA;

typedef struct LEXT_LP_BOX_DATA			/* Lex Prog box object data structure */
    {
    int		x1_pos;
    int		y1_pos;
    int		x2_pos;
    int		y2_pos;
    int		border_width;
    int		color;
    int		vector_pattern;
    int		pattern_size;
    } LEXT_LP_BOX_DATA;

typedef struct LEXT_LP_CIRCLE_DATA		/* Lex Prog circle object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		radius;
    int		border_width;
    int		color;
    int		vector_pattern;
    int		pattern_size;
    } LEXT_LP_CIRCLE_DATA;

typedef struct LEXT_LP_TRIANGLE_DATA		/* Lex Prog triangle object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    int		size;
    int		border_width;
    int		color;
    int		vector_pattern;
    int		pattern_size;
    } LEXT_LP_TRIANGLE_DATA;

typedef struct LEXT_LP_LEX_OBJECT_DATA		/* Lex Prog Lex Object object data structure */
    {
    int		x_pos;
    int		y_pos;
    int		rotation;
    char	display_object[LEXT_OBJECT_NAMLEN];
    int		color;
    int		arguments[LEXT_NUM_USER_ARGS];
    unsigned short	attributes;
    } LEXT_LP_LEX_OBJECT_DATA;

typedef void (*lext_image_change_function)(char *);		/* image change callback */

typedef void (*lext_display_up_function)(int);			/* display up (initialized) callback */

typedef void (*lext_control_function)(LEXT_SELECTED_OBJECT_DATA *);	/* control callback */

typedef void (*lext_monitor_function)(LEXT_SELECTED_OBJECT_DATA *, int);	/* monitor callback */

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

#ifdef __cplusplus
extern "C" {
#endif

int	lext_add_lex_draw_object_c(char *image_buffer, int object_type,
				   void *object_data);
int	lext_add_lex_prog_object_c(char *command_buffer, int buffer_length,
				   int object_type, void *object_data);
int	lext_callable_parameters(char *name, short *parameters);
int	lext_current_active_image(char *image_name);
int	lext_disable_device_monitoring(void);
int	lext_disable_image_control(void);
int	lext_draw_object_c(char *name, short param1, short param2, short param3,
			   short param4, short param5, short param6);
int	lext_enable_device_monitoring(lext_monitor_function monitor_func);
int	lext_enable_image_control(lext_control_function control_func);
int	lext_erase_object(char *name);
int	lext_file_source(void);
int	lext_image_menu_c(int top_row, int left_column, int height,
			  char *choice);
int	lext_init_active_image(char *name, int overlay,
			       char *substitute_device, int mode,
			       lext_image_change_function image_change_fn,
			       lext_display_up_function display_up_fn,
			       int num_limits=0,
			       float *caller_limits=(float *) NULL);
int	lext_modify_object_c(char *name, short attribute, short value,
			     int attribute_index);
int	lext_object_help_c(int top_row, int left_column, char *name, int type);
int	lext_object_information(char *name, LEXT_OBJECT_HEADER *info);
int	lext_object_menu_c(int top_row, int left_column, char *choice,
			   int special_entries,
			   char *title = (char *) NULL);
int	lext_object_parameters(char *name, short *parameters);
int	lext_read_command_file_c(char *file_name, char **data_buffer,
				 int *data_length);
int	lext_read_image_c(char *image_file, int image_number,
			  char *image_buffer);
int	lext_remove_active_image(void);
int	lext_save_command_file_c(char *command_file, char *command_buffer);
int	lext_save_image_c(char *image_file, int image_number,
			  char *image_buffer);
int	lext_sa_menu_c(int top_row, int left_column, int height, char *choice);
void	lext_set_log_file(char *log_file, unsigned int options);
int	lext_start_sa_c(char *name, int slot, int mode, int console=0,
			char *subst_device=(char *) NULL, int num_limits=0,
			float *caller_limits=(float *) NULL);
int	lext_version(void);

#ifdef __cplusplus
}
#endif

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

#define	LEXT_ADD_LEX_DRAW_OBJECT_C	lext_add_lex_draw_object_c
#define	LEXT_ADD_LEX_PROG_OBJECT_C	lext_add_lex_prog_object_c
#define	LEXT_CALLABLE_PARAMETERS	lext_callable_parameters
#define	LEXT_CURRENT_ACTIVE_IMAGE	lext_current_active_image
#define	LEXT_DISABLE_DEVICE_MONITORING	lext_disable_device_monitoring
#define	LEXT_DISABLE_IMAGE_CONTROL	lext_disable_image_control
#define	LEXT_DRAW_OBJECT_C		lext_draw_object_c
#define	LEXT_ENABLE_DEVICE_MONITORING	lext_enable_device_monitoring
#define	LEXT_ENABLE_IMAGE_CONTROL	lext_enable_image_control
#define	LEXT_ERASE_OBJECT		lext_erase_object
#define	LEXT_IMAGE_MENU_C		lext_image_menu_c
#define	LEXT_INIT_ACTIVE_IMAGE		lext_init_active_image
#define	LEXT_MODIFY_OBJECT_C		lext_modify_object_c
#define	LEXT_OBJECT_HELP_C		lext_object_help_c
#define	LEXT_OBJECT_INFORMATION		lext_object_information
#define	LEXT_OBJECT_MENU_C		lext_object_menu_c
#define	LEXT_OBJECT_PARAMETERS		lext_object_parameters
#define	LEXT_READ_IMAGE_C		lext_read_image_c
#define	LEXT_READ_COMMAND_FILE_C	lext_read_command_file_c
#define	LEXT_REMOVE_ACTIVE_IMAGE	lext_remove_active_image
#define	LEXT_SAVE_COMMAND_FILE_C	lext_save_command_file_c
#define	LEXT_SAVE_IMAGE_C		lext_save_image_c
#define	LEXT_SA_MENU_C			lext_sa_menu_c
#define	LEXT_SET_LOG_FILE		lext_set_log_file
#define	LEXT_START_SA_C			lext_start_sa_c
#define	LEXT_VERSION			lext_version

#endif