Updated to macro usage for paramLib interaction

This commit is contained in:
2025-06-18 08:51:41 +02:00
parent bc0d8d33dd
commit ca52a7398e

View File

@ -64,15 +64,25 @@ beamShiftAxis::beamShiftAxis(turboPmacController *pC, int axisNo)
// The girder translation cannot be disabled // The girder translation cannot be disabled
status = pC_->setIntegerParam(axisNo, pC_->motorCanDisable(), 0); status = pC_->setIntegerParam(axisNo, pC_->motorCanDisable(), 0);
if (status != asynSuccess) { if (status != asynSuccess) {
pC_->paramLibAccessFailed(status, "motorCanDisable", axisNo, asynPrint(
__PRETTY_FUNCTION__, __LINE__); pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d:\nFATAL ERROR "
"(setting a parameter value failed with %s)\n. Terminating IOC",
pC_->portName, axisNo, __PRETTY_FUNCTION__, __LINE__,
pC_->stringifyAsynStatus(status));
exit(-1);
} }
// The girder translation speed cannot be changed // The girder translation speed cannot be changed
status = pC_->setIntegerParam(axisNo, pC_->motorCanSetSpeed(), 0); status = pC_->setIntegerParam(axisNo, pC_->motorCanSetSpeed(), 0);
if (status != asynSuccess) { if (status != asynSuccess) {
pC_->paramLibAccessFailed(status, "motorCanDisable", axisNo, asynPrint(
__PRETTY_FUNCTION__, __LINE__); pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d:\nFATAL ERROR "
"(setting a parameter value failed with %s)\n. Terminating IOC",
pC_->portName, axisNo, __PRETTY_FUNCTION__, __LINE__,
pC_->stringifyAsynStatus(status));
exit(-1);
} }
} }
@ -196,22 +206,12 @@ asynStatus beamShiftAxis::doPoll(bool *moving) {
directly, but need to shrink them a bit. In this case, we're shrinking them directly, but need to shrink them a bit. In this case, we're shrinking them
by limitsOffset on both sides. by limitsOffset on both sides.
*/ */
pl_status = getAxisParamChecked(this, motorLimitsOffset, &limitsOffset);
pC_->getDoubleParam(axisNo(), pC_->motorLimitsOffset(), &limitsOffset);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorLimitsOffset_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
highLimit = highLimit - limitsOffset; highLimit = highLimit - limitsOffset;
lowLimit = lowLimit + limitsOffset; lowLimit = lowLimit + limitsOffset;
// Update the enablement PV. // Update the enablement PV.
pl_status = setIntegerParam(pC_->motorEnableRBV(), enabled); setAxisParamChecked(this, motorEnableRBV, enabled);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorEnableRBV_", axisNo(),
__PRETTY_FUNCTION__, __LINE__);
}
if (*moving) { if (*moving) {
// If the axis is moving, evaluate the movement direction // If the axis is moving, evaluate the movement direction
@ -223,67 +223,22 @@ asynStatus beamShiftAxis::doPoll(bool *moving) {
} }
errorStatus = handleError(error, userMessage, sizeof(userMessage)); errorStatus = handleError(error, userMessage, sizeof(userMessage));
pl_status = setStringParam(pC_->motorMessageText(), userMessage); setAxisParamChecked(this, motorMessageText, userMessage);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorMessageText",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
// Update the parameter library // Update the parameter library
if (error != 0) { if (error != 0) {
pl_status = setIntegerParam(pC_->motorStatusProblem(), true); setAxisParamChecked(this, motorStatusProblem, true);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
} }
if (*moving == false) { if (*moving == false) {
pl_status = setIntegerParam(pC_->motorMoveToHome(), 0); setAxisParamChecked(this, motorMoveToHome, false);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorMoveToHome_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
} }
pl_status = setIntegerParam(pC_->motorStatusMoving(), *moving); setAxisParamChecked(this, motorStatusMoving, *moving);
if (pl_status != asynSuccess) { setAxisParamChecked(this, motorStatusMoving, !(*moving));
return pC_->paramLibAccessFailed(pl_status, "motorStatusMoving_", setAxisParamChecked(this, motorStatusDirection, direction);
axisNo(), __PRETTY_FUNCTION__, setAxisParamChecked(this, motorHighLimitFromDriver, highLimit);
__LINE__); setAxisParamChecked(this, motorLowLimitFromDriver, lowLimit);
}
pl_status = setIntegerParam(pC_->motorStatusDone(), !(*moving));
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorStatusDone_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
pl_status = setIntegerParam(pC_->motorStatusDirection(), direction);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorStatusDirection_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
pl_status = pC_->setDoubleParam(axisNo(), pC_->motorHighLimitFromDriver(),
highLimit);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorHighLimitFromDriver_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
pl_status =
pC_->setDoubleParam(axisNo(), pC_->motorLowLimitFromDriver(), lowLimit);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorLowLimit_", axisNo(),
__PRETTY_FUNCTION__, __LINE__);
}
pl_status = setMotorPosition(currentPosition); pl_status = setMotorPosition(currentPosition);
if (pl_status != asynSuccess) { if (pl_status != asynSuccess) {
@ -420,12 +375,8 @@ asynStatus beamShiftAxis::handleError(int error, char *userMessage,
snprintf(userMessage, sizeUserMessage, snprintf(userMessage, sizeUserMessage,
"Unknown error P%2.2d01 = %d. Please call the support.", "Unknown error P%2.2d01 = %d. Please call the support.",
axisNo(), error); axisNo(), error);
status = setStringParam(pC_->motorMessageText(), userMessage);
if (status != asynSuccess) { setAxisParamChecked(this, motorMessageText, userMessage);
return pC_->paramLibAccessFailed(status, "motorMessageText_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
status = asynError; status = asynError;
break; break;
@ -455,19 +406,8 @@ asynStatus beamShiftAxis::doMove(double position, int relative,
// ========================================================================= // =========================================================================
pl_status = pC_->getIntegerParam(axisNo(), pC_->motorEnableRBV(), &enabled); getAxisParamChecked(this, motorEnableRBV, &enabled);
if (pl_status != asynSuccess) { getAxisParamChecked(this, motorRecResolution, &motorRecResolution);
return pC_->paramLibAccessFailed(pl_status, "enableMotorRBV_", axisNo(),
__PRETTY_FUNCTION__, __LINE__);
}
pl_status = pC_->getDoubleParam(axisNo(), pC_->motorRecResolution(),
&motorRecResolution);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorRecResolution_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
if (enabled == 0) { if (enabled == 0) {
asynPrint( asynPrint(
@ -499,12 +439,7 @@ asynStatus beamShiftAxis::doMove(double position, int relative,
"target position %lf failed.\n", "target position %lf failed.\n",
pC_->portName, axisNo(), __PRETTY_FUNCTION__, __LINE__, pC_->portName, axisNo(), __PRETTY_FUNCTION__, __LINE__,
motorCoordinatesPosition); motorCoordinatesPosition);
pl_status = setIntegerParam(pC_->motorStatusProblem(), true); setAxisParamChecked(this, motorStatusProblem, true);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
} }
return rw_status; return rw_status;
} }
@ -540,12 +475,7 @@ asynStatus beamShiftAxis::doHome(double min_velocity, double max_velocity,
Encoder type is absolute encoder Encoder type is absolute encoder
*/ */
asynStatus beamShiftAxis::readEncoderType() { asynStatus beamShiftAxis::readEncoderType() {
setAxisParamChecked(this, encoderType, AbsoluteEncoder);
asynStatus pl_status = setStringParam(pC_->encoderType(), AbsoluteEncoder);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "encoderType_", axisNo(),
__PRETTY_FUNCTION__, __LINE__);
}
return asynSuccess; return asynSuccess;
} }
@ -581,36 +511,17 @@ asynStatus beamShiftAxis::enable(bool on) {
// path. // path.
handleError(error, userMessage, sizeof(userMessage)); handleError(error, userMessage, sizeof(userMessage));
status = setIntegerParam(pC_->motorStatusProblem(), true); setAxisParamChecked(this, motorStatusProblem, true);
if (status != asynSuccess) { setAxisParamChecked(this, motorMessageText, userMessage);
return pC_->paramLibAccessFailed(status, "motorStatusProblem_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
status = setStringParam(pC_->motorMessageText(), userMessage);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorMessageText_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
return asynError; return asynError;
} }
return asynSuccess; return asynSuccess;
} else { } else {
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nAxis cannot be " "Controller \"%s\", axis %d => %s, line %d\nAxis cannot be "
"switched off.\n", "switched off.\n",
pC_->portName, axisNo(), __PRETTY_FUNCTION__, __LINE__); pC_->portName, axisNo(), __PRETTY_FUNCTION__, __LINE__);
status = setAxisParamChecked(this, motorMessageText, "Cannot be switched off.");
setStringParam(pC_->motorMessageText(), "Cannot be switched off.");
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorMessageText_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
return asynError; return asynError;
} }
} }