#ifndef _LOADROBOT_H_
#define _LOADROBOT_H_

/*-=-=-=-=-=-=-=-=-=-=-=- RCCL/RCI Notice of Copyright -=-=-=-=-=-=-=-=-=-=-*
 *									    *
 *	Copyright (C) 1991 by John E. Lloyd.				    *
 *									    *
 *	Information on copyright permissions, as well as a complete	    *
 *	disclaimer of warranty, is given in the file COPYRIGHT.		    *
 *									    *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

/*---------------------------------------------------------------------------
 *
 * DESCRIPTION:	Private definitions used by the routines which connect
 *		and disconnect robots from RCI tasks.
 * 
 * AUTHOR/DATE:	John Lloyd, Fall 1987
 *
 * MODIFICATION HISTORY:
 *
 *--------------------------------------------------------------------------*/

#include "../h/cdefs.h"
#include "../h/robot_jls.h"
#include "../h/robotComfxns.h"
#include "../h/rciTask.h"
#include "../h/IOdevice.h"

#include "../robots/robotData.h"

#include "../rci/robotDefs.h"
#include "../h/rciConfig.h"

typedef struct {
	int fd;		/* interrupt dev. ref number (a file descriptor */
	  		/*    on UNIX; a handle on other systems) */
	int refCnt;	/* No. of rdescs referencing this struct. */
	int openCnt;	/* No. of rdescs referencing the open file */
} RobotIdevDesc;

typedef struct _ROBOT_DESC {
	/* Per-robot structure containing internal information about
	   a robot which has been connected to an RCI task.
	 */

	struct _ROBOT_DESC *next;
	struct _ROBOT_DESC *prev;

	/* stuff set up by partial load */

	char *name;
	int nameLength;
	int class;
	int id;

	JLS *jls;
	KYN *kyn;
	void *var;
	int kynSize;
	int varSize;
	ROBOT_COMFXNS comfxns;

	int privSize;
	int shareSize;

	void *localMem[MAX_CPUS];	/* set inside setupRobot() */

	/* stuff set up by full load */

	int deviceInfoSet;		/* next few fields have been read */
	struct devAddr devAddr;		/* RCI interface device info */
	char *idevName;			/* name of interrupt device */
	int vector;			/* number of interrupt vector */
	int ipl;			/* IPL number for interrupt vector */
	int iaddr;			/* address of interrupt device */
	RobotIdevDesc *intrDesc;	/* interrupt reference struct. */

	/* stuff set up when we actually attach to a task */

	void *shareMemEx[MAX_CPUS];	/* set on demand in attachRobot() */

	int devHandle;
	int idev;
	int num;	/* robot number in RCI task */
	RCI_DESC *td;	/* descriptor of RCI task */
	
} ROBOT_DESC;

#endif
