Renamed from pmacV3 to turboPmac
This commit is contained in:
138
src/turboPmacController.h
Normal file
138
src/turboPmacController.h
Normal file
@@ -0,0 +1,138 @@
|
||||
/********************************************
|
||||
* turboPmacController.h
|
||||
*
|
||||
* PMAC V3 controller driver based on the asynMotorController class
|
||||
*
|
||||
* Stefan Mathis, September 2024
|
||||
********************************************/
|
||||
|
||||
#ifndef turboPmacController_H
|
||||
#define turboPmacController_H
|
||||
#include "turboPmacAxis.h"
|
||||
#include "sinqAxis.h"
|
||||
#include "sinqController.h"
|
||||
|
||||
class turboPmacController : public sinqController {
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new turboPmacController object
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
turboPmacController(const char *portName, const char *ipPortConfigName,
|
||||
int numAxes, double movingPollPeriod,
|
||||
double idlePollPeriod, double comTimeout);
|
||||
|
||||
/**
|
||||
* @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 *getAxis(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 *getAxis(int axisNo);
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
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 Save cast of the given asynAxis pointer to a turboPmacAxis pointer.
|
||||
* If the cast fails, this function returns a nullptr.
|
||||
*
|
||||
* @param asynAxis
|
||||
* @return turboPmacAxis*
|
||||
*/
|
||||
turboPmacAxis *castToAxis(asynMotorAxis *asynAxis);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
private:
|
||||
// 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;
|
||||
|
||||
/*
|
||||
Stores the constructor input comTimeout
|
||||
*/
|
||||
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 */
|
||||
Reference in New Issue
Block a user