diff --git a/sinqEPICSApp/src/EL734Driver.cpp b/sinqEPICSApp/src/EL734Driver.cpp index 293fb3b..5ed261c 100644 --- a/sinqEPICSApp/src/EL734Driver.cpp +++ b/sinqEPICSApp/src/EL734Driver.cpp @@ -341,12 +341,15 @@ asynStatus EL734Axis::stop(double acceleration ) asynStatus status = asynSuccess; //static const char *functionName = "EL734Axis::stop"; char command[COMLEN], reply[COMLEN]; + bool moving = false; - if(errorReported == 0){ + this->poll(&moving); + if(moving && errorReported == 0){ sprintf(command, "S %d", axisNo_); status = pC_->transactController(axisNo_,command,reply); errlogPrintf("Sent STOP on Axis %d\n", axisNo_); updateMsgTxtFromDriver("Axis interrupted"); + errorReported = 1; } return status; diff --git a/sinqEPICSApp/src/pmacAxis.cpp b/sinqEPICSApp/src/pmacAxis.cpp index 7f125b8..c69e8a4 100644 --- a/sinqEPICSApp/src/pmacAxis.cpp +++ b/sinqEPICSApp/src/pmacAxis.cpp @@ -284,15 +284,20 @@ asynStatus pmacAxis::setPosition(double position) { asynStatus pmacAxis::stop(double acceleration) { asynStatus status = asynError; static const char *functionName = "pmacAxis::stopAxis"; + bool moving = false; pC_->debugFlow(functionName); char command[128] = {0}; char response[32] = {0}; - sprintf(command, "M%2.2d=8", axisNo_); + this->getAxisStatus(&moving); - status = pC_->lowLevelWriteRead(axisNo_, command, response); + if(moving) { + // only send a stop when actually moving + sprintf(command, "M%2.2d=8", axisNo_); + status = pC_->lowLevelWriteRead(axisNo_, command, response); + } return status; } diff --git a/sinqEPICSApp/src/pmacController.cpp b/sinqEPICSApp/src/pmacController.cpp index af752df..3083e29 100644 --- a/sinqEPICSApp/src/pmacController.cpp +++ b/sinqEPICSApp/src/pmacController.cpp @@ -820,6 +820,7 @@ asynStatus pmacV3Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) { pmacV3Axis *pAxis = NULL; char command[64] = {0}; char response[64] = {0}; + int isOn; static const char *functionName = "pmacV3Controller::writeInt32"; debugFlow(functionName); @@ -834,16 +835,22 @@ asynStatus pmacV3Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) { pAxis->setIntegerParam(function, value); 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_); lowLevelWriteRead(pAxis->axisNo_, command, response); } sprintf(command, "M%2.2d14=%d\n", pAxis->axisNo_, value); - asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, + pAxis->updateMsgTxtFromDriver(""); + if(isOn != value) { + asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, "%s: Enable axis on controller %s, axis %d enable=%d\n", functionName, portName, pAxis->axisNo_, value); - pAxis->updateMsgTxtFromDriver(""); - lowLevelWriteRead(pAxis->axisNo_, command, response); + lowLevelWriteRead(pAxis->axisNo_, command, response); + } } return pmacController::writeInt32(pasynUser, value);