- allow scriptcontext objects to be dynamic
- enhancements in scriptcontext (error messages stored as properties)
This commit is contained in:
29
motor.c
29
motor.c
@@ -128,28 +128,25 @@ static int MotorCheckBoundaryImpl(pMotor self, float fVal, float *fNew,
|
||||
{
|
||||
float fHard;
|
||||
float fZero;
|
||||
char pBueffel[512];
|
||||
|
||||
float fLim;
|
||||
|
||||
assert(self);
|
||||
|
||||
/* check for fixed */
|
||||
if (ObVal(self->ParArray, FIX) >= 0) {
|
||||
sprintf(pBueffel, "Motor %s is Fixed", self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
snprintf(pError, iErrLen, "Motor %s is Fixed", self->name);
|
||||
return 0; /* is this an error? */
|
||||
}
|
||||
|
||||
/* check against software boundaries */
|
||||
if (fVal > ObVal(self->ParArray, SUPP)) {
|
||||
sprintf(pBueffel, "%f violates upper software limit %f on %s",
|
||||
fVal, ObVal(self->ParArray, SUPP), self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
snprintf(pError, iErrLen, "%g violates upper software limit %g on %s",
|
||||
fVal, ObVal(self->ParArray, SUPP), self->name);
|
||||
return 0;
|
||||
}
|
||||
if (fVal < ObVal(self->ParArray, SLOW)) {
|
||||
sprintf(pBueffel, "%f violates lower software limit %f on %s",
|
||||
snprintf(pError, iErrLen, "%g violates lower software limit %g on %s",
|
||||
fVal, ObVal(self->ParArray, SLOW), self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -163,15 +160,17 @@ static int MotorCheckBoundaryImpl(pMotor self, float fVal, float *fNew,
|
||||
|
||||
/* check for hardware limits */
|
||||
if (fHard > self->pDriver->fUpper) {
|
||||
sprintf(pBueffel, "%f violates upper hardware limit %f on %s",
|
||||
fVal, self->pDriver->fUpper, self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
fLim = self->pDriver->fUpper * ObVal(self->ParArray,SIGN) + fZero;
|
||||
snprintf(pError, iErrLen,
|
||||
"%g violates upper hardware limit %g (%g) on %s",
|
||||
fVal, fLim, self->pDriver->fUpper, self->name);
|
||||
return 0;
|
||||
}
|
||||
if (fHard < self->pDriver->fLower) {
|
||||
sprintf(pBueffel, "%f violates lower hardware limit %f on %s",
|
||||
fVal, self->pDriver->fLower, self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
fLim = self->pDriver->fLower * ObVal(self->ParArray,SIGN) + fZero;
|
||||
snprintf(pError, iErrLen,
|
||||
"%g violates lower hardware limit %g (%g) on %s",
|
||||
fVal, fLim, self->pDriver->fLower, self->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user