Initial commit for masterMacs
This commit is contained in:
215
src/masterMacsAxis.h
Normal file
215
src/masterMacsAxis.h
Normal file
@@ -0,0 +1,215 @@
|
||||
#ifndef masterMacsAXIS_H
|
||||
#define masterMacsAXIS_H
|
||||
#include "sinqAxis.h"
|
||||
#include <bitset>
|
||||
|
||||
// Forward declaration of the controller class to resolve the cyclic dependency
|
||||
// between C804Controller.h and C804Axis.h. See
|
||||
// https://en.cppreference.com/w/cpp/language/class.
|
||||
class masterMacsController;
|
||||
|
||||
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 `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 `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 `atFirstPoll` function from sinqAxis.
|
||||
*
|
||||
* 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 atFirstPoll();
|
||||
|
||||
/**
|
||||
* @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();
|
||||
|
||||
protected:
|
||||
masterMacsController *pC_;
|
||||
|
||||
asynStatus readConfig();
|
||||
bool initial_poll_;
|
||||
|
||||
/*
|
||||
The axis status and axis error of MasterMACS are given as an integer from
|
||||
the controller. The 16 individual bits contain the actual information.
|
||||
*/
|
||||
std::bitset<16> axisStatus_;
|
||||
std::bitset<16> axisError_;
|
||||
|
||||
/**
|
||||
* @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() { return axisStatus_[0]; }
|
||||
|
||||
/**
|
||||
* @brief Read the property from axisStatus_
|
||||
*/
|
||||
bool switchedOn() { return axisStatus_[1]; }
|
||||
|
||||
/**
|
||||
* @brief Read the property from axisStatus_
|
||||
*/
|
||||
bool enabled() { return axisStatus_[2]; }
|
||||
|
||||
/**
|
||||
* @brief Read the property from axisStatus_
|
||||
*/
|
||||
bool faultConditionSet() { return axisStatus_[3]; }
|
||||
|
||||
/**
|
||||
* @brief Read the property from axisStatus_
|
||||
*/
|
||||
bool voltagePresent() { return axisStatus_[4]; }
|
||||
|
||||
/**
|
||||
* @brief Read the property from axisStatus_
|
||||
*/
|
||||
bool quickStopping() { return axisStatus_[5] == 0; }
|
||||
|
||||
/**
|
||||
* @brief Read the property from axisStatus_
|
||||
*/
|
||||
bool switchOnDisabled() { return axisStatus_[6]; }
|
||||
|
||||
/**
|
||||
* @brief Read the property from axisStatus_
|
||||
*/
|
||||
bool newMoveCommandWhileMoving() { return axisStatus_[7]; }
|
||||
|
||||
/**
|
||||
* @brief Read the property from axisStatus_
|
||||
*/
|
||||
bool isMoving() { return axisStatus_[8]; }
|
||||
|
||||
/**
|
||||
* @brief Read the property from axisStatus_
|
||||
*/
|
||||
bool remoteMode() { return axisStatus_[9]; }
|
||||
|
||||
/**
|
||||
* @brief Read the property from axisStatus_
|
||||
*/
|
||||
bool targetReached() { return axisStatus_[10]; }
|
||||
|
||||
/**
|
||||
* @brief Read the property from axisStatus_
|
||||
*/
|
||||
bool internalLimitActive() { return axisStatus_[11]; }
|
||||
|
||||
// Bits 12 and 13 are unused
|
||||
|
||||
/**
|
||||
* @brief Read the property from axisStatus_
|
||||
*/
|
||||
bool setEventHasOcurred() { return axisStatus_[14]; }
|
||||
|
||||
/**
|
||||
* @brief Read the property from axisStatus_
|
||||
*/
|
||||
bool powerEnabled() { return axisStatus_[15]; }
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
|
||||
private:
|
||||
friend class masterMacsController;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user