From de4040d181bcb509db9a0058d4d4c30c2cbbd9a8 Mon Sep 17 00:00:00 2001 From: mp49 Date: Fri, 29 Jul 2011 10:17:08 +0000 Subject: [PATCH] motor: added shell function to XPS model 3 driver to disable auto enable of axes when attempting a move. This is done on a per controller basis. Call XPSDisableAutoEnable(port) at the shell. --- motorApp/NewportSrc/XPSAxis.cpp | 22 +++++++++----- motorApp/NewportSrc/XPSController.cpp | 42 ++++++++++++++++++++++++++- motorApp/NewportSrc/XPSController.h | 4 +++ 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/motorApp/NewportSrc/XPSAxis.cpp b/motorApp/NewportSrc/XPSAxis.cpp index 6b163845..17e872b0 100644 --- a/motorApp/NewportSrc/XPSAxis.cpp +++ b/motorApp/NewportSrc/XPSAxis.cpp @@ -211,15 +211,21 @@ asynStatus XPSAxis::move(double position, int relative, double min_velocity, dou driverName, functionName, pC_->portName, axisNo_, position, min_velocity, max_velocity, acceleration, minJerk, maxJerk); /* Look at the last poll value of the positioner status. If it is disabled, then enable it */ - if (axisStatus_ >= 20 && axisStatus_ <= 36) { - status = GroupMotionEnable(pollSocket_, groupName_); - if (status) { - asynPrint(pasynUser_, ASYN_TRACE_ERROR, - "%s:%s: motorAxisMove[%s,%d]: error performing GroupMotionEnable %d\n", - driverName, functionName, pC_->portName, axisNo_, status); - /* Error -27 is caused when the motor record changes dir i.e. when it aborts a move!*/ - return asynError; + /* This can be disabled by calling XPSDisableAutoEnable() at the IOC shell.*/ + if (pC_->autoEnable_) { + if (axisStatus_ >= 20 && axisStatus_ <= 36) { + status = GroupMotionEnable(pollSocket_, groupName_); + if (status) { + asynPrint(pasynUser_, ASYN_TRACE_ERROR, + "%s:%s: motorAxisMove[%s,%d]: error performing GroupMotionEnable %d\n", + driverName, functionName, pC_->portName, axisNo_, status); + /* Error -27 is caused when the motor record changes dir i.e. when it aborts a move!*/ + return asynError; + } } + } else { + //Return error if a move is attempted and auto enable is turned off. + return asynError; } status = PositionerSGammaParametersSet(pollSocket_, positionerName_, diff --git a/motorApp/NewportSrc/XPSController.cpp b/motorApp/NewportSrc/XPSController.cpp index 77284bf3..4f14cbde 100644 --- a/motorApp/NewportSrc/XPSController.cpp +++ b/motorApp/NewportSrc/XPSController.cpp @@ -193,6 +193,9 @@ XPSController::XPSController(const char *portName, const char *IPAddress, int IP epicsThreadGetStackSize(epicsThreadStackMedium), (EPICSTHREADFUNC)XPSProfileThreadC, (void *)this); + //By default, automatically enable axes that have been disabled. + autoEnable_ = 1; + } void XPSController::report(FILE *fp, int level) @@ -1268,6 +1271,14 @@ asynStatus XPSController::readbackProfile() return status ? asynError : asynSuccess; } +/* Function to disable the automatic enable of axes when moving */ +asynStatus XPSController::disableAutoEnable() +{ + autoEnable_ = 0; + return asynSuccess; +} + + /** The following functions have C linkage, and can be called directly or from iocsh */ @@ -1332,6 +1343,22 @@ asynStatus XPSConfigProfile(const char *XPSName, /* specify which contro } +asynStatus XPSDisableAutoEnable(const char *XPSName) +{ + XPSController *pC; + static const char *functionName = "XPSDisableAutoEnable"; + + pC = (XPSController*) findAsynPortDriver(XPSName); + if (!pC) { + printf("%s:%s: Error port %s not found\n", + driverName, functionName, XPSName); + return asynError; + } + + return pC->disableAutoEnable(); +} + + /* Code for iocsh registration */ @@ -1395,13 +1422,26 @@ static void configXPSProfileCallFunc(const iocshArgBuf *args) { XPSConfigProfile(args[0].sval, args[1].ival, args[2].sval, args[3].sval); } + + +/* XPSDisableAutoEnable */ +static const iocshArg XPSDisableAutoEnableArg0 = {"Controller port name", iocshArgString}; +static const iocshArg * const XPSDisableAutoEnableArgs[] = {&XPSDisableAutoEnableArg0}; +static const iocshFuncDef disableAutoEnable = {"XPSDisableAutoEnable", 1, XPSDisableAutoEnableArgs}; + +static void disableAutoEnableCallFunc(const iocshArgBuf *args) +{ + XPSDisableAutoEnable(args[0].sval); +} + + static void XPSRegister3(void) { iocshRegister(&configXPS, configXPSCallFunc); iocshRegister(&configXPSAxis, configXPSAxisCallFunc); iocshRegister(&configXPSProfile, configXPSProfileCallFunc); + iocshRegister(&disableAutoEnable, disableAutoEnableCallFunc); } epicsExportRegistrar(XPSRegister3); - } // extern "C" diff --git a/motorApp/NewportSrc/XPSController.h b/motorApp/NewportSrc/XPSController.h index ea0cf5d9..5daedd89 100644 --- a/motorApp/NewportSrc/XPSController.h +++ b/motorApp/NewportSrc/XPSController.h @@ -55,6 +55,9 @@ class XPSController : public asynMotorController { asynStatus processDeferredMoves(); asynStatus processDeferredMovesInGroup(char * groupName); + /*Disable automatic enable of axes.*/ + asynStatus disableAutoEnable(); + protected: XPSAxis **pAxes_; /**< Array of pointers to axis objects */ @@ -82,6 +85,7 @@ class XPSController : public asynMotorController { char firmwareVersion_[100]; int movesDeferred_; epicsEventId profileExecuteEvent_; + int autoEnable_; friend class XPSAxis; };