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 // 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);
} }
} }
@ -136,7 +146,7 @@ asynStatus beamShiftAxis::doPoll(bool *moving) {
asynStatus errorStatus = asynSuccess; asynStatus errorStatus = asynSuccess;
// Status of read-write-operations of ASCII commands to the controller // Status of read-write-operations of ASCII commands to the controller
asynStatus rw_status = asynSuccess; asynStatus status = asynSuccess;
// Status of parameter library operations // Status of parameter library operations
asynStatus pl_status = asynSuccess; asynStatus pl_status = asynSuccess;
@ -172,9 +182,9 @@ asynStatus beamShiftAxis::doPoll(bool *moving) {
- Lower limit - Lower limit
*/ */
snprintf(command, sizeof(command), "P154 Q110 P158 P159 Q113 Q114"); snprintf(command, sizeof(command), "P154 Q110 P158 P159 Q113 Q114");
rw_status = pC_->writeRead(axisNo(), command, response, 6); status = pC_->writeRead(axisNo(), command, response, 6);
if (rw_status != asynSuccess) { if (status != asynSuccess) {
return rw_status; return status;
}; };
nvals = sscanf(response, "%d %lf %d %d %lf %lf", (int *)moving, 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 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;
@ -442,10 +393,7 @@ asynStatus beamShiftAxis::doMove(double position, int relative,
double acceleration) { double acceleration) {
// Status of read-write-operations of ASCII commands to the controller // 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;
char command[pC_->MAXBUF_] = {0}; char command[pC_->MAXBUF_] = {0};
char response[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); 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(
@ -490,8 +427,8 @@ asynStatus beamShiftAxis::doMove(double position, int relative,
motorCoordinatesPosition); motorCoordinatesPosition);
// We don't expect an answer // We don't expect an answer
rw_status = pC_->writeRead(axisNo(), command, response, 0); status = pC_->writeRead(axisNo(), command, response, 0);
if (rw_status != asynSuccess) { if (status != asynSuccess) {
asynPrint( asynPrint(
pC_->pasynUser(), ASYN_TRACE_ERROR, pC_->pasynUser(), ASYN_TRACE_ERROR,
@ -499,14 +436,9 @@ 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 status;
} }
asynStatus beamShiftAxis::stop(double acceleration) { asynStatus beamShiftAxis::stop(double acceleration) {
@ -540,12 +472,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;
} }
@ -553,7 +480,6 @@ asynStatus beamShiftAxis::enable(bool on) {
char command[pC_->MAXBUF_] = {0}; char command[pC_->MAXBUF_] = {0};
char response[pC_->MAXBUF_] = {0}; char response[pC_->MAXBUF_] = {0};
char userMessage[pC_->MAXBUF_] = {0}; char userMessage[pC_->MAXBUF_] = {0};
asynStatus status = asynSuccess;
int nvals = 0; int nvals = 0;
int error = 0; int error = 0;
int enabled = 0; int enabled = 0;
@ -565,7 +491,10 @@ asynStatus beamShiftAxis::enable(bool on) {
if (on) { if (on) {
// Check if the axis is currently switched off // Check if the axis is currently switched off
snprintf(command, sizeof(command), "P158 P159"); 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); nvals = sscanf(response, "%d %d", &enabled, &error);
if (nvals != 2) { if (nvals != 2) {
@ -581,36 +510,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;
} }
} }