Allow enable/disable (tentative)

This commit is contained in:
brambilla_m
2022-02-28 15:33:47 +01:00
parent 929f9f600d
commit c805385ad1
5 changed files with 177 additions and 65 deletions

View File

@@ -368,34 +368,6 @@ static char *translateAxisError(int axErr)
}
}
asynStatus pmacV3Axis::getAxisStatus(bool *moving)
{
char command[pC_->PMAC_MAXBUF_];
char response[pC_->PMAC_MAXBUF_];
int cmdStatus = 0;
int done = 0, posChanging = 0;
double position = 0;
int nvals = 0;
int axisProblemFlag = 0;
epicsUInt32 axErr = 0, axStat = 0, highLim = 0, lowLim = 0;
char message[132], *axMessage;
/* read our status items one by one: our PMAC does not seem to give multiple
* responses ..*/
sprintf(command, "P%2.2d01", axisNo_);
cmdStatus = pC_->lowLevelWriteRead(axisNo_, command, response);
nvals = sscanf(response, "%d", &axErr);
if (cmdStatus || nvals != 1) {
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
"drvPmacAxisGetStatus: Failed to read axis Error Status: "
"%d\nCommand :%s\nResponse:%s\n",
cmdStatus, command, response);
updateMsgTxtFromDriver("Cannot read Axis Error Status");
}
}
asynStatus pmacAxis::getAxisStatus(bool *moving)
{
char command[pC_->PMAC_MAXBUF_];
@@ -625,6 +597,16 @@ asynStatus pmacHRPTAxis::getAxisStatus(bool *moving)
return result;
}
asynStatus pmacAxis::enable(int on) {
static const char *functionName = "pmacAxis::enable";
pC_->debugFlow(functionName);
// Cannot do this.
return asynSuccess;
}
/*================================= SeleneAxis code ======================================================*/
SeleneAxis::SeleneAxis(SeleneController *pC, int axisNo, double limitTarget)
: pmacAxis(pC, axisNo, false)
@@ -890,13 +872,13 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) {
double position = 0;
int nvals = 0;
int axisProblemFlag = 0;
epicsUInt32 axErr = 0, axStat = 0, highLim = 0, lowLim = 0;
epicsUInt32 axErr = 0, axStat = 0, highLim = 0, lowLim = 0, axDone = 0;
char message[132], *axMessage;
sprintf(command, "Q%2.2d10 P%2.2d00", axisNo_, axisNo_);
sprintf(command, "Q%2.2d10 P%2.2d00 P%2.2d23", axisNo_, axisNo_, axisNo_);
cmdStatus = pC_->lowLevelWriteRead(axisNo_, command, response);
nvals = sscanf(response, "%lf %d", &position, &axStat);
if (cmdStatus || nvals != 2) {
nvals = sscanf(response, "%lf %d %d", &position, &axStat, &axDone);
if (cmdStatus || nvals != 3) {
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
"drvPmacAxisGetStatus: Failed to read position and status, "
"Status: %d\nCommand :%s\nResponse:%s\n",
@@ -924,7 +906,7 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) {
// errlogPrintf("Polling, axStat = %d, position = %f\n", axStat, position);
/* are we done? */
if ((axStat == 0 || axStat == 14 || axStat < 0) && starting == 0) {
if ( axDone == 0 && starting == 0) {
done = 1;
} else {
starting = 0;
@@ -992,7 +974,7 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) {
}
sprintf(message, "poll results: axis %d, status %d, done = %d",
axisNo_, axStat, done);
axisNo_, axStat, axDone);
pC_->debugFlow(message);
if (*moving == false) {
@@ -1064,4 +1046,32 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) {
setIntegerParam(pC_->motorStatusProblem_, axisProblemFlag);
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;
// }