Implemented that enable commands are only sent when a status chnage is required

Stop commands are only sent by EL734 and pmac when actually moving. The
motor record logic calls stop() in an excessive way.
This commit is contained in:
2023-05-31 09:37:22 +02:00
parent 72afd02b4e
commit 8a6441927a
3 changed files with 22 additions and 7 deletions

View File

@@ -341,12 +341,15 @@ asynStatus EL734Axis::stop(double acceleration )
asynStatus status = asynSuccess; asynStatus status = asynSuccess;
//static const char *functionName = "EL734Axis::stop"; //static const char *functionName = "EL734Axis::stop";
char command[COMLEN], reply[COMLEN]; char command[COMLEN], reply[COMLEN];
bool moving = false;
if(errorReported == 0){ this->poll(&moving);
if(moving && errorReported == 0){
sprintf(command, "S %d", axisNo_); sprintf(command, "S %d", axisNo_);
status = pC_->transactController(axisNo_,command,reply); status = pC_->transactController(axisNo_,command,reply);
errlogPrintf("Sent STOP on Axis %d\n", axisNo_); errlogPrintf("Sent STOP on Axis %d\n", axisNo_);
updateMsgTxtFromDriver("Axis interrupted"); updateMsgTxtFromDriver("Axis interrupted");
errorReported = 1;
} }
return status; return status;

View File

@@ -284,15 +284,20 @@ asynStatus pmacAxis::setPosition(double position) {
asynStatus pmacAxis::stop(double acceleration) { asynStatus pmacAxis::stop(double acceleration) {
asynStatus status = asynError; asynStatus status = asynError;
static const char *functionName = "pmacAxis::stopAxis"; static const char *functionName = "pmacAxis::stopAxis";
bool moving = false;
pC_->debugFlow(functionName); pC_->debugFlow(functionName);
char command[128] = {0}; char command[128] = {0};
char response[32] = {0}; char response[32] = {0};
sprintf(command, "M%2.2d=8", axisNo_); this->getAxisStatus(&moving);
if(moving) {
// only send a stop when actually moving
sprintf(command, "M%2.2d=8", axisNo_);
status = pC_->lowLevelWriteRead(axisNo_, command, response); status = pC_->lowLevelWriteRead(axisNo_, command, response);
}
return status; return status;
} }

View File

@@ -820,6 +820,7 @@ asynStatus pmacV3Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) {
pmacV3Axis *pAxis = NULL; pmacV3Axis *pAxis = NULL;
char command[64] = {0}; char command[64] = {0};
char response[64] = {0}; char response[64] = {0};
int isOn;
static const char *functionName = "pmacV3Controller::writeInt32"; static const char *functionName = "pmacV3Controller::writeInt32";
debugFlow(functionName); debugFlow(functionName);
@@ -834,17 +835,23 @@ asynStatus pmacV3Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) {
pAxis->setIntegerParam(function, value); pAxis->setIntegerParam(function, value);
if (function == enableAxis_) { if (function == enableAxis_) {
if(value == 1) { // only send commands when a state change is necessary
snprintf(command, sizeof(command), "P%2.2d00", pAxis->axisNo_);
this->lowLevelWriteRead(pAxis->axisNo_, command, response);
isOn = strtol(response, NULL, 10);
if(value == 1 && isOn == 0) {
sprintf(command, "M%2.2d=15\n", pAxis->axisNo_); sprintf(command, "M%2.2d=15\n", pAxis->axisNo_);
lowLevelWriteRead(pAxis->axisNo_, command, response); 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);
pAxis->updateMsgTxtFromDriver("");
if(isOn != 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",
functionName, portName, pAxis->axisNo_, value); functionName, portName, pAxis->axisNo_, value);
pAxis->updateMsgTxtFromDriver("");
lowLevelWriteRead(pAxis->axisNo_, command, response); lowLevelWriteRead(pAxis->axisNo_, command, response);
} }
}
return pmacController::writeInt32(pasynUser, value); return pmacController::writeInt32(pasynUser, value);
} }