Files
mastermacs/src/masterMacsAxis.h
2025-06-17 13:21:55 +02:00

294 lines
6.5 KiB
C++

#ifndef masterMacsAXIS_H
#define masterMacsAXIS_H
#include "masterMacsController.h"
#include "sinqAxis.h"
#include <memory>
struct masterMacsAxisImpl;
class masterMacsAxis : public sinqAxis {
public:
/**
* @brief Construct a new masterMacsAxis
*
* @param pController Pointer to the associated controller
* @param axisNo Index of the axis
*/
masterMacsAxis(masterMacsController *pController, int axisNo);
/**
* @brief Destroy the masterMacsAxis
*
*/
virtual ~masterMacsAxis();
/**
* @brief Implementation of the `doHome` function from sinqAxis. The
* parameters are described in the documentation of `sinqAxis::doHome`.
*
* @param minVelocity
* @param maxVelocity
* @param acceleration
* @param forwards
* @return asynStatus
*/
asynStatus doHome(double minVelocity, double maxVelocity,
double acceleration, int forwards);
/**
* @brief Implementation of the `doPoll` function from sinqAxis. The
* parameters are described in the documentation of `sinqAxis::doPoll`.
*
* @param moving
* @return asynStatus
*/
asynStatus doPoll(bool *moving);
/**
* @brief Implementation of the `doMove` function from sinqAxis. The
* parameters are described in the documentation of `sinqAxis::doMove`.
*
* @param position
* @param relative
* @param min_velocity
* @param max_velocity
* @param acceleration
* @return asynStatus
*/
asynStatus doMove(double position, int relative, double min_velocity,
double max_velocity, double acceleration);
/**
* @brief Implementation of the `stop` function from asynMotorAxis
*
* @param acceleration Acceleration ACCEL from the motor record. This
* value is currently not used.
* @return asynStatus
*/
asynStatus stop(double acceleration);
/**
* @brief Implementation of the `doReset` function from sinqAxis.
*
* @param on
* @return asynStatus
*/
asynStatus doReset();
/**
* @brief Readout of some values from the controller at IOC startup
*
* 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.
*
* @return asynStatus
*/
asynStatus init();
/**
* @brief Enable / disable the axis.
*
* @param on
* @return asynStatus
*/
asynStatus enable(bool on);
/**
* @brief Read the encoder type (incremental or absolute) for this axis from
* the MCU and store the information in the PV ENCODER_TYPE.
*
* @return asynStatus
*/
asynStatus readEncoderType();
/**
* @brief Check if the axis needs to run its initialization function
*
* @return true
* @return false
*/
bool needInit();
/**
* @brief Instruct the axis to run its init() function during the next poll
*
* @param needInit
*/
void setNeedInit(bool needInit);
/**
* @brief Return a pointer to the axis controller
*/
virtual masterMacsController *pController() override { return pC_; };
/**
* @brief Read the Master MACS status with the xR10 command and store the
* result in axisStatus_
*
*/
asynStatus readAxisStatus();
/*
The functions below read the specified status bit from the axisStatus
bitset. Since a bit can either be 0 or 1, the return value is given as a
boolean.
*/
/**
* @brief Read the property from axisStatus_
*/
bool readyToBeSwitchedOn();
/**
* @brief Read the property from axisStatus_
*/
bool switchedOn();
// Bit 2 is unused
/**
* @brief Read the property from axisStatus_
*/
bool faultConditionSet();
/**
* @brief Read the property from axisStatus_
*/
bool voltagePresent();
/**
* @brief Read the property from axisStatus_
*/
bool quickStopping();
/**
* @brief Read the property from axisStatus_
*/
bool switchOnDisabled();
/**
* @brief Read the property from axisStatus_
*/
bool warning();
// Bit 8 is unused
/**
* @brief Read the property from axisStatus_
*/
bool remoteMode();
/**
* @brief Read the property from axisStatus_
*/
bool targetReached();
/**
* @brief Read the property from axisStatus_
*/
bool internalLimitActive();
// Bits 12 and 13 are unused
/**
* @brief Read the property from axisStatus_
*/
bool setEventHasOcurred();
/**
* @brief Read the property from axisStatus_
*/
bool powerEnabled();
/**
* @brief Read the Master MACS status with the xR10 command and store the
* result in axisStatus_
*
*/
asynStatus readAxisError();
/*
The functions below read the specified error bit from the axisError_
bitset. Since a bit can either be 0 or 1, the return value is given as a
boolean.
*/
/**
* @brief Read the property from axisError_
*/
bool shortCircuit();
/**
* @brief Read the property from axisError_
*/
bool encoderError();
/**
* @brief Read the property from axisError_
*/
bool followingError();
/**
* @brief Read the property from axisError_
*/
bool communicationError();
/**
* @brief Read the property from axisError_
*/
bool feedbackError();
/**
* @brief Read the property from axisError_
*/
bool positiveLimitSwitch();
/**
* @brief Read the property from axisError_
*/
bool negativeLimitSwitch();
/**
* @brief Read the property from axisError_
*/
bool positiveSoftwareLimit();
/**
* @brief Read the property from axisError_
*/
bool negativeSoftwareLimit();
/**
* @brief Read the property from axisError_
*/
bool overCurrent();
/**
* @brief Read the property from axisError_
*/
bool overTemperature();
/**
* @brief Read the property from axisError_
*/
bool overVoltage();
/**
* @brief Read the property from axisError_
*/
bool underVoltage();
/**
* @brief Read the property from axisError_
*/
bool stoFault();
private:
masterMacsController *pC_;
std::unique_ptr<masterMacsAxisImpl> pMasterMacsA_;
};
#endif