Added safe limit setter
This commit is contained in:
@@ -493,6 +493,31 @@ asynStatus sinqAxis::setMotorPosition(double motorPos) {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asynStatus sinqAxis::setLimits(double highLimit, double lowLimit) {
|
||||||
|
asynStatus status = asynSuccess;
|
||||||
|
|
||||||
|
if (highLimit < lowLimit) {
|
||||||
|
double motorPos;
|
||||||
|
double motorRecRes;
|
||||||
|
status = motorPosition(&motorPos);
|
||||||
|
if (status != asynSuccess) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
getAxisParamChecked(this, motorRecResolution, &motorRecRes);
|
||||||
|
|
||||||
|
// This is a safe fallback
|
||||||
|
setAxisParamChecked(this, motorHighLimitFromDriver,
|
||||||
|
motorPos + motorRecRes);
|
||||||
|
setAxisParamChecked(this, motorLowLimitFromDriver,
|
||||||
|
motorPos - motorRecRes);
|
||||||
|
} else {
|
||||||
|
setAxisParamChecked(this, motorHighLimitFromDriver, highLimit);
|
||||||
|
setAxisParamChecked(this, motorLowLimitFromDriver, lowLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
asynStatus sinqAxis::assertConnected() {
|
asynStatus sinqAxis::assertConnected() {
|
||||||
int connected = 0;
|
int connected = 0;
|
||||||
getAxisParamChecked(this, motorConnected, &connected);
|
getAxisParamChecked(this, motorConnected, &connected);
|
||||||
|
|||||||
@@ -391,6 +391,20 @@ class HIDDEN sinqAxis : public asynMotorAxis {
|
|||||||
*/
|
*/
|
||||||
asynStatus setMotorPosition(double motorPosition);
|
asynStatus setMotorPosition(double motorPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sanity-check the limits and write them into the database
|
||||||
|
*
|
||||||
|
* If the given `highLimit` is smaller than the `lowLimit`, the limits are
|
||||||
|
* set to `highLimit = motorPosition + motorRecResolution`,
|
||||||
|
* `lowLimit = motorPosition - motorRecResolution` and a warning is
|
||||||
|
* displayed in the IOC shell. This is not an error
|
||||||
|
*
|
||||||
|
* @param highLimit
|
||||||
|
* @param lowLimit
|
||||||
|
* @return asynStatus
|
||||||
|
*/
|
||||||
|
asynStatus setLimits(double highLimit, double lowLimit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if the axis is not connected and print a corresponding error
|
* @brief Check if the axis is not connected and print a corresponding error
|
||||||
* message
|
* message
|
||||||
|
|||||||
Reference in New Issue
Block a user