3 Commits
1.0.0 ... main

Author SHA1 Message Date
5e61af6625 Removed unneeded variables 2025-06-18 08:55:12 +02:00
ca52a7398e Updated to macro usage for paramLib interaction 2025-06-18 08:51:41 +02:00
bc0d8d33dd Updated turboPmac 2025-06-18 08:37:07 +02:00
2 changed files with 46 additions and 136 deletions

View File

@ -64,15 +64,25 @@ beamShiftAxis::beamShiftAxis(turboPmacController *pC, int axisNo)
// The girder translation cannot be disabled
status = pC_->setIntegerParam(axisNo, pC_->motorCanDisable(), 0);
if (status != asynSuccess) {
pC_->paramLibAccessFailed(status, "motorCanDisable", axisNo,
__PRETTY_FUNCTION__, __LINE__);
asynPrint(
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
status = pC_->setIntegerParam(axisNo, pC_->motorCanSetSpeed(), 0);
if (status != asynSuccess) {
pC_->paramLibAccessFailed(status, "motorCanDisable", axisNo,
__PRETTY_FUNCTION__, __LINE__);
asynPrint(
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);
}
}
@ -136,7 +146,7 @@ asynStatus beamShiftAxis::doPoll(bool *moving) {
asynStatus errorStatus = asynSuccess;
// Status of read-write-operations of ASCII commands to the controller
asynStatus rw_status = asynSuccess;
asynStatus status = asynSuccess;
// Status of parameter library operations
asynStatus pl_status = asynSuccess;
@ -172,9 +182,9 @@ asynStatus beamShiftAxis::doPoll(bool *moving) {
- Lower limit
*/
snprintf(command, sizeof(command), "P154 Q110 P158 P159 Q113 Q114");
rw_status = pC_->writeRead(axisNo(), command, response, 6);
if (rw_status != asynSuccess) {
return rw_status;
status = pC_->writeRead(axisNo(), command, response, 6);
if (status != asynSuccess) {
return status;
};
nvals = sscanf(response, "%d %lf %d %d %lf %lf", (int *)moving,
@ -196,22 +206,12 @@ asynStatus beamShiftAxis::doPoll(bool *moving) {
directly, but need to shrink them a bit. In this case, we're shrinking them
by limitsOffset on both sides.
*/
pl_status =
pC_->getDoubleParam(axisNo(), pC_->motorLimitsOffset(), &limitsOffset);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorLimitsOffset_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
getAxisParamChecked(this, motorLimitsOffset, &limitsOffset);
highLimit = highLimit - limitsOffset;
lowLimit = lowLimit + limitsOffset;
// Update the enablement PV.
pl_status = setIntegerParam(pC_->motorEnableRBV(), enabled);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorEnableRBV_", axisNo(),
__PRETTY_FUNCTION__, __LINE__);
}
setAxisParamChecked(this, motorEnableRBV, enabled);
if (*moving) {
// If the axis is moving, evaluate the movement direction
@ -223,67 +223,22 @@ asynStatus beamShiftAxis::doPoll(bool *moving) {
}
errorStatus = handleError(error, userMessage, sizeof(userMessage));
pl_status = setStringParam(pC_->motorMessageText(), userMessage);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorMessageText",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
setAxisParamChecked(this, motorMessageText, userMessage);
// Update the parameter library
if (error != 0) {
pl_status = setIntegerParam(pC_->motorStatusProblem(), true);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
setAxisParamChecked(this, motorStatusProblem, true);
}
if (*moving == false) {
pl_status = setIntegerParam(pC_->motorMoveToHome(), 0);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorMoveToHome_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
setAxisParamChecked(this, motorMoveToHome, false);
}
pl_status = setIntegerParam(pC_->motorStatusMoving(), *moving);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorStatusMoving_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
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__);
}
setAxisParamChecked(this, motorStatusMoving, *moving);
setAxisParamChecked(this, motorStatusMoving, !(*moving));
setAxisParamChecked(this, motorStatusDirection, direction);
setAxisParamChecked(this, motorHighLimitFromDriver, highLimit);
setAxisParamChecked(this, motorLowLimitFromDriver, lowLimit);
pl_status = setMotorPosition(currentPosition);
if (pl_status != asynSuccess) {
@ -420,12 +375,8 @@ asynStatus beamShiftAxis::handleError(int error, char *userMessage,
snprintf(userMessage, sizeUserMessage,
"Unknown error P%2.2d01 = %d. Please call the support.",
axisNo(), error);
status = setStringParam(pC_->motorMessageText(), userMessage);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorMessageText_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
setAxisParamChecked(this, motorMessageText, userMessage);
status = asynError;
break;
@ -442,10 +393,7 @@ asynStatus beamShiftAxis::doMove(double position, int relative,
double acceleration) {
// Status of read-write-operations of ASCII commands to the controller
asynStatus rw_status = asynSuccess;
// Status of parameter library operations
asynStatus pl_status = asynSuccess;
asynStatus status = asynSuccess;
char command[pC_->MAXBUF_] = {0};
char response[pC_->MAXBUF_] = {0};
@ -455,19 +403,8 @@ asynStatus beamShiftAxis::doMove(double position, int relative,
// =========================================================================
pl_status = pC_->getIntegerParam(axisNo(), pC_->motorEnableRBV(), &enabled);
if (pl_status != asynSuccess) {
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__);
}
getAxisParamChecked(this, motorEnableRBV, &enabled);
getAxisParamChecked(this, motorRecResolution, &motorRecResolution);
if (enabled == 0) {
asynPrint(
@ -490,8 +427,8 @@ asynStatus beamShiftAxis::doMove(double position, int relative,
motorCoordinatesPosition);
// We don't expect an answer
rw_status = pC_->writeRead(axisNo(), command, response, 0);
if (rw_status != asynSuccess) {
status = pC_->writeRead(axisNo(), command, response, 0);
if (status != asynSuccess) {
asynPrint(
pC_->pasynUser(), ASYN_TRACE_ERROR,
@ -499,14 +436,9 @@ asynStatus beamShiftAxis::doMove(double position, int relative,
"target position %lf failed.\n",
pC_->portName, axisNo(), __PRETTY_FUNCTION__, __LINE__,
motorCoordinatesPosition);
pl_status = setIntegerParam(pC_->motorStatusProblem(), true);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
setAxisParamChecked(this, motorStatusProblem, true);
}
return rw_status;
return status;
}
asynStatus beamShiftAxis::stop(double acceleration) {
@ -540,12 +472,7 @@ asynStatus beamShiftAxis::doHome(double min_velocity, double max_velocity,
Encoder type is absolute encoder
*/
asynStatus beamShiftAxis::readEncoderType() {
asynStatus pl_status = setStringParam(pC_->encoderType(), AbsoluteEncoder);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "encoderType_", axisNo(),
__PRETTY_FUNCTION__, __LINE__);
}
setAxisParamChecked(this, encoderType, AbsoluteEncoder);
return asynSuccess;
}
@ -553,7 +480,6 @@ asynStatus beamShiftAxis::enable(bool on) {
char command[pC_->MAXBUF_] = {0};
char response[pC_->MAXBUF_] = {0};
char userMessage[pC_->MAXBUF_] = {0};
asynStatus status = asynSuccess;
int nvals = 0;
int error = 0;
int enabled = 0;
@ -565,7 +491,10 @@ asynStatus beamShiftAxis::enable(bool on) {
if (on) {
// Check if the axis is currently switched off
snprintf(command, sizeof(command), "P158 P159");
status = pC_->writeRead(axisNo(), command, response, 2);
asynStatus status = pC_->writeRead(axisNo(), command, response, 2);
if (status != asynSuccess) {
return status;
}
nvals = sscanf(response, "%d %d", &enabled, &error);
if (nvals != 2) {
@ -581,36 +510,17 @@ asynStatus beamShiftAxis::enable(bool on) {
// path.
handleError(error, userMessage, sizeof(userMessage));
status = setIntegerParam(pC_->motorStatusProblem(), true);
if (status != asynSuccess) {
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__);
}
setAxisParamChecked(this, motorStatusProblem, true);
setAxisParamChecked(this, motorMessageText, userMessage);
return asynError;
}
return asynSuccess;
} else {
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nAxis cannot be "
"switched off.\n",
pC_->portName, axisNo(), __PRETTY_FUNCTION__, __LINE__);
status =
setStringParam(pC_->motorMessageText(), "Cannot be switched off.");
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorMessageText_",
axisNo(), __PRETTY_FUNCTION__,
__LINE__);
}
setAxisParamChecked(this, motorMessageText, "Cannot be switched off.");
return asynError;
}
}