From e0b3ef225d1c027fbe3ec043bf178895fc7296ea Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Mon, 23 Feb 2026 11:38:23 +0300 Subject: [PATCH] ... --- include/mcc/mcc_generic_movecontrols.h | 116 +++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 include/mcc/mcc_generic_movecontrols.h diff --git a/include/mcc/mcc_generic_movecontrols.h b/include/mcc/mcc_generic_movecontrols.h new file mode 100644 index 0000000..e16397f --- /dev/null +++ b/include/mcc/mcc_generic_movecontrols.h @@ -0,0 +1,116 @@ +#pragma once + +#include "mcc_error.h" + + +namespace mcc::impl +{ +enum class MccGenericMovementControlsErrorCode : int { + ERROR_OK, + ERROR_IN_PZONE, + ERRROR_NEAR_PZONE, + ERROR_TELEMETRY_TIMEOUT +}; +} // namespace mcc::impl + +namespace std +{ +template <> +class is_error_code_enum : public true_type +{ +}; +} // namespace std + +namespace mcc::impl +{ + +// error category +struct MccGenericMovementControlsErrorCategory : std::error_category { + const char* name() const noexcept { return "MCC-GENERIC-MOVECONTRL"; } + + std::string message(int ec) const + { + MccGenericMovementControlsErrorCode err = static_cast(ec); + + switch (err) { + case MccGenericMovementControlsErrorCode::ERROR_OK: + return "OK"; + case MccGenericMovementControlsErrorCode::ERROR_IN_PZONE: + return "target is in zone"; + case MccGenericMovementControlsErrorCode::ERRROR_NEAR_PZONE: + return "mount is near zone"; + case MccGenericMovementControlsErrorCode::ERROR_TELEMETRY_TIMEOUT: + return "telemetry data timeout"; + default: + return "unknown"; + } + + static const MccGenericMovementControlsErrorCategory& get() + { + static const MccGenericMovementControlsErrorCategory constInst; + return constInst; + } + } +}; + + +inline std::error_code make_error_code(MccGenericMovementControlsErrorCode ec) +{ + return std::error_code(static_cast(ec), MccGenericMovementControlsErrorCategory::get()); +} + + +struct MccGenericMovementControlsParams { + // timeout to telemetry updating + std::chrono::milliseconds telemetryTimeout{3000}; + + // braking acceleration after execution of mount stopping command (in rads/s^2) + // it must be given as non-negative value!!! + double brakingAccelX{0.0}; + double brakingAccelY{0.0}; + + // ******* slewing mode ******* + + // coordinates difference to stop slewing (in radians) + double slewToleranceRadius{5.0_arcsecs}; + + // slewing trajectory file. if empty - just skip saving + std::string slewingPathFilename{}; + + + // ******* tracking mode ******* + + // maximal target-to-mount difference for tracking process (in arcsecs) + // it it is greater then the current mount coordinates are used as target one + double trackingMaxCoordDiff{20.0}; + + // tracking trajectory file. if empty - just skip saving + std::string trackingPathFilename{}; +}; + + +template +class MccGenericMovementControls +{ +public: + typedef MccError error_t; + + typedef PARAMS_T movement_params_t; + + error_t slewToTarget(bool slew_and_stop) {} + + error_t trackTarget() {} + + error_t stopMount() {} + + error_t setMovementParams(movement_params_t const& pars) { _currentParams->store(pars); } + + movement_params_t getMovementParams() const { return _currentParams->load(); } + +protected: + MccGenericMovementControls() = default; + + std::unique_ptr> _currentParams{new std::atomic{}}; +}; + +} // namespace mcc::impl