Files
turboPmac/src/turboPmacController.h
smathis dfb55a1b76 Added new feature msgPrintControl from sinqMotor 0.8.0. Correspondingly,
the minimum version requirement for sinqMotor has been bumped to 0.8.0.
2025-03-04 09:29:19 +01:00

146 lines
5.5 KiB
C++

/********************************************
* turboPmacController.h
*
* Turbo PMAC controller driver based on the asynMotorController class
*
* Stefan Mathis, September 2024
********************************************/
#ifndef turboPmacController_H
#define turboPmacController_H
#include "sinqAxis.h"
#include "sinqController.h"
#include "turboPmacAxis.h"
class turboPmacController : public sinqController {
public:
/**
* @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
* @param numAxes See sinqController constructor
* @param movingPollPeriod See sinqController constructor
* @param idlePollPeriod See sinqController constructor
* @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,
int numExtraParams = 0);
/**
* @brief Get the axis object
*
* @param pasynUser Specify the axis via the asynUser
* @return turboPmacAxis* If no axis could be found, this is a
* nullptr
*/
turboPmacAxis *getTurboPmacAxis(asynUser *pasynUser);
/**
* @brief Get the axis object
*
* @param axisNo Specify the axis via its index
* @return turboPmacAxis* If no axis could be found, this is a
* nullptr
*/
turboPmacAxis *getTurboPmacAxis(int axisNo);
/**
* @brief Overloaded function of sinqController
*
* The function is overloaded in order to read motorCanDisable_.
*
* @param pasynUser
* @param value
* @return asynStatus
*/
virtual asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
/**
* @brief Overloaded function of sinqController
*
* The function is overloaded to allow rereading the encoder and config.
*
* @param pasynUser Specify the axis via the asynUser
* @param value New value
* @return asynStatus
*/
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
protected:
asynUser *lowLevelPortUser_;
/**
* @brief Send a command to the hardware and receive a response
*
* @param axisNo Axis to which the command should be send
* @param command Command for the hardware
* @param response Buffer for the response. This buffer is
* expected to have the size MAXBUF_.
* @param numExpectedResponses The PMAC MCU can send multiple responses at
* once. The number of responses is determined by the number of
* "subcommands" within command. Therefore it is known in advance how many
* "subresponses" are expected. This can be used to check the integrity of
* the received response, since the subresponses are separated by carriage
* returns (/r). The number of carriage returns is compared to
* numExpectedResponses to determine if the communication was successfull.
* @return asynStatus
*/
asynStatus writeRead(int axisNo, const char *command, char *response,
int numExpectedResponses);
/**
* @brief Specialized version of sinqController::errMsgCouldNotParseResponse
* for turboPmac
*
* This is an overloaded version of
* sinqController::errMsgCouldNotParseResponse which calls
* adjustResponseForLogging on response before handing it over to
* sinqController::errMsgCouldNotParseResponse.
*
* @param command Command which led to the unparseable message
* @param response Response which wasn't parseable
* @param axisNo_ Axis where the problem occurred
* @param functionName Name of the caller function. It is recommended
to use a macro, e.g. __func__ or __PRETTY_FUNCTION__.
* @param lineNumber Source code line where this function is
called. It is recommended to use a macro, e.g. __LINE__.
* @return asynStatus Returns asynError.
*/
asynStatus errMsgCouldNotParseResponse(const char *command,
const char *response, int axisNo_,
const char *functionName,
int lineNumber);
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.
static const uint32_t MAXBUF_ = 200;
/*
Timeout for the communication process in seconds
*/
double comTimeout_;
char lastResponse[MAXBUF_];
// Indices of additional PVs
#define FIRST_turboPmac_PARAM rereadEncoderPosition_
int rereadEncoderPosition_;
int readConfig_;
#define LAST_turboPmac_PARAM readConfig_
friend class turboPmacAxis;
};
#define NUM_turboPmac_DRIVER_PARAMS \
(&LAST_turboPmac_PARAM - &FIRST_turboPmac_PARAM + 1)
#endif /* turboPmacController_H */