/*------------------------------------------------------------------------
	Header file for an EL734 motor driver 
	
	
	Mark Koennecke, November 1996
	
	copyright: see implementation file
----------------------------------------------------------------------------*/

#ifndef SICSEL734
#define SICSEL734
#include "SCinter.h"

#define MOTREDO -1
#define MOTFAIL  0
#define MOTOK    1

  typedef struct __AbstractMoDriv {
                           /* general motor driver interface 
                              fields. REQUIRED!
                           */
                           float fUpper; /* upper limit */
                           float fLower; /* lower limit */
                           char *name;
                           int   (*GetPosition)(void *self, float *fPos);
                           int   (*RunTo)(void *self,float fNewVal);
                           int   (*GetStatus)(void *self);
                           void  (*GetError)(void *self, int *iCode, char *buffer, int iBufLen);
                           int   (*TryAndFixIt)(void *self, int iError,float fNew);
                           int   (*ContinueAfterWarn)(void *self);
                           int   (*Halt)(void *self);
                           } 
                             MotorDriver;
                             
 /* the first fields above HAVE to be IDENTICAL to those below */                                

  typedef struct __MoDriv {
                           /* general motor driver interface 
                              fields. REQUIRED!
                           */
                           float fUpper; /* upper limit */
                           float fLower; /* lower limit */
                           char *name;
                           int   (*GetPosition)(void *self,float *fPos);
                           int   (*RunTo)(void *self, float fNewVal);
                           int   (*GetStatus)(void *self);
                           void  (*GetError)(void *self, int *iCode, char *buffer, int iBufLen);
                           int   (*TryAndFixIt)(void *self,int iError, float fNew);
                           int   (*ContinueAfterWarn)(void *self);
                           int   (*Halt)(void *self);
                           
                           
                           /* EL-734 specific fields */
                           int iPort;
                           char *hostname;
                           int iChannel;
                           int iMotor;
                           void *EL734struct;
                           int iMSR;
                          } EL734Driv;

  typedef struct ___MoSDriv {
                           /* general motor driver interface 
                              fields. REQUIRED!
                           */
                           float fUpper; /* upper limit */
                           float fLower; /* lower limit */
                           char *name;
                           int   (*GetPosition)(void *self,float *fPos);
                           int   (*RunTo)(void *self, float fNewVal);
                           int   (*GetStatus)(void *self);
                           void  (*GetError)(void *self, int *iCode, char *buffer, int iBufLen);
                           int   (*TryAndFixIt)(void *self,int iError, float fNew);
                           int   (*ContinueAfterWarn)(void *self);
                           int   (*Halt)(void *self);
                           
                           /* Simulation  specific fields */
                           float fFailure; /* percent random failures*/
                           float fSpeed;
                           long iTime;
                           float fPos;     /* position */
                          } SIMDriv;

    
/*--------------------------- EL734 -----------------------------------*/                                
  MotorDriver *CreateEL734(SConnection *pCon, int argc, char *argv[]);
  MotorDriver *CreateEL734DC(SConnection *pCon, int argc, char *argv[]);
  void         KillEL734(void *pData);

/* ----------------------- Simulation -----------------------------------*/
  MotorDriver *CreateSIM(SConnection *pCon, int argc, char *argv[]);
  void         KillSIM(void *pData);

/*------------------------ Default ContinueAfterWarn -----------------*/
  int MoDrivXXXContinue(void *pData);
#endif

