From 022ff155a98ab0d41de6009b0d4afcc4422fc9ee Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Thu, 24 Jul 2025 09:28:23 +0300 Subject: [PATCH] ... --- cxx/asibfm700_hardware.cpp | 44 +++++++++++++++++++++++++++++--------- cxx/asibfm700_hardware.h | 4 +++- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/cxx/asibfm700_hardware.cpp b/cxx/asibfm700_hardware.cpp index c9311f9..767bf24 100644 --- a/cxx/asibfm700_hardware.cpp +++ b/cxx/asibfm700_hardware.cpp @@ -90,12 +90,42 @@ std::string_view AsibFM700Hardware::id() const } +AsibFM700Hardware::error_t AsibFM700Hardware::getState(AsibFM700Hardware::hw_state_t& state) const +{ + mountdata_t data; + error_t err = static_cast(Mount.getMountData(&data)); + + if (err == AsibFM700HardwareErrorCode::ERROR_OK) { + // are both motors stopped? + bool stop_motors = (data.extradata.ExtraBits & XMOTOR_STOP_BIT) && (data.extradata.ExtraBits & YMOTOR_STOP_BIT); + if (stop_motors) { + state = hw_state_t::HW_STATE_STOP; + return AsibFM700HardwareErrorCode::ERROR_OK; + } + } + + return err; +} + AsibFM700Hardware::error_t AsibFM700Hardware::setPos(AsibFM700Hardware::axes_pos_t pos) { - // according to hardware configuration (encoders pins (Eddy said)) X is DEC-axis and Y is HA-axis + // according to"SiTech protocol notes" X is DEC-axis and Y is HA-axis double X = pos.y, Y = pos.x; - auto err = static_cast(Mount.moveTo(&X, &Y)); + error_t err = static_cast(Mount.moveTo(&X, &Y)); + + coordpair_t hw_pos{.X = pos.y, .Y = pos.x}; + switch (pos.state) { + case hw_state_t::HW_STATE_SLEW: // slew mount + err = static_cast(Mount.slewTo(&hw_pos, pos.flags)); + break; + case hw_state_t::HW_STATE_TRACK: // interpretate as guiding correction + break; + case hw_state_t::HW_STATE_STOP: + break; + default: + break; + } return err; } @@ -105,7 +135,7 @@ AsibFM700Hardware::error_t AsibFM700Hardware::setPos(AsibFM700Hardware::axes_pos AsibFM700Hardware::error_t AsibFM700Hardware::getPos(AsibFM700Hardware::axes_pos_t& pos) { mountdata_t data; - auto err = static_cast(Mount.getMountData(&data)); + error_t err = static_cast(Mount.getMountData(&data)); if (err == AsibFM700HardwareErrorCode::ERROR_OK) { // time point from sidservo library is 'double' number represented UNIXTIME with @@ -124,13 +154,7 @@ AsibFM700Hardware::error_t AsibFM700Hardware::getPos(AsibFM700Hardware::axes_pos pos.yrate = data.encXspeed.val; // mount state - - // are both motors stopped? - bool stop_motors = (data.extradata.ExtraBits & XMOTOR_STOP_BIT) && (data.extradata.ExtraBits & YMOTOR_STOP_BIT); - if (stop_motors) { - pos.state = hw_state_t::HW_STATE_STOP; - return AsibFM700HardwareErrorCode::ERROR_OK; - } + err = getState(pos.state); } return err; diff --git a/cxx/asibfm700_hardware.h b/cxx/asibfm700_hardware.h index a992b54..f204473 100644 --- a/cxx/asibfm700_hardware.h +++ b/cxx/asibfm700_hardware.h @@ -35,7 +35,7 @@ struct AsibFM700HardwareErrorCategory : public std::error_category { }; -inline std::error_code make_error_code(AsibFM700HardwareErrorCode ec) +static inline std::error_code make_error_code(AsibFM700HardwareErrorCode ec) { return std::error_code(static_cast(ec), AsibFM700HardwareErrorCategory::get()); } @@ -77,6 +77,7 @@ public: coord_t xrate, yrate; hw_state_t state; + slewflags_t flags; }; @@ -105,6 +106,7 @@ public: std::string_view id() const; + error_t getState(hw_state_t&) const; error_t setPos(axes_pos_t); error_t getPos(axes_pos_t&);