Updated turboPmac dependency to 0.15.1

This commit is contained in:
2025-05-14 16:39:16 +02:00
parent 60960dde44
commit 203bb9475f
11 changed files with 757 additions and 286 deletions
+215 -100
View File
@@ -104,43 +104,26 @@ detectorTowerController::detectorTowerController(
stringifyAsynStatus(status));
exit(-1);
}
status =
createParam("SUPPORT_ORIGIN", asynParamFloat64, &liftSupportOrigin_);
if (status != asynSuccess) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"Controller \"%s\" => %s, line %d\nFATAL ERROR (creating a "
"parameter failed with %s).\nTerminating IOC",
portName, __PRETTY_FUNCTION__, __LINE__,
stringifyAsynStatus(status));
exit(-1);
}
status = createParam("SUPPORT_ADJUST_ORIGIN", asynParamFloat64,
&liftSupportAdjustOrigin_);
if (status != asynSuccess) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"Controller \"%s\" => %s, line %d\nFATAL ERROR (creating a "
"parameter failed with %s).\nTerminating IOC",
portName, __PRETTY_FUNCTION__, __LINE__,
stringifyAsynStatus(status));
exit(-1);
}
}
asynStatus detectorTowerController::readInt32(asynUser *pasynUser,
epicsInt32 *value) {
// The detector tower or its auxiliary axes cannot be disabled
// The detector axes cannot be disabled
if (pasynUser->reason == motorCanDisable_) {
detectorTowerAngleAxis *angleAxis =
getDetectorTowerAngleAxis(pasynUser);
if (angleAxis != nullptr) {
detectorTowerAngleAxis *aAxis = getDetectorTowerAngleAxis(pasynUser);
if (aAxis != nullptr) {
*value = 0;
return asynSuccess;
}
detectorTowerLiftAxis *liftAxis = getDetectorTowerLiftAxis(pasynUser);
if (liftAxis != nullptr) {
detectorTowerLiftAxis *lAxis = getDetectorTowerLiftAxis(pasynUser);
if (lAxis != nullptr) {
*value = 0;
return asynSuccess;
}
detectorTowerSupportAxis *sAxis =
getDetectorTowerSupportAxis(pasynUser);
if (sAxis != nullptr) {
*value = 0;
return asynSuccess;
}
@@ -151,17 +134,19 @@ asynStatus detectorTowerController::readInt32(asynUser *pasynUser,
asynStatus detectorTowerController::writeInt32(asynUser *pasynUser,
epicsInt32 value) {
// =====================================================================
if (pasynUser->reason == changeState_) {
detectorTowerAngleAxis *angleAxis =
getDetectorTowerAngleAxis(pasynUser);
if (angleAxis != nullptr) {
return angleAxis->toggleWorkingChangerState(value);
detectorTowerAngleAxis *aAxis = getDetectorTowerAngleAxis(pasynUser);
if (aAxis != nullptr) {
return aAxis->toggleWorkingChangerState(value);
}
detectorTowerLiftAxis *liftAxis = getDetectorTowerLiftAxis(pasynUser);
if (liftAxis != nullptr) {
return liftAxis->angleAxis()->toggleWorkingChangerState(value);
detectorTowerLiftAxis *lAxis = getDetectorTowerLiftAxis(pasynUser);
if (lAxis != nullptr) {
return lAxis->angleAxis()->toggleWorkingChangerState(value);
}
detectorTowerSupportAxis *sAxis =
getDetectorTowerSupportAxis(pasynUser);
if (sAxis != nullptr) {
return sAxis->angleAxis()->toggleWorkingChangerState(value);
}
}
return turboPmacController::writeInt32(pasynUser, value);
@@ -176,7 +161,7 @@ asynStatus detectorTowerController::writeFloat64(asynUser *pasynUser,
if (function == motorAdjustOrigin_) {
// Is this function called by an asynUser of the angle or lift axis?
// Is this function called by a detector axis?
detectorTowerAngleAxis *aAxis = getDetectorTowerAngleAxis(pasynUser);
if (aAxis != nullptr) {
status = aAxis->adjustOrigin(value);
@@ -184,26 +169,27 @@ asynStatus detectorTowerController::writeFloat64(asynUser *pasynUser,
return status;
}
return turboPmacController::writeFloat64(pasynUser, value);
} else {
detectorTowerLiftAxis *lAxis = getDetectorTowerLiftAxis(pasynUser);
if (lAxis != nullptr) {
status = lAxis->adjustOrigin(value);
if (status != asynSuccess) {
return status;
}
return turboPmacController::writeFloat64(pasynUser, value);
}
}
return asynSuccess;
} else if (function == liftSupportAdjustOrigin_) {
detectorTowerLiftAxis *lAxis = getDetectorTowerLiftAxis(pasynUser);
if (lAxis != nullptr) {
status = lAxis->adjustSupportOrigin(value);
status = lAxis->adjustOrigin(value);
if (status != asynSuccess) {
return status;
}
return turboPmacController::writeFloat64(pasynUser, value);
}
detectorTowerSupportAxis *sAxis =
getDetectorTowerSupportAxis(pasynUser);
if (sAxis != nullptr) {
status = sAxis->adjustOrigin(value);
if (status != asynSuccess) {
return status;
}
return turboPmacController::writeFloat64(pasynUser, value);
}
return asynSuccess;
} else {
return turboPmacController::writeFloat64(pasynUser, value);
@@ -252,10 +238,30 @@ detectorTowerController::getDetectorTowerLiftAxis(int axisNo) {
return dynamic_cast<detectorTowerLiftAxis *>(asynAxis);
}
asynStatus
detectorTowerController::pollDetectorAxes(bool *moving,
detectorTowerAngleAxis *angleAxis,
detectorTowerLiftAxis *liftAxis) {
/*
Access one of the axes of the controller via the axis adress stored in asynUser.
If the axis does not exist or is not a Axis, a nullptr is returned and an
error is emitted.
*/
detectorTowerSupportAxis *
detectorTowerController::getDetectorTowerSupportAxis(asynUser *pasynUser) {
asynMotorAxis *asynAxis = asynMotorController::getAxis(pasynUser);
return dynamic_cast<detectorTowerSupportAxis *>(asynAxis);
}
/*
Access one of the axes of the controller via the axis index.
If the axis does not exist or is not a Axis, the function must return Null
*/
detectorTowerSupportAxis *
detectorTowerController::getDetectorTowerSupportAxis(int axisNo) {
asynMotorAxis *asynAxis = asynMotorController::getAxis(axisNo);
return dynamic_cast<detectorTowerSupportAxis *>(asynAxis);
}
asynStatus detectorTowerController::pollDetectorAxes(
bool *moving, detectorTowerAngleAxis *angleAxis,
detectorTowerLiftAxis *liftAxis, detectorTowerSupportAxis *supportAxis) {
// Return value for the poll
asynStatus pollStatus = asynSuccess;
@@ -267,6 +273,8 @@ detectorTowerController::pollDetectorAxes(bool *moving,
asynStatus plStatus = asynSuccess;
char userMessage[MAXBUF_] = {0};
// User message which was created in one of the other axis methods
char oldUserMessage[MAXBUF_] = {0};
char response[MAXBUF_] = {0};
int nvals = 0;
@@ -292,20 +300,26 @@ detectorTowerController::pollDetectorAxes(bool *moving,
double liftAdjustOriginHighLimit = 0.0;
double liftAdjustOriginLowLimit = 0.0;
double supportOrigin = 0.0;
double angleOrigin = 0.0;
double angleAdjustOriginHighLimit = 0.0;
double angleAdjustOriginLowLimit = 0.0;
double supportOrigin = 0.0;
int angleAxisNo = angleAxis->axisNo();
int liftAxisNo = liftAxis->axisNo();
int supportAxisNo = supportAxis->axisNo();
/*
For messages which in principle concern both axes, use the smaller of the
two indices.
For messages which in principle concern all axes, use the smallest index
*/
int comAxisNo = angleAxisNo > liftAxisNo ? liftAxisNo : angleAxisNo;
int comAxisNo = angleAxisNo;
if (comAxisNo > liftAxisNo) {
comAxisNo = liftAxisNo;
}
if (comAxisNo > supportAxisNo) {
comAxisNo = supportAxisNo;
}
// =========================================================================
@@ -329,6 +343,11 @@ detectorTowerController::pollDetectorAxes(bool *moving,
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);
if (plStatus != asynSuccess) {
@@ -340,6 +359,11 @@ detectorTowerController::pollDetectorAxes(bool *moving,
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
plStatus = angleAxis->motorPosition(&prevAngle);
@@ -458,13 +482,9 @@ detectorTowerController::pollDetectorAxes(bool *moving,
}
resetCountPosState = false;
plStatus =
setStringParam(motorMessageText(), "Reset one of the tower axes.");
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorMessageText_",
comAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
snprintf(userMessage, sizeof(userMessage),
"Reset one of the tower axes."
);
pollStatus = asynError;
break;
@@ -504,12 +524,6 @@ detectorTowerController::pollDetectorAxes(bool *moving,
"Unknown state P358 = %d has been reached. Please call "
"the support.",
positionState);
plStatus = setStringParam(motorMessageText(), userMessage);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorMessageText_",
comAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
pollStatus = asynError;
}
@@ -627,12 +641,6 @@ detectorTowerController::pollDetectorAxes(bool *moving,
"Axis release was removed while moving. Try resetting the axis "
"and issue the move command again.");
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorMessageText_",
comAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
pollStatus = asynError;
break;
@@ -797,8 +805,13 @@ detectorTowerController::pollDetectorAxes(bool *moving,
getMsgPrintControl().resetCount(keyError, pasynUser());
}
// Update the parameter library for both axes
if (error != 0) {
// Update the parameter library for all axes
getStringParam(angleAxisNo, motorMessageText(), sizeof(oldUserMessage), oldUserMessage);
if (error != 0 || oldUserMessage[0] != '\0') {
plStatus = angleAxis->setIntegerParam(motorStatusProblem(), true);
if (plStatus != asynSuccess) {
@@ -813,9 +826,17 @@ detectorTowerController::pollDetectorAxes(bool *moving,
liftAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
plStatus = supportAxis->setIntegerParam(motorStatusProblem(), true);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorStatusProblem_",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
}
// Update the user message text
// Update the user message text, if one is available
if (userMessage[0] != '\0') {
plStatus = angleAxis->setStringParam(motorMessageText(), userMessage);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorMessageText_", angleAxisNo,
@@ -826,6 +847,13 @@ detectorTowerController::pollDetectorAxes(bool *moving,
return paramLibAccessFailed(plStatus, "motorMessageText_", liftAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = supportAxis->setStringParam(motorMessageText(), userMessage);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorMessageText_",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
}
// Update the working position state PV
plStatus = angleAxis->setIntegerParam(positionStateRBV(), positionState);
@@ -838,6 +866,12 @@ detectorTowerController::pollDetectorAxes(bool *moving,
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
plStatus = angleAxis->setIntegerParam(motorEnableRBV(), 1);
@@ -850,6 +884,11 @@ detectorTowerController::pollDetectorAxes(bool *moving,
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?
plStatus = angleAxis->setIntegerParam(motorStatusMoving(), *moving);
@@ -862,6 +901,12 @@ detectorTowerController::pollDetectorAxes(bool *moving,
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?
plStatus = angleAxis->setIntegerParam(motorStatusDone(), !(*moving));
@@ -874,8 +919,13 @@ detectorTowerController::pollDetectorAxes(bool *moving,
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 angleDir are the axes currently moving?
// In which direction are the axes currently moving?
plStatus = angleAxis->setIntegerParam(motorStatusDirection(), angleDir);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorStatusDirection_",
@@ -886,6 +936,13 @@ detectorTowerController::pollDetectorAxes(bool *moving,
return paramLibAccessFailed(plStatus, "motorStatusDirection_",
liftAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
// Using the lift direction for the support axis is done on purpose!
plStatus = supportAxis->setIntegerParam(motorStatusDirection(), liftDir);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorStatusDirection_",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
// High limits from hardware
plStatus =
@@ -900,6 +957,14 @@ detectorTowerController::pollDetectorAxes(bool *moving,
return paramLibAccessFailed(plStatus, "motorHighLimitFromDriver",
liftAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
// Using the lift high limit for the support axis is done on purpose!
plStatus = setDoubleParam(supportAxisNo, motorHighLimitFromDriver(),
liftHighLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorHighLimitFromDriver",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
// Low limits from hardware
plStatus =
@@ -914,6 +979,14 @@ detectorTowerController::pollDetectorAxes(bool *moving,
return paramLibAccessFailed(plStatus, "motorLowLimitFromDriver",
liftAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
// Using the lift low limit for the support axis is done on purpose!
plStatus =
setDoubleParam(supportAxisNo, motorLowLimitFromDriver(), liftLowLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorLowLimitFromDriver",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
// Write the motor origin
plStatus = setDoubleParam(angleAxisNo, motorOrigin(), angleOrigin);
@@ -926,11 +999,9 @@ detectorTowerController::pollDetectorAxes(bool *moving,
return paramLibAccessFailed(plStatus, "motorOrigin", liftAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
// Write the lift support origin motor
plStatus = setDoubleParam(liftAxisNo, liftSupportOrigin(), supportOrigin);
plStatus = setDoubleParam(supportAxisNo, motorOrigin(), supportOrigin);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "liftSupportOrigin", liftAxisNo,
return paramLibAccessFailed(plStatus, "supportOrigin", supportAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
@@ -949,6 +1020,15 @@ detectorTowerController::pollDetectorAxes(bool *moving,
return paramLibAccessFailed(plStatus, "motorOriginHighLimitFromDriver",
liftAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
// Using the lift high limit for the support axis is done on purpose!
plStatus =
setDoubleParam(supportAxisNo, motorAdjustOriginHighLimitFromDriver(),
liftAdjustOriginHighLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorOriginHighLimitFromDriver",
supportAxisNo, __PRETTY_FUNCTION__,
__LINE__);
}
// Origin adjustment low limit
plStatus =
@@ -966,6 +1046,15 @@ detectorTowerController::pollDetectorAxes(bool *moving,
"motorAdjustOriginLowLimitFromDriver",
liftAxisNo, __PRETTY_FUNCTION__, __LINE__);
}
// Using the lift low limit for the support axis is done on purpose!
plStatus =
setDoubleParam(supportAxisNo, motorAdjustOriginLowLimitFromDriver(),
liftAdjustOriginLowLimit);
if (plStatus != asynSuccess) {
return paramLibAccessFailed(
plStatus, "motorAdjustOriginLowLimitFromDriver", supportAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
// Axes positions
plStatus = angleAxis->setMotorPosition(angle);
@@ -976,22 +1065,13 @@ detectorTowerController::pollDetectorAxes(bool *moving,
if (plStatus != asynSuccess) {
return plStatus;
}
// Something went wrong -> Report a status problem
if (pollStatus != asynSuccess) {
plStatus = angleAxis->setIntegerParam(motorStatusProblem(), true);
if (plStatus != asynSuccess) {
paramLibAccessFailed(plStatus, "motorStatusProblem_", angleAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
plStatus = liftAxis->setIntegerParam(motorStatusProblem(), true);
if (plStatus != asynSuccess) {
paramLibAccessFailed(plStatus, "motorStatusProblem_", liftAxisNo,
__PRETTY_FUNCTION__, __LINE__);
}
// Using the lift position for the support axis is done on purpose!
plStatus = supportAxis->setMotorPosition(lift);
if (plStatus != asynSuccess) {
return plStatus;
}
// Update the parameter library
// Update the parameter library for all three axes
bool wantToPrint = false;
plStatus = angleAxis->callParamCallbacks();
@@ -1009,6 +1089,7 @@ detectorTowerController::pollDetectorAxes(bool *moving,
if (wantToPrint) {
pollStatus = plStatus;
}
plStatus = liftAxis->callParamCallbacks();
wantToPrint = plStatus != asynSuccess;
if (getMsgPrintControl().shouldBePrinted(portName, liftAxisNo,
@@ -1025,6 +1106,40 @@ detectorTowerController::pollDetectorAxes(bool *moving,
pollStatus = plStatus;
}
plStatus = supportAxis->callParamCallbacks();
wantToPrint = plStatus != asynSuccess;
if (getMsgPrintControl().shouldBePrinted(portName, supportAxisNo,
__PRETTY_FUNCTION__, __LINE__,
wantToPrint, pasynUser())) {
asynPrint(pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line "
"%d:\ncallParamCallbacks failed with %s.%s\n",
portName, supportAxisNo, __PRETTY_FUNCTION__, __LINE__,
stringifyAsynStatus(pollStatus),
getMsgPrintControl().getSuffix());
}
if (wantToPrint) {
pollStatus = plStatus;
}
// Reset the message text for the next poll cycle AFTER updating the PVs
plStatus = angleAxis->setStringParam(motorMessageText(), "");
if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorMessageText_", angleAxisNo,
__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;
}