From 403eecafae03a13ee443d9f32644a42bbff3533c Mon Sep 17 00:00:00 2001 From: Michele Brambilla Date: Mon, 7 Mar 2022 16:40:46 +0100 Subject: [PATCH] pmac Enable PV successfully tested --- sinqEPICSApp/src/pmacAxis.cpp | 15 +++++++++++---- sinqEPICSApp/src/pmacAxis.h | 9 ++------- sinqEPICSApp/src/pmacController.cpp | 18 ++++++++++-------- sinqEPICSApp/src/pmacController.h | 3 +++ 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/sinqEPICSApp/src/pmacAxis.cpp b/sinqEPICSApp/src/pmacAxis.cpp index 895c57c..a2da5e9 100644 --- a/sinqEPICSApp/src/pmacAxis.cpp +++ b/sinqEPICSApp/src/pmacAxis.cpp @@ -909,9 +909,13 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) { double position = 0; int nvals = 0; int axisProblemFlag = 0; - epicsUInt32 axErr = 0, axStat = 0, highLim = 0, lowLim = 0, axDone = 0; + epicsUInt32 axErr = 0, highLim = 0, lowLim = 0, axDone = 0; + int axStat=0; char message[132], *axMessage; + static const char *functionName = "pmacV3Axis::getAxisStatus"; + + pmacV3Controller* p3C_ = (pmacV3Controller*)pC_; sprintf(command, "Q%2.2d10 P%2.2d00 P%2.2d23", axisNo_, axisNo_, axisNo_); cmdStatus = pC_->lowLevelWriteRead(axisNo_, command, response); nvals = sscanf(response, "%lf %d %d", &position, &axStat, &axDone); @@ -923,6 +927,9 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) { updateMsgTxtFromDriver("Cannot read Axis position and status"); } + // printf("axStat: %d\n", axStat); + setIntegerParam(p3C_->axisState_, axStat); + setDoubleParam(pC_->motorPosition_, position * MULT); setDoubleParam(pC_->motorEncoderPosition_, position * MULT); @@ -940,8 +947,6 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) { previous_position_ = position; previous_direction_ = direction; - setIntegerParam(pC_->axisStatus_, axStat); - // errlogPrintf("Polling, axStat = %d, position = %f\n", axStat, position); /* are we done? */ @@ -1059,10 +1064,11 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) { /* Set any axis specific general problem bits. */ } - if (axStat < 0 || axErr != 0) { + if ((axStat < 0 && axStat != -3) || axErr != 0) { axisProblemFlag = 1; if (axisErrorCount < 10) { axMessage = translateAxisError(axErr); + printf("axErr: %d\taxStat: %d\taxMessage: %s\n", axErr, axStat, axMessage); asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, "drvPmacAxisGetStatus: Axis %d is in deep trouble: axis error " "code %d, translated: %s:, status code = %d\n", @@ -1084,6 +1090,7 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) { } setIntegerParam(pC_->motorStatusProblem_, axisProblemFlag); + callParamCallbacks(); return asynSuccess; } diff --git a/sinqEPICSApp/src/pmacAxis.h b/sinqEPICSApp/src/pmacAxis.h index e38bff4..90b530f 100644 --- a/sinqEPICSApp/src/pmacAxis.h +++ b/sinqEPICSApp/src/pmacAxis.h @@ -68,6 +68,7 @@ protected: bool autoEnable; friend class pmacController; + friend class pmacV3Controller; }; /*----------------------------------------------------------------------------------------------*/ class pmacHRPTAxis : public pmacAxis @@ -142,16 +143,10 @@ class pmacV3Axis : public pmacAxis { public: pmacV3Axis(pmacController *pController, int axisNo); - /* : pmacAxis(pController,axisNo, false) { */ -/* printf("\n*************************\n\n"); */ -/* printf("class name: %s", getClassName(*this)); */ -/* printf("\n*************************\n\n"); */ -/* }; */ + asynStatus poll(bool *moving); protected: - int axisState_; - asynStatus getAxisStatus(bool *moving); friend class pmacController; diff --git a/sinqEPICSApp/src/pmacController.cpp b/sinqEPICSApp/src/pmacController.cpp index 9a5c8bc..b35cda4 100644 --- a/sinqEPICSApp/src/pmacController.cpp +++ b/sinqEPICSApp/src/pmacController.cpp @@ -858,23 +858,25 @@ asynStatus pmacV3Controller::readInt32(asynUser *pasynUser, epicsInt32 *value) { int function = pasynUser->reason; asynStatus status = asynError; - pmacAxis *pAxis = NULL; - static const char *functionName = "pmacController::readInt32"; - char command[this->PMAC_MAXBUF_]; - char response[this->PMAC_MAXBUF_]; + pmacV3Axis *pAxis = NULL; + static const char *functionName = "pmacV3Controller::readInt32"; + char command[128]; + char response[128]; debugFlow(functionName); - pAxis = this->getAxis(pasynUser); + pAxis = (pmacV3Axis*)(this->getAxis(pasynUser)); if (!pAxis) { return asynError; } if (function == axisState_) { snprintf(command, sizeof(command), "P%2.2d00", pAxis->axisNo_); - status = this->lowLevelWriteRead(axisNo_, command, response); + status = this->lowLevelWriteRead(pAxis->axisNo_, command, response); *value = strtol(response, NULL, 10); - setIntegerParam(pAxis->axisState_, value); - return status + + setIntegerParam(axisState_, *value); + callParamCallbacks(); + return status; } return pmacController::readInt32(pasynUser, value); } diff --git a/sinqEPICSApp/src/pmacController.h b/sinqEPICSApp/src/pmacController.h index 647d021..4f0ba64 100644 --- a/sinqEPICSApp/src/pmacController.h +++ b/sinqEPICSApp/src/pmacController.h @@ -183,7 +183,10 @@ public: friend class pmacAxis; protected: + pmacV3Axis **pAxes_; /**< Array of pointers to axis objects */ + int enableAxis_; + int axisState_; }; #endif /* pmacController_H */