diff --git a/motorApp/MotorSrc/asynMotorAxis.cpp b/motorApp/MotorSrc/asynMotorAxis.cpp index 8752f9e0..104ec514 100644 --- a/motorApp/MotorSrc/asynMotorAxis.cpp +++ b/motorApp/MotorSrc/asynMotorAxis.cpp @@ -234,10 +234,36 @@ asynStatus asynMotorAxis::executeProfile() return asynSuccess; } -/** Function to readback the actual motor positions from a coordinated move of multiple axes. */ +/** Function to readback the actual motor positions from a coordinated move of multiple axes. + * This base class function converts the readbacks and following errors from controller units + * to user units and does callbacks on the arrays. + * Caution: this function modifies the readbacks in place, so it must only be called + * once per readback operation. + */ asynStatus asynMotorAxis::readbackProfile() { + int i; + double resolution; + double offset; + int direction; + int numReadbacks; + int status=0; // static const char *functionName = "asynMotorController::readbackProfile"; - // Convert readbacks and following errors from controller units to user units and do callbacks + + status |= pC_->getDoubleParam(axisNo_, pC_->profileMotorResolution_, &resolution); + status |= pC_->getDoubleParam(axisNo_, pC_->profileMotorOffset_, &offset); + status |= pC_->getIntegerParam(axisNo_, pC_->profileMotorDirection_, &direction); + status |= pC_->getIntegerParam(axisNo_, pC_->profileNumReadbacks_, &numReadbacks); + if (status) return asynError; + if (resolution == 0.0) return asynError; + + // Convert to user units + if (direction != 0) resolution = -resolution; + for (i=0; idoCallbacksFloat64Array(profileReadbacks_, numReadbacks, axisNo_, pC_->profileReadbacks_); + pC_->doCallbacksFloat64Array(profileFollowingErrors_, numReadbacks, axisNo_, pC_->profileFollowingErrors_); return asynSuccess; }