move string parameters from "list" to "slist" because non-numerics in "list" upset hipadaba stuff. Also implement motor "setpos" command with two arguments.
r1869 | dcl | 2007-04-18 09:35:32 +1000 (Wed, 18 Apr 2007) | 2 lines
This commit is contained in:
@@ -1579,7 +1579,6 @@ static int DMC2280SetPar(void *pData, SConnection *pCon,
|
||||
pDMC2280Driv self = NULL;
|
||||
char pError[ERRLEN];
|
||||
char cmd[CMDLEN];
|
||||
float oldZero, newZero;
|
||||
|
||||
self = (pDMC2280Driv)pData;
|
||||
|
||||
@@ -1605,6 +1604,7 @@ static int DMC2280SetPar(void *pData, SConnection *pCon,
|
||||
}
|
||||
|
||||
if(strcasecmp(name,SETPOS) == 0) {
|
||||
float oldZero, newZero;
|
||||
if (self->pMot == NULL)
|
||||
self->pMot = FindMotor(pServ->pSics, self->name);
|
||||
MotorGetPar(self->pMot,"softzero",&oldZero);
|
||||
@@ -1787,19 +1787,29 @@ static int DMC2280SetPar(void *pData, SConnection *pCon,
|
||||
* \param *name (r) name of motor.
|
||||
* \param *pCon (r) connection object.
|
||||
*/
|
||||
static void DMC2280List(void *self, char *name, SConnection *pCon){
|
||||
static void DMC2280StrList(void *self, char *name, SConnection *pCon){
|
||||
char buffer[BUFFLEN];
|
||||
|
||||
snprintf(buffer, BUFFLEN, "%s.long_name = %s\n", name, ((pDMC2280Driv)self)->long_name);
|
||||
SCWrite(pCon, buffer, eStatus);
|
||||
snprintf(buffer, BUFFLEN, "%s.axis = %c\n", name, ((pDMC2280Driv)self)->axisLabel);
|
||||
SCWrite(pCon, buffer, eStatus);
|
||||
snprintf(buffer, BUFFLEN, "%s.units = %s\n", name, ((pDMC2280Driv)self)->units);
|
||||
SCWrite(pCon, buffer, eStatus);
|
||||
return;
|
||||
}
|
||||
/** \brief List the motor parameters to the client.
|
||||
* \param self (r) provides access to the motor's data structure
|
||||
* \param *name (r) name of motor.
|
||||
* \param *pCon (r) connection object.
|
||||
*/
|
||||
static void DMC2280List(void *self, char *name, SConnection *pCon){
|
||||
char buffer[BUFFLEN];
|
||||
|
||||
snprintf(buffer, BUFFLEN, "%s.stepsPerX = %f\n", name, ((pDMC2280Driv)self)->stepsPerX);
|
||||
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);
|
||||
SCWrite(pCon, buffer, eStatus);
|
||||
snprintf(buffer, BUFFLEN, "%s.speed = %f\n", name, ((pDMC2280Driv)self)->speed);
|
||||
SCWrite(pCon, buffer, eStatus);
|
||||
snprintf(buffer, BUFFLEN, "%s.maxSpeed = %f\n", name, ((pDMC2280Driv)self)->maxSpeed);
|
||||
@@ -2096,6 +2106,7 @@ MotorDriver *CreateDMC2280(SConnection *pCon, char *motor, char *params) {
|
||||
/* TODO Initialise current position and target to get a sensible initial list output */
|
||||
return (MotorDriver *)pNew;
|
||||
}
|
||||
|
||||
int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
@@ -2115,7 +2126,7 @@ int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (strcasecmp("long_name", argv[1]) == 0) {
|
||||
else if (strcasecmp("long_name", argv[1]) == 0) {
|
||||
if (argc > 2) {
|
||||
strncpy(self->long_name, argv[2], sizeof(self->long_name));
|
||||
self->long_name[sizeof(self->long_name) - 1] = '\0';
|
||||
@@ -2127,7 +2138,7 @@ int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (strcasecmp("part", argv[1]) == 0) {
|
||||
else if (strcasecmp("part", argv[1]) == 0) {
|
||||
if (argc > 2) {
|
||||
strncpy(self->part, argv[2], sizeof(self->part));
|
||||
self->part[sizeof(self->part) - 1] = '\0';
|
||||
@@ -2139,7 +2150,35 @@ int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (strcasecmp("list", argv[1]) == 0) {
|
||||
else if (strcasecmp("list", argv[1]) == 0) {
|
||||
}
|
||||
else if (strcasecmp("slist", argv[1]) == 0) {
|
||||
DMC2280StrList(self, argv[0], pCon);
|
||||
return 1;
|
||||
}
|
||||
else if(strcasecmp(SETPOS, argv[1]) == 0) {
|
||||
float oldZero, newZero, currPos, newValue;
|
||||
if (self->pMot == NULL)
|
||||
self->pMot = FindMotor(pServ->pSics, self->name);
|
||||
MotorGetPar(self->pMot, "softzero", &oldZero);
|
||||
if (argc > 3) {
|
||||
sscanf(argv[2], "%f", &currPos);
|
||||
currPos += oldZero;
|
||||
sscanf(argv[3], "%f", &newValue);
|
||||
}
|
||||
else if (argc > 2 ){
|
||||
sscanf(argv[2], "%f", &newValue);
|
||||
currPos = self->pMot->fPosition;
|
||||
}
|
||||
else {
|
||||
char buffer[BUFFLEN];
|
||||
snprintf(buffer, BUFFLEN, "%s.setPos = %f\n", self->name, oldZero);
|
||||
SCWrite(pCon, buffer, eStatus);
|
||||
return 1;
|
||||
}
|
||||
newZero = (currPos - newValue);
|
||||
MotorSetPar(self->pMot, pCon, "softzero", newZero);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return MotorAction(pCon, pSics, pData, argc, argv);
|
||||
|
||||
Reference in New Issue
Block a user