Various improvements:
- Moved the encoder type PV to sinqMotor - Unified the PV naming scheme - Removed the IsEnabled function - this status is read out from the parameter library (motorEnableRBV_)
This commit is contained in:
@ -17,6 +17,20 @@ asynStatus sinqAxis::atFirstPoll() {
|
||||
asynStatus status = asynSuccess;
|
||||
int variableSpeed = 0;
|
||||
|
||||
// Motor is assumed to be enabled
|
||||
status = pC_->setIntegerParam(axisNo_, pC_->motorEnableRBV_, 1);
|
||||
if (status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(status, "motorEnableRBV_",
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
// By default, motors cannot be disabled
|
||||
status = pC_->setIntegerParam(axisNo_, pC_->motorCanDisable_, 0);
|
||||
if (status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(status, "motorCanDisable_",
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
status =
|
||||
pC_->getIntegerParam(axisNo_, pC_->motorCanSetSpeed_, &variableSpeed);
|
||||
if (status != asynSuccess) {
|
||||
@ -118,10 +132,6 @@ asynStatus sinqAxis::poll(bool *moving) {
|
||||
}
|
||||
}
|
||||
|
||||
// Update the enable RBV
|
||||
bool axisIsEnabled = false;
|
||||
|
||||
pl_status = isEnabled(&axisIsEnabled);
|
||||
if (pl_status != asynSuccess) {
|
||||
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
||||
"%s => line %d:\nFunction isEnabled failed with %s.\n",
|
||||
@ -134,12 +144,6 @@ asynStatus sinqAxis::poll(bool *moving) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
} else {
|
||||
pl_status = setIntegerParam(pC_->motorEnableRBV_, axisIsEnabled);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorEnableRBV_",
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
// According to the function documentation of asynMotorAxis::poll, this
|
||||
@ -256,11 +260,6 @@ asynStatus sinqAxis::doHome(double minVelocity, double maxVelocity,
|
||||
|
||||
asynStatus sinqAxis::enable(bool on) { return asynSuccess; }
|
||||
|
||||
asynStatus sinqAxis::isEnabled(bool *on) {
|
||||
*on = true;
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
asynStatus sinqAxis::setVeloFields(double velo, double vbas, double vmax) {
|
||||
asynStatus status = asynSuccess;
|
||||
int variableSpeed = 0;
|
||||
|
@ -152,16 +152,6 @@ class epicsShareClass sinqAxis : public asynMotorAxis {
|
||||
*/
|
||||
virtual asynStatus enable(bool on);
|
||||
|
||||
/**
|
||||
* @brief This function should set "on" to true, if the motor is enabled,
|
||||
* and false otherwise. It should be implemented by a child class of
|
||||
* sinqAxis.
|
||||
*
|
||||
* @param on
|
||||
* @return asynStatus
|
||||
*/
|
||||
virtual asynStatus isEnabled(bool *on);
|
||||
|
||||
/**
|
||||
* @brief Populate the motor record fields VELO, VBAS and VMAX
|
||||
*
|
||||
|
@ -204,6 +204,15 @@ sinqController::sinqController(const char *portName,
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
status = createParam("ENCODER_TYPE", asynParamOctet, &encoderType_);
|
||||
if (status != asynSuccess) {
|
||||
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
|
||||
"%s => line %d:\nFATAL ERROR (creating a parameter failed "
|
||||
"with %s).\nTerminating IOC",
|
||||
__PRETTY_FUNCTION__, __LINE__, stringifyAsynStatus(status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// Poller configuration
|
||||
status = startPoller(movingPollPeriod, idlePollPeriod, 1);
|
||||
if (status != asynSuccess) {
|
||||
@ -247,12 +256,27 @@ asynStatus sinqController::writeInt32(asynUser *pasynUser, epicsInt32 value) {
|
||||
|
||||
asynStatus sinqController::readInt32(asynUser *pasynUser, epicsInt32 *value) {
|
||||
if (pasynUser->reason == motorEnableRBV_) {
|
||||
// Value is updated in the poll function of an axis
|
||||
return asynSuccess;
|
||||
// Read out the parameter library
|
||||
asynMotorAxis *asynAxis = getAxis(pasynUser);
|
||||
sinqAxis *axis = dynamic_cast<sinqAxis *>(asynAxis);
|
||||
if (axis == nullptr) {
|
||||
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
|
||||
"%s => line %d:\nAxis %d is not an instance of sinqAxis",
|
||||
__PRETTY_FUNCTION__, __LINE__, axis->axisNo_);
|
||||
return asynError;
|
||||
}
|
||||
return getIntegerParam(axis->axisNo_, motorEnableRBV_, value);
|
||||
} else if (pasynUser->reason == motorCanDisable_) {
|
||||
// By default, motors cannot be disabled
|
||||
*value = 1;
|
||||
return asynSuccess;
|
||||
// Check if the motor can be disabled
|
||||
asynMotorAxis *asynAxis = getAxis(pasynUser);
|
||||
sinqAxis *axis = dynamic_cast<sinqAxis *>(asynAxis);
|
||||
if (axis == nullptr) {
|
||||
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
|
||||
"%s => line %d:\nAxis %d is not an instance of sinqAxis",
|
||||
__PRETTY_FUNCTION__, __LINE__, axis->axisNo_);
|
||||
return asynError;
|
||||
}
|
||||
return getIntegerParam(axis->axisNo_, motorCanDisable_, value);
|
||||
} else {
|
||||
return asynMotorController::readInt32(pasynUser, value);
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ Stefan Mathis, November 2024
|
||||
|
||||
#define motorMessageIsFromDriverString "MOTOR_MESSAGE_DRIVER"
|
||||
#define motorMessageTextString "MOTOR_MESSAGE_TEXT"
|
||||
#define IncrementalEncoder "Incremental encoder"
|
||||
#define AbsoluteEncoder "Absolute encoder"
|
||||
|
||||
class epicsShareClass sinqController : public asynMotorController {
|
||||
public:
|
||||
@ -146,7 +148,8 @@ class epicsShareClass sinqController : public asynMotorController {
|
||||
int motorAcclFromDriver_;
|
||||
int motorHighLimitFromDriver_;
|
||||
int motorLowLimitFromDriver_;
|
||||
#define LAST_SINQMOTOR_PARAM motorLowLimitFromDriver_
|
||||
int encoderType_;
|
||||
#define LAST_SINQMOTOR_PARAM encoderType_
|
||||
};
|
||||
#define NUM_SINQMOTOR_DRIVER_PARAMS \
|
||||
(&LAST_SINQMOTOR_PARAM - &FIRST_SINQMOTOR_PARAM + 1)
|
||||
|
Reference in New Issue
Block a user