Make sure non-persistent error messages are shown for one poll cycle

This commit is contained in:
2025-05-14 16:44:30 +02:00
parent 203bb9475f
commit d575d4fe76
2 changed files with 60 additions and 54 deletions

View File

@ -260,9 +260,8 @@ asynStatus detectorTowerAngleAxis::startCombinedMove() {
} }
if (isInChangerPos) { if (isInChangerPos) {
plStatus = setStringParam( plStatus = setStringParam(pC_->motorMessageText(),
pC_->motorMessageText(), "Move the axis to working state first.");
"Move the axis to working state first.");
if (plStatus != asynSuccess) { if (plStatus != asynSuccess) {
return pC_->paramLibAccessFailed(plStatus, "motorMessageText", return pC_->paramLibAccessFailed(plStatus, "motorMessageText",
axisNo_, __PRETTY_FUNCTION__, axisNo_, __PRETTY_FUNCTION__,
@ -449,9 +448,6 @@ detectorTowerAngleAxis::toggleWorkingChangerState(bool toChangingPosition) {
axisNo_, __PRETTY_FUNCTION__, axisNo_, __PRETTY_FUNCTION__,
__LINE__); __LINE__);
} }
return pC_->paramLibAccessFailed(plStatus, "motorMessageText_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
} }
plStatus = setIntegerParam(pC_->changeStateRBV(), toChangingPosition); plStatus = setIntegerParam(pC_->changeStateRBV(), toChangingPosition);

View File

@ -272,9 +272,9 @@ asynStatus detectorTowerController::pollDetectorAxes(
// Status of parameter library operations // Status of parameter library operations
asynStatus plStatus = asynSuccess; asynStatus plStatus = asynSuccess;
char userMessage[MAXBUF_] = {0}; char errorMessage[MAXBUF_] = {0};
// User message which was created in one of the other axis methods // User message which was created in one of the other axis methods
char oldUserMessage[MAXBUF_] = {0}; char waitingErrorMessage[MAXBUF_] = {0};
char response[MAXBUF_] = {0}; char response[MAXBUF_] = {0};
int nvals = 0; int nvals = 0;
@ -482,9 +482,8 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetCountPosState = false; resetCountPosState = false;
snprintf(userMessage, sizeof(userMessage), snprintf(errorMessage, sizeof(errorMessage),
"Reset one of the tower axes." "Reset one of the tower axes.");
);
pollStatus = asynError; pollStatus = asynError;
break; break;
@ -520,7 +519,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetCountPosState = false; resetCountPosState = false;
snprintf(userMessage, sizeof(userMessage), snprintf(errorMessage, sizeof(errorMessage),
"Unknown state P358 = %d has been reached. Please call " "Unknown state P358 = %d has been reached. Please call "
"the support.", "the support.",
positionState); positionState);
@ -567,7 +566,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetError = false; resetError = false;
snprintf(userMessage, sizeof(userMessage), snprintf(errorMessage, sizeof(errorMessage),
"Brake COZ not released. Try resetting the axis."); "Brake COZ not released. Try resetting the axis.");
pollStatus = asynError; pollStatus = asynError;
@ -584,7 +583,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetError = false; resetError = false;
snprintf(userMessage, sizeof(userMessage), snprintf(errorMessage, sizeof(errorMessage),
"Move command rejected because axis is already moving. Try " "Move command rejected because axis is already moving. Try "
"resetting the axis."); "resetting the axis.");
@ -601,7 +600,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetError = false; resetError = false;
snprintf(userMessage, sizeof(userMessage), snprintf(errorMessage, sizeof(errorMessage),
"Error in motor FTZ. Try resetting the axis."); "Error in motor FTZ. Try resetting the axis.");
pollStatus = asynError; pollStatus = asynError;
@ -618,9 +617,9 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetError = false; resetError = false;
snprintf(userMessage, sizeof(userMessage), snprintf(errorMessage, sizeof(errorMessage),
"Axis stopped unexpectedly. Try resetting the axis " "Axis stopped unexpectedly. Try resetting the axis and issue "
"and issue the move command again."); "the move command again.");
pollStatus = asynError; pollStatus = asynError;
break; break;
@ -637,7 +636,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
resetError = false; resetError = false;
snprintf( snprintf(
userMessage, sizeof(userMessage), errorMessage, sizeof(errorMessage),
"Axis release was removed while moving. Try resetting the axis " "Axis release was removed while moving. Try resetting the axis "
"and issue the move command again."); "and issue the move command again.");
@ -655,7 +654,8 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetError = false; resetError = false;
snprintf(userMessage, sizeof(userMessage), "Emergency stop activated."); snprintf(errorMessage, sizeof(errorMessage),
"Emergency stop activated.");
pollStatus = asynError; pollStatus = asynError;
break; break;
@ -670,7 +670,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetError = false; resetError = false;
snprintf(userMessage, sizeof(userMessage), snprintf(errorMessage, sizeof(errorMessage),
"Error in motor COZ. Try resetting the axis."); "Error in motor COZ. Try resetting the axis.");
pollStatus = asynError; pollStatus = asynError;
@ -686,7 +686,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetError = false; resetError = false;
snprintf(userMessage, sizeof(userMessage), snprintf(errorMessage, sizeof(errorMessage),
"Error in motor COM. Try resetting the axis."); "Error in motor COM. Try resetting the axis.");
pollStatus = asynError; pollStatus = asynError;
@ -702,7 +702,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetError = false; resetError = false;
snprintf(userMessage, sizeof(userMessage), snprintf(errorMessage, sizeof(errorMessage),
"Error in motor COX. Try resetting the axis."); "Error in motor COX. Try resetting the axis.");
pollStatus = asynError; pollStatus = asynError;
@ -719,7 +719,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
resetError = false; resetError = false;
snprintf( snprintf(
userMessage, sizeof(userMessage), errorMessage, sizeof(errorMessage),
"Hit end switch FTZ. Try moving the axis in the other direction."); "Hit end switch FTZ. Try moving the axis in the other direction.");
pollStatus = asynError; pollStatus = asynError;
@ -737,7 +737,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetError = false; resetError = false;
snprintf(userMessage, sizeof(userMessage), snprintf(errorMessage, sizeof(errorMessage),
"Maximum allowed following error exceeded (P359 = %d). " "Maximum allowed following error exceeded (P359 = %d). "
"Check if movement range is blocked.", "Check if movement range is blocked.",
error); error);
@ -756,7 +756,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetError = false; resetError = false;
snprintf(userMessage, sizeof(userMessage), snprintf(errorMessage, sizeof(errorMessage),
"Minimum allowed angle exceeded (P359 = %d). Try moving the " "Minimum allowed angle exceeded (P359 = %d). Try moving the "
"axis in the other direction.", "axis in the other direction.",
error); error);
@ -775,7 +775,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetError = false; resetError = false;
snprintf(userMessage, sizeof(userMessage), snprintf(errorMessage, sizeof(errorMessage),
"Maximum allowed angle exceeded (P359 = %d). Try moving the " "Maximum allowed angle exceeded (P359 = %d). Try moving the "
"axis in the other direction.", "axis in the other direction.",
error); error);
@ -794,7 +794,7 @@ asynStatus detectorTowerController::pollDetectorAxes(
} }
resetError = false; resetError = false;
snprintf(userMessage, sizeof(userMessage), "Unknown error P359 = %d.", snprintf(errorMessage, sizeof(errorMessage), "Unknown error P359 = %d.",
error); error);
pollStatus = asynError; pollStatus = asynError;
@ -805,13 +805,14 @@ asynStatus detectorTowerController::pollDetectorAxes(
getMsgPrintControl().resetCount(keyError, pasynUser()); getMsgPrintControl().resetCount(keyError, pasynUser());
} }
// Update the parameter library for all axes /*
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.
*/
getStringParam(angleAxisNo, motorMessageText(), sizeof(waitingErrorMessage),
waitingErrorMessage);
if (error != 0 || waitingErrorMessage[0] != '\0') {
getStringParam(angleAxisNo, motorMessageText(), sizeof(oldUserMessage), oldUserMessage);
if (error != 0 || oldUserMessage[0] != '\0') {
plStatus = angleAxis->setIntegerParam(motorStatusProblem(), true); plStatus = angleAxis->setIntegerParam(motorStatusProblem(), true);
if (plStatus != asynSuccess) { if (plStatus != asynSuccess) {
@ -835,25 +836,29 @@ getStringParam(angleAxisNo, motorMessageText(), sizeof(oldUserMessage), oldUserM
} }
} }
// Update the user message text, if one is available // Update the error message text with the one created in this poll (in case
if (userMessage[0] != '\0') { // it is not empty).
plStatus = angleAxis->setStringParam(motorMessageText(), userMessage); if (errorMessage[0] != '\0') {
if (plStatus != asynSuccess) { plStatus = angleAxis->setStringParam(motorMessageText(), errorMessage);
return paramLibAccessFailed(plStatus, "motorMessageText_", angleAxisNo, if (plStatus != asynSuccess) {
__PRETTY_FUNCTION__, __LINE__); return paramLibAccessFailed(plStatus, "motorMessageText_",
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__);
}
} }
plStatus = liftAxis->setStringParam(motorMessageText(), userMessage);
if (plStatus != asynSuccess) {
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 // Update the working position state PV
plStatus = angleAxis->setIntegerParam(positionStateRBV(), positionState); plStatus = angleAxis->setIntegerParam(positionStateRBV(), positionState);
@ -1122,7 +1127,12 @@ if (userMessage[0] != '\0') {
pollStatus = plStatus; pollStatus = plStatus;
} }
// Reset the message text for the next poll cycle AFTER updating the PVs /*
Reset the message text for the next poll cycle AFTER updating the PVs.
This makes sure that non-persistent error messages are shown for at least
one poll cycle, but are cleared afterwards. Persisting error messages will
be recreated during each poll.
*/
plStatus = angleAxis->setStringParam(motorMessageText(), ""); plStatus = angleAxis->setStringParam(motorMessageText(), "");
if (plStatus != asynSuccess) { if (plStatus != asynSuccess) {
return paramLibAccessFailed(plStatus, "motorMessageText_", angleAxisNo, return paramLibAccessFailed(plStatus, "motorMessageText_", angleAxisNo,