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

View File

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