From 08ad1e665b8e158c0f78121ed4973011115b2e27 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Tue, 11 Nov 2025 18:10:06 +0300 Subject: [PATCH] ... --- asibfm700/asibfm700_mount.h | 2 ++ asibfm700/asibfm700_netserver_main.cpp | 5 +++-- mcc/mcc_generic_mount.h | 4 +++- mcc/mcc_slewing_model.h | 10 +++++++--- mcc/mcc_telemetry.h | 15 ++++++++++----- mcc/mcc_tracking_model.h | 4 +++- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/asibfm700/asibfm700_mount.h b/asibfm700/asibfm700_mount.h index 6a6ed3f..48e1c20 100644 --- a/asibfm700/asibfm700_mount.h +++ b/asibfm700/asibfm700_mount.h @@ -53,6 +53,8 @@ protected: void enter(MccGenericFsmMountErrorEvent& event) { + enterLog(event); + // event.mount()->logWarn("The mount already in error state!"); auto err = event.eventData(); event.mount()->logError("An error occured: {} [{} {}]", err.message(), err.value(), err.category().name()); diff --git a/asibfm700/asibfm700_netserver_main.cpp b/asibfm700/asibfm700_netserver_main.cpp index c2ada0f..9bacde4 100644 --- a/asibfm700/asibfm700_netserver_main.cpp +++ b/asibfm700/asibfm700_netserver_main.cpp @@ -44,7 +44,8 @@ int main(int argc, char* argv[]) options.positional_help("[endpoint0] [enpoint1] ... [endpointN]"); options.parse_positional({"endpoints"}); - asio::io_context ctx(2); + // asio::io_context ctx(2); + asio::io_context ctx; try { @@ -153,7 +154,7 @@ int main(int argc, char* argv[]) } - asio::thread_pool pool(3); + asio::thread_pool pool(5); asio::post(pool, [&ctx]() { ctx.run(); }); diff --git a/mcc/mcc_generic_mount.h b/mcc/mcc_generic_mount.h index a9cc172..bf700d4 100644 --- a/mcc/mcc_generic_mount.h +++ b/mcc/mcc_generic_mount.h @@ -255,7 +255,7 @@ public: _enteredTargetCoordiniates.pair_kind == MccCoordPairKind::COORDS_KIND_HADEC_APP) { xstr = MccAngle(_enteredTargetCoordiniates.X).sexagesimal(true); } else { - MccAngle(_enteredTargetCoordiniates.X).sexagesimal(); + xstr = MccAngle(_enteredTargetCoordiniates.X).sexagesimal(); } logInfo(std::format("Set entered target coordinates to: {} {} {}", xstr, @@ -598,6 +598,7 @@ protected: using transition_t = fsm::fsm_transition_table_t< std::pair>, + std::pair>, std::pair, std::pair>, std::pair>; @@ -664,6 +665,7 @@ protected: using transition_t = fsm::fsm_transition_table_t< std::pair>, + std::pair>, std::pair, std::pair>; diff --git a/mcc/mcc_slewing_model.h b/mcc/mcc_slewing_model.h index 3e355c5..f8a7aeb 100644 --- a/mcc/mcc_slewing_model.h +++ b/mcc/mcc_slewing_model.h @@ -199,7 +199,7 @@ public: return mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE); } - std::chrono::steady_clock::time_point start_slewing_tp, last_adjust_tp; + // std::chrono::steady_clock::time_point start_slewing_tp, last_adjust_tp; // mcc_tp2tp(hw_state.time_point, start_slewing_tp); // not compiled!! // double dist, dx, dy, sinY, rate2, xrate; @@ -210,6 +210,10 @@ public: bool adjust_mode = false; static constexpr auto sideral_rate2 = slewing_params_t::sideralRate * slewing_params_t::sideralRate; + std::chrono::steady_clock::time_point start_slewing_tp, last_adjust_tp; + start_slewing_tp = std::chrono::steady_clock::now(); + last_adjust_tp = start_slewing_tp; + while (true) { // wait for updated telemetry data { @@ -231,10 +235,10 @@ public: // and check them for getting into the prohibited zones if constexpr (mccIsEquatorialMount(CONTROLS_T::mountType)) { cpt.X = tdata.HA + tdata.speedX * min_time_to_pzone_in_secs; - cpt.X = tdata.DEC_APP + tdata.speedY * min_time_to_pzone_in_secs; + cpt.Y = tdata.DEC_APP + tdata.speedY * min_time_to_pzone_in_secs; } else if constexpr (mccIsAltAzMount(CONTROLS_T::mountType)) { cpt.X = tdata.AZ + tdata.speedX * min_time_to_pzone_in_secs; - cpt.X = tdata.ZD + tdata.speedY * min_time_to_pzone_in_secs; + cpt.Y = tdata.ZD + tdata.speedY * min_time_to_pzone_in_secs; } mcc_tp2tp(tdata.time_point, cpt.time_point); diff --git a/mcc/mcc_telemetry.h b/mcc/mcc_telemetry.h index 0dd02f9..eee88c7 100644 --- a/mcc/mcc_telemetry.h +++ b/mcc/mcc_telemetry.h @@ -598,15 +598,20 @@ public: *_isDataUpdated = false; - // std::future update_ft = std::async(std::launch::async, _updateFunc, stop_source.get_token()); - std::future update_ft = - std::async(std::launch::async, _updateFunc, _internalUpdatingStopSource.get_token()); + std::future update_ft = std::async(std::launch::async, _updateFunc, stop_source.get_token()); + // std::future update_ft = + // std::async(std::launch::async, _updateFunc, _internalUpdatingStopSource.get_token()); auto status = update_ft.wait_for(timeout); if (status == std::future_status::ready) { *_isDataUpdated = true; _lastUpdateError = update_ft.get(); - } else { + } else if (status == std::future_status::deferred) { // std::async was invoked in this thread, get result + _lastUpdateError = update_ft.get(); + if (!_lastUpdateError) { + *_isDataUpdated = true; + } + } else { // timeout stop_source.request_stop(); _lastUpdateError = MccTelemetryErrorCode::ERROR_DATA_TIMEOUT; } @@ -631,7 +636,7 @@ public: return MccTelemetryErrorCode::ERROR_DATA_TIMEOUT; } - std::lock_guard thread_lock{*_updateMutex}; + // std::lock_guard thread_lock{*_updateMutex}; if (!_lastUpdateError) { mcc_copy_telemetry_data(_data, tdata); diff --git a/mcc/mcc_tracking_model.h b/mcc/mcc_tracking_model.h index 8bce7d8..58f01b3 100644 --- a/mcc/mcc_tracking_model.h +++ b/mcc/mcc_tracking_model.h @@ -254,8 +254,10 @@ public: std::chrono::steady_clock::time_point last_corr_tp, last_ipzone_update_tp; + last_corr_tp = std::chrono::steady_clock::now(); + last_ipzone_update_tp = last_corr_tp; - while (*_stopTracking) { + while (!*_stopTracking) { // wait for updated telemetry data { std::lock_guard lock{*_currentParamsMutex};