Some cleanup, force reload encoder before enable
This commit is contained in:
@ -940,11 +940,6 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) {
|
|||||||
st = setDoubleParam(pC_->motorEncoderPosition_, position * MULT);
|
st = setDoubleParam(pC_->motorEncoderPosition_, position * MULT);
|
||||||
cmdStatus = cmdStatus > st ? cmdStatus : st;
|
cmdStatus = cmdStatus > st ? cmdStatus : st;
|
||||||
|
|
||||||
if(axisNo_ == 2) {
|
|
||||||
printf("position(%d): %lf\n", axisNo_, position);
|
|
||||||
printf("ack(%d): %d\n", axisNo_, acknowledge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Use previous position and current position to calculate direction.*/
|
/* Use previous position and current position to calculate direction.*/
|
||||||
if ((position - previous_position_) > 0) {
|
if ((position - previous_position_) > 0) {
|
||||||
direction = 1;
|
direction = 1;
|
||||||
@ -961,65 +956,65 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) {
|
|||||||
previous_direction_ = direction;
|
previous_direction_ = direction;
|
||||||
|
|
||||||
/* are we done? */
|
/* are we done? */
|
||||||
if ((axStat == 0 || axStat == 14 || axStat < 0) && starting == 0) {
|
if ((axStat == 0 || axStat < 0) && starting == 0) {
|
||||||
done = 1;
|
done = 1;
|
||||||
} else {
|
} else {
|
||||||
starting = 0;
|
starting = 0;
|
||||||
done = 0;
|
done = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (starting && time(NULL) > startTime + 10) {
|
// if (starting && time(NULL) > startTime + 10) {
|
||||||
/*
|
// /*
|
||||||
did not start in 10 seconds: messed up: cause an alarm
|
// did not start in 10 seconds: messed up: cause an alarm
|
||||||
*/
|
// */
|
||||||
done = 1;
|
// done = 1;
|
||||||
*moving = false;
|
// *moving = false;
|
||||||
st = setIntegerParam(pC_->motorStatusMoving_, false);
|
// st = setIntegerParam(pC_->motorStatusMoving_, false);
|
||||||
cmdStatus = cmdStatus > st ? cmdStatus : st;
|
// cmdStatus = cmdStatus > st ? cmdStatus : st;
|
||||||
st = setIntegerParam(pC_->motorStatusDone_, true);
|
// st = setIntegerParam(pC_->motorStatusDone_, true);
|
||||||
cmdStatus = cmdStatus > st ? cmdStatus : st;
|
// cmdStatus = cmdStatus > st ? cmdStatus : st;
|
||||||
st = setIntegerParam(pC_->motorStatusProblem_, true);
|
// st = setIntegerParam(pC_->motorStatusProblem_, true);
|
||||||
cmdStatus = cmdStatus > st ? cmdStatus : st;
|
// cmdStatus = cmdStatus > st ? cmdStatus : st;
|
||||||
errlogPrintf("Axis %d did not start within 10 seconds!! BROKEN\n", axisNo_);
|
// errlogPrintf("Axis %d did not start within 10 seconds!! BROKEN\n", axisNo_);
|
||||||
updateMsgTxtFromDriver("Axis did not start within 10 seconds");
|
// updateMsgTxtFromDriver("Axis did not start within 10 seconds");
|
||||||
starting = 0;
|
// starting = 0;
|
||||||
return st;
|
// return st;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/*
|
// /*
|
||||||
code to test against too long status 5 or 6
|
// code to test against too long status 5 or 6
|
||||||
*/
|
// */
|
||||||
if (axStat == 5 || axStat == 6) {
|
// if (axStat == 5 || axStat == 6) {
|
||||||
if (status6Time == 0) {
|
// if (status6Time == 0) {
|
||||||
status6Time = time(NULL);
|
// status6Time = time(NULL);
|
||||||
statusPos = position;
|
// statusPos = position;
|
||||||
} else {
|
// } else {
|
||||||
if (time(NULL) > status6Time + 60) {
|
// if (time(NULL) > status6Time + 60) {
|
||||||
/* trigger error only when not moving */
|
// /* trigger error only when not moving */
|
||||||
if (abs(position - statusPos) < .1) {
|
// if (abs(position - statusPos) < .1) {
|
||||||
done = 1;
|
// done = 1;
|
||||||
*moving = false;
|
// *moving = false;
|
||||||
st = setIntegerParam(pC_->motorStatusMoving_, false);
|
// st = setIntegerParam(pC_->motorStatusMoving_, false);
|
||||||
cmdStatus = cmdStatus > st ? cmdStatus : st;
|
// cmdStatus = cmdStatus > st ? cmdStatus : st;
|
||||||
st = setIntegerParam(pC_->motorStatusDone_, true);
|
// st = setIntegerParam(pC_->motorStatusDone_, true);
|
||||||
cmdStatus = cmdStatus > st ? cmdStatus : st;
|
// cmdStatus = cmdStatus > st ? cmdStatus : st;
|
||||||
st = setIntegerParam(pC_->motorStatusProblem_, true);
|
// st = setIntegerParam(pC_->motorStatusProblem_, true);
|
||||||
cmdStatus = cmdStatus > st ? cmdStatus : st;
|
// cmdStatus = cmdStatus > st ? cmdStatus : st;
|
||||||
|
|
||||||
errlogPrintf(
|
// errlogPrintf(
|
||||||
"Axis %d stayed in 5,6 for more then 60 seconds BROKEN\n",
|
// "Axis %d stayed in 5,6 for more then 60 seconds BROKEN\n",
|
||||||
axisNo_);
|
// axisNo_);
|
||||||
updateMsgTxtFromDriver(
|
// updateMsgTxtFromDriver(
|
||||||
"Axis stayed in 5,6 for more then 60 seconds: BROKEN");
|
// "Axis stayed in 5,6 for more then 60 seconds: BROKEN");
|
||||||
status6Time = 0;
|
// status6Time = 0;
|
||||||
return cmdStatus;
|
// return cmdStatus;
|
||||||
} else {
|
// } else {
|
||||||
status6Time = time(NULL);
|
// status6Time = time(NULL);
|
||||||
statusPos = position;
|
// statusPos = position;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!done) {
|
if (!done) {
|
||||||
*moving = true;
|
*moving = true;
|
||||||
|
@ -816,7 +816,7 @@ asynStatus SeleneController::writeFloat64(asynUser *pasynUser, epicsFloat64 valu
|
|||||||
|
|
||||||
asynStatus pmacV3Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) {
|
asynStatus pmacV3Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) {
|
||||||
int function = pasynUser->reason;
|
int function = pasynUser->reason;
|
||||||
asynStatus status = asynError;
|
asynStatus status = asynSuccess;
|
||||||
pmacV3Axis *pAxis = NULL;
|
pmacV3Axis *pAxis = NULL;
|
||||||
char command[64] = {0};
|
char command[64] = {0};
|
||||||
char response[64] = {0};
|
char response[64] = {0};
|
||||||
@ -831,9 +831,13 @@ asynStatus pmacV3Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) {
|
|||||||
|
|
||||||
/* Set the parameter and readback in the parameter library. This may be
|
/* 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 */
|
* overwritten when we read back the status at the end, but that's OK */
|
||||||
status = pAxis->setIntegerParam(function, value);
|
pAxis->setIntegerParam(function, value);
|
||||||
|
|
||||||
if (function == enableAxis_) {
|
if (function == enableAxis_) {
|
||||||
|
if(value == 1) {
|
||||||
|
sprintf(command, "M%2.2d=15\n", pAxis->axisNo_);
|
||||||
|
lowLevelWriteRead(pAxis->axisNo_, command, response);
|
||||||
|
}
|
||||||
sprintf(command, "M%2.2d14=%d\n", pAxis->axisNo_, value);
|
sprintf(command, "M%2.2d14=%d\n", pAxis->axisNo_, value);
|
||||||
asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW,
|
asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW,
|
||||||
"%s: Enable axis on controller %s, axis %d enable=%d\n",
|
"%s: Enable axis on controller %s, axis %d enable=%d\n",
|
||||||
@ -845,7 +849,7 @@ asynStatus pmacV3Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) {
|
|||||||
|
|
||||||
// Execute the command.
|
// Execute the command.
|
||||||
if (command[0] != 0 && status == asynSuccess) {
|
if (command[0] != 0 && status == asynSuccess) {
|
||||||
status = lowLevelWriteRead(pAxis->axisNo_, command, response);
|
lowLevelWriteRead(pAxis->axisNo_, command, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pmacController::writeInt32(pasynUser, value);
|
return pmacController::writeInt32(pasynUser, value);
|
||||||
|
Reference in New Issue
Block a user