Updated param lib accessors to use macro to reduce boilerplate
This commit is contained in:
@@ -96,8 +96,13 @@ seleneLiftAxis::seleneLiftAxis(seleneGuideController *pC, int axis1No,
|
||||
// Selene guide motors 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);
|
||||
}
|
||||
|
||||
// Even though this happens already in sinqAxis, a default value for
|
||||
@@ -151,44 +156,17 @@ asynStatus seleneLiftAxis::init() {
|
||||
}
|
||||
|
||||
// Assume the virtual axes are not moving at the start
|
||||
status = setIntegerParam(pC_->motorStatusMoving(), 0);
|
||||
if (status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(status, "motorStatusMoving", axisNo_,
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
status = setIntegerParam(pC_->motorStatusDone(), 1);
|
||||
if (status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(status, "motorStatusDone", axisNo_,
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
setAxisParamChecked(this, motorStatusMoving, false);
|
||||
setAxisParamChecked(this, motorStatusDone, true);
|
||||
|
||||
status = angleAxis_->setIntegerParam(pC_->motorStatusMoving(), 0);
|
||||
if (status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(status, "motorStatusMoving",
|
||||
angleAxis_->axisNo(),
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
status = angleAxis_->setIntegerParam(pC_->motorStatusDone(), 1);
|
||||
if (status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(status, "motorStatusDone",
|
||||
angleAxis_->axisNo(),
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
setAxisParamChecked(angleAxis_, motorStatusMoving, false);
|
||||
setAxisParamChecked(angleAxis_, motorStatusDone, true);
|
||||
|
||||
// The virtual axes should always be seen as enabled, since the underlying
|
||||
// hardware is automatically enabled after sending a start command to the
|
||||
// controller and automatically disabled after the movement finished.
|
||||
status = setIntegerParam(pC_->motorEnableRBV(), 1);
|
||||
if (status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(status, "motorEnableRBV_", axisNo_,
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
status = angleAxis_->setIntegerParam(pC_->motorEnableRBV(), 1);
|
||||
if (status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(status, "motorEnableRBV_",
|
||||
angleAxis_->axisNo(),
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
setAxisParamChecked(this, motorEnableRBV, true);
|
||||
setAxisParamChecked(angleAxis_, motorEnableRBV, true);
|
||||
|
||||
status = normalizePositions();
|
||||
if (status != asynSuccess) {
|
||||
@@ -277,12 +255,7 @@ asynStatus seleneLiftAxis::normalizePositions() {
|
||||
}
|
||||
|
||||
asynStatus seleneLiftAxis::doPoll(bool *moving) {
|
||||
|
||||
// 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 response[pC_->MAXBUF_] = {0};
|
||||
char userMessage[pC_->MAXBUF_] = {0};
|
||||
@@ -293,18 +266,12 @@ asynStatus seleneLiftAxis::doPoll(bool *moving) {
|
||||
|
||||
// =========================================================================
|
||||
|
||||
pl_status =
|
||||
pC_->getIntegerParam(axisNo(), pC_->motorStatusDone(), &wasDone);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorStatusMoving",
|
||||
axisNo(), __PRETTY_FUNCTION__,
|
||||
__LINE__);
|
||||
}
|
||||
getAxisParamChecked(this, motorStatusDone, &wasDone);
|
||||
|
||||
const char *command = "P158";
|
||||
rw_status = pC_->writeRead(axisNo_, command, response, 1);
|
||||
if (rw_status != asynSuccess) {
|
||||
return rw_status;
|
||||
status = pC_->writeRead(axisNo_, command, response, 1);
|
||||
if (status != asynSuccess) {
|
||||
return status;
|
||||
}
|
||||
|
||||
nvals = sscanf(response, "%d", &axStatus);
|
||||
@@ -315,31 +282,12 @@ asynStatus seleneLiftAxis::doPoll(bool *moving) {
|
||||
*moving = (axStatus != 0);
|
||||
|
||||
// Set the moving status of seleneLiftAxis
|
||||
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__);
|
||||
}
|
||||
setAxisParamChecked(this, motorStatusMoving, *moving);
|
||||
setAxisParamChecked(this, motorStatusDone, !(*moving));
|
||||
|
||||
// Set the moving status of seleneAngleAxis
|
||||
pl_status = angleAxis_->setIntegerParam(pC_->motorStatusMoving(), *moving);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorStatusMoving",
|
||||
angleAxis_->axisNo(),
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
pl_status = angleAxis_->setIntegerParam(pC_->motorStatusDone(), !(*moving));
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorStatusDone",
|
||||
angleAxis_->axisNo(),
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
setAxisParamChecked(angleAxis_, motorStatusMoving, *moving);
|
||||
setAxisParamChecked(angleAxis_, motorStatusDone, !(*moving));
|
||||
|
||||
/*
|
||||
If an seleneOffsetAxis is moving, the positions of the virtual axes
|
||||
@@ -358,22 +306,17 @@ asynStatus seleneLiftAxis::doPoll(bool *moving) {
|
||||
|
||||
double motorRecResolution = 0.0;
|
||||
|
||||
asynStatus pl_status = pC_->getDoubleParam(
|
||||
axisNo_, pC_->motorRecResolution(), &motorRecResolution);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorRecResolution_",
|
||||
axisNo_, __PRETTY_FUNCTION__,
|
||||
__LINE__);
|
||||
getAxisParamChecked(angleAxis_, motorRecResolution,
|
||||
&motorRecResolution);
|
||||
|
||||
status = offsetAxes_[2]->motorPosition(&offsetAx2Pos);
|
||||
if (status != asynSuccess) {
|
||||
return status;
|
||||
}
|
||||
|
||||
pl_status = offsetAxes_[2]->motorPosition(&offsetAx2Pos);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pl_status;
|
||||
}
|
||||
|
||||
pl_status = offsetAxes_[3]->motorPosition(&offsetAx3Pos);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pl_status;
|
||||
status = offsetAxes_[3]->motorPosition(&offsetAx3Pos);
|
||||
if (status != asynSuccess) {
|
||||
return status;
|
||||
}
|
||||
|
||||
deriveLiftAndAngle(
|
||||
@@ -382,14 +325,14 @@ asynStatus seleneLiftAxis::doPoll(bool *moving) {
|
||||
&angle);
|
||||
|
||||
// Set the position values in the parameter library
|
||||
pl_status = setMotorPosition(lift);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pl_status;
|
||||
status = setMotorPosition(lift);
|
||||
if (status != asynSuccess) {
|
||||
return status;
|
||||
}
|
||||
|
||||
pl_status = angleAxis_->setMotorPosition(angle);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pl_status;
|
||||
status = angleAxis_->setMotorPosition(angle);
|
||||
if (status != asynSuccess) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// Calculate the new liftPosition_ of all seleneOffsetAxis
|
||||
@@ -414,45 +357,22 @@ asynStatus seleneLiftAxis::doPoll(bool *moving) {
|
||||
|
||||
// Set the limits for the lift axis
|
||||
double motPos = 0.0;
|
||||
pl_status = motorPosition(&motPos);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pl_status;
|
||||
status = motorPosition(&motPos);
|
||||
if (status != asynSuccess) {
|
||||
return status;
|
||||
}
|
||||
|
||||
pl_status = pC_->setDoubleParam(axisNo_, pC_->motorHighLimitFromDriver(),
|
||||
motPos + smallestDistHighLimit);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorHighLimitFromDriver_",
|
||||
axisNo_, __PRETTY_FUNCTION__,
|
||||
__LINE__);
|
||||
}
|
||||
|
||||
pl_status = pC_->setDoubleParam(axisNo_, pC_->motorLowLimitFromDriver(),
|
||||
motPos - smallestDistLowLimit);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorLowLimit_", axisNo_,
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
setAxisParamChecked(this, motorHighLimitFromDriver,
|
||||
motPos + smallestDistHighLimit);
|
||||
setAxisParamChecked(this, motorLowLimitFromDriver,
|
||||
motPos - smallestDistLowLimit);
|
||||
|
||||
// The virtual axes are in an error state, if at least one of the underlying
|
||||
// real axes is in an error state.
|
||||
for (int i = 0; i < numAxes_; i++) {
|
||||
pl_status = pC_->getStringParam(offsetAxes_[i]->axisNo(),
|
||||
pC_->motorMessageText(),
|
||||
sizeof(userMessage), userMessage);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorMessageText",
|
||||
offsetAxes_[i]->axisNo(),
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
setAxisParamChecked(offsetAxes_[i], motorMessageText, userMessage);
|
||||
if (strlen(userMessage) != 0) {
|
||||
pl_status = setStringParam(pC_->motorMessageText(), userMessage);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
||||
axisNo_, __PRETTY_FUNCTION__,
|
||||
__LINE__);
|
||||
}
|
||||
setAxisParamChecked(this, motorMessageText, userMessage);
|
||||
return asynError;
|
||||
}
|
||||
}
|
||||
@@ -464,17 +384,10 @@ asynStatus seleneLiftAxis::doMove(double position, int relative,
|
||||
double min_velocity, double max_velocity,
|
||||
double acceleration) {
|
||||
double motorRecResolution = 0.0;
|
||||
asynStatus status = asynSuccess;
|
||||
|
||||
status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution(),
|
||||
&motorRecResolution);
|
||||
if (status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(status, "motorRecResolution_", axisNo_,
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
getAxisParamChecked(this, motorRecResolution, &motorRecResolution);
|
||||
setTargetPosition(position * motorRecResolution);
|
||||
targetSet_ = true;
|
||||
status = startCombinedMoveFromVirtualAxis();
|
||||
asynStatus status = startCombinedMoveFromVirtualAxis();
|
||||
targetSet_ = false;
|
||||
return status;
|
||||
}
|
||||
@@ -540,12 +453,7 @@ asynStatus seleneLiftAxis::stop(double acceleration) {
|
||||
"failed.\n",
|
||||
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__);
|
||||
|
||||
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;
|
||||
@@ -561,24 +469,13 @@ asynStatus seleneLiftAxis::doReset() {
|
||||
}
|
||||
|
||||
asynStatus seleneLiftAxis::enable(bool on) {
|
||||
asynStatus pl_status = setStringParam(pC_->motorMessageText(),
|
||||
"Axis cannot be enabled / disabled");
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
||||
axisNo_, __PRETTY_FUNCTION__,
|
||||
__LINE__);
|
||||
}
|
||||
return pl_status;
|
||||
setAxisParamChecked(this, motorMessageText,
|
||||
"Axis cannot be enabled / disabled");
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
asynStatus seleneLiftAxis::readEncoderType() {
|
||||
asynStatus pl_status =
|
||||
setStringParam(pC_->encoderType(), IncrementalEncoder);
|
||||
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "encoderType_", axisNo_,
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
setAxisParamChecked(this, encoderType, IncrementalEncoder);
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user