10 Commits
0.2.2 ... main

Author SHA1 Message Date
bc8561c299 Updated turboPmac version 2025-06-18 08:33:04 +02:00
cf6f836416 Updated turboPmac version 2025-06-17 16:51:08 +02:00
6e99b37ed2 Updated turboPmac version 2025-06-17 13:26:13 +02:00
f745af48fe Added destructor for detectorTowerController 2025-06-10 15:04:34 +02:00
0fd312b672 Updated dependency turboPmac to 1.1.1 2025-06-10 15:01:42 +02:00
c15e513b2e Updated turboPmac to 1.1.1 2025-06-10 15:00:33 +02:00
6f9b890374 Updated turboPmac to 1.1 2025-06-10 14:44:59 +02:00
fbbe8c4553 Updated turboPmac to 1.1 2025-06-10 14:22:15 +02:00
675819741b Updated turboPmac version 2025-06-10 13:57:57 +02:00
eb3826ec35 Stop or reset now also resets the deferred movement flags 2025-06-10 11:15:40 +02:00
9 changed files with 157 additions and 559 deletions

View File

@ -1,5 +1,7 @@
#include "detectorTowerAngleAxis.h" #include "detectorTowerAngleAxis.h"
#include "detectorTowerController.h" #include "detectorTowerController.h"
#include "detectorTowerLiftAxis.h"
#include "detectorTowerSupportAxis.h"
#include "turboPmacController.h" #include "turboPmacController.h"
#include <epicsExport.h> #include <epicsExport.h>
#include <errlog.h> #include <errlog.h>
@ -157,17 +159,8 @@ asynStatus detectorTowerAngleAxis::init() {
} }
// Initialize the motorStatusMoving flag // Initialize the motorStatusMoving flag
status = setIntegerParam(pC_->motorStatusMoving(), 0); setAxisParamChecked(this, motorStatusMoving, false);
if (status != asynSuccess) { setAxisParamChecked(this, changeStateRBV, positionState == 2);
return pC_->paramLibAccessFailed(status, "motorStatusMoving_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
status = setIntegerParam(pC_->changeStateRBV(), positionState == 2);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "changeStateRBV", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
return callParamCallbacks(); return callParamCallbacks();
} }
@ -181,15 +174,9 @@ asynStatus detectorTowerAngleAxis::poll(bool *moving) {
if (axisNo() < liftAxis()->axisNo() && axisNo() < supportAxis()->axisNo()) { if (axisNo() < liftAxis()->axisNo() && axisNo() < supportAxis()->axisNo()) {
status = pC_->pollDetectorAxes(moving, this, liftAxis(), supportAxis()); status = pC_->pollDetectorAxes(moving, this, liftAxis(), supportAxis());
} else { } else {
status = pC_->getIntegerParam(axisNo(), pC_->motorStatusMoving(), getAxisParamChecked(this, motorStatusMoving, moving);
(int *)moving);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorStatusMoving",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
} }
} setWasMoving(*moving);
wasMoving_ = *moving;
return status; return status;
} }
@ -206,17 +193,11 @@ asynStatus detectorTowerAngleAxis::doMove(double position, int relative,
double max_velocity, double max_velocity,
double acceleration) { double acceleration) {
double motorRecResolution = 0.0; double motorRecResolution = 0.0;
asynStatus plStatus = pC_->getDoubleParam( getAxisParamChecked(this, motorRecResolution, &motorRecResolution);
axisNo_, pC_->motorRecResolution(), &motorRecResolution);
if (plStatus != asynSuccess) {
return pC_->paramLibAccessFailed(plStatus, "motorRecResolution_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
// Signal to the deferredMovementCollectorLoop that a movement should be // Signal to the deferredMovementCollectorLoop that a movement should be
// started to the defined target position. // started to the defined target position.
targetPosition_ = position * motorRecResolution; setTargetPosition(position * motorRecResolution);
receivedTarget_ = true; receivedTarget_ = true;
return asynSuccess; return asynSuccess;
@ -225,10 +206,7 @@ asynStatus detectorTowerAngleAxis::doMove(double position, int relative,
asynStatus detectorTowerAngleAxis::startCombinedMove() { asynStatus detectorTowerAngleAxis::startCombinedMove() {
// Status of read-write-operations of ASCII commands to the controller // Status of read-write-operations of ASCII commands to the controller
asynStatus rwStatus = asynSuccess; asynStatus status = asynSuccess;
// Status of parameter library operations
asynStatus plStatus = asynSuccess;
char command[pC_->MAXBUF_] = {0}; char command[pC_->MAXBUF_] = {0};
char response[pC_->MAXBUF_] = {0}; char response[pC_->MAXBUF_] = {0};
@ -237,12 +215,7 @@ asynStatus detectorTowerAngleAxis::startCombinedMove() {
// ========================================================================= // =========================================================================
plStatus = getAxisParamChecked(this, positionStateRBV, &positionState);
pC_->getIntegerParam(axisNo_, pC_->positionStateRBV(), &positionState);
if (plStatus != asynSuccess) {
return pC_->paramLibAccessFailed(plStatus, "positionStateRBV_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// If the axis is in changer position, it must be moved into working // If the axis is in changer position, it must be moved into working
// position before any move can be started. // position before any move can be started.
@ -259,20 +232,9 @@ asynStatus detectorTowerAngleAxis::startCombinedMove() {
pC_->getMsgPrintControl().getSuffix()); pC_->getMsgPrintControl().getSuffix());
} }
if (isInChangerPos) { if (isInChangerPos) {
setAxisParamChecked(this, motorMessageText,
plStatus = setStringParam(pC_->motorMessageText(),
"Move the axis to working state first."); "Move the axis to working state first.");
if (plStatus != asynSuccess) { setAxisParamChecked(this, motorStatusProblem, true);
return pC_->paramLibAccessFailed(plStatus, "motorMessageText",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
plStatus = setIntegerParam(pC_->motorStatusProblem(), true);
if (plStatus != asynSuccess) {
return pC_->paramLibAccessFailed(plStatus, "motorStatusProblem_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
callParamCallbacks(); callParamCallbacks();
startingDeferredMovement_ = false; startingDeferredMovement_ = false;
@ -282,77 +244,64 @@ asynStatus detectorTowerAngleAxis::startCombinedMove() {
// Set the target positions for beam tilt, detector tilt offset and lift // Set the target positions for beam tilt, detector tilt offset and lift
// offset // offset
snprintf(command, sizeof(command), "Q451=%lf Q454=%lf P350=1", snprintf(command, sizeof(command), "Q451=%lf Q454=%lf P350=1",
targetPosition_, liftAxis_->targetPosition_); targetPosition(), liftAxis_->targetPosition());
// Lock the access to the controller since this function runs in another // Lock the access to the controller since this function runs in another
// thread than the poll method. // thread than the poll method.
pC_->lock(); pC_->lock();
// We don't expect an answer // We don't expect an answer
rwStatus = pC_->writeRead(axisNo_, command, response, 0); status = pC_->writeRead(axisNo_, command, response, 0);
// Free the controller again // Free the controller again
pC_->unlock(); pC_->unlock();
if (rwStatus != asynSuccess) { if (status != asynSuccess) {
asynPrint( asynPrint(
pC_->pasynUser(), ASYN_TRACE_ERROR, pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nStarting movement to " "Controller \"%s\", axis %d => %s, line %d\nStarting movement to "
"target position %lf failed.\n", "target position %lf failed.\n",
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
motorCoordinatesPosition); motorCoordinatesPosition);
plStatus = setIntegerParam(pC_->motorStatusProblem(), true); setAxisParamChecked(this, motorStatusProblem, true);
if (plStatus != asynSuccess) {
return pC_->paramLibAccessFailed(plStatus, "motorStatusProblem_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
callParamCallbacks(); callParamCallbacks();
} }
return rwStatus; return status;
} }
asynStatus detectorTowerAngleAxis::stop(double acceleration) { asynStatus detectorTowerAngleAxis::stop(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 rwStatus = asynSuccess; asynStatus status = asynSuccess;
// Status of parameter library operations
asynStatus plStatus = asynSuccess;
char response[pC_->MAXBUF_] = {0}; char response[pC_->MAXBUF_] = {0};
// ========================================================================= // =========================================================================
rwStatus = pC_->writeRead(axisNo_, "P350=8", response, 0); status = pC_->writeRead(axisNo_, "P350=8", response, 0);
if (rwStatus != asynSuccess) { if (status != asynSuccess) {
asynPrint( asynPrint(
pC_->pasynUser(), ASYN_TRACE_ERROR, pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nStopping the movement " "Controller \"%s\", axis %d => %s, line %d\nStopping the movement "
"failed.\n", "failed.\n",
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__); pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__);
plStatus = setIntegerParam(pC_->motorStatusProblem(), true); setAxisParamChecked(this, motorStatusProblem, true);
if (plStatus != asynSuccess) {
return pC_->paramLibAccessFailed(plStatus, "motorStatusProblem_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
return asynError; return asynError;
} }
return rwStatus; // Reset the deferred movement flags
startingDeferredMovement_ = false;
deferredMovementWait_ = false;
return status;
} }
// The detector tower axis uses absolute encoders // The detector tower axis uses absolute encoders
asynStatus detectorTowerAngleAxis::readEncoderType() { asynStatus detectorTowerAngleAxis::readEncoderType() {
asynStatus status = setStringParam(pC_->encoderType(), AbsoluteEncoder); setAxisParamChecked(this, encoderType, AbsoluteEncoder);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "encoderType_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
return asynSuccess; return asynSuccess;
} }
@ -362,27 +311,19 @@ detectorTowerAngleAxis::toggleWorkingChangerState(bool toChangingPosition) {
char response[pC_->MAXBUF_] = {0}; char response[pC_->MAXBUF_] = {0};
// Status of read-write-operations of ASCII commands to the controller // Status of read-write-operations of ASCII commands to the controller
asynStatus rwStatus = asynSuccess; asynStatus status = asynSuccess;
// Status of parameter library operations
asynStatus plStatus = asynSuccess;
bool moving = false; bool moving = false;
int positionState = 0; int positionState = 0;
// ========================================================================= // =========================================================================
rwStatus = poll(&moving); status = poll(&moving);
if (rwStatus != asynSuccess) { if (status != asynSuccess) {
return rwStatus; return status;
} }
plStatus = getAxisParamChecked(this, positionStateRBV, &positionState);
pC_->getIntegerParam(axisNo_, pC_->positionStateRBV(), &positionState);
if (plStatus != asynSuccess) {
return pC_->paramLibAccessFailed(plStatus, "positionStateRBV_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
if (moving) { if (moving) {
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
@ -392,21 +333,10 @@ detectorTowerAngleAxis::toggleWorkingChangerState(bool toChangingPosition) {
toChangingPosition ? "changer" : "working", toChangingPosition ? "changer" : "working",
pC_->getMsgPrintControl().getSuffix()); pC_->getMsgPrintControl().getSuffix());
plStatus = setStringParam( setAxisParamChecked(
pC_->motorMessageText(), this, motorMessageText,
"Axis cannot be moved to changer position while it is moving."); "Axis cannot be moved to changer position while it is moving.");
if (plStatus != asynSuccess) { setAxisParamChecked(this, changeStateRBV, !toChangingPosition);
return pC_->paramLibAccessFailed(plStatus, "motorMessageText_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
plStatus = setIntegerParam(pC_->changeStateRBV(), !toChangingPosition);
if (plStatus != asynSuccess) {
return pC_->paramLibAccessFailed(plStatus, "changeStateRBV",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
return asynError; return asynError;
} }
@ -424,39 +354,20 @@ detectorTowerAngleAxis::toggleWorkingChangerState(bool toChangingPosition) {
pC_->getMsgPrintControl().getSuffix()); pC_->getMsgPrintControl().getSuffix());
// Update the PV anyway, even though nothing changed. // Update the PV anyway, even though nothing changed.
plStatus = setIntegerParam(pC_->changeStateRBV(), toChangingPosition); setAxisParamChecked(this, changeStateRBV, toChangingPosition);
if (plStatus != asynSuccess) {
return pC_->paramLibAccessFailed(plStatus, "changeStateRBV",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
return asynSuccess; return asynSuccess;
} }
// Move the axis into changer or working position // Move the axis into changer or working position
if (toChangingPosition) { if (toChangingPosition) {
rwStatus = pC_->writeRead(axisNo_, "P350=2", response, 0); status = pC_->writeRead(axisNo_, "P350=2", response, 0);
} else { } else {
rwStatus = pC_->writeRead(axisNo_, "P350=3", response, 0); status = pC_->writeRead(axisNo_, "P350=3", response, 0);
} }
if (plStatus != asynSuccess) { setAxisParamChecked(this, changeStateRBV, toChangingPosition);
plStatus = setIntegerParam(pC_->changeStateRBV(), !toChangingPosition); return asynSuccess;
if (plStatus != asynSuccess) {
return pC_->paramLibAccessFailed(plStatus, "changeStateRBV",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
}
plStatus = setIntegerParam(pC_->changeStateRBV(), toChangingPosition);
if (plStatus != asynSuccess) {
return pC_->paramLibAccessFailed(plStatus, "changeStateRBV", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
return rwStatus;
} }
asynStatus detectorTowerAngleAxis::adjustOrigin(double newOrigin) { asynStatus detectorTowerAngleAxis::adjustOrigin(double newOrigin) {
@ -468,12 +379,7 @@ asynStatus detectorTowerAngleAxis::adjustOrigin(double newOrigin) {
// ========================================================================= // =========================================================================
status = getAxisParamChecked(this, positionStateRBV, &positionState);
pC_->getIntegerParam(axisNo_, pC_->positionStateRBV(), &positionState);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "positionStateRBV_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// If the axis is in changer position, it must be moved into working // If the axis is in changer position, it must be moved into working
// position before any move can be started. // position before any move can be started.
@ -502,12 +408,7 @@ asynStatus detectorTowerAngleAxis::adjustOrigin(double newOrigin) {
"angle origin %lf failed.\n", "angle origin %lf failed.\n",
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
newOrigin); newOrigin);
status = setIntegerParam(pC_->motorStatusProblem(), true); setAxisParamChecked(this, motorStatusProblem, true);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorStatusProblem_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
} }
return status; return status;
@ -516,15 +417,13 @@ asynStatus detectorTowerAngleAxis::adjustOrigin(double newOrigin) {
asynStatus detectorTowerAngleAxis::doReset() { asynStatus detectorTowerAngleAxis::doReset() {
char response[pC_->MAXBUF_] = {0}; char response[pC_->MAXBUF_] = {0};
asynStatus plStatus = asynSuccess;
int positionState = 0; int positionState = 0;
plStatus = getAxisParamChecked(this, positionStateRBV, &positionState);
pC_->getIntegerParam(axisNo_, pC_->positionStateRBV(), &positionState);
if (plStatus != asynSuccess) { // Reset the deferred movement flags
return pC_->paramLibAccessFailed(plStatus, "positionStateRBV_", axisNo_, startingDeferredMovement_ = false;
__PRETTY_FUNCTION__, __LINE__); deferredMovementWait_ = false;
}
/* /*
Check which action should be performed: Check which action should be performed:

View File

@ -1,14 +1,7 @@
#ifndef detectorTowerAngleAxis_H #ifndef detectorTowerAngleAxis_H
#define detectorTowerAngleAxis_H #define detectorTowerAngleAxis_H
#include "detectorTowerController.h"
#include "turboPmacAxis.h" #include "turboPmacAxis.h"
#include <errlog.h>
// Forward declaration of the controller class to resolve the cyclic dependency
// between the controller and the axis .h-file. See
// https://en.cppreference.com/w/cpp/language/class.
class detectorTowerController;
class detectorTowerLiftAxis;
class detectorTowerSupportAxis;
class detectorTowerAngleAxis : public turboPmacAxis { class detectorTowerAngleAxis : public turboPmacAxis {
public: public:
@ -164,6 +157,11 @@ class detectorTowerAngleAxis : public turboPmacAxis {
*/ */
int error_; int error_;
/**
* @brief Return a pointer to the axis controller
*/
virtual detectorTowerController *pController() override { return pC_; };
protected: protected:
detectorTowerController *pC_; detectorTowerController *pC_;
detectorTowerLiftAxis *liftAxis_; detectorTowerLiftAxis *liftAxis_;

View File

@ -1,6 +1,7 @@
#include "detectorTowerController.h" #include "detectorTowerController.h"
#include "detectorTowerAngleAxis.h" #include "detectorTowerAngleAxis.h"
#include "turboPmacController.h" #include "detectorTowerLiftAxis.h"
#include "detectorTowerSupportAxis.h"
#include <epicsExport.h> #include <epicsExport.h>
#include <errlog.h> #include <errlog.h>
#include <iocsh.h> #include <iocsh.h>
@ -106,11 +107,13 @@ detectorTowerController::detectorTowerController(
} }
} }
detectorTowerController::~detectorTowerController() {}
asynStatus detectorTowerController::readInt32(asynUser *pasynUser, asynStatus detectorTowerController::readInt32(asynUser *pasynUser,
epicsInt32 *value) { epicsInt32 *value) {
// The detector axes cannot be disabled // The detector axes cannot be disabled
if (pasynUser->reason == motorCanDisable_) { if (pasynUser->reason == motorCanDisable()) {
detectorTowerAngleAxis *aAxis = getDetectorTowerAngleAxis(pasynUser); detectorTowerAngleAxis *aAxis = getDetectorTowerAngleAxis(pasynUser);
if (aAxis != nullptr) { if (aAxis != nullptr) {
*value = 0; *value = 0;
@ -284,7 +287,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
int error = 0; int error = 0;
int positionState = 0; int positionState = 0;
int inPosition = 0; int notInPosition = 0;
double angle = 0.0; double angle = 0.0;
double prevAngle = 0.0; double prevAngle = 0.0;
@ -334,37 +337,13 @@ asynStatus detectorTowerController::pollDetectorAxes(
The motorStatusProblem_ field changes the motor record fields SEVR and STAT. The motorStatusProblem_ field changes the motor record fields SEVR and STAT.
*/ */
plStatus = angleAxis->setIntegerParam(motorStatusProblem(), false); setAxisParamChecked(angleAxis, motorStatusProblem, false);
if (plStatus != asynSuccess) { setAxisParamChecked(liftAxis, motorStatusProblem, false);
paramLibAccessFailed(plStatus, "motorStatusProblem_", angleAxisNo, setAxisParamChecked(supportAxis, motorStatusProblem, false);
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = liftAxis->setIntegerParam(motorStatusProblem(), false);
if (plStatus != asynSuccess) {
paramLibAccessFailed(plStatus, "motorStatusProblem_", liftAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = supportAxis->setIntegerParam(motorStatusProblem(), false);
if (plStatus != asynSuccess) {
paramLibAccessFailed(plStatus, "motorStatusProblem_", supportAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = angleAxis->setIntegerParam(motorStatusCommsError(), false); setAxisParamChecked(angleAxis, motorStatusCommsError, false);
if (plStatus != asynSuccess) { setAxisParamChecked(liftAxis, motorStatusCommsError, false);
paramLibAccessFailed(plStatus, "motorStatusCommsError_", angleAxisNo, setAxisParamChecked(supportAxis, motorStatusCommsError, false);
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = liftAxis->setIntegerParam(motorStatusCommsError(), false);
if (plStatus != asynSuccess) {
paramLibAccessFailed(plStatus, "motorStatusCommsError_", liftAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = supportAxis->setIntegerParam(motorStatusCommsError(), false);
if (plStatus != asynSuccess) {
paramLibAccessFailed(plStatus, "motorStatusCommsError_", supportAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
// Read the previous motor positions // Read the previous motor positions
plStatus = angleAxis->motorPosition(&prevAngle); plStatus = angleAxis->motorPosition(&prevAngle);
@ -401,7 +380,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
nvals = nvals =
sscanf(response, sscanf(response,
"%d %d %d %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", "%d %d %d %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",
&inPosition, &positionState, &error, &angle, &angleHighLimit, &notInPosition, &positionState, &error, &angle, &angleHighLimit,
&angleLowLimit, &angleOrigin, &angleAdjustOriginHighLimit, &angleLowLimit, &angleOrigin, &angleAdjustOriginHighLimit,
&angleAdjustOriginLowLimit, &lift, &liftHighLimit, &liftLowLimit, &angleAdjustOriginLowLimit, &lift, &liftHighLimit, &liftLowLimit,
&liftOrigin, &liftAdjustOriginHighLimit, &liftOrigin, &liftAdjustOriginHighLimit,
@ -425,20 +404,12 @@ asynStatus detectorTowerController::pollDetectorAxes(
*/ */
// Angle // Angle
plStatus = getDoubleParam(angleAxisNo, motorLimitsOffset(), &limitsOffset); getAxisParamChecked(angleAxis, motorLimitsOffset, &limitsOffset);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorLimitsOffset_", angleAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
angleHighLimit = angleHighLimit - limitsOffset; angleHighLimit = angleHighLimit - limitsOffset;
angleLowLimit = angleLowLimit + limitsOffset; angleLowLimit = angleLowLimit + limitsOffset;
// Lift // Lift
plStatus = getDoubleParam(liftAxisNo, motorLimitsOffset(), &limitsOffset); getAxisParamChecked(liftAxis, motorLimitsOffset, &limitsOffset);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorLimitsOffset_", liftAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
liftHighLimit = liftHighLimit - limitsOffset; liftHighLimit = liftHighLimit - limitsOffset;
liftLowLimit = liftLowLimit + limitsOffset; liftLowLimit = liftLowLimit + limitsOffset;
@ -446,7 +417,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
angleAxis->error_ = error; angleAxis->error_ = error;
// Check if the tower is moving // Check if the tower is moving
if (inPosition == 1 || positionState > 2) { if (notInPosition == 1 || positionState > 2) {
// By now, the controller has actually started the movement // By now, the controller has actually started the movement
angleAxis->startingDeferredMovement_ = false; angleAxis->startingDeferredMovement_ = false;
*moving = true; *moving = true;
@ -810,258 +781,84 @@ asynStatus detectorTowerController::pollDetectorAxes(
Does the paramLib already contain an error message? If either this is the Does the paramLib already contain an error message? If either this is the
case or if error != 0, report a status problem for all axes. case or if error != 0, report a status problem for all axes.
*/ */
getStringParam(angleAxisNo, motorMessageText(), sizeof(waitingErrorMessage), getAxisParamChecked(angleAxis, motorMessageText, &waitingErrorMessage);
waitingErrorMessage);
if (error != 0 || errorMessage[0] != '\0' || if (error != 0 || errorMessage[0] != '\0' ||
waitingErrorMessage[0] != '\0') { waitingErrorMessage[0] != '\0') {
plStatus = angleAxis->setIntegerParam(motorStatusProblem(), true); setAxisParamChecked(angleAxis, motorStatusProblem, true);
if (plStatus != asynSuccess) { setAxisParamChecked(liftAxis, motorStatusProblem, true);
return paramLibAccessFailed(plStatus, "motorStatusProblem_", setAxisParamChecked(supportAxis, motorStatusProblem, true);
angleAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
plStatus = liftAxis->setIntegerParam(motorStatusProblem(), true);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorStatusProblem_",
liftAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
plStatus = supportAxis->setIntegerParam(motorStatusProblem(), true);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorStatusProblem_",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
} }
// Update the error message text with the one created in this poll (in case // Update the error message text with the one created in this poll (in case
// it is not empty). // it is not empty).
if (errorMessage[0] != '\0') { if (errorMessage[0] != '\0') {
plStatus = angleAxis->setStringParam(motorMessageText(), errorMessage); setAxisParamChecked(angleAxis, motorMessageText, errorMessage);
if (plStatus != asynSuccess) { setAxisParamChecked(liftAxis, motorMessageText, errorMessage);
return paramLibAccessFailed(plStatus, "motorMessageText_", setAxisParamChecked(supportAxis, motorMessageText, errorMessage);
angleAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
plStatus = liftAxis->setStringParam(motorMessageText(), errorMessage);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorMessageText_",
liftAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
plStatus =
supportAxis->setStringParam(motorMessageText(), errorMessage);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorMessageText_",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
} }
// Update the working position state PV // Update the working position state PV
plStatus = angleAxis->setIntegerParam(positionStateRBV(), positionState); setAxisParamChecked(angleAxis, positionStateRBV, positionState);
if (plStatus != asynSuccess) { setAxisParamChecked(liftAxis, positionStateRBV, positionState);
return paramLibAccessFailed(plStatus, "positionStateRBV_", angleAxisNo, setAxisParamChecked(supportAxis, positionStateRBV, positionState);
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = liftAxis->setIntegerParam(positionStateRBV(), positionState);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "positionStateRBV_", liftAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = supportAxis->setIntegerParam(positionStateRBV(), positionState);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "positionStateRBV_",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
// The axes are always enabled // The axes are always enabled
plStatus = angleAxis->setIntegerParam(motorEnableRBV(), 1); setAxisParamChecked(angleAxis, motorEnableRBV, true);
if (plStatus != asynSuccess) { setAxisParamChecked(liftAxis, motorEnableRBV, true);
return paramLibAccessFailed(plStatus, "motorEnableRBV_", angleAxisNo, setAxisParamChecked(supportAxis, motorEnableRBV, true);
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = liftAxis->setIntegerParam(motorEnableRBV(), 1);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorEnableRBV_", liftAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = supportAxis->setIntegerParam(motorEnableRBV(), 1);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorEnableRBV_", supportAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
// Are the axes currently moving? // Are the axes currently moving?
plStatus = angleAxis->setIntegerParam(motorStatusMoving(), *moving); setAxisParamChecked(angleAxis, motorStatusMoving, *moving);
if (plStatus != asynSuccess) { setAxisParamChecked(liftAxis, motorStatusMoving, *moving);
return paramLibAccessFailed(plStatus, "motorStatusMoving_", angleAxisNo, setAxisParamChecked(supportAxis, motorStatusMoving, *moving);
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = liftAxis->setIntegerParam(motorStatusMoving(), *moving);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorStatusMoving_", liftAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = supportAxis->setIntegerParam(motorStatusMoving(), *moving);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorStatusMoving_",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
// Is the axis movement done? // Is the axis movement done?
plStatus = angleAxis->setIntegerParam(motorStatusDone(), !(*moving)); setAxisParamChecked(angleAxis, motorStatusDone, !(*moving));
if (plStatus != asynSuccess) { setAxisParamChecked(liftAxis, motorStatusDone, !(*moving));
return paramLibAccessFailed(plStatus, "motorStatusDone_", angleAxisNo, setAxisParamChecked(supportAxis, motorStatusDone, !(*moving));
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = liftAxis->setIntegerParam(motorStatusDone(), !(*moving));
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorStatusDone_", liftAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = supportAxis->setIntegerParam(motorStatusDone(), !(*moving));
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorStatusDone_", supportAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
// In which direction are the axes currently moving? // In which direction are the axes currently moving?
plStatus = angleAxis->setIntegerParam(motorStatusDirection(), angleDir); setAxisParamChecked(angleAxis, motorStatusDirection, angleDir);
if (plStatus != asynSuccess) { setAxisParamChecked(liftAxis, motorStatusDirection, liftDir);
return paramLibAccessFailed(plStatus, "motorStatusDirection_",
angleAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
plStatus = liftAxis->setIntegerParam(motorStatusDirection(), liftDir);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorStatusDirection_",
liftAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
// Using the lift direction for the support axis is done on purpose! // Using the lift direction for the support axis is done on purpose!
plStatus = supportAxis->setIntegerParam(motorStatusDirection(), liftDir); setAxisParamChecked(supportAxis, motorStatusDirection, liftDir);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorStatusDirection_",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
// High limits from hardware // High limits from hardware
plStatus = setAxisParamChecked(angleAxis, motorHighLimitFromDriver, angleHighLimit);
setDoubleParam(angleAxisNo, motorHighLimitFromDriver(), angleHighLimit); setAxisParamChecked(liftAxis, motorHighLimitFromDriver, liftHighLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorHighLimitFromDriver",
angleAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
plStatus =
setDoubleParam(liftAxisNo, motorHighLimitFromDriver(), liftHighLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorHighLimitFromDriver",
liftAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
// Using the lift high limit for the support axis is done on purpose! // Using the lift high limit for the support axis is done on purpose!
plStatus = setDoubleParam(supportAxisNo, motorHighLimitFromDriver(), setAxisParamChecked(supportAxis, motorHighLimitFromDriver, liftHighLimit);
liftHighLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorHighLimitFromDriver",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
// Low limits from hardware // Low limits from hardware
plStatus = setAxisParamChecked(angleAxis, motorLowLimitFromDriver, angleLowLimit);
setDoubleParam(angleAxisNo, motorLowLimitFromDriver(), angleLowLimit); setAxisParamChecked(liftAxis, motorLowLimitFromDriver, liftLowLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorLowLimitFromDriver",
angleAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
plStatus =
setDoubleParam(liftAxisNo, motorLowLimitFromDriver(), liftLowLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorLowLimitFromDriver",
liftAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
// Using the lift low limit for the support axis is done on purpose! // Using the lift low limit for the support axis is done on purpose!
plStatus = setAxisParamChecked(supportAxis, motorLowLimitFromDriver, liftLowLimit);
setDoubleParam(supportAxisNo, motorLowLimitFromDriver(), liftLowLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorLowLimitFromDriver",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
// Write the motor origin // Write the motor origin
plStatus = setDoubleParam(angleAxisNo, motorOrigin(), angleOrigin); setAxisParamChecked(angleAxis, motorOrigin, angleOrigin);
if (plStatus != asynSuccess) { setAxisParamChecked(liftAxis, motorOrigin, liftOrigin);
return paramLibAccessFailed(plStatus, "motorOrigin", angleAxisNo, setAxisParamChecked(supportAxis, motorOrigin, supportOrigin);
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = setDoubleParam(liftAxisNo, motorOrigin(), liftOrigin);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorOrigin", liftAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = setDoubleParam(supportAxisNo, motorOrigin(), supportOrigin);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "supportOrigin", supportAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
// Origin adjustment high limit // Origin adjustment high limit
plStatus = setAxisParamChecked(angleAxis, motorAdjustOriginHighLimitFromDriver,
setDoubleParam(angleAxisNo, motorAdjustOriginHighLimitFromDriver(),
angleAdjustOriginHighLimit); angleAdjustOriginHighLimit);
if (plStatus != asynSuccess) { setAxisParamChecked(liftAxis, motorAdjustOriginHighLimitFromDriver,
return paramLibAccessFailed(plStatus, "motorOriginHighLimitFromDriver",
angleAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
plStatus =
setDoubleParam(liftAxisNo, motorAdjustOriginHighLimitFromDriver(),
liftAdjustOriginHighLimit); liftAdjustOriginHighLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorOriginHighLimitFromDriver",
liftAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
// Using the lift high limit for the support axis is done on purpose! // Using the lift high limit for the support axis is done on purpose!
plStatus = setAxisParamChecked(supportAxis, motorAdjustOriginHighLimitFromDriver,
setDoubleParam(supportAxisNo, motorAdjustOriginHighLimitFromDriver(),
liftAdjustOriginHighLimit); liftAdjustOriginHighLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorOriginHighLimitFromDriver",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
// Origin adjustment low limit // Origin adjustment low limit
plStatus = setAxisParamChecked(angleAxis, motorAdjustOriginLowLimitFromDriver,
setDoubleParam(angleAxisNo, motorAdjustOriginLowLimitFromDriver(),
angleAdjustOriginLowLimit); angleAdjustOriginLowLimit);
if (plStatus != asynSuccess) { setAxisParamChecked(liftAxis, motorAdjustOriginLowLimitFromDriver,
return paramLibAccessFailed(plStatus,
"motorAdjustOriginLowLimitFromDriver",
angleAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
plStatus = setDoubleParam(liftAxisNo, motorAdjustOriginLowLimitFromDriver(),
liftAdjustOriginLowLimit); liftAdjustOriginLowLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus,
"motorAdjustOriginLowLimitFromDriver",
liftAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
// Using the lift low limit for the support axis is done on purpose! // Using the lift low limit for the support axis is done on purpose!
plStatus = setAxisParamChecked(supportAxis, motorAdjustOriginLowLimitFromDriver,
setDoubleParam(supportAxisNo, motorAdjustOriginLowLimitFromDriver(),
liftAdjustOriginLowLimit); liftAdjustOriginLowLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(
plStatus, "motorAdjustOriginLowLimitFromDriver", supportAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
// Axes positions // Axes positions
plStatus = angleAxis->setMotorPosition(angle); plStatus = angleAxis->setMotorPosition(angle);
@ -1135,22 +932,9 @@ asynStatus detectorTowerController::pollDetectorAxes(
one poll cycle, but are cleared afterwards. Persisting error messages will one poll cycle, but are cleared afterwards. Persisting error messages will
be recreated during each poll. be recreated during each poll.
*/ */
plStatus = angleAxis->setStringParam(motorMessageText(), ""); setAxisParamChecked(angleAxis, motorMessageText, "");
if (plStatus != asynSuccess) { setAxisParamChecked(liftAxis, motorMessageText, "");
return paramLibAccessFailed(plStatus, "motorMessageText_", angleAxisNo, setAxisParamChecked(supportAxis, motorMessageText, "");
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = liftAxis->setStringParam(motorMessageText(), "");
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorMessageText_", liftAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = supportAxis->setStringParam(motorMessageText(), "");
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorMessageText_",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
return pollStatus; return pollStatus;
} }

View File

@ -8,11 +8,15 @@
#ifndef detectorTowerController_H #ifndef detectorTowerController_H
#define detectorTowerController_H #define detectorTowerController_H
#include "detectorTowerAngleAxis.h"
#include "detectorTowerLiftAxis.h"
#include "detectorTowerSupportAxis.h"
#include "turboPmacController.h" #include "turboPmacController.h"
// Forward declaration of the axis classes to resolve the cyclic dependency
// between the controller and the axis .h-file. See
// https://en.cppreference.com/w/cpp/language/class.
class detectorTowerAngleAxis;
class detectorTowerLiftAxis;
class detectorTowerSupportAxis;
class detectorTowerController : public turboPmacController { class detectorTowerController : public turboPmacController {
public: public:
@ -35,6 +39,8 @@ class detectorTowerController : public turboPmacController {
int numAxes, double movingPollPeriod, int numAxes, double movingPollPeriod,
double idlePollPeriod, double comTimeout); double idlePollPeriod, double comTimeout);
virtual ~detectorTowerController();
/** /**
* @brief Overloaded function of turboPmacController * @brief Overloaded function of turboPmacController
* *

View File

@ -1,6 +1,7 @@
#include "detectorTowerLiftAxis.h" #include "detectorTowerLiftAxis.h"
#include "detectorTowerAngleAxis.h" #include "detectorTowerAngleAxis.h"
#include "detectorTowerController.h" #include "detectorTowerController.h"
#include "detectorTowerSupportAxis.h"
#include "turboPmacController.h" #include "turboPmacController.h"
#include <epicsExport.h> #include <epicsExport.h>
#include <errlog.h> #include <errlog.h>
@ -111,11 +112,7 @@ asynStatus detectorTowerLiftAxis::init() {
} }
// Initialize the motorStatusMoving flag // Initialize the motorStatusMoving flag
status = setIntegerParam(pC_->motorStatusMoving(), 0); setAxisParamChecked(this, motorStatusMoving, false);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorStatusMoving_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// Check if we are currently in the changer position and update the PV // Check if we are currently in the changer position and update the PV
// accordingly // accordingly
@ -126,11 +123,7 @@ asynStatus detectorTowerLiftAxis::init() {
__PRETTY_FUNCTION__, __LINE__); __PRETTY_FUNCTION__, __LINE__);
} }
status = setIntegerParam(pC_->changeStateRBV(), positionState == 2); setAxisParamChecked(this, changeStateRBV, positionState == 2);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "changeStateRBV", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
return callParamCallbacks(); return callParamCallbacks();
} }
@ -146,15 +139,9 @@ asynStatus detectorTowerLiftAxis::poll(bool *moving) {
status = pC_->pollDetectorAxes(moving, angleAxis(), this, status = pC_->pollDetectorAxes(moving, angleAxis(), this,
angleAxis()->supportAxis()); angleAxis()->supportAxis());
} else { } else {
status = pC_->getIntegerParam(axisNo(), pC_->motorStatusMoving(), getAxisParamChecked(this, motorStatusMoving, moving);
(int *)moving);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorStatusMoving",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
} }
} setWasMoving(*moving);
wasMoving_ = *moving;
return status; return status;
} }
@ -172,18 +159,12 @@ asynStatus detectorTowerLiftAxis::doMove(double position, int relative,
double acceleration) { double acceleration) {
double motorRecResolution = 0.0; double motorRecResolution = 0.0;
asynStatus plStatus = pC_->getDoubleParam( getAxisParamChecked(this, motorRecResolution, &motorRecResolution);
axisNo_, pC_->motorRecResolution(), &motorRecResolution);
if (plStatus != asynSuccess) {
return pC_->paramLibAccessFailed(plStatus, "motorRecResolution_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
// Signal to the deferredMovementCollectorLoop (of the // Signal to the deferredMovementCollectorLoop (of the
// detectorTowerAngleAxis) that a movement should be started to the // detectorTowerAngleAxis) that a movement should be started to the
// defined target position. // defined target position.
targetPosition_ = position * motorRecResolution; setTargetPosition(position * motorRecResolution);
angleAxis_->receivedTarget_ = true; angleAxis_->receivedTarget_ = true;
return asynSuccess; return asynSuccess;
@ -192,37 +173,8 @@ asynStatus detectorTowerLiftAxis::doMove(double position, int relative,
asynStatus detectorTowerLiftAxis::reset() { return angleAxis()->reset(); }; asynStatus detectorTowerLiftAxis::reset() { return angleAxis()->reset(); };
asynStatus detectorTowerLiftAxis::stop(double acceleration) { asynStatus detectorTowerLiftAxis::stop(double acceleration) {
return angleAxis()->stop(acceleration);
// Status of read-write-operations of ASCII commands to the controller };
asynStatus rwStatus = asynSuccess;
// Status of parameter library operations
asynStatus plStatus = asynSuccess;
char response[pC_->MAXBUF_] = {0};
// =========================================================================
rwStatus = pC_->writeRead(axisNo_, "P350=8", response, 0);
if (rwStatus != asynSuccess) {
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nStopping "
"the movement "
"failed.\n",
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__);
plStatus = setIntegerParam(pC_->motorStatusProblem(), true);
if (plStatus != asynSuccess) {
return pC_->paramLibAccessFailed(plStatus, "motorStatusProblem_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
return asynError;
}
return rwStatus;
}
asynStatus detectorTowerLiftAxis::readEncoderType() { asynStatus detectorTowerLiftAxis::readEncoderType() {
return angleAxis()->readEncoderType(); return angleAxis()->readEncoderType();
@ -237,12 +189,7 @@ asynStatus detectorTowerLiftAxis::adjustOrigin(double newOrigin) {
// ========================================================================= // =========================================================================
status = getAxisParamChecked(this, positionStateRBV, &positionState);
pC_->getIntegerParam(axisNo_, pC_->positionStateRBV(), &positionState);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "positionStateRBV_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// If the axis is in changer position, it must be moved into working // If the axis is in changer position, it must be moved into working
// position before any move can be started. // position before any move can be started.
@ -271,12 +218,7 @@ asynStatus detectorTowerLiftAxis::adjustOrigin(double newOrigin) {
"lift origin %lf failed.\n", "lift origin %lf failed.\n",
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
newOrigin); newOrigin);
status = setIntegerParam(pC_->motorStatusProblem(), true); setAxisParamChecked(this, motorStatusProblem, true);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorStatusProblem_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
} }
return status; return status;

View File

@ -1,13 +1,8 @@
#ifndef detectorTowerLiftAxis_H #ifndef detectorTowerLiftAxis_H
#define detectorTowerLiftAxis_H #define detectorTowerLiftAxis_H
#include "detectorTowerController.h"
#include "turboPmacAxis.h" #include "turboPmacAxis.h"
// Forward declaration of the controller class to resolve the cyclic dependency
// between the controller and the axis .h-file. See
// https://en.cppreference.com/w/cpp/language/class.
class detectorTowerController;
class detectorTowerAngleAxis;
class detectorTowerLiftAxis : public turboPmacAxis { class detectorTowerLiftAxis : public turboPmacAxis {
public: public:
/** /**
@ -19,10 +14,6 @@ class detectorTowerLiftAxis : public turboPmacAxis {
detectorTowerLiftAxis(detectorTowerController *pController, int axisNo, detectorTowerLiftAxis(detectorTowerController *pController, int axisNo,
detectorTowerAngleAxis *angleAxis); detectorTowerAngleAxis *angleAxis);
/**
* @brief Destroy the turboPmacAxis
*
*/
virtual ~detectorTowerLiftAxis(); virtual ~detectorTowerLiftAxis();
/** /**
@ -114,6 +105,11 @@ class detectorTowerLiftAxis : public turboPmacAxis {
*/ */
asynStatus readEncoderType(); asynStatus readEncoderType();
/**
* @brief Return a pointer to the axis controller
*/
virtual detectorTowerController *pController() override { return pC_; };
protected: protected:
detectorTowerController *pC_; detectorTowerController *pC_;
detectorTowerAngleAxis *angleAxis_; detectorTowerAngleAxis *angleAxis_;

View File

@ -1,6 +1,7 @@
#include "detectorTowerSupportAxis.h" #include "detectorTowerSupportAxis.h"
#include "detectorTowerAngleAxis.h" #include "detectorTowerAngleAxis.h"
#include "detectorTowerController.h" #include "detectorTowerController.h"
#include "detectorTowerLiftAxis.h"
#include "turboPmacController.h" #include "turboPmacController.h"
#include <epicsExport.h> #include <epicsExport.h>
#include <errlog.h> #include <errlog.h>
@ -111,11 +112,7 @@ asynStatus detectorTowerSupportAxis::init() {
} }
// Initialize the motorStatusMoving flag // Initialize the motorStatusMoving flag
status = setIntegerParam(pC_->motorStatusMoving(), 0); setAxisParamChecked(this, motorStatusMoving, false);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorStatusMoving_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// Check if we are currently in the changer position and update the PV // Check if we are currently in the changer position and update the PV
// accordingly // accordingly
@ -126,12 +123,7 @@ asynStatus detectorTowerSupportAxis::init() {
__PRETTY_FUNCTION__, __LINE__); __PRETTY_FUNCTION__, __LINE__);
} }
status = setIntegerParam(pC_->changeStateRBV(), positionState == 2); setAxisParamChecked(this, changeStateRBV, positionState == 2);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "changeStateRBV", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
return callParamCallbacks(); return callParamCallbacks();
} }
@ -147,15 +139,9 @@ asynStatus detectorTowerSupportAxis::poll(bool *moving) {
status = pC_->pollDetectorAxes(moving, angleAxis(), status = pC_->pollDetectorAxes(moving, angleAxis(),
angleAxis()->liftAxis(), this); angleAxis()->liftAxis(), this);
} else { } else {
status = pC_->getIntegerParam(axisNo(), pC_->motorStatusMoving(), getAxisParamChecked(this, motorStatusMoving, moving);
(int *)moving);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorStatusMoving",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
} }
} setWasMoving(*moving);
wasMoving_ = *moving;
return status; return status;
} }
@ -186,12 +172,7 @@ asynStatus detectorTowerSupportAxis::adjustOrigin(double newOrigin) {
// ========================================================================= // =========================================================================
status = getAxisParamChecked(this, positionStateRBV, &positionState);
pC_->getIntegerParam(axisNo_, pC_->positionStateRBV(), &positionState);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "positionStateRBV_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// If the axis is in changer position, it must be moved into working // If the axis is in changer position, it must be moved into working
// position before any move can be started. // position before any move can be started.
@ -220,12 +201,8 @@ asynStatus detectorTowerSupportAxis::adjustOrigin(double newOrigin) {
"lift origin %lf failed.\n", "lift origin %lf failed.\n",
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
newOrigin); newOrigin);
status = setIntegerParam(pC_->motorStatusProblem(), true);
if (status != asynSuccess) { setAxisParamChecked(this, motorStatusProblem, true);
return pC_->paramLibAccessFailed(status, "motorStatusProblem_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
} }
return status; return status;

View File

@ -1,13 +1,8 @@
#ifndef detectorTowerSupportAxis_H #ifndef detectorTowerSupportAxis_H
#define detectorTowerSupportAxis_H #define detectorTowerSupportAxis_H
#include "detectorTowerController.h"
#include "turboPmacAxis.h" #include "turboPmacAxis.h"
// Forward declaration of the controller class to resolve the cyclic dependency
// between the controller and the axis .h-file. See
// https://en.cppreference.com/w/cpp/language/class.
class detectorTowerController;
class detectorTowerAngleAxis;
/** /**
* @brief Passive axis which is mostly controlled indirectly by the hardware * @brief Passive axis which is mostly controlled indirectly by the hardware
* *
@ -24,10 +19,6 @@ class detectorTowerSupportAxis : public turboPmacAxis {
detectorTowerSupportAxis(detectorTowerController *pController, int axisNo, detectorTowerSupportAxis(detectorTowerController *pController, int axisNo,
detectorTowerAngleAxis *angleAxis); detectorTowerAngleAxis *angleAxis);
/**
* @brief Destroy the detectorTowerSupportAxis
*
*/
virtual ~detectorTowerSupportAxis(); virtual ~detectorTowerSupportAxis();
/** /**
@ -116,6 +107,11 @@ class detectorTowerSupportAxis : public turboPmacAxis {
*/ */
asynStatus readEncoderType(); asynStatus readEncoderType();
/**
* @brief Return a pointer to the axis controller
*/
virtual detectorTowerController *pController() override { return pC_; };
protected: protected:
detectorTowerController *pC_; detectorTowerController *pC_;
detectorTowerAngleAxis *angleAxis_; detectorTowerAngleAxis *angleAxis_;