mountcontrol/cxx/asibfm700_hardware.h
Timur A. Fatkhullin 2faa3f0aca ...
2025-07-21 23:49:12 +03:00

117 lines
2.6 KiB
C++

#pragma once
/* AstroSIB-FM700 FORK MOUNT CONTROL LIBRARY */
/* HARDWARE WRAPPER IMPLEMENTATION */
#include "../LibSidServo/sidservo.h"
#include "mcc_mount_concepts.h"
#include "mcc_mount_coord.h"
namespace asibfm700
{
/* error codes enum definition */
enum class AsibFM700HardwareErrorCode : 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();
};
inline std::error_code make_error_code(AsibFM700HardwareErrorCode ec)
{
return std::error_code(static_cast<int>(ec), AsibFM700HardwareErrorCategory::get());
}
} // namespace asibfm700
namespace std
{
template <>
class is_error_code_enum<asibfm700::AsibFM700HardwareErrorCode> : public true_type
{
};
} // namespace std
namespace asibfm700
{
class AsibFM700Hardware final
{
public:
// definitions from concept
typedef std::error_code error_t;
typedef mcc::MccAngle coord_t;
typedef std::chrono::system_clock::time_point time_point_t; // UTC time
struct axes_pos_t {
time_point_t time_point;
coord_t x, y;
coord_t xrate, yrate;
};
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;
};
AsibFM700Hardware(const hardware_config_t& conf);
~AsibFM700Hardware();
AsibFM700Hardware(const AsibFM700Hardware&) = delete;
AsibFM700Hardware& operator=(const AsibFM700Hardware&) = delete;
AsibFM700Hardware(AsibFM700Hardware&&) = default;
AsibFM700Hardware& operator=(AsibFM700Hardware&&) = default;
std::string_view id() const;
error_t setPos(axes_pos_t);
error_t getPos(axes_pos_t&);
error_t stop();
error_t init();
private:
hardware_config_t _hardwareConfig;
// static void moveInst(AsibFM700Hardware* from, AsibFM700Hardware* to);
};
static_assert(mcc::traits::mcc_mount_hardware_c<AsibFM700Hardware>, "AsibFM700Hardware!!!");
} // namespace asibfm700