From d471041c595962babdb4475cc6f83af2bf680b75 Mon Sep 17 00:00:00 2001 From: smathis Date: Mon, 10 Mar 2025 16:55:10 +0100 Subject: [PATCH] Removed friend class declaration and replaced access to private properties with accessors --- src/turboPmacAxis.cpp | 262 +++++++++++++++++++------------------- src/turboPmacAxis.h | 3 - src/turboPmacController.h | 13 +- 3 files changed, 138 insertions(+), 140 deletions(-) diff --git a/src/turboPmacAxis.cpp b/src/turboPmacAxis.cpp index c297f8c..52cec66 100644 --- a/src/turboPmacAxis.cpp +++ b/src/turboPmacAxis.cpp @@ -54,13 +54,13 @@ turboPmacAxis::turboPmacAxis(turboPmacController *pC, int axisNo, line 40). However, we want the IOC creation to stop completely, since this is a configuration error. */ - if (axisNo >= pC->numAxes_) { - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + if (axisNo >= pC->numAxes()) { + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d: FATAL ERROR: " "Axis index %d must be smaller than the total number of axes " "%d", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, - axisNo_, pC->numAxes_); + axisNo_, pC->numAxes()); exit(-1); } @@ -82,10 +82,10 @@ turboPmacAxis::turboPmacAxis(turboPmacController *pC, int axisNo, axisStatus_ = 0; // Provide initial values for some parameter library entries - status = pC_->setIntegerParam(axisNo_, pC_->rereadEncoderPosition_, 0); + status = pC_->setIntegerParam(axisNo_, pC_->rereadEncoderPosition(), 0); if (status != asynSuccess) { asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_ERROR, + pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d:\nFATAL ERROR " "(setting a parameter value failed with %s)\n. Terminating IOC", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, @@ -94,10 +94,10 @@ turboPmacAxis::turboPmacAxis(turboPmacController *pC, int axisNo, } // turboPmac motors can always be disabled - status = pC_->setIntegerParam(axisNo_, pC_->motorCanDisable_, 1); + status = pC_->setIntegerParam(axisNo_, pC_->motorCanDisable(), 1); if (status != asynSuccess) { asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_ERROR, + pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nFATAL ERROR " "(setting a parameter value failed with %s)\n. Terminating IOC", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, @@ -135,11 +135,11 @@ asynStatus turboPmacAxis::init() { time_t now = time(NULL); time_t maxInitTime = 60; while (1) { - status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution_, + status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution(), &motorRecResolution); if (status == asynParamUndefined) { if (now + maxInitTime < time(NULL)) { - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line " "%d\nInitializing the parameter library failed.\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, @@ -186,14 +186,14 @@ asynStatus turboPmacAxis::init() { motorPosition = motorPosition / motorRecResolution; // Store these values in the parameter library - status = pC_->setDoubleParam(axisNo_, pC_->motorPosition_, motorPosition); + status = pC_->setDoubleParam(axisNo_, pC_->motorPosition(), motorPosition); if (status != asynSuccess) { return pC_->paramLibAccessFailed(status, "motorPosition_", axisNo_, __PRETTY_FUNCTION__, __LINE__); } // Initial motor status is idle - status = pC_->setIntegerParam(axisNo_, pC_->motorStatusDone_, 1); + status = pC_->setIntegerParam(axisNo_, pC_->motorStatusDone(), 1); if (status != asynSuccess) { return pC_->paramLibAccessFailed(status, "motorStatusDone_", axisNo_, __PRETTY_FUNCTION__, __LINE__); @@ -215,7 +215,7 @@ asynStatus turboPmacAxis::init() { // If we can't communicate with the parameter library, it doesn't make // sense to try and upstream this to the user -> Just log the error asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_ERROR, + pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\ncallParamCallbacks " "failed with %s.\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, @@ -266,10 +266,10 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { time_t currentTime = time(NULL); bool timedOut = (currentTime > timeAtHandshake_ + 5); - if (pC_->msgPrintControl_.shouldBePrinted( + if (pC_->getMsgPrintControl().shouldBePrinted( pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, timedOut, - pC_->pasynUserSelf)) { - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + pC_->asynUserSelf())) { + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nAsked for a " "handshake at %ld s and didn't get a positive reply yet " "(current time is %ld s).\n", @@ -279,7 +279,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { if (timedOut) { pl_status = - setStringParam(pC_->motorMessageText_, + setStringParam(pC_->motorMessageText(), "Timed out while waiting for a handshake"); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", @@ -315,14 +315,14 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { // poll. This is already part of the movement procedure. *moving = true; - pl_status = setIntegerParam(pC_->motorStatusMoving_, *moving); + pl_status = setIntegerParam(pC_->motorStatusMoving(), *moving); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorStatusMoving_", axisNo_, __PRETTY_FUNCTION__, __LINE__); } - pl_status = setIntegerParam(pC_->motorStatusDone_, !(*moving)); + pl_status = setIntegerParam(pC_->motorStatusDone(), !(*moving)); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorStatusDone_", axisNo_, __PRETTY_FUNCTION__, @@ -334,7 +334,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { } // Motor resolution from parameter library - pl_status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution_, + pl_status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution(), &motorRecResolution); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorRecResolution_", @@ -344,14 +344,14 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { // Read the previous motor position pl_status = - pC_->getDoubleParam(axisNo_, pC_->motorPosition_, &previousPosition); + pC_->getDoubleParam(axisNo_, pC_->motorPosition(), &previousPosition); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorPosition_", axisNo_, __PRETTY_FUNCTION__, __LINE__); } // Read the previous motor position - pl_status = pC_->getIntegerParam(axisNo_, pC_->motorStatusDone_, + pl_status = pC_->getIntegerParam(axisNo_, pC_->motorStatusDone(), &previousStatusDone); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorStatusDone_", axisNo_, @@ -391,7 +391,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { by limitsOffset on both sides. */ pl_status = - pC_->getDoubleParam(axisNo_, pC_->motorLimitsOffset_, &limitsOffset); + pC_->getDoubleParam(axisNo_, pC_->motorLimitsOffset(), &limitsOffset); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorLimitsOffset_", axisNo_, __PRETTY_FUNCTION__, @@ -404,7 +404,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { axisStatus_ = axStatus; // Update the enablement PV - pl_status = setIntegerParam(pC_->motorEnableRBV_, + pl_status = setIntegerParam(pC_->motorEnableRBV(), (axStatus != -3 && axStatus != -5)); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorEnableRBV_", axisNo_, @@ -433,7 +433,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { // Axis is deactivated *moving = false; - pl_status = setStringParam(pC_->motorMessageText_, "Deactivated"); + pl_status = setStringParam(pC_->motorMessageText(), "Deactivated"); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, @@ -444,18 +444,18 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { // Emergency stop *moving = false; - if (pC_->msgPrintControl_.shouldBePrinted(keyStatus, true, - pC_->pasynUserSelf)) { + if (pC_->getMsgPrintControl().shouldBePrinted(keyStatus, true, + pC_->asynUserSelf())) { asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_ERROR, + pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nEmergency stop " "activated.%s\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, - pC_->msgPrintControl_.getSuffix()); + pC_->getMsgPrintControl().getSuffix()); } resetCountStatus = false; - pl_status = setStringParam(pC_->motorMessageText_, "Emergency stop"); + pl_status = setStringParam(pC_->motorMessageText(), "Emergency stop"); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, @@ -467,7 +467,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { // Disabled *moving = false; - pl_status = setStringParam(pC_->motorMessageText_, "Disabled"); + pl_status = setStringParam(pC_->motorMessageText(), "Disabled"); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, @@ -499,7 +499,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { *moving = true; asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_FLOW, + pC_->asynUserSelf(), ASYN_TRACE_FLOW, "Controller \"%s\", axis %d => %s, line %d\nAxis is moving\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__); @@ -507,14 +507,14 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { default: *moving = false; - if (pC_->msgPrintControl_.shouldBePrinted(keyStatus, true, - pC_->pasynUserSelf)) { + if (pC_->getMsgPrintControl().shouldBePrinted(keyStatus, true, + pC_->asynUserSelf())) { - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nReached " "unreachable state P%2.2d00 = %d.%s\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, - axisNo_, axStatus, pC_->msgPrintControl_.getSuffix()); + axisNo_, axStatus, pC_->getMsgPrintControl().getSuffix()); } resetCountStatus = false; @@ -522,7 +522,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { "Unknown state P%2.2d00 = %d has been reached. Please call " "the support.", axisNo_, error); - pl_status = setStringParam(pC_->motorMessageText_, userMessage); + pl_status = setStringParam(pC_->motorMessageText(), userMessage); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, @@ -531,7 +531,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { } if (resetCountStatus) { - pC_->msgPrintControl_.resetCount(keyStatus, pC_->pasynUserSelf); + pC_->getMsgPrintControl().resetCount(keyStatus, pC_->asynUserSelf()); } if (*moving) { @@ -556,17 +556,17 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { case 1: // EPICS should already prevent this issue in the first place, // since it contains the user limits - if (pC_->msgPrintControl_.shouldBePrinted(keyError, true, - pC_->pasynUserSelf)) { - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, + pC_->asynUserSelf())) { + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nTarget " "position would exceed user limits.%s\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, - pC_->msgPrintControl_.getSuffix()); + pC_->getMsgPrintControl().getSuffix()); } resetError = false; - pl_status = setStringParam(pC_->motorMessageText_, + pl_status = setStringParam(pC_->motorMessageText(), "Target position would exceed software " "limits. Please call the support."); if (pl_status != asynSuccess) { @@ -579,19 +579,19 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { break; case 5: // Command not possible - if (pC_->msgPrintControl_.shouldBePrinted(keyStatus, true, - pC_->pasynUserSelf)) { + if (pC_->getMsgPrintControl().shouldBePrinted(keyStatus, true, + pC_->asynUserSelf())) { asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_ERROR, + pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nAxis is " "still moving, but received another move command. EPICS " "should prevent this, check if *moving is set correctly.%s\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, - pC_->msgPrintControl_.getSuffix()); + pC_->getMsgPrintControl().getSuffix()); } resetError = false; - pl_status = setStringParam(pC_->motorMessageText_, + pl_status = setStringParam(pC_->motorMessageText(), "Axis received move command while it is " "still moving. Please call the support."); if (pl_status != asynSuccess) { @@ -603,13 +603,13 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { poll_status = asynError; break; case 8: - if (pC_->msgPrintControl_.shouldBePrinted(keyError, true, - pC_->pasynUserSelf)) { - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, + pC_->asynUserSelf())) { + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nAir cushion " "feedback stopped during movement (P%2.2d01 = %d).%s\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, - axisNo_, error, pC_->msgPrintControl_.getSuffix()); + axisNo_, error, pC_->getMsgPrintControl().getSuffix()); } resetError = false; @@ -618,7 +618,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { "%d). Please call the support.", axisNo_, error); - pl_status = setStringParam(pC_->motorMessageText_, userMessage); + pl_status = setStringParam(pC_->motorMessageText(), userMessage); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, @@ -626,14 +626,14 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { } break; case 9: - if (pC_->msgPrintControl_.shouldBePrinted(keyError, true, - pC_->pasynUserSelf)) { + if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, + pC_->asynUserSelf())) { asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_ERROR, + pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nNo air cushion " "feedback before movement start (P%2.2d01 = %d).%s\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, axisNo_, - error, pC_->msgPrintControl_.getSuffix()); + error, pC_->getMsgPrintControl().getSuffix()); } resetError = false; @@ -641,7 +641,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { "No air cushion feedback before movement start (P%2.2d01 = " "%d). Please call the support.", axisNo_, error); - pl_status = setStringParam(pC_->motorMessageText_, userMessage); + pl_status = setStringParam(pC_->motorMessageText(), userMessage); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, @@ -656,14 +656,14 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { which is not properly homed or if a bug occured. */ - if (pC_->msgPrintControl_.shouldBePrinted(keyError, true, - pC_->pasynUserSelf)) { + if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, + pC_->asynUserSelf())) { asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_ERROR, + pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nAxis hit the " "controller limits.%s\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, - pC_->msgPrintControl_.getSuffix()); + pC_->getMsgPrintControl().getSuffix()); } resetError = false; @@ -674,7 +674,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { "Otherwise please call the support.", axisNo_, error); - pl_status = setStringParam(pC_->motorMessageText_, userMessage); + pl_status = setStringParam(pC_->motorMessageText(), userMessage); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, @@ -686,14 +686,14 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { case 11: // Following error - if (pC_->msgPrintControl_.shouldBePrinted(keyError, true, - pC_->pasynUserSelf)) { + if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, + pC_->asynUserSelf())) { asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_ERROR, + pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nMaximum allowed " "following error exceeded.%s\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, - pC_->msgPrintControl_.getSuffix()); + pC_->getMsgPrintControl().getSuffix()); } resetError = false; @@ -702,7 +702,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { "Check if movement range is blocked. " "Otherwise please call the support.", axisNo_, error); - pl_status = setStringParam(pC_->motorMessageText_, command); + pl_status = setStringParam(pC_->motorMessageText(), command); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, @@ -713,13 +713,13 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { break; case 12: - if (pC_->msgPrintControl_.shouldBePrinted(keyError, true, - pC_->pasynUserSelf)) { - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, + pC_->asynUserSelf())) { + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nSecurity " "input is triggered (P%2.2d01 = %d).%s\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, - axisNo_, error, pC_->msgPrintControl_.getSuffix()); + axisNo_, error, pC_->getMsgPrintControl().getSuffix()); } resetError = false; @@ -728,7 +728,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { "for errors (if available). Otherwise please call " "the support.", axisNo_, error); - pl_status = setStringParam(pC_->motorMessageText_, command); + pl_status = setStringParam(pC_->motorMessageText(), command); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, @@ -741,13 +741,13 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { case 13: // Driver hardware error triggered - if (pC_->msgPrintControl_.shouldBePrinted(keyError, true, - pC_->pasynUserSelf)) { - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, + pC_->asynUserSelf())) { + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nDriver " "hardware error triggered.%s\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, - pC_->msgPrintControl_.getSuffix()); + pC_->getMsgPrintControl().getSuffix()); } resetError = false; @@ -755,7 +755,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { "Driver hardware error (P%2.2d01 = 13). " "Please call the support.", axisNo_); - pl_status = setStringParam(pC_->motorMessageText_, command); + pl_status = setStringParam(pC_->motorMessageText(), command); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, @@ -768,13 +768,13 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { // EPICS should already prevent this issue in the first place, // since it contains the user limits - if (pC_->msgPrintControl_.shouldBePrinted(keyError, true, - pC_->pasynUserSelf)) { - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, + pC_->asynUserSelf())) { + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nMove " "command exceeds hardware limits (P%2.2d01 = %d).%s\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, - axisNo_, error, pC_->msgPrintControl_.getSuffix()); + axisNo_, error, pC_->getMsgPrintControl().getSuffix()); } resetError = false; @@ -782,7 +782,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { "Move command exceeds hardware limits (P%2.2d01 = %d). Please " "call the support.", axisNo_, error); - pl_status = setStringParam(pC_->motorMessageText_, userMessage); + pl_status = setStringParam(pC_->motorMessageText(), userMessage); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, @@ -793,21 +793,21 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { break; default: - if (pC_->msgPrintControl_.shouldBePrinted(keyError, true, - pC_->pasynUserSelf)) { + if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, + pC_->asynUserSelf())) { asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_ERROR, + pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nUnknown error " "P%2.2d01 = %d.%s\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, axisNo_, - error, pC_->msgPrintControl_.getSuffix()); + error, pC_->getMsgPrintControl().getSuffix()); } resetError = false; snprintf(userMessage, sizeof(userMessage), "Unknown error P%2.2d01 = %d. Please call the support.", axisNo_, error); - pl_status = setStringParam(pC_->motorMessageText_, userMessage); + pl_status = setStringParam(pC_->motorMessageText(), userMessage); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, @@ -819,12 +819,12 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { } if (resetError) { - pC_->msgPrintControl_.resetCount(keyError, pC_->pasynUserSelf); + pC_->getMsgPrintControl().resetCount(keyError, pC_->asynUserSelf()); } // Update the parameter library if (error != 0) { - pl_status = setIntegerParam(pC_->motorStatusProblem_, true); + pl_status = setIntegerParam(pC_->motorStatusProblem(), true); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_", axisNo_, __PRETTY_FUNCTION__, @@ -833,7 +833,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { } if (*moving == false) { - pl_status = setIntegerParam(pC_->motorMoveToHome_, 0); + pl_status = setIntegerParam(pC_->motorMoveToHome(), 0); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMoveToHome_", axisNo_, __PRETTY_FUNCTION__, @@ -841,28 +841,28 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { } } - pl_status = setIntegerParam(pC_->motorStatusMoving_, *moving); + pl_status = setIntegerParam(pC_->motorStatusMoving(), *moving); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorStatusMoving_", axisNo_, __PRETTY_FUNCTION__, __LINE__); } - pl_status = setIntegerParam(pC_->motorStatusDone_, !(*moving)); + pl_status = setIntegerParam(pC_->motorStatusDone(), !(*moving)); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorStatusDone_", axisNo_, __PRETTY_FUNCTION__, __LINE__); } - pl_status = setIntegerParam(pC_->motorStatusDirection_, direction); + pl_status = setIntegerParam(pC_->motorStatusDirection(), direction); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorStatusDirection_", axisNo_, __PRETTY_FUNCTION__, __LINE__); } - pl_status = - pC_->setDoubleParam(axisNo_, pC_->motorHighLimitFromDriver_, highLimit); + pl_status = pC_->setDoubleParam(axisNo_, pC_->motorHighLimitFromDriver(), + highLimit); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorHighLimitFromDriver_", axisNo_, __PRETTY_FUNCTION__, @@ -870,7 +870,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { } pl_status = - pC_->setDoubleParam(axisNo_, pC_->motorLowLimitFromDriver_, lowLimit); + pC_->setDoubleParam(axisNo_, pC_->motorLowLimitFromDriver(), lowLimit); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorLowLimit_", axisNo_, __PRETTY_FUNCTION__, __LINE__); @@ -880,7 +880,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) { // turboPmacAxis::init()) currentPosition = currentPosition / motorRecResolution; - pl_status = setDoubleParam(pC_->motorPosition_, currentPosition); + pl_status = setDoubleParam(pC_->motorPosition(), currentPosition); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorPosition_", axisNo_, __PRETTY_FUNCTION__, __LINE__); @@ -909,13 +909,13 @@ asynStatus turboPmacAxis::doMove(double position, int relative, // ========================================================================= - pl_status = pC_->getIntegerParam(axisNo_, pC_->motorEnableRBV_, &enabled); + pl_status = pC_->getIntegerParam(axisNo_, pC_->motorEnableRBV(), &enabled); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "enableMotorRBV_", axisNo_, __PRETTY_FUNCTION__, __LINE__); } - pl_status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution_, + pl_status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution(), &motorRecResolution); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorRecResolution_", @@ -925,7 +925,7 @@ asynStatus turboPmacAxis::doMove(double position, int relative, if (enabled == 0) { asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_ERROR, + pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nAxis is disabled.\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__); return asynSuccess; @@ -935,13 +935,13 @@ asynStatus turboPmacAxis::doMove(double position, int relative, motorCoordinatesPosition = position * motorRecResolution; motorVelocity = maxVelocity * motorRecResolution; - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_FLOW, + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_FLOW, "Controller \"%s\", axis %d => %s, line %d\nStart of axis to " "position %lf.\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, position); // Check if the speed is allowed to be changed - pl_status = pC_->getIntegerParam(axisNo_, pC_->motorCanSetSpeed_, + pl_status = pC_->getIntegerParam(axisNo_, pC_->motorCanSetSpeed(), &motorCanSetSpeed); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorCanSetSpeed_", @@ -957,7 +957,7 @@ asynStatus turboPmacAxis::doMove(double position, int relative, motorVelocity); writeOffset = strlen(command); - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_FLOW, + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_FLOW, "Controller \"%s\", axis %d => %s, line %d\nSetting speed " "to %lf.\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, @@ -981,12 +981,12 @@ asynStatus turboPmacAxis::doMove(double position, int relative, if (rw_status != asynSuccess) { asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_ERROR, + pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nStarting movement to " "target position %lf failed.\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, motorCoordinatesPosition); - pl_status = setIntegerParam(pC_->motorStatusProblem_, true); + pl_status = setIntegerParam(pC_->motorStatusProblem(), true); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_", axisNo_, __PRETTY_FUNCTION__, @@ -1026,12 +1026,12 @@ asynStatus turboPmacAxis::stop(double acceleration) { if (rw_status != asynSuccess) { asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_ERROR, + pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nStopping the movement " "failed.\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__); - pl_status = setIntegerParam(pC_->motorStatusProblem_, true); + pl_status = setIntegerParam(pC_->motorStatusProblem(), true); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_", axisNo_, __PRETTY_FUNCTION__, @@ -1058,15 +1058,15 @@ asynStatus turboPmacAxis::reset() { snprintf(command, sizeof(command), "P%2.2d01=0", axisNo_); rw_status = pC_->writeRead(axisNo_, command, response, 0); - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, "Resetting\n"); + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Resetting\n"); if (rw_status != asynSuccess) { - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nResetting the " "error failed\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__); - pl_status = setIntegerParam(pC_->motorStatusProblem_, true); + pl_status = setIntegerParam(pC_->motorStatusProblem(), true); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_", axisNo_, __PRETTY_FUNCTION__, @@ -1093,7 +1093,7 @@ asynStatus turboPmacAxis::doHome(double min_velocity, double max_velocity, // ========================================================================= - pl_status = pC_->getStringParam(axisNo_, pC_->encoderType_, + pl_status = pC_->getStringParam(axisNo_, pC_->encoderType(), sizeof(response), response); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "encoderType_", axisNo_, @@ -1109,14 +1109,14 @@ asynStatus turboPmacAxis::doHome(double min_velocity, double max_velocity, return rw_status; } - pl_status = setIntegerParam(pC_->motorMoveToHome_, 1); + pl_status = setIntegerParam(pC_->motorMoveToHome(), 1); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMoveToHome_", axisNo_, __PRETTY_FUNCTION__, __LINE__); } - pl_status = setStringParam(pC_->motorMessageText_, "Homing"); + pl_status = setStringParam(pC_->motorMessageText(), "Homing"); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, @@ -1124,7 +1124,7 @@ asynStatus turboPmacAxis::doHome(double min_velocity, double max_velocity, } return callParamCallbacks(); } else { - pl_status = setStringParam(pC_->motorMessageText_, + pl_status = setStringParam(pC_->motorMessageText(), "Can't home a motor with absolute encoder"); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", @@ -1183,9 +1183,9 @@ asynStatus turboPmacAxis::readEncoderType() { // If true, the encoder is incremental if (encoder_id <= number_of_axes) { - pl_status = setStringParam(pC_->encoderType_, IncrementalEncoder); + pl_status = setStringParam(pC_->encoderType(), IncrementalEncoder); } else { - pl_status = setStringParam(pC_->encoderType_, AbsoluteEncoder); + pl_status = setStringParam(pC_->encoderType(), AbsoluteEncoder); } if (pl_status != asynSuccess) { @@ -1222,7 +1222,7 @@ asynStatus turboPmacAxis::rereadEncoder() { if (rw_status != asynSuccess) { return rw_status; } - pl_status = pC_->getStringParam(axisNo_, pC_->encoderType_, + pl_status = pC_->getStringParam(axisNo_, pC_->encoderType(), sizeof(encoderType), encoderType); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "encoderType_", axisNo_, @@ -1231,7 +1231,7 @@ asynStatus turboPmacAxis::rereadEncoder() { // Abort if the axis is incremental if (strcmp(encoderType, IncrementalEncoder) == 0) { - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_FLOW, + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_FLOW, "Controller \"%s\", axis %d => %s, line %d\nEncoder is " "not reread because it is incremental.\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__); @@ -1241,19 +1241,19 @@ asynStatus turboPmacAxis::rereadEncoder() { // Check if the axis is disabled. If not, inform the user that this // is necessary int enabled = 0; - pl_status = pC_->getIntegerParam(axisNo_, pC_->motorEnableRBV_, &enabled); + pl_status = pC_->getIntegerParam(axisNo_, pC_->motorEnableRBV(), &enabled); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "enableMotorRBV_", axisNo_, __PRETTY_FUNCTION__, __LINE__); } if (enabled == 1) { - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_WARNING, + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_WARNING, "Controller \"%s\", axis %d => %s, line %d\nAxis must be " "disabled before rereading the encoder.\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__); pl_status = setStringParam( - pC_->motorMessageText_, + pC_->motorMessageText(), "Axis must be disabled before rereading the encoder."); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", @@ -1264,7 +1264,7 @@ asynStatus turboPmacAxis::rereadEncoder() { } else { snprintf(command, sizeof(command), "M%2.2d=15", axisNo_); asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_FLOW, + pC_->asynUserSelf(), ASYN_TRACE_FLOW, "Controller \"%s\", axis %d => %s, line %d\nRereading absolute " "encoder via command %s.\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, command); @@ -1279,7 +1279,7 @@ asynStatus turboPmacAxis::rereadEncoder() { // turn off parameter as finished rereading // this will only be immediately noticed in the read back variable // though - pl_status = pC_->setIntegerParam(pC_->rereadEncoderPosition_, 0); + pl_status = pC_->setIntegerParam(pC_->rereadEncoderPosition(), 0); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "rereadEncoderPosition_", axisNo_, __PRETTY_FUNCTION__, @@ -1311,13 +1311,13 @@ asynStatus turboPmacAxis::enable(bool on) { // actually be disabled in this state! if (axisStatus_ == 1 || axisStatus_ == 2 || axisStatus_ == 3 || axisStatus_ == 4 || axisStatus_ == 5) { - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nAxis is not " "idle and can therefore not be enabled / disabled.\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__); pl_status = - setStringParam(pC_->motorMessageText_, + setStringParam(pC_->motorMessageText(), "Axis cannot be disabled while it is moving."); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", @@ -1332,7 +1332,7 @@ asynStatus turboPmacAxis::enable(bool on) { // was sent => Do nothing if ((axisStatus_ != -3) == on) { asynPrint( - pC_->pasynUserSelf, ASYN_TRACE_WARNING, + pC_->asynUserSelf(), ASYN_TRACE_WARNING, "Controller \"%s\", axis %d => %s, line %d\nAxis is already %s.\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, on ? "enabled" : "disabled"); @@ -1349,14 +1349,14 @@ asynStatus turboPmacAxis::enable(bool on) { // Enable / disable the axis if it is not moving snprintf(command, sizeof(command), "M%2.2d14=%d", axisNo_, on); - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_FLOW, + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_FLOW, "Controller \"%s\", axis %d => %s, line %d\n%s axis\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, on ? "Enable" : "Disable"); if (on == 0) { - pl_status = setStringParam(pC_->motorMessageText_, "Disabling ..."); + pl_status = setStringParam(pC_->motorMessageText(), "Disabling ..."); } else { - pl_status = setStringParam(pC_->motorMessageText_, "Enabling ..."); + pl_status = setStringParam(pC_->motorMessageText(), "Enabling ..."); } if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", @@ -1396,7 +1396,7 @@ asynStatus turboPmacAxis::enable(bool on) { // Failed to change axis status within timeout_enable_disable => Send a // corresponding message - asynPrint(pC_->pasynUserSelf, ASYN_TRACE_FLOW, + asynPrint(pC_->asynUserSelf(), ASYN_TRACE_FLOW, "Controller \"%s\", axis %d => %s, line %d\nFailed to %s axis " "within %d seconds\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, @@ -1405,7 +1405,7 @@ asynStatus turboPmacAxis::enable(bool on) { // Output message to user snprintf(command, sizeof(command), "Failed to %s within %d seconds", on ? "enable" : "disable", timeout_enable_disable); - pl_status = setStringParam(pC_->motorMessageText_, "Enabling ..."); + pl_status = setStringParam(pC_->motorMessageText(), "Enabling ..."); if (pl_status != asynSuccess) { return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", axisNo_, __PRETTY_FUNCTION__, diff --git a/src/turboPmacAxis.h b/src/turboPmacAxis.h index 1a76dd9..f8a5bcb 100644 --- a/src/turboPmacAxis.h +++ b/src/turboPmacAxis.h @@ -120,9 +120,6 @@ class turboPmacAxis : public sinqAxis { // The axis status is used when enabling / disabling the motor int axisStatus_; - - private: - friend class turboPmacController; }; #endif diff --git a/src/turboPmacController.h b/src/turboPmacController.h index ab913ad..74585eb 100644 --- a/src/turboPmacController.h +++ b/src/turboPmacController.h @@ -73,9 +73,6 @@ class turboPmacController : public sinqController { */ virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value); - protected: - asynUser *lowLevelPortUser_; - /** * @brief Send a command to the hardware and receive a response * @@ -118,12 +115,18 @@ class turboPmacController : public sinqController { const char *functionName, int lineNumber); - protected: + // Accessors for additional PVs + int rereadEncoderPosition() { return rereadEncoderPosition_; } + int readConfig() { return readConfig_; } + // Set the maximum buffer size. This is an empirical value which must be // large enough to avoid overflows for all commands to the device / // responses from it. static const uint32_t MAXBUF_ = 200; + protected: + asynUser *lowLevelPortUser_; + /* Timeout for the communication process in seconds */ @@ -136,8 +139,6 @@ class turboPmacController : public sinqController { int rereadEncoderPosition_; int readConfig_; #define LAST_turboPmac_PARAM readConfig_ - - friend class turboPmacAxis; }; #define NUM_turboPmac_DRIVER_PARAMS \ (&LAST_turboPmac_PARAM - &FIRST_turboPmac_PARAM + 1)