From 19c5e177655bc1536e7fe440925e3d1775b56a70 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Fri, 20 Feb 2026 14:44:34 +0300 Subject: [PATCH] ... --- asibfm700_servocontroller.cpp | 43 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/asibfm700_servocontroller.cpp b/asibfm700_servocontroller.cpp index 093c8f1..d0c8076 100644 --- a/asibfm700_servocontroller.cpp +++ b/asibfm700_servocontroller.cpp @@ -104,8 +104,10 @@ AsibFM700ServoController::error_t AsibFM700ServoController::hardwareSetState(har { std::lock_guard lock{*_setStateMutex}; + error_t err; + if (state.movementState == hardware_movement_state_t::HW_MOVE_STOPPING) { // stop! - error_t err = static_cast(Mount.stop()); + err = static_cast(Mount.stop()); if (err) { return err; } @@ -136,37 +138,30 @@ AsibFM700ServoController::error_t AsibFM700ServoController::hardwareSetState(har return err; } - // static thread_local coordval_pair_t cvalpair{.X{0.0, 0.0}, .Y{0.0, 0.0}}; - // static thread_local coordpair_t cpair{.X = 0.0, .Y = 0.0}; - // cvalpair.X = {.val = state.Y, .t = tp}; - // cvalpair.Y = {.val = state.X, .t = tp}; - - // cpair.X = state.tagY; - // cpair.Y = state.tagX; - - // time point from sidservo library is 'double' number represented UNIXTIME with - // microseconds/nanoseconds precision - // double tp = std::chrono::duration(state.time_point.time_since_epoch()).count(); - - - // 2025-12-04: coordval_pair_t.X.t is now of type struct timespec auto ns = std::chrono::duration_cast(state.XY.epoch().UTC().time_since_epoch()); auto secs = std::chrono::floor(ns); ns -= secs; std::timespec tp{.tv_sec = secs.count(), .tv_nsec = ns.count()}; - // according to"SiTech protocol notes" X is DEC-axis and Y is HA-axis - coordval_pair_t cvalpair{.X{.val = state.XY.y(), .t = tp}, .Y{.val = state.XY.x(), .t = tp}}; - coordpair_t cp{.X = state.XY.y(), .Y = state.XY.x()}; + if (state.movementState == hardware_movement_state_t::HW_MOVE_SLEWING) { + // according to"SiTech protocol notes" X is DEC-axis and Y is HA-axis + coordpair_t cp{.X = state.XY.y(), .Y = state.XY.x()}; - // correctTo is asynchronous function!!! - // - // according to the Eddy's implementation of the LibSidServo library it is safe - // to pass the addresses of 'cvalpair' and 'cpair' automatic variables - auto err = static_cast(Mount.moveTo(&cp)); - // auto err = static_cast(Mount.correctTo(&cvalpair)); + err = static_cast(Mount.moveTo(&cp)); + } else if (state.movementState == hardware_movement_state_t::HW_MOVE_ADJUSTING || + state.movementState == hardware_movement_state_t::HW_MOVE_TRACKING || + state.movementState == hardware_movement_state_t::HW_MOVE_GUIDING) { + // according to"SiTech protocol notes" X is DEC-axis and Y is HA-axis + coordval_pair_t cvalpair{.X{.val = state.XY.y(), .t = tp}, .Y{.val = state.XY.x(), .t = tp}}; + + // correctTo is asynchronous function!!! + // + // according to the Eddy's implementation of the LibSidServo library it is safe + // to pass the addresses of 'cvalpair' and 'cpair' automatic variables + err = static_cast(Mount.correctTo(&cvalpair)); + } return err; }