This commit is contained in:
2026-02-27 12:29:45 +03:00
parent 6199af6392
commit 3bd12bcf6d
4 changed files with 42 additions and 15 deletions

View File

@@ -183,10 +183,13 @@ public:
virtual ~MccGenericMount()
{
auto err = MOVE_CNTRL_T::stopMount();
if (err) {
logError(formatError(err));
}
// auto err = MOVE_CNTRL_T::stopMount();
// if (err) {
// logError(formatError(err));
// }
// WARNING: it is assumed here that mount stopping is performed in a derived class or, it is more logicaly,
// in MOVE_CNTRL_T-class
// logDebug(std::format("Delete MccGenericMount class instance (thread: {})", std::this_thread::get_id()));
logDebug("Delete MccGenericMount class instance (thread: {})", std::this_thread::get_id());

View File

@@ -261,7 +261,15 @@ public:
virtual ~MccGenericMovementControls()
{
stopMount();
// if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
// // if future is valid then stop is already called
// if (!_stopFuncFuture.valid()) {
// // stopMount();
// _stopFunc();
// }
// } else {
// stopMount();
// }
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
if (_slewFuncFuture.valid()) {
@@ -283,7 +291,21 @@ public:
*_stopMovementRequest = false;
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
_slewFuncFuture = std::async(std::launch::async, _slewFunc, slew_and_stop);
if (_slewFuncFuture.valid()) { // already slewing
_slewFuncFuture = std::async(
std::launch::async,
[this](bool st) {
auto err = _stopFunc(); // first, stop mount
if (!err) {
return _slewFunc(st);
} else {
return err;
}
},
slew_and_stop);
} else {
_slewFuncFuture = std::async(std::launch::async, _slewFunc, slew_and_stop);
}
return MccGenericMovementControlsErrorCode::ERROR_OK;
} else if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_BLOCKING) {
@@ -298,7 +320,9 @@ public:
*_stopMovementRequest = false;
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
_trackFuncFuture = std::async(std::launch::async, _trackFunc);
if (!_trackFuncFuture.valid()) {
_trackFuncFuture = std::async(std::launch::async, _trackFunc);
} // already tracking
return MccGenericMovementControlsErrorCode::ERROR_OK;
} else if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_BLOCKING) {
@@ -313,7 +337,10 @@ public:
*_stopMovementRequest = true;
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
_stopFuncFuture = std::async(std::launch::async, _stopFunc);
// if future is valid then stop is already called
if (!_stopFuncFuture.valid()) {
_stopFuncFuture = std::async(std::launch::async, _stopFunc);
}
return MccGenericMovementControlsErrorCode::ERROR_OK;
} else if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_BLOCKING) {

View File

@@ -967,9 +967,6 @@ public:
return output_msg.template byteRepr<typename base_t::handle_message_func_result_t>();
};
// special functor (used in the destructor)
_stopMountFunc = [mount_ptr]() { mount_ptr->stopMount(); };
}
virtual ~MccGenericMountNetworkServer()
@@ -977,8 +974,6 @@ public:
std::stringstream st;
st << std::this_thread::get_id();
_stopMountFunc();
logInfo(std::format("Delete MccGenericMountNetworkServer class instance (thread ID = {})", st.str()));
}
@@ -987,8 +982,6 @@ protected:
MccSerializedAngleFormatPrec _coordPrec{2, 1, 7};
std::function<void()> _stopMountFunc{};
template <typename RESULT_MSG_T, typename INPUT_MSG_T, mcc_generic_mount_c MountT>
RESULT_MSG_T handleMessage(const INPUT_MSG_T& input_msg, MountT* mount_ptr)
requires(

View File

@@ -318,6 +318,8 @@ public:
error_t setPointingTarget(mcc_skypoint_c auto const& sp)
{
std::lock_guard lock{*_updateMutex};
_enteredTargetPos = sp;
return MccTelemetryErrorCode::ERROR_OK;
@@ -326,6 +328,8 @@ public:
auto getPointingTarget() const
{
std::lock_guard lock{*_updateMutex};
return _enteredTargetPos;
}