Skip to content

Commit

Permalink
Merge pull request #60 from epics-motor/setPosition-disable
Browse files Browse the repository at this point in the history
Allow disabling setPosition
  • Loading branch information
kmpeters authored Jun 11, 2024
2 parents 3f690cb + 17a0aac commit 8830d2f
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
1 change: 1 addition & 0 deletions acsMotionApp/Db/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ DB += SPiiPlusRealVar.db
DB += SPiiPlusProgram.db
DB += SPiiPlusAxisExtra.db
DB += SPiiPlusFeedback.db
DB += SPiiPlusDisableSetPos.db
DB += SPiiPlusTest.db

#----------------------------------------------------
Expand Down
16 changes: 16 additions & 0 deletions acsMotionApp/Db/SPiiPlusDisableSetPos.db
Original file line number Diff line number Diff line change
@@ -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")
}

20 changes: 17 additions & 3 deletions acsMotionApp/src/SPiiPlusDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion acsMotionApp/src/SPiiPlusDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -286,6 +288,8 @@ class epicsShareClass SPiiPlusController : public asynMotorController
int SPiiPlusHomingOffsetNeg_;
int SPiiPlusHomingCurrLimit_;
//
int SPiiPlusDisableSetPos_;
//
int SPiiPlusTest_;
#define LAST_SPIIPLUS_PARAM SPiiPlusTest_

Expand Down
15 changes: 15 additions & 0 deletions iocs/acsMotionIOC/iocBoot/iocAcsMotion/AcsMotion.substitutions
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8830d2f

Please sign in to comment.