Applied PIMPL principle

This commit is contained in:
2025-05-23 12:16:25 +02:00
parent e0a74c5598
commit d1d694ad6b
5 changed files with 328 additions and 98 deletions

View File

@@ -1,13 +1,15 @@
#ifndef masterMacsAXIS_H
#define masterMacsAXIS_H
#include "sinqAxis.h"
#include <bitset>
#include <memory>
// Forward declaration of the controller class to resolve the cyclic dependency
// between the controller and the axis .h-file. See
// https://en.cppreference.com/w/cpp/language/class.
class masterMacsController;
struct masterMaxsAxisImpl;
class masterMacsAxis : public sinqAxis {
public:
/**
@@ -105,23 +107,23 @@ class masterMacsAxis : public sinqAxis {
*/
asynStatus readEncoderType();
protected:
masterMacsController *pC_;
double lastSetSpeed_;
bool waitForHandshake_;
time_t timeAtHandshake_;
/**
* @brief Check if the axis needs to run its initialization function
*
* @return true
* @return false
*/
bool needInit();
bool targetReachedUninitialized_;
/**
* @brief Instruct the axis to run its init() function during the next poll
*
* @param needInit
*/
void setNeedInit(bool needInit);
asynStatus readConfig();
/*
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_
@@ -130,7 +132,7 @@ class masterMacsAxis : public sinqAxis {
asynStatus readAxisStatus();
/*
The functions below read the specified status bit from the axisStatus_
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.
*/
@@ -138,68 +140,68 @@ class masterMacsAxis : public sinqAxis {
/**
* @brief Read the property from axisStatus_
*/
bool readyToBeSwitchedOn() { return axisStatus_[0]; }
bool readyToBeSwitchedOn();
/**
* @brief Read the property from axisStatus_
*/
bool switchedOn() { return axisStatus_[1]; }
bool switchedOn();
// Bit 2 is unused
/**
* @brief Read the property from axisStatus_
*/
bool faultConditionSet() { return axisStatus_[3]; }
bool faultConditionSet();
/**
* @brief Read the property from axisStatus_
*/
bool voltagePresent() { return axisStatus_[4]; }
bool voltagePresent();
/**
* @brief Read the property from axisStatus_
*/
bool quickStopping() { return axisStatus_[5] == 0; }
bool quickStopping();
/**
* @brief Read the property from axisStatus_
*/
bool switchOnDisabled() { return axisStatus_[6]; }
bool switchOnDisabled();
/**
* @brief Read the property from axisStatus_
*/
bool warning() { return axisStatus_[7]; }
bool warning();
// Bit 8 is unused
/**
* @brief Read the property from axisStatus_
*/
bool remoteMode() { return axisStatus_[9]; }
bool remoteMode();
/**
* @brief Read the property from axisStatus_
*/
bool targetReached() { return axisStatus_[10]; }
bool targetReached();
/**
* @brief Read the property from axisStatus_
*/
bool internalLimitActive() { return axisStatus_[11]; }
bool internalLimitActive();
// Bits 12 and 13 are unused
/**
* @brief Read the property from axisStatus_
*/
bool setEventHasOcurred() { return axisStatus_[14]; }
bool setEventHasOcurred();
/**
* @brief Read the property from axisStatus_
*/
bool powerEnabled() { return axisStatus_[15]; }
bool powerEnabled();
/**
* @brief Read the Master MACS status with the xR10 command and store the
@@ -217,72 +219,76 @@ class masterMacsAxis : public sinqAxis {
/**
* @brief Read the property from axisError_
*/
bool shortCircuit() { return axisError_[1]; }
bool shortCircuit();
/**
* @brief Read the property from axisError_
*/
bool encoderError() { return axisError_[2]; }
bool encoderError();
/**
* @brief Read the property from axisError_
*/
bool followingError() { return axisError_[3]; }
bool followingError();
/**
* @brief Read the property from axisError_
*/
bool communicationError() { return axisError_[4]; }
bool communicationError();
/**
* @brief Read the property from axisError_
*/
bool feedbackError() { return axisError_[5]; }
bool feedbackError();
/**
* @brief Read the property from axisError_
*/
bool positiveLimitSwitch() { return axisError_[6]; }
bool positiveLimitSwitch();
/**
* @brief Read the property from axisError_
*/
bool negativeLimitSwitch() { return axisError_[7]; }
bool negativeLimitSwitch();
/**
* @brief Read the property from axisError_
*/
bool positiveSoftwareLimit() { return axisError_[8]; }
bool positiveSoftwareLimit();
/**
* @brief Read the property from axisError_
*/
bool negativeSoftwareLimit() { return axisError_[9]; }
bool negativeSoftwareLimit();
/**
* @brief Read the property from axisError_
*/
bool overCurrent() { return axisError_[10]; }
bool overCurrent();
/**
* @brief Read the property from axisError_
*/
bool overTemperature() { return axisError_[11]; }
bool overTemperature();
/**
* @brief Read the property from axisError_
*/
bool overVoltage() { return axisError_[12]; }
bool overVoltage();
/**
* @brief Read the property from axisError_
*/
bool underVoltage() { return axisError_[13]; }
bool underVoltage();
/**
* @brief Read the property from axisError_
*/
bool stoFault() { return axisError_[15]; }
bool stoFault();
private:
masterMacsController *pC_;
std::unique_ptr<masterMaxsAxisImpl> pMasterMacsA_;
};
#endif