diff --git a/src/beamShiftAxis.cpp b/src/beamShiftAxis.cpp index 314b511..9128c7b 100644 --- a/src/beamShiftAxis.cpp +++ b/src/beamShiftAxis.cpp @@ -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); } } @@ -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; @@ -455,19 +406,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( @@ -499,12 +439,7 @@ 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; } @@ -540,12 +475,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; } @@ -581,36 +511,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; } }