Added safe limit setter
All checks were successful
Test And Build / Lint (push) Successful in 5s
Test And Build / Build (push) Successful in 6s

This commit is contained in:
2026-02-10 08:48:25 +01:00
parent 82f509596d
commit 95bc899114
2 changed files with 39 additions and 0 deletions

View File

@@ -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);

View File

@@ -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