From 84e9b9a7aea66b395108d80c3a3fd0165ab6c01f Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Fri, 20 Feb 2026 12:08:46 +0300 Subject: [PATCH] ... --- asibfm700_mount.cpp | 12 ++++++++++++ asibfm700_mount.h | 1 + asibfm700_netserver.cpp | 18 +++++++++++++++--- asibfm700_netserver.h | 12 +++++++++--- asibfm700_servocontroller.cpp | 5 +++-- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/asibfm700_mount.cpp b/asibfm700_mount.cpp index 788cbcf..8f79353 100644 --- a/asibfm700_mount.cpp +++ b/asibfm700_mount.cpp @@ -323,6 +323,18 @@ Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const Asibfm700MountCo } +Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const std::string& cfg_filename) +{ + Asibfm700MountConfig new_config; + auto err = new_config.load(cfg_filename); + if (err) { + return mcc::mcc_deduced_err(err, std::make_error_code(std::errc::file_exists)); + } + + return updateMountConfig(new_config); +} + + /* PROTECTED METHODS */ void Asibfm700Mount::errorLogging(const std::string& msg, const std::error_code& err) diff --git a/asibfm700_mount.h b/asibfm700_mount.h index d0373f7..d8b93ba 100644 --- a/asibfm700_mount.h +++ b/asibfm700_mount.h @@ -59,6 +59,7 @@ public: error_t initMount(); error_t updateMountConfig(Asibfm700MountConfig const&); + error_t updateMountConfig(std::string const&); Asibfm700MountConfig currentMountConfig(); protected: diff --git a/asibfm700_netserver.cpp b/asibfm700_netserver.cpp index 3e7fef2..61f588c 100644 --- a/asibfm700_netserver.cpp +++ b/asibfm700_netserver.cpp @@ -56,9 +56,21 @@ Asibfm700MountNetServer::Asibfm700MountNetServer(asio::io_context& ctx, output_msg.construct(mcc::network::MCC_COMMPROTO_KEYWORD_SERVER_ACK_STR, ASIBFM700_COMMPROTO_KEYWORD_SITEGEO_STR, lon, lat); - } - - else { + } else if (input_msg.withKey(ASIBFM700_COMMPROTO_KEYWORD_RELOADCFG_STR)) { + if (input_msg.paramSize()) { + auto vp = input_msg.paramValue(0); + auto err = mount_ptr->updateMountConfig(vp.value()); + if (err) { + output_msg.construct(mcc::network::MCC_COMMPROTO_KEYWORD_SERVER_ERROR_STR, err); + } else { + output_msg.construct(mcc::network::MCC_COMMPROTO_KEYWORD_SERVER_ACK_STR, + ASIBFM700_COMMPROTO_KEYWORD_RELOADCFG_STR); + } + } else { // a filename must be given + output_msg.construct(mcc::network::MCC_COMMPROTO_KEYWORD_SERVER_ERROR_STR, + std::make_error_code(std::errc::invalid_argument)); + } + } else { // basic network message processing output_msg = base_t::handleMessage(input_msg, mount_ptr); } diff --git a/asibfm700_netserver.h b/asibfm700_netserver.h index 0f1297c..e907efe 100644 --- a/asibfm700_netserver.h +++ b/asibfm700_netserver.h @@ -91,13 +91,19 @@ static constexpr auto merge_arrays(const std::array& arr1, const std::ar // meteo parameters (ambient air temperature, humidity and atmosperic pressure) constexpr static std::string_view ASIBFM700_COMMPROTO_KEYWORD_METEO_STR{"METEO"}; + // current site geodetic longtude and latitude constexpr static std::string_view ASIBFM700_COMMPROTO_KEYWORD_SITEGEO_STR{"SITEGEO"}; +// reload mount configuration file +constexpr static std::string_view ASIBFM700_COMMPROTO_KEYWORD_RELOADCFG_STR{"RELOADCFG"}; + + struct Asibfm700NetMessageValidKeywords { - static constexpr std::array NETMSG_VALID_KEYWORDS = details::merge_arrays( - mcc::network::MccNetMessageValidKeywords::NETMSG_VALID_KEYWORDS, - std::array{ASIBFM700_COMMPROTO_KEYWORD_METEO_STR, ASIBFM700_COMMPROTO_KEYWORD_SITEGEO_STR}); + static constexpr std::array NETMSG_VALID_KEYWORDS = + details::merge_arrays(mcc::network::MccNetMessageValidKeywords::NETMSG_VALID_KEYWORDS, + std::array{ASIBFM700_COMMPROTO_KEYWORD_METEO_STR, ASIBFM700_COMMPROTO_KEYWORD_SITEGEO_STR, + ASIBFM700_COMMPROTO_KEYWORD_RELOADCFG_STR}); // hashes of valid keywords static constexpr std::array NETMSG_VALID_KEYWORD_HASHES = [](std::index_sequence) { diff --git a/asibfm700_servocontroller.cpp b/asibfm700_servocontroller.cpp index 936afb1..093c8f1 100644 --- a/asibfm700_servocontroller.cpp +++ b/asibfm700_servocontroller.cpp @@ -159,13 +159,14 @@ AsibFM700ServoController::error_t AsibFM700ServoController::hardwareSetState(har // 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()}; // 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.correctTo(&cvalpair, &cpair)); - auto err = static_cast(Mount.correctTo(&cvalpair)); + auto err = static_cast(Mount.moveTo(&cp)); + // auto err = static_cast(Mount.correctTo(&cvalpair)); return err; }