Adjusted function for reading the target position

This commit is contained in:
2025-06-10 16:37:02 +02:00
parent c736c191d0
commit 3780dee24f
6 changed files with 31 additions and 51 deletions

View File

@ -56,21 +56,20 @@ asynStatus seleneAngleAxis::doMove(double position, int relative,
axisNo_, __PRETTY_FUNCTION__, axisNo_, __PRETTY_FUNCTION__,
__LINE__); __LINE__);
} }
targetPosition_ = position * motorRecResolution; setTargetPosition(position * motorRecResolution);
targetSet_ = true; targetSet_ = true;
return liftAxis_->startCombinedMoveFromVirtualAxis(); return liftAxis_->startCombinedMoveFromVirtualAxis();
targetSet_ = false; targetSet_ = false;
} }
asynStatus seleneAngleAxis::targetPosition(double *targetPosition) { double seleneAngleAxis::targetPosition() {
asynStatus status = asynSuccess;
if (targetSet_) { if (targetSet_) {
*targetPosition = targetPosition_; return turboPmacAxis::targetPosition();
} else { } else {
status = motorPosition(targetPosition); double targetPos = 0;
motorPosition(&targetPos);
return targetPos;
} }
return status;
} }
asynStatus seleneAngleAxis::doPoll(bool *moving) { asynStatus seleneAngleAxis::doPoll(bool *moving) {

View File

@ -102,13 +102,11 @@ class seleneAngleAxis : public turboPmacAxis {
double acceleration, int forwards); double acceleration, int forwards);
/** /**
* @brief Read the target position from the axis and write it into the * @brief Override of the superclass method
* provided pointer.
* *
* @param targetPosition * @return double
* @return asynStatus
*/ */
asynStatus targetPosition(double *targetPosition); double targetPosition();
/** /**
* @brief Set the offsets of axis 3 and 4 to zero and recalculate all other * @brief Set the offsets of axis 3 and 4 to zero and recalculate all other

View File

@ -472,22 +472,21 @@ asynStatus seleneLiftAxis::doMove(double position, int relative,
return pC_->paramLibAccessFailed(status, "motorRecResolution_", axisNo_, return pC_->paramLibAccessFailed(status, "motorRecResolution_", axisNo_,
__PRETTY_FUNCTION__, __LINE__); __PRETTY_FUNCTION__, __LINE__);
} }
targetPosition_ = position * motorRecResolution; setTargetPosition(position * motorRecResolution);
targetSet_ = true; targetSet_ = true;
status = startCombinedMoveFromVirtualAxis(); status = startCombinedMoveFromVirtualAxis();
targetSet_ = false; targetSet_ = false;
return status; return status;
} }
asynStatus seleneLiftAxis::targetPosition(double *targetPosition) { double seleneLiftAxis::targetPosition() {
asynStatus status = asynSuccess;
if (targetSet_) { if (targetSet_) {
*targetPosition = targetPosition_; return turboPmacAxis::targetPosition();
} else { } else {
status = motorPosition(targetPosition); double targetPos = 0;
motorPosition(&targetPos);
return targetPos;
} }
return status;
} }
asynStatus seleneLiftAxis::startCombinedMove() { asynStatus seleneLiftAxis::startCombinedMove() {
@ -500,26 +499,15 @@ asynStatus seleneLiftAxis::startCombinedMove() {
// ========================================================================= // =========================================================================
status = targetPosition(&liftTargetPosition); liftTargetPosition = targetPosition();
if (status != asynSuccess) { angleTargetPosition = angleAxis_->targetPosition();
return status;
}
status = angleAxis_->targetPosition(&angleTargetPosition);
if (status != asynSuccess) {
return status;
}
auto targetPositions = auto targetPositions =
positionsFromLiftAndAngle(liftTargetPosition, angleTargetPosition); positionsFromLiftAndAngle(liftTargetPosition, angleTargetPosition);
// Apply the offsets of the individual offset axes // Apply the offsets of the individual offset axes
for (int i = 0; i < numAxes_; i++) { for (int i = 0; i < numAxes_; i++) {
double offsetTargetPosition = 0.0; targetPositions[i] =
status = offsetAxes_[i]->targetPosition(&offsetTargetPosition); targetPositions[i] + offsetAxes_[i]->targetPosition();
if (status != asynSuccess) {
return status;
}
targetPositions[i] = targetPositions[i] + offsetTargetPosition;
} }
// Set all target positions and send the move command // Set all target positions and send the move command

View File

@ -256,13 +256,11 @@ class seleneLiftAxis : public turboPmacAxis {
bool virtualAxisMovement() { return virtualAxisMovement_; } bool virtualAxisMovement() { return virtualAxisMovement_; }
/** /**
* @brief Read the target position from the axis and write it into the * @brief Override of the superclass method
* provided pointer.
* *
* @param targetPosition * @return double
* @return asynStatus
*/ */
asynStatus targetPosition(double *targetPosition); double targetPosition();
/** /**
* @brief Access the position of the lift axis * @brief Access the position of the lift axis

View File

@ -151,15 +151,14 @@ asynStatus seleneOffsetAxis::init() {
return status; return status;
} }
asynStatus seleneOffsetAxis::targetPosition(double *targetPosition) { double seleneOffsetAxis::targetPosition() {
asynStatus status = asynSuccess;
if (targetSet_) { if (targetSet_) {
*targetPosition = targetPosition_; return turboPmacAxis::targetPosition();
} else { } else {
status = motorPosition(targetPosition); double targetPos = 0;
motorPosition(&targetPos);
return targetPos;
} }
return status;
} }
asynStatus seleneOffsetAxis::doPoll(bool *moving) { asynStatus seleneOffsetAxis::doPoll(bool *moving) {
@ -332,7 +331,7 @@ asynStatus seleneOffsetAxis::doMove(double position, int relative,
} }
// Set the target position // Set the target position
targetPosition_ = position * motorRecResolution; setTargetPosition(position * motorRecResolution);
targetSet_ = true; targetSet_ = true;
asynStatus status = liftAxis_->startCombinedMoveFromOffsetAxis(); asynStatus status = liftAxis_->startCombinedMoveFromOffsetAxis();
targetSet_ = false; targetSet_ = false;

View File

@ -81,13 +81,11 @@ class seleneOffsetAxis : public turboPmacAxis {
asynStatus setPositionsFromEncoderPosition(double encoderPosition); asynStatus setPositionsFromEncoderPosition(double encoderPosition);
/** /**
* @brief Read the target position from the axis and write it into the * @brief Override of the superclass method
* provided pointer.
* *
* @param targetPosition * @return double
* @return asynStatus
*/ */
asynStatus targetPosition(double *targetPosition); double targetPosition();
/** /**
* @brief Set the offsets of axis 3 and 4 to zero and recalculate all other * @brief Set the offsets of axis 3 and 4 to zero and recalculate all other