/*--------------------------------------------------------------------------
	SICS needs to run motors. This is where this happens.
	
	Mark Koennecke, November 1996
	
	copyright: see implementation file
	
----------------------------------------------------------------------------*/
#ifndef SICSMOTOR
#define SICSMOTOR
#include "Scommon.h"
#include "obpar.h"
#include "modriv.h"
#include "obdes.h"
#include "interface.h"

  typedef struct __Motor {
			  pObjectDescriptor pDescriptor;                          
                          ObPar *ParArray;
                          pIDrivable pDrivInt;
                          pICallBack pCall;
                          char *drivername;
                          char *name;
                          MotorDriver *pDriver;
                          float fTarget;
                          float fPosition;
                          } Motor;
   typedef Motor *pMotor;
/*-------------------------------------------------------------------------*/      

/* parameter management */
   int  MotorGetPar(pMotor self, char *name, float *fVal);
   int  MotorSetPar(pMotor self, SConnection *pCon, char *name, float fVal);

/* driving */
   long MotorRun(void *self, SConnection *pCon, float fNew);
   int MotorCheckBoundary(pMotor self, float fVal, float *fHard,
                          char *error, int iErrLen);  
   int MotorCheckPosition(void *self, SConnection *pCon);
   
/* Where are we ? */
   int MotorGetSoftPosition(pMotor self,SConnection *pCon, float *fVal);
   int MotorGetHardPosition(pMotor self,SConnection *pCon, float *fVal);
                                       
/* creation */
   int MotorCreate(SConnection *pCon, SicsInterp *pSics, void *pData,
                   int argc, char *argv[]);
   pMotor MotorInit(char *drivername,char *name, MotorDriver *pDriv);
   void   MotorKill(void *self);

/* interface to interpreter */
   int MotorAction(SConnection *pCon, SicsInterp *pSics, void *pData,
                   int argc, char *argv[]);
   pMotor FindMotor(SicsInterp *pSics, char *name);                   
                   
#endif

