Files
mastermacs/src/masterMacsAxis.h
smathis 9a52a4b9ce
Some checks failed
Test And Build / Lint (push) Failing after 4s
Test And Build / Build (push) Successful in 7s
Implemented velocity mode, but didn't test it yet
2026-01-20 16:52:52 +01:00

373 lines
10 KiB
C++

#ifndef masterMacsAXIS_H
#define masterMacsAXIS_H
#include "masterMacsController.h"
#include "sinqAxis.h"
#include <memory>
struct HIDDEN masterMacsAxisImpl;
class HIDDEN 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 Delete the copy and copy assignment constructors, because this
* class should not be copied (it is tied to hardware!)
*/
masterMacsAxis(const masterMacsAxis &) = delete;
masterMacsAxis &operator=(const masterMacsAxis &) = delete;
/**
* @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 `doMoveVelocity` function from sinqAxis. The
* parameters are described in the documentation of
* `sinqAxis::doMoveVelocity`.
*
* @param minVelocity
* @param maxVelocity
* @param acceleration
* @return asynStatus
*/
asynStatus doMoveVelocity(double minVelocity, double maxVelocity,
double acceleration);
/**
* @brief Implementation of the `doMove` function from sinqAxis. The
* parameters are described in the documentation of `sinqAxis::doMove`.
*
* @param position
* @param relative
* @param minVelocity
* @param maxVelocity
* @param acceleration
* @return asynStatus
*/
asynStatus doMove(double position, int relative, double minVelocity,
double maxVelocity, 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 Performs a "node reset" on the axis as defined in the CANopen
* standard
*
* A "node reset" is a factory reset on the axis which completely deletes
* all configured information (e.g. limits or speed) from the axis. The
* MasterMACS controller then reapplies the initial configuration to this
* axis. It can therefore be seen as a "hard" version of the normal error
* reset performed by the `doReset` method.
*
* @return asynStatus
*/
asynStatus nodeReset();
/**
* @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 Write the new operation mode (position or velocity) to the
* MasterMACS controller.
*
* @param mode
* @return asynStatus
*/
asynStatus setMode(int mode);
/**
* @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 (see masterMacsAxisImpl redefinition in
* masterMacsAxis.cpp)
*
*/
asynStatus readAxisStatus();
/**
* @brief Read the upper and lower limits and store them in the parameter
* library.
*/
asynStatus readLimits();
/*
The functions below read the specified status bit from the axisStatus (see
masterMacsAxisImpl redefinition in masterMacsAxis.cpp) bitset. Since a bit
can either be 0 or 1, the return value is given as a boolean.
*/
/**
* @brief Read the property from axisStatus (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool readyToBeSwitchedOn();
/**
* @brief Read the property from axisStatus (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool switchedOn();
// Bit 2 is unused
/**
* @brief Read the property from axisStatus (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool faultConditionSet();
/**
* @brief Read the property from axisStatus (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool voltagePresent();
/**
* @brief Read the property from axisStatus (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool quickStopping();
/**
* @brief Read the property from axisStatus (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool switchOnDisabled();
/**
* @brief Read the property from axisStatus (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool warning();
// Bit 8 is unused
/**
* @brief Read the property from axisStatus (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool remoteMode();
/**
* @brief Read the property from axisStatus (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool targetReached();
/**
* @brief Read the property from axisStatus (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool internalLimitActive();
// Bits 12 and 13 are unused
/**
* @brief Read the property from axisStatus (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool setEventHasOcurred();
/**
* @brief Read the property from axisStatus (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool powerEnabled();
/**
* @brief Read the Master MACS error with the xR10 command and store
* the result in axisError (see masterMacsAxisImpl redefinition in
* masterMacsAxis.cpp)
*
*/
asynStatus readAxisError();
/*
The functions below read the specified error bit from the axisError (see
masterMacsAxisImpl redefinition in masterMacsAxis.cpp) bitset. Since a bit
can either be 0 or 1, the return value is given as a boolean.
*/
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool shortCircuit();
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool encoderError();
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool followingError();
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool communicationError();
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool feedbackError();
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool positiveLimitSwitch();
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool negativeLimitSwitch();
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool positiveSoftwareLimit();
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool negativeSoftwareLimit();
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool overCurrent();
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool overTemperature();
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool overVoltage();
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool underVoltage();
/**
* @brief Read the property from axisError (see masterMacsAxisImpl
* redefinition in masterMacsAxis.cpp)
*/
bool stoFault();
private:
masterMacsController *pC_;
std::unique_ptr<masterMacsAxisImpl> pMasterMacsA_;
};
#endif