diff --git a/site_ansto/motor_dmc2280.c b/site_ansto/motor_dmc2280.c index d583e43c..a69b7fa7 100644 --- a/site_ansto/motor_dmc2280.c +++ b/site_ansto/motor_dmc2280.c @@ -30,19 +30,8 @@ #include #include "anstoutil.h" -/* -#include "splint/splint_fortify.h" -#include "splint/splint_tclDecls.h" -#include "splint/splint_dynstring.h" -#include "splint/splint_SCinter.h" -*/ - -/*@-incondefs@*/ -/* XXX Should this also free pData */ -#if 0 -int readRS232(prs232 self, /*@out@*/void *data, /*@out@*/int *dataLen); -int readRS232TillTerm(prs232 self, /*@out@*/void *data, int *datalen); -#endif +#define UNITSLEN 256 +#define TEXTPARLEN 1024 void KillRS232(/*@only@*/ void *pData); /*@+incondefs@*/ @@ -75,6 +64,8 @@ typedef struct __MoDriv { void (*ListDriverPar)(void *self, char *motorName, SConnection *pCon); void (*KillPrivate)(/*@only@*/void *self); + int (*GetDriverTextPar)(void *self, char *name, + char *textPar); /* DMC-2280 specific fields */ @@ -1174,6 +1165,23 @@ static int DMC2280Halt(void *pData){ return 1; } +/** \brief Allow motor drivers to return text values like units. + * + * Refactoring: Should replace this with a function that will + * return hdb values. + * This is the first step in the refactoring process. */ +int DMC2280GetTextPar(void *pData, char *name, char *textPar) { + pDMC2280Driv self = NULL; + + self = (pDMC2280Driv)pData; + + if(strcmp(name,UNITS) == 0) { + snprintf(textPar, UNITSLEN, self->units); + return 1; + } + return 0; +} + /** \brief Fetches the value of the named parameter, * implements the GetDriverPar method in the MotorDriver interface. * @@ -1526,7 +1534,7 @@ static void DMC2280List(void *self, char *name, SConnection *pCon){ SCWrite(pCon, buffer, eStatus); snprintf(buffer, BUFFLEN, "%s.home = %f\n", name, ((pDMC2280Driv)self)->home); SCWrite(pCon, buffer, eStatus); - snprintf(buffer, BUFFLEN, "%s.units = %s\n", name, ((pDMC2280Driv)self)->units); + snprintf(buffer, BUFFLEN, "%s.units = %s\n", name, ((pDMC2280Driv)self)->units); SCWrite(pCon, buffer, eStatus); snprintf(buffer, BUFFLEN, "%s.speed = %f\n", name, ((pDMC2280Driv)self)->speed); SCWrite(pCon, buffer, eStatus); @@ -1713,6 +1721,7 @@ static void KillDMC2280(/*@only@*/void *pData){ pNew->SetDriverPar = DMC2280SetPar; pNew->ListDriverPar = DMC2280List; pNew->KillPrivate = KillDMC2280; + pNew->GetDriverTextPar = DMC2280GetTextPar; pNew->blockage_ckInterval = 0.5; pNew->blockage_thresh = 0.5; pNew->blockage_ratio = 2.0;