/***************************************************************************
file name:	GT400LIB.H

contents:
	This file contains various defines that is used with the GOOGOL TECH.
	GT400 motion control board software source code. GT400LIB.C will include
	this file. If GT400LIB.C is used in user file ,please include the file:
	GT400LIB.H
****************************************************************************/

/* return explain:
  -2		版本出错			GT_VRSN_ERR
  -1		通讯失败   			GT_COM_ERR
  0			OK                      GT_CMD_OK
  1			命令出错                GT_CMD_ERR
  2			半径=0或太大            GT_RADI_ERR
  3			直线长度=0或太大        GT_LEN_ERR
  4			（加）速度=0或太大      GT_ANV_ERR
  5			参数矛盾                GT_PRM_ANTI
  6			方程无解                GT_MAP_ERR
  7        过程参数错误                  	GT_PRM_ERR
*/
#if !defined(_USERLIB)
#define _USERLIB

#ifdef __cplusplus
extern "C" {
#endif


/*retrun explain:*/
#define GT_VRSN_ERR		-2
#define GT_COM_ERR    		-1
#define GT_CMD_OK     		0
#define GT_CMD_ERR  		1
#define GT_RADI_ERR  		2
#define GT_LEN_ERR  		3
#define GT_ANV_ERR  		4
#define GT_PRM_ANTI  		5
#define GT_MAP_ERR	  	6
#define GT_PRM_ERR	  	7

/*****************/
/* base address  */
/*****************/
 short   GT_SetAddr(unsigned short address);
 short   GT_GetAddr(unsigned short*);

/****************/
/* axis control */
/****************/
 short	GT_Axis(unsigned short);
 short	GT_AxisI(void);

/**********************/
/* profile generation */
/**********************/
 short  GT_PrflT(void);
 short	GT_PrflS(void);
 short	GT_PrflV(void);
 short	GT_PrflG(unsigned short);

 short	GT_SetPos(long);
 short  GT_SetVel(double);
 short  GT_SetAcc(double);
 short  GT_SetMAcc(double);
 short  GT_SetJerk(double);
 short  GT_SetRatio(double);
 short  GT_SmthStp(void);
 short  GT_AbptStp(void);
 short  GT_ZeroPos(void);
 short 	GT_SynchPos(void);
 short 	GT_SetAtlPos(long);
 short 	GT_GetPos(long*);
 short 	GT_GetVel(double*);
 short 	GT_GetAcc(double*);
 short 	GT_GetMAcc(double*);
 short 	GT_GetJerk(double*);
 short 	GT_GetRatio(double*);
 short  GT_GetAtlPos(long*);
 short  GT_GetAtlVel(double *value); 
 
/******************/
/* digital filter */
/******************/
 short 	GT_SetKp(double);
 short 	GT_SetKd(double);
 short 	GT_SetKi(double);
 short 	GT_SetKvff(double);
 short 	GT_SetKaff(double);
 short 	GT_SetILmt(unsigned short);
 short 	GT_SetMtrLmt(unsigned short);
 short 	GT_SetMtrBias(short);
 short  GT_SetPosErr(unsigned short);
 short	GT_GetKp(double*);
 short	GT_GetKd(double*);
 short	GT_GetKi(double*);
 short	GT_GetKvff(double*);
 short  GT_GetKaff(double*);
 short	GT_GetILmt(unsigned short*);
 short  GT_GetMtrLmt(unsigned short*);
 short  GT_GetMtrBias(short*);
 short	GT_GetPosErr(unsigned short*);
 short	GT_GetIntgr(short*);
 short	GT_GetAtlErr(short*);
 short	GT_AuStpOn(void);
 short	GT_AuStpOff(void);

/********************/
/* parameter update */
/********************/
 short   GT_PosBrk(void);
 short   GT_NegBrk(void);
 short   GT_ExtBrk(void);
 short   GT_MtnBrk(void);
 short   GT_BrkOff(void);
 short   GT_SetBrkCn(long);
 short   GT_Update(void);
 short   GT_MltiUpdt(unsigned short);
 short   GT_AuUpdtOn(void);
 short   GT_AuUpdtOff(void);
 short   GT_GetBrkCn(long*);

/**********************/
/* interrupt process */
/**********************/
 short   GT_TmrIntr(void);
 short   GT_EvntIntr(void);
 short   GT_SetIntrTm(unsigned short);
 short   GT_SetIntrMsk(unsigned short);
 short   GT_RstIntr(unsigned short);
 short   GT_GetIntrMsk(unsigned short*);
 short   GT_GetIntr(unsigned short*);
 short   GT_GetIntrTm(unsigned short*);

/***************/
/* status/mode */
/***************/
 short   GT_ClrSts(void);
 short   GT_RstSts(unsigned short);
 short   GT_GetSts(unsigned short*);
 short   GT_GetMode(unsigned short*);
 short 	 GT_CaptHomInx(void);

/***********/
/* encoder */
/***********/
 short   GT_EncSns(unsigned short);
 short   GT_CaptIndex(void);
 short 	 GT_HomeSns(unsigned short value);
 short   GT_CaptHome(void);
 short   GT_CaptProb(void);
 short   GT_GetCapt(long*);

/**************/
/* axis/motor */
/**************/
 short   GT_CtrlMode(int Mode);
 short   GT_CloseLp(void);
 short   GT_OpenLp(void);
 short   GT_SetMtrCmd(short);
 short   GT_GetMtrCmd(short*);
 short   GT_AxisOn(void);
 short   GT_AxisOff(void);
 short   GT_LmtsOn(void);
 short   GT_LmtsOff(void);
 short   GT_DrvRst(void);
 short   GT_EncOn(void);
 short   GT_EncOff(void);
 short   GT_StepDir(void);
 short   GT_StepPulse(void);
 short 	GT_AlarmOn(void);
 short 	GT_AlarmOff(void);

/******************/
/* Extendable I/O */
/******************/
 short   GT_ExOpt(unsigned short);
 short   GT_ExInpt(unsigned short*);

/*****************/
/* miscellaneous */
/*****************/
 short   GT_GetCmdSts(unsigned short*);
 short   GT_LmtSns(unsigned short);
 short   GT_GetLmtSwt(unsigned short*);
 short   GT_SetSmplTm(double);
 short   GT_GetSmplTm(double*);
 short   GT_Reset(void);
 short   GT_HardRst(void);
 

/*************************/
/*interpolation functions*/
/*************************/
 short   GT_SetAccLmt(double);
 short   GT_GetAccLmt(double*);
 short   GT_MapAxis(unsigned short,double*);
 short   GT_StrtList(void);
 short   GT_AddList(void);
 short   GT_EndList(void);
 short   GT_SetSynVel(double vel);
 short   GT_SetSynAcc(double accel);
 short   GT_StrtMtn(void);
 short   GT_LnXY(double x,double y);
 short   GT_LnXYZ(double x,double y,double z);
 short   GT_LnXYZA(double x,double y,double z,double A);
 short   GT_ArcXY(double x_center,double y_center,double angle);
 short   GT_ArcYZ(double y_center,double z_center,double angle);
 short   GT_ArcZX(double z_center,double x_center,double angle);
 short   GT_ArcXYP(double x_end,double y_end,double r,short dir);
 short   GT_ArcYZP(double y_end,double z_end,double r,short dir);
 short   GT_ArcZXP(double z_end,double x_end,double r,short dir);
 short   GT_MvXY(double x,double y,double vel,double accel);
 short   GT_MvXYZ(double x,double y,double z,double vel,double accel);
 short   GT_MvXYZA(double x,double y,double z,double A,double vel,double accel);
 short   GT_GetBrkPnt(double *pnt);
 short   GT_GetPrfPnt(double* pnt);
 short   GT_StpMtn(void);
 short   GT_EStpMtn(void);
 short   GT_CrdAuStpOn(void);
 short   GT_CrdAuStpOff(void);
 short   GT_GetCrdSts(unsigned short*);
 short   GT_GetMtnNm(unsigned short*);
 short   GT_ArcRErrLmt(double r_err_lmt);


/*******************/
/* option function */
/*******************/
 short   GT_EncPos(short Enc_Num, long* Actl_Pos);
 short   GT_EncVel(short Enc_Num, double* Actl_Vel);
 short   GT_GetAdc(short channel, short* D_data);
 short 	 GT_SetAdcChn(unsigned short value);
 short   GT_SetTime(unsigned short value);
 short 	 GT_DutyRatio(unsigned short value);
 short   GT_SetEncCapt(void);
 short   GT_GetEncCapt(long *value);
 short   GT_GetEncSts(unsigned short *value);
 short	 GT_ClrEncPos(unsigned short);
 short 	 GT_Override(double value);
 short 	 GT_SetHBFrq(unsigned short value);
 short 	 GT_GetHBCmd(unsigned short *value);
 short   GT_GetPrflVel(double *value);
 short	 GT_GetPrflPos(long *value);



#ifdef __cplusplus
}
#endif

#endif //_USERLIB