diff --git a/src/beamShiftAxis.cpp b/src/beamShiftAxis.cpp index 3947cdb..460790c 100644 --- a/src/beamShiftAxis.cpp +++ b/src/beamShiftAxis.cpp @@ -156,6 +156,7 @@ asynStatus beamShiftAxis::doPoll(bool *moving) { double highLimit = 0.0; double lowLimit = 0.0; double limitsOffset = 0.0; + int enabled = 0; // ========================================================================= @@ -173,15 +174,15 @@ asynStatus beamShiftAxis::doPoll(bool *moving) { - Upper limit - Lower limit */ - snprintf(command, sizeof(command), "P154 Q110 P159 Q113 Q114"); - rw_status = pC_->writeRead(axisNo(), command, response, 5); + snprintf(command, sizeof(command), "P154 Q110 P158 P159 Q113 Q114"); + rw_status = pC_->writeRead(axisNo(), command, response, 6); if (rw_status != asynSuccess) { return rw_status; }; - nvals = sscanf(response, "%d %lf %d %lf %lf", (int *)moving, - ¤tPosition, &error, &highLimit, &lowLimit); - if (nvals != 5) { + nvals = sscanf(response, "%d %lf %d %d %lf %lf", (int *)moving, + ¤tPosition, &enabled, &error, &highLimit, &lowLimit); + if (nvals != 6) { return pC_->couldNotParseResponse(command, response, axisNo(), __PRETTY_FUNCTION__, __LINE__); } @@ -208,8 +209,8 @@ asynStatus beamShiftAxis::doPoll(bool *moving) { highLimit = highLimit - limitsOffset; lowLimit = lowLimit + limitsOffset; - // Update the enablement PV. If the error is 1, the axis is not enabled - pl_status = setIntegerParam(pC_->motorEnableRBV(), (error != 1)); + // Update the enablement PV. + pl_status = setIntegerParam(pC_->motorEnableRBV(), enabled); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorEnableRBV_", axisNo(), __PRETTY_FUNCTION__, __LINE__); @@ -309,8 +310,20 @@ asynStatus beamShiftAxis::handleError(int error, char *userMessage, // No error break; case 1: - // Axis is not switched on. This is a normal state which is not - // problematic, it just requires that the user enables the axis. + // Axis is not switched on. + + if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, + pC_->pasynUser())) { + asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, + "Controller \"%s\", axis %d => %s, line %d\nAxis must " + "be enabled first.%s\n", + pC_->portName, axisNo(), __PRETTY_FUNCTION__, __LINE__, + pC_->getMsgPrintControl().getSuffix()); + } + resetError = false; + + snprintf(userMessage, sizeUserMessage, "Axis must be enabled first."); + status = asynError; break; case 2: // Axis received a new command while it was moving @@ -327,7 +340,7 @@ asynStatus beamShiftAxis::handleError(int error, char *userMessage, resetError = false; snprintf(userMessage, sizeUserMessage, - "Axis received move command while it is still moving. Please " + "Axis received move command, but is still moving. Please " "call the support."); status = asynError; break; @@ -379,6 +392,21 @@ asynStatus beamShiftAxis::handleError(int error, char *userMessage, "Target position exceeds limits. Please call the support."); status = asynError; break; + case 6: + // Axis received a new command while it was moving + if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, + pC_->pasynUser())) { + asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, + "Controller \"%s\", axis %d => %s, line %d\nAxis is not " + "ready, delete error first.%s\n", + pC_->portName, axisNo(), __PRETTY_FUNCTION__, __LINE__, + pC_->getMsgPrintControl().getSuffix()); + } + resetError = false; + + snprintf(userMessage, sizeUserMessage, "Delete error first."); + status = asynError; + break; default: if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, @@ -531,6 +559,7 @@ asynStatus beamShiftAxis::enable(bool on) { asynStatus status = asynSuccess; int nvals = 0; int error = 0; + int enabled = 0; // ========================================================================= @@ -538,16 +567,16 @@ asynStatus beamShiftAxis::enable(bool on) { // message if (on) { // Check if the axis is currently switched off - snprintf(command, sizeof(command), "P159"); - status = pC_->writeRead(axisNo(), command, response, 1); + snprintf(command, sizeof(command), "P158 P159"); + status = pC_->writeRead(axisNo(), command, response, 2); - nvals = sscanf(response, "%d", &error); - if (nvals != 1) { + nvals = sscanf(response, "%d %d", &enabled, &error); + if (nvals != 2) { return pC_->couldNotParseResponse(command, response, axisNo(), __PRETTY_FUNCTION__, __LINE__); } - if (error == 1) { + if (enabled == 0) { snprintf(command, sizeof(command), "P152=1"); return pC_->writeRead(axisNo(), command, response, 0); } else { diff --git a/turboPmac b/turboPmac index 55b523d..a11d10c 160000 --- a/turboPmac +++ b/turboPmac @@ -1 +1 @@ -Subproject commit 55b523ddaa2d696f28a35c391ea96d07d82a8d5a +Subproject commit a11d10cb6ca6770a9168c0a0ef6ef1e7f6436cdc