Fixed a bug in readInt32 and prepared the turboPmac library to serve the

detectorTower library
This commit is contained in:
2025-02-26 14:08:37 +01:00
parent 4c104cb90c
commit 8f597550fa
6 changed files with 74 additions and 52 deletions

View File

@@ -109,9 +109,6 @@ turboPmacAxis::~turboPmacAxis(void) {
// clean up the pointer pC here.
}
/**
Read the configuration at the first poll
*/
asynStatus turboPmacAxis::init() {
// Local variable declaration
@@ -478,9 +475,11 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
"state P%2.2d00 = %d\n",
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, axisNo_,
axStatus);
pl_status = setStringParam(
pC_->motorMessageText_,
"Unreachable state has been reached. Please call the support.");
snprintf(userMessage, sizeof(userMessage),
"Unknown state P%2.2d00 = %d has been reached. Please call "
"the support.",
axisNo_, error);
pl_status = setStringParam(pC_->motorMessageText_, userMessage);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
axisNo_, __PRETTY_FUNCTION__,
@@ -675,11 +674,11 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, axisNo_,
error);
snprintf(command, sizeof(command),
snprintf(userMessage, sizeof(userMessage),
"Move command exceeds hardware limits (P%2.2d01 = %d). Please "
"call the support.",
axisNo_, error);
pl_status = setStringParam(pC_->motorMessageText_, command);
pl_status = setStringParam(pC_->motorMessageText_, userMessage);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
axisNo_, __PRETTY_FUNCTION__,
@@ -695,9 +694,10 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
axisNo_, error);
pl_status = setStringParam(
pC_->motorMessageText_,
"Unknown error P%2.2d01 = %d. Please call the support.");
snprintf(userMessage, sizeof(userMessage),
"Unknown error P%2.2d01 = %d. Please call the support.",
axisNo_, error);
pl_status = setStringParam(pC_->motorMessageText_, userMessage);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
axisNo_, __PRETTY_FUNCTION__,

View File

@@ -3,7 +3,7 @@
#include "sinqAxis.h"
// Forward declaration of the controller class to resolve the cyclic dependency
// between C804Controller.h and C804Axis.h. See
// between the controller and the axis .h-file. See
// https://en.cppreference.com/w/cpp/language/class.
class turboPmacController;
@@ -74,7 +74,7 @@ class turboPmacAxis : public sinqAxis {
* The following steps are performed:
* - Read out the motor status, motor position, velocity and acceleration
* from the MCU and store this information in the parameter library.
* - Set the enable PV accordint to the initial status of the axis.
* - Set the enable PV according to the initial status of the axis.
*
* @return asynStatus
*/

View File

@@ -29,23 +29,11 @@ void adjustResponseForPrint(char *dst, const char *src, size_t buf_length) {
}
}
/**
* @brief Construct a new turboPmacController::turboPmacController object
*
* @param portName See documentation of sinqController
* @param ipPortConfigName See documentation of sinqController
* @param numAxes See documentation of sinqController
* @param movingPollPeriod See documentation of sinqController
* @param idlePollPeriod See documentation of sinqController
* @param comTimeout Time after which a communication timeout error
* is declared in writeRead (in seconds)
* @param extraParams See documentation of sinqController
*/
turboPmacController::turboPmacController(const char *portName,
const char *ipPortConfigName,
int numAxes, double movingPollPeriod,
double idlePollPeriod,
double comTimeout)
double comTimeout, int numExtraParams)
: sinqController(
portName, ipPortConfigName, numAxes, movingPollPeriod, idlePollPeriod,
/*
@@ -53,7 +41,7 @@ turboPmacController::turboPmacController(const char *portName,
- REREAD_ENCODER_POSITION
- READ_CONFIG
*/
NUM_turboPmac_DRIVER_PARAMS)
numExtraParams + NUM_turboPmac_DRIVER_PARAMS)
{
@@ -510,13 +498,14 @@ asynStatus turboPmacController::writeInt32(asynUser *pasynUser,
}
}
asynStatus sinqController::readInt32(asynUser *pasynUser, epicsInt32 *value) {
asynStatus turboPmacController::readInt32(asynUser *pasynUser,
epicsInt32 *value) {
// PMACs can be disabled
if (pasynUser->reason == motorCanDisable_) {
*value = 1;
return asynSuccess;
} else {
return asynMotorController::readInt32(pasynUser, value);
return sinqController::readInt32(pasynUser, value);
}
}
@@ -582,7 +571,7 @@ static const iocshArg CreateControllerArg5 = {"Communication timeout (s)",
static const iocshArg *const CreateControllerArgs[] = {
&CreateControllerArg0, &CreateControllerArg1, &CreateControllerArg2,
&CreateControllerArg3, &CreateControllerArg4, &CreateControllerArg5};
static const iocshFuncDef configturboPmacCreateController = {
static const iocshFuncDef configTurboPmacCreateController = {
"turboPmacController", 6, CreateControllerArgs};
static void configTurboPmacCreateControllerCallFunc(const iocshArgBuf *args) {
turboPmacCreateController(args[0].sval, args[1].sval, args[2].ival,
@@ -592,7 +581,7 @@ static void configTurboPmacCreateControllerCallFunc(const iocshArgBuf *args) {
// This function is made known to EPICS in turboPmac.dbd and is called by EPICS
// in order to register both functions in the IOC shell
static void turboPmacControllerRegister(void) {
iocshRegister(&configturboPmacCreateController,
iocshRegister(&configTurboPmacCreateController,
configTurboPmacCreateControllerCallFunc);
}
epicsExportRegistrar(turboPmacControllerRegister);

View File

@@ -13,10 +13,10 @@
#include "turboPmacAxis.h"
class turboPmacController : public sinqController {
public:
/**
* @brief Construct a new turboPmacController object
* @brief Construct a new turboPmacController object. This function is meant
to be called from a child class constructor.
*
* @param portName See sinqController constructor
* @param ipPortConfigName See sinqController constructor
@@ -26,10 +26,12 @@ class turboPmacController : public sinqController {
* @param comTimeout When trying to communicate with the device,
the underlying asynOctetSyncIO interface waits for a response until this
time (in seconds) has passed, then it declares a timeout.
* @param numExtraParams Number of extra parameters from a child class
*/
turboPmacController(const char *portName, const char *ipPortConfigName,
int numAxes, double movingPollPeriod,
double idlePollPeriod, double comTimeout);
double idlePollPeriod, double comTimeout,
int numExtraParams = 0);
/**
* @brief Get the axis object
@@ -49,6 +51,17 @@ class turboPmacController : public sinqController {
*/
turboPmacAxis *getAxis(int axisNo);
/**
* @brief Overloaded function of sinqController
*
* The function is overloaded in order to read motorCanDisable_
*
* @param pasynUser
* @param value
* @return asynStatus
*/
asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
/**
* @brief Overloaded function of sinqController
*
@@ -114,7 +127,7 @@ class turboPmacController : public sinqController {
const char *functionName,
int lineNumber);
private:
protected:
// Set the maximum buffer size. This is an empirical value which must be
// large enough to avoid overflows for all commands to the device /
// responses from it.