Added flag to disable reading the limits from the hardware

This commit is contained in:
2025-06-10 11:14:42 +02:00
parent e316fcf67b
commit 26175290bf
4 changed files with 48 additions and 10 deletions

View File

@ -31,3 +31,14 @@ record(longout, "$(INSTR)FlushHardware") {
field(PINI, "NO")
field(VAL, "1")
}
# If this PV is set to 1 (default), the position limits are read out from the
# controller. Otherwise, the limits given in the substitution file (DHLM and
# DLLM) are used.
# This record is coupled to the parameter library via limFromHardware -> LIM_FROM_HARDWARE.
record(longout, "$(INSTR)$(M):LimFromHardware") {
field(DTYP, "asynInt32")
field(OUT, "@asyn($(CONTROLLER),$(AXIS),1) LIM_FROM_HARDWARE")
field(PINI, "YES")
field(VAL, "$(LIMFROMHARDWARE=1)")
}

View File

@ -609,19 +609,30 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
__LINE__);
}
pl_status = pC_->setDoubleParam(axisNo_, pC_->motorHighLimitFromDriver(),
highLimit);
int limFromHardware = 0;
pl_status =
pC_->getIntegerParam(axisNo_, pC_->limFromHardware(), &limFromHardware);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorHighLimitFromDriver_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
return pC_->paramLibAccessFailed(pl_status, "limFromHardware", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
pl_status =
pC_->setDoubleParam(axisNo_, pC_->motorLowLimitFromDriver(), lowLimit);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorLowLimit_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
if (limFromHardware != 0) {
pl_status = pC_->setDoubleParam(
axisNo_, pC_->motorHighLimitFromDriver(), highLimit);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(
pl_status, "motorHighLimitFromDriver_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
pl_status = pC_->setDoubleParam(axisNo_, pC_->motorLowLimitFromDriver(),
lowLimit);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorLowLimit_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
}
pl_status = setMotorPosition(currentPosition);

View File

@ -45,6 +45,7 @@ struct turboPmacControllerImpl {
int rereadEncoderPosition;
int readConfig;
int flushHardware;
int limFromHardware;
};
#define NUM_turboPmac_DRIVER_PARAMS 3
@ -114,6 +115,17 @@ turboPmacController::turboPmacController(const char *portName,
exit(-1);
}
status = createParam("LIM_FROM_HARDWARE", asynParamInt32,
&pTurboPmacC_->limFromHardware);
if (status != asynSuccess) {
asynPrint(this->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\" => %s, line %d\nFATAL ERROR (creating a "
"parameter failed with %s).\nTerminating IOC",
portName, __PRETTY_FUNCTION__, __LINE__,
stringifyAsynStatus(status));
exit(-1);
}
/*
Define the end-of-string of a message coming from the device to EPICS.
It is not necessary to append a terminator to outgoing messages, since
@ -506,6 +518,9 @@ int turboPmacController::rereadEncoderPosition() {
}
int turboPmacController::readConfig() { return pTurboPmacC_->readConfig; }
int turboPmacController::flushHardware() { return pTurboPmacC_->flushHardware; }
int turboPmacController::limFromHardware() {
return pTurboPmacC_->limFromHardware;
}
asynUser *turboPmacController::pasynInt32SyncIOipPort() {
return pTurboPmacC_->pasynInt32SyncIOipPort;

View File

@ -122,6 +122,7 @@ class turboPmacController : public sinqController {
int rereadEncoderPosition();
int readConfig();
int flushHardware();
int limFromHardware();
asynUser *pasynInt32SyncIOipPort();