diff --git a/acsMotionApp/Db/Makefile b/acsMotionApp/Db/Makefile index b3ebc58..bdb0ab0 100644 --- a/acsMotionApp/Db/Makefile +++ b/acsMotionApp/Db/Makefile @@ -28,6 +28,7 @@ DB += SPiiPlusRealVar.db DB += SPiiPlusProgram.db DB += SPiiPlusAxisExtra.db DB += SPiiPlusFeedback.db +DB += SPiiPlusDisableSetPos.db DB += SPiiPlusTest.db #---------------------------------------------------- diff --git a/acsMotionApp/Db/SPiiPlusDisableSetPos.db b/acsMotionApp/Db/SPiiPlusDisableSetPos.db new file mode 100644 index 0000000..a67f056 --- /dev/null +++ b/acsMotionApp/Db/SPiiPlusDisableSetPos.db @@ -0,0 +1,16 @@ +record(bo,"$(P)$(M):disableSetPos") { + field(DESC, "Disable set position") + field(DTYP, "asynInt32") + field(OUT, "@asyn($(PORT),$(ADDR))SPIIPLUS_DISABLE_SET_POS") + field(ZNAM, "Off") + field(ONAM, "On") + field(VAL, 1) + field(PINI, "YES") +} + +# Also tell autosave to never restore the position, which is redundant +# NOTE: this only takes effect if RSTM hasn't been autosaved yet +record(motor,"$(P)$(M)") { + field(RSTM, "Never") +} + diff --git a/acsMotionApp/src/SPiiPlusDriver.cpp b/acsMotionApp/src/SPiiPlusDriver.cpp index 27b4fa4..0d64d82 100644 --- a/acsMotionApp/src/SPiiPlusDriver.cpp +++ b/acsMotionApp/src/SPiiPlusDriver.cpp @@ -98,6 +98,8 @@ SPiiPlusController::SPiiPlusController(const char* ACSPortName, const char* asyn createParam(SPiiPlusHomingOffsetNegString, asynParamFloat64, &SPiiPlusHomingOffsetNeg_); createParam(SPiiPlusHomingCurrLimitString, asynParamFloat64, &SPiiPlusHomingCurrLimit_); // + createParam(SPiiPlusDisableSetPosString, asynParamInt32, &SPiiPlusDisableSetPos_); + // createParam(SPiiPlusTestString, asynParamInt32, &SPiiPlusTest_); // Initialize this variable to avoid freeing random memory @@ -856,11 +858,23 @@ asynStatus SPiiPlusAxis::setPosition(double position) { SPiiPlusController* controller = (SPiiPlusController*) pC_; asynStatus status; + int disableSetPos; std::stringstream cmd; + static const char *functionName = "setPosition"; - // The controller automatically updates APOS and FPOS when RPOS is updated - cmd << "SET RPOS(" << axisNo_ << ")=" << (position * resolution_); - status = controller->pComm_->writeReadAck(cmd); + controller->getIntegerParam(axisNo_, controller->SPiiPlusDisableSetPos_, &disableSetPos); + + if (!disableSetPos) + { + // The controller automatically updates APOS and FPOS when RPOS is updated + cmd << "SET RPOS(" << axisNo_ << ")=" << (position * resolution_); + status = controller->pComm_->writeReadAck(cmd); + } + else + { + asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, "%s:%s: Changing the position of axis %i is disabled; Ignoring requested position: %lf\n", driverName, functionName, axisNo_, (position * resolution_)); + status = asynError; + } return status; } diff --git a/acsMotionApp/src/SPiiPlusDriver.h b/acsMotionApp/src/SPiiPlusDriver.h index 1d27d55..94c98e9 100644 --- a/acsMotionApp/src/SPiiPlusDriver.h +++ b/acsMotionApp/src/SPiiPlusDriver.h @@ -141,7 +141,9 @@ #define SPiiPlusHomingOffsetNegString "SPIIPLUS_HOMING_OFFSET_NEG" #define SPiiPlusHomingCurrLimitString "SPIIPLUS_HOMING_CURR_LIMIT" // -#define SPiiPlusTestString "SPIIPLUS_TEST" +#define SPiiPlusDisableSetPosString "SPIIPLUS_DISABLE_SET_POS" +// +#define SPiiPlusTestString "SPIIPLUS_TEST" struct SPiiPlusDrvUser_t { const char *programName; @@ -286,6 +288,8 @@ class epicsShareClass SPiiPlusController : public asynMotorController int SPiiPlusHomingOffsetNeg_; int SPiiPlusHomingCurrLimit_; // + int SPiiPlusDisableSetPos_; + // int SPiiPlusTest_; #define LAST_SPIIPLUS_PARAM SPiiPlusTest_ diff --git a/iocs/acsMotionIOC/iocBoot/iocAcsMotion/AcsMotion.substitutions b/iocs/acsMotionIOC/iocBoot/iocAcsMotion/AcsMotion.substitutions index 4778eb3..0988867 100644 --- a/iocs/acsMotionIOC/iocBoot/iocAcsMotion/AcsMotion.substitutions +++ b/iocs/acsMotionIOC/iocBoot/iocAcsMotion/AcsMotion.substitutions @@ -45,6 +45,21 @@ pattern {pm1:, 8, 2000, 2000, ACS1, 7, 2.0, 4} } +### Uncomment the following to disable setting the position for axes with absolute encoders +#!file "$(TOP)/db/SPiiPlusDisableSetPos.db" +#!{ +#!pattern +#!{M, PORT, ADDR} +#!{m1, ACS1, 0} +#!{m2, ACS1, 1} +#!{m3, ACS1, 2} +#!{m4, ACS1, 3} +#!{m5, ACS1, 4} +#!{m6, ACS1, 5} +#!{m7, ACS1, 6} +#!{m8, ACS1, 7} +#!} + file "$(TOP)/db/SPiiPlusAxisExtra.db" { pattern