diff --git a/sinqEPICSApp/src/pmacAxis.cpp b/sinqEPICSApp/src/pmacAxis.cpp index 4b8f5b7..895c57c 100644 --- a/sinqEPICSApp/src/pmacAxis.cpp +++ b/sinqEPICSApp/src/pmacAxis.cpp @@ -172,7 +172,6 @@ asynStatus pmacAxis::getAxisInitialStatus(void) // Enable the axis. After startup, the axis are disabled on the controller... // Warning: Selene lift axis should not be automatically enabled - if (autoEnable) { sprintf(command, "M%2.2d14=1\n", axisNo_); asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, "Enable axis %d: %s",axisNo_,command); @@ -941,6 +940,8 @@ 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? */ @@ -1086,30 +1087,4 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) { return asynSuccess; } -// pmacV3Axis::enable(int on) { -// char command[pC_->PMAC_MAXBUF_]; -// char response[pC_->PMAC_MAXBUF_]; -// int cmdStatus = 0; -// static const char *functionName = "pmacV3Axis::enable"; - -// pC_->debugFlow(functionName); - -// // Enable the axis. After startup, the axis are disabled on the controller... -// sprintf(command, "M%2.2d14=%1.1d", axisNo_, on); -// cmdStatus = pC_->lowLevelWriteRead(axisNo_, command, response); -// if (cmdStatus) { -// if(on) { -// asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, -// "%s: Error: enabling axis %d failed.\n", functionName, axisNo_); -// } else { -// asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, -// "%s: Error: disabling axis %d failed.\n", functionName, axisNo_); -// } -// return asynError; -// } - -// callParamCallbacks(); - -// return asynSuccess; -// } diff --git a/sinqEPICSApp/src/pmacAxis.h b/sinqEPICSApp/src/pmacAxis.h index ac317c6..e38bff4 100644 --- a/sinqEPICSApp/src/pmacAxis.h +++ b/sinqEPICSApp/src/pmacAxis.h @@ -24,8 +24,6 @@ class pmacController; class SeleneController; -#define PMAC_EnableAxis "PMAC_ENABLE_AXIS" - class pmacAxis : public SINQAxis { public: @@ -152,6 +150,8 @@ public: 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 93bbc9e..9a5c8bc 100644 --- a/sinqEPICSApp/src/pmacController.cpp +++ b/sinqEPICSApp/src/pmacController.cpp @@ -472,7 +472,6 @@ asynStatus pmacController::writeInt32(asynUser *pasynUser, epicsInt32 value) } - /** Returns a pointer to an pmacAxis object. * Returns NULL if the axis number encoded in pasynUser is invalid. * \param[in] pasynUser asynUser structure that encodes the axis index number. */ @@ -581,6 +580,7 @@ SeleneController::SeleneController(const char *portName, const char *lowLevelPor pmacController(portName, lowLevelPortName, lowLevelPortAddress, numAxes, movingPollPeriod, idlePollPeriod, extraParams) { static const char *functionName = "pmacV3Controller::pmacV3Controller"; createParam(EnableAxisString, asynParamInt32, &enableAxis_); + createParam(AxisStateString, asynParamInt32, &axisState_); callParamCallbacks(); } @@ -854,6 +854,32 @@ asynStatus pmacV3Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) { return status; } +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_]; + + debugFlow(functionName); + + pAxis = 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); + *value = strtol(response, NULL, 10); + setIntegerParam(pAxis->axisState_, value); + return status + } + return pmacController::readInt32(pasynUser, value); +} + + /* Code for iocsh registration */ #ifdef vxWorks diff --git a/sinqEPICSApp/src/pmacController.h b/sinqEPICSApp/src/pmacController.h index 7bf1969..647d021 100644 --- a/sinqEPICSApp/src/pmacController.h +++ b/sinqEPICSApp/src/pmacController.h @@ -165,6 +165,7 @@ class SeleneController : public pmacController { }; #define EnableAxisString "ENABLE_AXIS" +#define AxisStateString "AXIS_STATE" class pmacV3Controller : public pmacController { public: @@ -175,6 +176,9 @@ public: // overloaded because we want to enable/disable the motor asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value); + // overloaded because we want to read the axis state + asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value); + friend class pmacV3Axis; friend class pmacAxis;