From 12d5e53ee80e74e9ba0133591f7dda96e82ceff7 Mon Sep 17 00:00:00 2001 From: mp49 Date: Fri, 29 Jul 2011 10:46:56 +0000 Subject: [PATCH] motor: XPS model 3 driver. Added code to poller to check for error states. Added function to disable MSTA problem bit when in state 20 (disabled state). --- motorApp/NewportSrc/XPSAxis.cpp | 38 +++++++++++++++--------- motorApp/NewportSrc/XPSController.cpp | 42 +++++++++++++++++++++++++-- motorApp/NewportSrc/XPSController.h | 3 ++ 3 files changed, 67 insertions(+), 16 deletions(-) diff --git a/motorApp/NewportSrc/XPSAxis.cpp b/motorApp/NewportSrc/XPSAxis.cpp index 72387549..8843417d 100644 --- a/motorApp/NewportSrc/XPSAxis.cpp +++ b/motorApp/NewportSrc/XPSAxis.cpp @@ -588,29 +588,34 @@ asynStatus XPSAxis::poll(bool *moving) setIntegerParam(pC_->motorStatusHomed_, 0); } - if ((axisStatus_ >= 0 && axisStatus_ <= 9) || - (axisStatus_ >= 20 && axisStatus_ <= 42)) { - /* Not initialized, homed or disabled */ - asynPrint(pasynUser_, ASYN_TRACE_FLOW, - "%s:%s: [%s,%d]: in bad state %d\n", - driverName, functionName, pC_->portName, axisNo_, axisStatus_); - /* setIntegerParam(axis, motorStatusHighHardLimit, 1); - * setIntegerParam(axis, motorStatusLowHardLimit, 1); - */ - } - /* Test for following error, and set appropriate param. */ if ((axisStatus_ == 21 || axisStatus_ == 22) || (axisStatus_ >= 24 && axisStatus_ <= 26) || (axisStatus_ == 28 || axisStatus_ == 35)) { - asynPrint(pasynUser_, ASYN_TRACE_FLOW, - "%s:%s: [%s,%d]: in following error. XPS State Code: %d\n", - driverName, functionName, pC_->portName, axisNo_, axisStatus_); + asynPrint(pasynUser_, ASYN_TRACE_FLOW, + "%s:%s: [%s,%d]: in following error. XPS State Code: %d\n", + driverName, functionName, pC_->portName, axisNo_, axisStatus_); setIntegerParam(pC_->motorStatusFollowingError_, 1); } else { setIntegerParam(pC_->motorStatusFollowingError_, 0); } + /*Test for states that mean we cannot move an axis (disabled, uninitialised, etc.) + and set problem bit in MSTA.*/ + if ((axisStatus_ < 10) || ((axisStatus_ >= 20) && (axisStatus_ <= 42)) || + (axisStatus_ == 50) || (axisStatus_ == 64)) { + if ( (pC_->noDisableError_ > 0) && (axisStatus_==20) ) { + setIntegerParam(pC_->motorStatusProblem_, 0); + } else { + asynPrint(pasynUser_, ASYN_TRACE_FLOW, + "%s:%s: [%s,%d]: in unintialised/disabled/not referenced. XPS State Code: %d\n", + driverName, functionName, pC_->portName, axisNo_, axisStatus_); + setIntegerParam(pC_->motorStatusProblem_, 1); + } + } else { + setIntegerParam(pC_->motorStatusProblem_, 0); + } + status = GroupPositionCurrentGet(pollSocket_, positionerName_, 1, @@ -1167,3 +1172,8 @@ asynStatus XPSAxis::readbackProfile() asynMotorAxis::readbackProfile(); return asynSuccess; } + + + + + diff --git a/motorApp/NewportSrc/XPSController.cpp b/motorApp/NewportSrc/XPSController.cpp index 4f14cbde..5f0e0522 100644 --- a/motorApp/NewportSrc/XPSController.cpp +++ b/motorApp/NewportSrc/XPSController.cpp @@ -79,6 +79,10 @@ Versions: Release 4-5 and higher. LOSS OR DAMAGES. */ +#include +using std::cout; +using std::endl; + #include #include #include @@ -196,6 +200,9 @@ XPSController::XPSController(const char *portName, const char *IPAddress, int IP //By default, automatically enable axes that have been disabled. autoEnable_ = 1; + /* Flag used to turn off setting MSTA problem bit when the axis is disabled.*/ + noDisableError_ = 0; + } void XPSController::report(FILE *fp, int level) @@ -1278,6 +1285,13 @@ asynStatus XPSController::disableAutoEnable() return asynSuccess; } +/* Function to disable the MSTA problem bit in the event of an XPS Disable state 20 */ +asynStatus XPSController::noDisableError() +{ + noDisableError_ = 1; + return asynSuccess; +} + @@ -1350,8 +1364,7 @@ asynStatus XPSDisableAutoEnable(const char *XPSName) pC = (XPSController*) findAsynPortDriver(XPSName); if (!pC) { - printf("%s:%s: Error port %s not found\n", - driverName, functionName, XPSName); + cout << driverName << "::" << functionName << " Error port " << XPSName << "not found." << endl; return asynError; } @@ -1359,6 +1372,20 @@ asynStatus XPSDisableAutoEnable(const char *XPSName) } +asynStatus XPSNoDisableError(const char *XPSName) +{ + XPSController *pC; + static const char *functionName = "XPSNoDisableError"; + + pC = (XPSController*) findAsynPortDriver(XPSName); + if (!pC) { + cout << driverName << "::" << functionName << " Error port " << XPSName << "not found." << endl; + return asynError; + } + + return pC->noDisableError(); +} + /* Code for iocsh registration */ @@ -1434,6 +1461,16 @@ static void disableAutoEnableCallFunc(const iocshArgBuf *args) XPSDisableAutoEnable(args[0].sval); } +/* XPSNoDisableError */ +static const iocshArg XPSNoDisableErrorArg0 = {"Controller port name", iocshArgString}; +static const iocshArg * const XPSNoDisableErrorArgs[] = {&XPSNoDisableErrorArg0}; +static const iocshFuncDef noDisableError = {"XPSNoDisableError", 1, XPSNoDisableErrorArgs}; + +static void noDisableErrorCallFunc(const iocshArgBuf *args) +{ + XPSNoDisableError(args[0].sval); +} + static void XPSRegister3(void) { @@ -1441,6 +1478,7 @@ static void XPSRegister3(void) iocshRegister(&configXPSAxis, configXPSAxisCallFunc); iocshRegister(&configXPSProfile, configXPSProfileCallFunc); iocshRegister(&disableAutoEnable, disableAutoEnableCallFunc); + iocshRegister(&noDisableError, noDisableErrorCallFunc); } epicsExportRegistrar(XPSRegister3); diff --git a/motorApp/NewportSrc/XPSController.h b/motorApp/NewportSrc/XPSController.h index 5daedd89..390f2d9e 100644 --- a/motorApp/NewportSrc/XPSController.h +++ b/motorApp/NewportSrc/XPSController.h @@ -57,6 +57,8 @@ class XPSController : public asynMotorController { /*Disable automatic enable of axes.*/ asynStatus disableAutoEnable(); + /* Function to disable the MSTA problem bit in the event of an XPS Disable state 20 */ + asynStatus noDisableError(); protected: XPSAxis **pAxes_; /**< Array of pointers to axis objects */ @@ -86,6 +88,7 @@ class XPSController : public asynMotorController { int movesDeferred_; epicsEventId profileExecuteEvent_; int autoEnable_; + int noDisableError_; friend class XPSAxis; };