125 lines
2.8 KiB
C++
125 lines
2.8 KiB
C++
#pragma once
|
|
|
|
#include <mcc_defaults.h>
|
|
#include <mcc_generics.h>
|
|
|
|
#include "../LibSidServo/sidservo.h"
|
|
|
|
|
|
namespace asibfm700
|
|
{
|
|
|
|
/* error codes enum definition */
|
|
|
|
enum class AsibFM700ServoControllerErrorCode : int {
|
|
// error codes from sidservo library
|
|
ERROR_OK = MCC_E_OK,
|
|
ERROR_FATAL = MCC_E_FATAL,
|
|
ERROR_BADFORMAT = MCC_E_BADFORMAT,
|
|
ERROR_ENCODERDEV = MCC_E_ENCODERDEV,
|
|
ERROR_MOUNTDEV = MCC_E_MOUNTDEV,
|
|
ERROR_FAILED = MCC_E_FAILED,
|
|
// my codes ...
|
|
};
|
|
|
|
// error category
|
|
struct AsibFM700HardwareErrorCategory : public std::error_category {
|
|
const char* name() const noexcept;
|
|
std::string message(int ec) const;
|
|
|
|
static const AsibFM700HardwareErrorCategory& get();
|
|
};
|
|
|
|
|
|
static inline std::error_code make_error_code(AsibFM700ServoControllerErrorCode ec)
|
|
{
|
|
return std::error_code(static_cast<int>(ec), AsibFM700HardwareErrorCategory::get());
|
|
}
|
|
|
|
} // namespace asibfm700
|
|
|
|
|
|
namespace std
|
|
{
|
|
|
|
template <>
|
|
class is_error_code_enum<asibfm700::AsibFM700ServoControllerErrorCode> : public true_type
|
|
{
|
|
};
|
|
|
|
} // namespace std
|
|
|
|
|
|
namespace asibfm700
|
|
{
|
|
|
|
class AsibFM700ServoController
|
|
{
|
|
public:
|
|
typedef std::error_code error_t;
|
|
|
|
enum class hardware_moving_state_t : int {
|
|
HW_MOVE_STOPPED,
|
|
HW_MOVE_SLEWING,
|
|
HW_MOVE_ADJUSTING,
|
|
HW_MOVE_TRACKING,
|
|
HW_MOVE_GUIDING
|
|
};
|
|
|
|
struct hardware_state_t {
|
|
static constexpr mcc::MccCoordPairKind pair_kind = mcc::MccCoordPairKind::COORDS_KIND_HADEC_APP;
|
|
mcc::MccTimePoint time_point;
|
|
|
|
double X, Y, speedX, speedY;
|
|
|
|
hardware_moving_state_t moving_state;
|
|
};
|
|
|
|
|
|
struct hardware_config_t {
|
|
// the 'char*' fields from conf_t:
|
|
// wrap it to std::string
|
|
std::string MountDevPath;
|
|
std::string EncoderDevPath;
|
|
std::string EncoderXDevPath;
|
|
std::string EncoderYDevPath;
|
|
|
|
conf_t devConfig;
|
|
hardware_configuration_t hwConfig;
|
|
};
|
|
|
|
/* constructors and destructor */
|
|
|
|
AsibFM700ServoController();
|
|
|
|
AsibFM700ServoController(hardware_config_t config);
|
|
|
|
AsibFM700ServoController(const AsibFM700ServoController&) = delete;
|
|
AsibFM700ServoController& operator=(const AsibFM700ServoController&) = delete;
|
|
|
|
AsibFM700ServoController(AsibFM700ServoController&&);
|
|
AsibFM700ServoController& operator=(AsibFM700ServoController&&);
|
|
|
|
~AsibFM700ServoController();
|
|
|
|
/* public methods */
|
|
|
|
constexpr std::string_view hardwareName() const;
|
|
|
|
error_t hardwareSetState(hardware_state_t state);
|
|
error_t hardwareGetState(hardware_state_t* state);
|
|
|
|
error_t hardwareStop();
|
|
error_t hardwareInit();
|
|
|
|
void hardwareUpdateConfig(conf_t cfg);
|
|
void hardwareUpdateConfig(hardware_configuration_t cfg);
|
|
|
|
private:
|
|
hardware_config_t _hardwareConfig;
|
|
|
|
std::unique_ptr<std::mutex> _setStateMutex;
|
|
};
|
|
|
|
} // namespace asibfm700
|