/****************************************************************************/
/* Copyright 1991 - 2016 MBARI												*/
/****************************************************************************/
/* Summary	: User command definitions for OASIS5 mooring controller		*/
/* Filename : usrcmds.h														*/
/* Author	: Robert Herlien (rah)											*/
/* Project	: OASIS5 Mooring												*/
/* $Revision: 1.0 $															*/
/* Created	: 07/18/2016 rah												*/
/*																			*/
/* MBARI provides this documentation and code "as is", with no warranty,	*/
/* express or implied, of its quality or consistency. It is provided without*/
/* support and without obligation on the part of the Monterey Bay Aquarium	*/
/* Research Institute to assist in its use, correction, modification, or	*/
/* enhancement. This information should not be published or distributed to	*/
/* third parties without specific written permission from MBARI.			*/
/*																			*/
/****************************************************************************/
/* Modification History:													*/
/* 03feb2003 rah - OASIS3 version created from OASIS usrcmds.h				*/
/* 18jul2016 rah - OASIS5 version created from OASIS3 version				*/
/****************************************************************************/

#ifndef INCusrcmdsh
#define INCusrcmdsh		1

#include <oasis.h>
#include <sem.h>

#define NPARMS	4				/* Max number of parms for user function*/

typedef unsigned int	ParmMask_t;

typedef struct					/****************************************/
{								/* Structure for function table			*/
	char	*fe_cs;				/* Command string						*/
	char	*fe_info;			/* Information for help screen			*/
	Int16 (*fe_cmd)();			/* Pointer to function to impl. command */
	Nat16 fe_parmtype[NPARMS];	/* Parameter types						*/
} FuncEntry;					/****************************************/
								/* Parameter types						*/
#define NOPARM	0				/* No corresponding parameter			*/
#define STRING	1				/* String, until next delimiter			*/
#define ALL		2				/* Parameter is rest command string		*/
#define DEC		3				/* Number, default radix is decimal		*/
#define HEX		4				/* Number, default radix is hexadecimal */
								/****************************************/

typedef enum					/****************************************/
{								/* Protocol to use for telemetry		*/
	TELEM_UUENCODE = 0,			/* Send in UUencode format				*/
	TELEM_ASCII,				/* Send ASCII							*/
	TELEM_BINARY				/* Send binary data						*/
} TelemType;					/****************************************/

#define MAX_RECS		30

typedef struct func_node FuncNode; /* One node in function linked list	*/

struct func_node					/************************************/
{									/* Structure for function table		*/
	FuncNode		*func_next;		/* For linked list					*/
	FuncNode		*func_prev;		/* For linked list					*/
	char			*fn_cs;			/* Command string					*/
	char			*fn_info;		/* Information for help screen		*/
	Int16			(*fn_cmd)();	/* Ptr to function to impl. command */
	Nat16			fn_parmtype[NPARMS]; /* Parameter types				*/
};									/************************************/

#define FN_NULL ((FuncNode *)0)


/****************************************/
/* Function Declarations				*/
/****************************************/

Int16	analog(ParmMask_t pmask, Parm_t port);
Int16	quit(Void);
//Int16 reset(ParmMask_t pmask, char *s);
Int16	reset(ParmMask_t pmask, char *s, char *unused1, char *unused2,
			  char *unused3, char *cmdline);
Int16	usr_power(ParmMask_t, Parm_t);
Errno	usrSemWait(SemID sem);
Int16	connect(ParmMask_t, char *, Parm_t, Parm_t, Parm_t, Byte *);
Int16	usr_time(ParmMask_t pmask, char *s);
Int16	tnc_cmd(ParmMask_t, char *, Parm_t, Parm_t, Parm_t, Byte *);
Int16	display(ParmMask_t, Parm_t, Parm_t);
Int16	set(ParmMask_t, Byte *);
Int16	getlog(ParmMask_t pmask, Parm_t, Parm_t);
Int16	getylog(ParmMask_t pmask, Parm_t, Parm_t);
Int16	dump(ParmMask_t, Parm_t, Parm_t);
Int16	checkLog(ParmMask_t pmask, Parm_t blk, Parm_t nblks);
Int16	getdata(ParmMask_t pmask, Parm_t maxRecs);
Int16	getydata(ParmMask_t pmask, Parm_t maxRecs);
Int16	getlognmbrs(Void);
Void	initUsrLog(LogRecNum firstRcd);
Int16	aux(ParmMask_t, char *, Parm_t, Parm_t);
Int16	init(ParmMask_t, char *, Parm_t, Parm_t);
Int16	sync(ParmMask_t, char *, Parm_t, Parm_t);
MBool	getparm(Nat32 *result, Nat32 radix, Byte *buffer);
Int16	drvparms(ParmMask_t, char *, Parm_t, Parm_t, Parm_t, Byte *);
Int16	drvadd(ParmMask_t, char *, char *, Parm_t, Parm_t, Byte *);
Int16	drvdel(ParmMask_t, char *);
Int16	sample(ParmMask_t, char *);
Int16	lsample(ParmMask_t, char *);
Int16	usrKill(ParmMask_t, char *);
Int16	checkStack(Void);
Int16	version(ParmMask_t pmask, char *arg);
Int16	usrWakeBits(ParmMask_t pmask, Parm_t bits);
Int16	usrGetnum(ParmMask_t pmask, Parm_t radix, char *s);
Int16	usrSysLog(ParmMask_t pmask, char *fmt, Parm_t parm1,
				  Parm_t parm2, Parm_t parm3);
#ifdef TNC
Int16	radiomsg(ParmMask_t, char *);
#endif

#endif /* INCusrcmdsh */
