Initial commit for masterMacs
This commit is contained in:
105
src/masterMacsController.h
Normal file
105
src/masterMacsController.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/********************************************
|
||||
* masterMacsController.h
|
||||
*
|
||||
* PMAC V3 controller driver based on the asynMotorController class
|
||||
*
|
||||
* Stefan Mathis, September 2024
|
||||
********************************************/
|
||||
|
||||
#ifndef masterMacsController_H
|
||||
#define masterMacsController_H
|
||||
#include "masterMacsAxis.h"
|
||||
#include "sinqAxis.h"
|
||||
#include "sinqController.h"
|
||||
|
||||
class masterMacsController : public sinqController {
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new masterMacsController 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.
|
||||
*/
|
||||
masterMacsController(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 masterMacsAxis* If no axis could be found, this is a
|
||||
* nullptr
|
||||
*/
|
||||
masterMacsAxis *getAxis(asynUser *pasynUser);
|
||||
|
||||
/**
|
||||
* @brief Get the axis object
|
||||
*
|
||||
* @param axisNo Specify the axis via its index
|
||||
* @return masterMacsAxis* If no axis could be found, this is a
|
||||
* nullptr
|
||||
*/
|
||||
masterMacsAxis *getAxis(int axisNo);
|
||||
|
||||
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,
|
||||
bool expectResponse);
|
||||
|
||||
/**
|
||||
* @brief Save cast of the given asynAxis pointer to a masterMacsAxis
|
||||
* pointer. If the cast fails, this function returns a nullptr.
|
||||
*
|
||||
* @param asynAxis
|
||||
* @return masterMacsAxis*
|
||||
*/
|
||||
masterMacsAxis *castToAxis(asynMotorAxis *asynAxis);
|
||||
|
||||
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_;
|
||||
|
||||
// Indices of additional PVs
|
||||
#define FIRST_masterMacs_PARAM rereadEncoderPosition_
|
||||
int rereadEncoderPosition_;
|
||||
int readConfig_;
|
||||
#define LAST_masterMacs_PARAM readConfig_
|
||||
|
||||
friend class masterMacsAxis;
|
||||
};
|
||||
#define NUM_masterMacs_DRIVER_PARAMS \
|
||||
(&LAST_masterMacs_PARAM - &FIRST_masterMacs_PARAM + 1)
|
||||
|
||||
#endif /* masterMacsController_H */
|
||||
Reference in New Issue
Block a user