diff --git a/CMakeLists.txt b/CMakeLists.txt index 2411edf..a46afd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,10 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) # ******* C++ PART OF THE PROJECT ******* set(EXAMPLES OFF CACHE BOOL "" FORCE) +set(CMAKE_BUILD_TYPE "Release") add_subdirectory(LibSidServo) +set(CMAKE_BUILD_TYPE "Debug") + # add_subdirectory(cxx) add_subdirectory(mcc) add_subdirectory(asibfm700) diff --git a/asibfm700/asibfm700_mount.cpp b/asibfm700/asibfm700_mount.cpp index 39c66b9..2d3cc1c 100644 --- a/asibfm700/asibfm700_mount.cpp +++ b/asibfm700/asibfm700_mount.cpp @@ -200,7 +200,8 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount() if (ok) { logInfo("Start updating telemetry data"); } else { - logError("Cannot update telemetry data!"); + auto err = lastUpdateError(); + logError("Cannot update telemetry data (err = {} [{}])!", err.message(), err.category().name()); } return mcc::MccGenericMountErrorCode::ERROR_OK; diff --git a/mcc/mcc_finite_state_machine.h b/mcc/mcc_finite_state_machine.h index 5395796..75fe87e 100644 --- a/mcc/mcc_finite_state_machine.h +++ b/mcc/mcc_finite_state_machine.h @@ -317,6 +317,7 @@ protected: std::vector> _destroyFunc{}; std::string_view _currentStateID; + std::string_view _previousStateID; std::vector _stateID{}; std::vector _eventID{}; @@ -367,7 +368,7 @@ protected: public: template - constexpr MccFiniteStateMachine(InitStateT) : _currentStateID(InitStateT::ID) + constexpr MccFiniteStateMachine(InitStateT) : _currentStateID(InitStateT::ID), _previousStateID(InitStateT::ID) { using states_t = deduce_states_t; auto states = std::make_shared(); @@ -417,6 +418,7 @@ public: p_event->onTransit(); } + _previousStateID = curr_state_t::ID; *currentState = &std::get(*states); _currentStateID = to_state_t::ID; @@ -525,6 +527,11 @@ public: return _currentStateID; } + std::string_view previousStateID() const + { + return _previousStateID; + } + // returns IDs of all deduced unique states diff --git a/mcc/mcc_generic_mount.h b/mcc/mcc_generic_mount.h index 55bdea3..85e2350 100644 --- a/mcc/mcc_generic_mount.h +++ b/mcc/mcc_generic_mount.h @@ -469,6 +469,16 @@ protected: // only initialization is allowed here using transition_t = fsm::fsm_transition_table_t< std::pair>>; + + void exit(fsm::traits::fsm_event_c auto& event) + { + this->exitLog(event); + } + + void enter(fsm::traits::fsm_event_c auto& event) + { + this->enterLog(event); + } }; // template @@ -510,22 +520,23 @@ protected: std::pair>; - void exit(MccGenericFsmMountInitEvent& event) - { - if constexpr (mcc_generic_log_mount_c) { - event.mount()->logWarn("It seems a re-entering to the initializing state was asked! Ignore the event!"); - } - } + // void exit(MccGenericFsmMountInitEvent& event) + // { + // if constexpr (mcc_generic_log_mount_c) { + // event.mount()->logWarn("It seems a re-entering to the initializing state was asked! Ignore the + // event!"); + // } + // } - void enter(MccGenericFsmMountInitEvent& event) - { - if constexpr (mcc_generic_log_mount_c) { - event.mount()->logWarn( - "It seems a re-entering to the initializing state was asked! Ignore the event and wait for the " - "mount " - "to initialize!"); - } - } + // void enter(MccGenericFsmMountInitEvent& event) + // { + // if constexpr (mcc_generic_log_mount_c) { + // event.mount()->logWarn( + // "It seems a re-entering to the initializing state was asked! Ignore the event and wait for the " + // "mount " + // "to initialize!"); + // } + // } void exit(fsm::traits::fsm_event_c auto& event) { @@ -534,14 +545,25 @@ protected: void enter(fsm::traits::fsm_event_c auto& event) { - enterLog(event); + this->enterLog(event); + + event.mount()->logDebug( + std::format("Current ID: '{}', previous ID: '{}'", ID, event.mount()->previousStateID())); + + if (event.mount()->previousStateID() == ID) { + event.mount()->logWarn( + "It seems a re-entering to the initializing state was asked! Ignore the event and wait for the " + "mount " + "to initialize!"); + return; + } auto* mount_ptr = event.mount(); // call base-class initMount method! auto err = static_cast(mount_ptr)->initMount(); if (err) { - mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr}); + mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr, err}); return; } diff --git a/mcc/mcc_telemetry.h b/mcc/mcc_telemetry.h index 1a67a9c..4f53331 100644 --- a/mcc/mcc_telemetry.h +++ b/mcc/mcc_telemetry.h @@ -652,6 +652,10 @@ public: return MccTelemetryErrorCode::ERROR_OK; } + error_t lastUpdateError() const + { + return _lastUpdateError; + } error_t setPointingTarget(mcc_celestial_point_c auto pt) {