From 9809a4be5bcbb062e8e706c5c9fb99d97e340d9f Mon Sep 17 00:00:00 2001 From: MarkRivers Date: Thu, 1 Mar 2012 20:07:15 +0000 Subject: [PATCH] New ACRAxis::setClosedLoop and ACRAxis::report methods; moved per-axis reporting out of ACRController::report into ACRAxis::report --- motorApp/ACRSrc/ACRMotorDriver.cpp | 68 +++++++++++++++++------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/motorApp/ACRSrc/ACRMotorDriver.cpp b/motorApp/ACRSrc/ACRMotorDriver.cpp index 46c884b9..9b4a6479 100644 --- a/motorApp/ACRSrc/ACRMotorDriver.cpp +++ b/motorApp/ACRSrc/ACRMotorDriver.cpp @@ -112,29 +112,15 @@ extern "C" int ACRCreateController(const char *portName, const char *ACRPortName */ void ACRController::report(FILE *fp, int level) { - int axis; - ACRAxis *pAxis; - fprintf(fp, "ACR motor driver %s, numAxes=%d, moving poll period=%f, idle poll period=%f\n", this->portName, numAxes_, movingPollPeriod_, idlePollPeriod_); if (level > 0) { fprintf(fp, " binary input = 0x%x\n", binaryIn_); fprintf(fp, " binary output readback = 0x%x\n", binaryOutRBV_); - for (axis=0; axisaxisNo_, pAxis->pulsesPerUnit_, - pAxis->encoderPosition_, pAxis->theoryPosition_, - pAxis->currentLimits_, pAxis->currentFlags_); - } } + // Call the base class method asynMotorController::report(fp, level); } @@ -172,20 +158,11 @@ asynStatus ACRController::writeInt32(asynUser *pasynUser, epicsInt32 value) ACRAxis *pAxis = getAxis(pasynUser); static const char *functionName = "writeInt32"; - /* Set the parameter and readback in the parameter library. This may be overwritten when we read back the * status at the end, but that's OK */ status = setIntegerParam(pAxis->axisNo_, function, value); - if (function == motorSetClosedLoop_) - { - sprintf(outString_, "DRIVE %s %s", value ? "ON":"OFF", pAxis->axisName_); - writeController(); - asynPrint(pasynUser, ASYN_TRACE_FLOW, - "%s:%s: %s setting closed loop=%d on %s\n", - driverName, functionName, this->portName, value, pAxis->axisName_); - } - else if (function == ACRReadBinaryIO_) + if (function == ACRReadBinaryIO_) { readBinaryIO(); } @@ -387,6 +364,32 @@ ACRAxis::ACRAxis(ACRController *pC, int axisNo) callParamCallbacks(); } +/** Reports on status of the driver + * \param[in] fp The file pointer on which report information will be written + * \param[in] level The level of report detail desired + * + * If details > 0 then information is printed about each axis. + * After printing controller-specific information calls asynMotorController::report() + */ +void ACRAxis::report(FILE *fp, int level) +{ + if (level > 0) { + fprintf(fp, " axis %d\n" + " pulsesPerUnit_ = %f\n" + " encoder position=%f\n" + " theory position=%f\n" + " limits=0x%x\n" + " flags=0x%x\n", + axisNo_, pulsesPerUnit_, + encoderPosition_, theoryPosition_, + currentLimits_, currentFlags_); + } + + // Call the base class method + asynMotorAxis::report(fp, level); +} + + asynStatus ACRAxis::move(double position, int relative, double minVelocity, double maxVelocity, double acceleration) { asynStatus status; @@ -444,14 +447,10 @@ asynStatus ACRAxis::moveVelocity(double minVelocity, double maxVelocity, double asynStatus ACRAxis::stop(double acceleration ) { asynStatus status; - static const char *functionName = "stopAxis"; + //static const char *functionName = "stopAxis"; sprintf(pC_->outString_, "%s JOG OFF", axisName_); status = pC_->writeController(); - - asynPrint(pasynUser_, ASYN_TRACE_FLOW, - "%s:%s: Set axis %d to stop, status=%d\n", - driverName, functionName, axisNo_, status); return status; } @@ -466,6 +465,15 @@ asynStatus ACRAxis::setPosition(double position) return status; } +asynStatus ACRAxis::setClosedLoop(bool closedLoop) +{ + asynStatus status; + + sprintf(pC_->outString_, "DRIVE %s %s", closedLoop ? "ON":"OFF", axisName_); + status = pC_->writeController(); + return status; +} + /** Polls the axis. * This function reads the controller position, encoder position, the limit status, the moving status, * and the drive power-on status. It does not current detect following error, etc. but this could be