Updated to sinqMotor 1.6.1

This commit is contained in:
2026-01-20 16:50:03 +01:00
parent fd41d4c9c0
commit 18e68b193a
5 changed files with 54 additions and 52 deletions

View File

@@ -190,8 +190,9 @@ asynStatus masterMacsAxis::init() {
double motVelocity = 0.0; double motVelocity = 0.0;
double motVmax = 0.0; double motVmax = 0.0;
double motAccel = 0.0; double motAccel = 0.0;
double motMode = 0; int motMode = 0;
double motCanSetMode = 0; int dynamicLimits = 0;
int motCanSetMode = 0;
// ========================================================================= // =========================================================================
@@ -298,11 +299,12 @@ asynStatus masterMacsAxis::init() {
if (status != asynSuccess) { if (status != asynSuccess) {
return status; return status;
} }
nvals = sscanf(response, "%d", &pMasterMacsA_->dynamicLimits); nvals = sscanf(response, "%d", &dynamicLimits);
if (nvals != 1) { if (nvals != 1) {
return pC_->couldNotParseResponse("R32", response, axisNo_, return pC_->couldNotParseResponse("R32", response, axisNo_,
__PRETTY_FUNCTION__, __LINE__); __PRETTY_FUNCTION__, __LINE__);
} }
pMasterMacsA_->dynamicLimits = bool(dynamicLimits);
// Check the current motor mode // Check the current motor mode
status = pC_->read(axisNo_, 07, response); status = pC_->read(axisNo_, 07, response);
@@ -1176,6 +1178,43 @@ asynStatus masterMacsAxis::enable(bool on) {
return asynError; return asynError;
} }
asynStatus masterMacsAxis::setMode(int mode) {
// masterMacs can be disabled
if (pasynUser->reason == motorSetMode()) {
// First call to the sinqController function. It checks whether it is
// possible to set the mode and whether the given value is valid.
asynStatus status = sinqController::writeInt32(pasynUser, value);
if (status == asynSuccess) {
// Now write to the hardware
char command[MAXBUF_];
int axisNo;
getAddress(pasynUser, &axisNo);
// Map the EPICS value to MasterMACS values (see
// MasterMACS_manual.pdf).
int adjustedValue = 0;
if (value == 0) {
adjustedValue = 1;
} else if (value == 1) {
adjustedValue = 3;
} else {
// This branch is unreachable, as it is is already checked
// within sinqController::writeInt32 that value is either 0
// or 1.
return asynError;
}
snprintf(command, sizeof(value), "%d", adjustedValue);
return write(axisNo, 07, command);
}
return status;
} else {
return sinqController::writeInt32(pasynUser, value);
}
}
bool masterMacsAxis::needInit() { return pMasterMacsA_->needInit; } bool masterMacsAxis::needInit() { return pMasterMacsA_->needInit; }
/** /**

View File

@@ -130,6 +130,15 @@ class HIDDEN masterMacsAxis : public sinqAxis {
*/ */
asynStatus enable(bool on); asynStatus enable(bool on);
/**
* @brief Write the new operation mode (position or velocity) to the
* MasterMACS controller.
*
* @param mode
* @return asynStatus
*/
asynStatus masterMacsAxis::setMode(int mode);
/** /**
* @brief Read the encoder type (incremental or absolute) for this axis * @brief Read the encoder type (incremental or absolute) for this axis
* from the MCU and store the information in the PV ENCODER_TYPE. * from the MCU and store the information in the PV ENCODER_TYPE.

View File

@@ -574,44 +574,6 @@ asynStatus masterMacsController::readInt32(asynUser *pasynUser,
} }
} }
asynStatus masterMacsController::writeInt32(asynUser *pasynUser,
epicsInt32 value) {
// masterMacs can be disabled
if (pasynUser->reason == motorSetMode()) {
// First call to the sinqController function. It checks whether it is
// possible to set the mode and whether the given value is valid.
asynStatus status = sinqController::writeInt32(pasynUser, value);
if (status == asynSuccess) {
// Now write to the hardware
char command[MAXBUF_];
int axisNo;
getAddress(pasynUser, &axisNo);
// Map the EPICS value to MasterMACS values (see
// MasterMACS_manual.pdf).
int adjustedValue = 0;
if (value == 0) {
adjustedValue = 1;
} else if (value == 1) {
adjustedValue = 3;
} else {
// This branch is unreachable, as it is is already checked
// within sinqController::writeInt32 that value is either 0
// or 1.
return asynError;
}
snprintf(command, sizeof(value), "%d", adjustedValue);
return write(axisNo, 07, command);
}
return status;
} else {
return sinqController::writeInt32(pasynUser, value);
}
}
double masterMacsController::comTimeout() { return pMasterMacsC_->comTimeout; } double masterMacsController::comTimeout() { return pMasterMacsC_->comTimeout; }
int masterMacsController::nodeReset() { return pMasterMacsC_->nodeReset; } int masterMacsController::nodeReset() { return pMasterMacsC_->nodeReset; }

View File

@@ -54,15 +54,6 @@ class HIDDEN masterMacsController : public sinqController {
*/ */
asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value); asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
/**
* @brief Overloaded version of the sinqController version
*
* @param pasynUser
* @param value
* @return asynStatus
*/
asynStatus writeInt32(asynUser *pasynUser, epicsInt32 *value);
/** /**
* @brief Get the axis object * @brief Get the axis object
* *
@@ -84,7 +75,8 @@ class HIDDEN masterMacsController : public sinqController {
/** /**
* @brief Overloaded function of sinqController * @brief Overloaded function of sinqController
* *
* The function is overloaded to allow resetting the node * The function is overloaded to allow resetting the node and changing the
* operation mode.
* *
* @param pasynUser Specify the axis via the asynUser * @param pasynUser Specify the axis via the asynUser
* @param value New value * @param value New value