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).

This commit is contained in:
mp49
2011-07-29 10:46:56 +00:00
parent 3a65e1060d
commit 12d5e53ee8
3 changed files with 67 additions and 16 deletions
+24 -14
View File
@@ -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;
}
+40 -2
View File
@@ -79,6 +79,10 @@ Versions: Release 4-5 and higher.
LOSS OR DAMAGES.
*/
#include <iostream>
using std::cout;
using std::endl;
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -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);
+3
View File
@@ -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;
};