diff --git a/sinqEPICSApp/src/EuroMoveDriver.cpp b/sinqEPICSApp/src/EuroMoveDriver.cpp index f5f3641..7db7a86 100644 --- a/sinqEPICSApp/src/EuroMoveDriver.cpp +++ b/sinqEPICSApp/src/EuroMoveDriver.cpp @@ -314,6 +314,7 @@ asynStatus EuroMoveAxis::move(double position, int relative, double minVelocity, sprintf(command,"G%d=%d", motNo, (int)position); status = pC_->transactController(motNo,command,reply); next_poll = -1; + targetPosition = (int)position; return status; } @@ -478,16 +479,28 @@ asynStatus EuroMoveAxis::poll(bool *moving) /* Testing limit switches */ if((axStatus & 2) > 0){ // bit 2 - setIntegerParam(pC_->motorStatusHighLimit_, true); - errlogPrintf("HighLimit detected on %d\n", motNo); - sendStop(); + if(targetPosition > position) { + /* + Error codition only when we wish to move further + */ + setIntegerParam(pC_->motorStatusHighLimit_, true); + errlogPrintf("HighLimit detected on %d\n", motNo); + updateMsgTxtFromDriver("On high limit switch"); + sendStop(); + } } else { setIntegerParam(pC_->motorStatusHighLimit_, false); } if((axStatus & 1) > 0){ // bit 1 - setIntegerParam(pC_->motorStatusLowLimit_, true); - errlogPrintf("LowLimit detected on %d\n", motNo); - sendStop(); + setIntegerParam(pC_->motorStatusLowLimit_, true); + if(targetPosition < position) { + /* + Error treatment onlly when we want to go below the limits + */ + errlogPrintf("LowLimit detected on %d\n", motNo); + sendStop(); + updateMsgTxtFromDriver("On low limit switch"); + } } else { setIntegerParam(pC_->motorStatusLowLimit_, false); } diff --git a/sinqEPICSApp/src/EuroMoveDriver.h b/sinqEPICSApp/src/EuroMoveDriver.h index 990a224..3a66e45 100644 --- a/sinqEPICSApp/src/EuroMoveDriver.h +++ b/sinqEPICSApp/src/EuroMoveDriver.h @@ -49,6 +49,7 @@ private: asynStatus sendStop(); int resolution; friend class EuroMoveController; + int targetPosition; }; class EuroMoveController : public SINQController {