From 3f108fcc13d27fe4627f3bbcd3adc6f7bb373c65 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Sat, 1 Nov 2025 17:53:24 +0300 Subject: [PATCH] ... --- asibfm700/asibfm700_mount.h | 12 ++- asibfm700/asibfm700_servocontroller.cpp | 2 + mcc/mcc_defaults.h | 31 +++++- mcc/mcc_generic_mount.h | 123 ++++++++++++++---------- mcc/mcc_netserver.h | 10 ++ 5 files changed, 117 insertions(+), 61 deletions(-) diff --git a/asibfm700/asibfm700_mount.h b/asibfm700/asibfm700_mount.h index 37d74e6..6a6ed3f 100644 --- a/asibfm700/asibfm700_mount.h +++ b/asibfm700/asibfm700_mount.h @@ -46,14 +46,16 @@ protected: struct Asibfm700ErrorState : base_gm_class_t::MccGenericFsmMountBaseState { static constexpr std::string_view ID{"ASIBFM700-MOUNT-ERROR-STATE"}; - void exit(MccGenericFsmMountErrorEvent& event) - { - event.mount()->logWarn("The mount already in error state!"); - } + // void exit(MccGenericFsmMountErrorEvent& event) + // { + // event.mount()->logWarn("The mount already in error state!"); + // } void enter(MccGenericFsmMountErrorEvent& event) { - event.mount()->logWarn("The mount already in error state!"); + // 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()); } void exit(mcc::fsm::traits::fsm_event_c auto& event) diff --git a/asibfm700/asibfm700_servocontroller.cpp b/asibfm700/asibfm700_servocontroller.cpp index 6e33044..90824fc 100644 --- a/asibfm700/asibfm700_servocontroller.cpp +++ b/asibfm700/asibfm700_servocontroller.cpp @@ -148,6 +148,8 @@ AsibFM700ServoController::error_t AsibFM700ServoController::hardwareGetState(har } else { state->time_point = tp_t{std::chrono::duration_cast(secs)}; } + // WARNING: TEMPORARY (WAIT FOR Eddy fix its implementation of LibSidServo)!!! + state->time_point = decltype(state->time_point)::clock::now(); // according to "SiTech protocol notes" X is DEC-axis and Y is HA-axis state->X = mdata.encYposition.val; diff --git a/mcc/mcc_defaults.h b/mcc/mcc_defaults.h index 5e19557..11336ff 100644 --- a/mcc/mcc_defaults.h +++ b/mcc/mcc_defaults.h @@ -590,6 +590,8 @@ protected: } else { return std::make_error_code(std::errc::invalid_argument); } + + return {}; } template @@ -602,6 +604,8 @@ protected: } else { return std::make_error_code(std::errc::invalid_argument); } + + return {}; } }; @@ -671,8 +675,8 @@ protected: template void serializePairKindTimePoint(const T& value, OR& bytes) { - std::format_to(std::back_inserter(bytes), "{0:}{1:}{2:}{3:%F}T{3:%T}", _delimiter, - MccCoordPairKindToStr(value.pair_kind), _delimiter, value.time_point); + std::format_to(std::back_inserter(bytes), "{0:}{1:}{2:%F}T{2:%T}", MccCoordPairKindToStr(value.pair_kind), + _delimiter, value.time_point); } template ... Ts> @@ -957,6 +961,8 @@ public: template void operator()(const T& value, OR& bytes) { + static MccEqtHrzCoordsSerializer eqhrz_ser; + // output format: RA_ICRS, DEC_ICRS, RA_APP, DEC_APP, HA, AZ, ZD, ALT, X, Y, pair-kind, time-point // in the case of sexagesimal output X,Y coordinates will be interpretated // according to value.pair_kind field @@ -972,7 +978,11 @@ public: std::format_to(std::back_inserter(bytes), "{}", _delimiter); - MccEqtHrzCoordsSerializer{}(value, bytes); + eqhrz_ser.setFormat(_currentFormat); + eqhrz_ser.setPrecision(_currentPrec); + eqhrz_ser(value, bytes); + + // MccEqtHrzCoordsSerializer{}(value, bytes); } }; @@ -1020,15 +1030,26 @@ public: template void operator()(const T& value, OR& bytes) { + static MccEqtHrzCoordsSerializer eqhrz_ser; + static MccPointingTargetSerializer pt_ser; + // output format: , speedX, speedY, pcmX, pcmY, refCorr, - MccEqtHrzCoordsSerializer{}(value, bytes); + eqhrz_ser.setFormat(_currentFormat); + eqhrz_ser.setPrecision(_currentPrec); + eqhrz_ser(value, bytes); + + // MccEqtHrzCoordsSerializer{}(value, bytes); std::format_to(std::back_inserter(bytes), "{}", _delimiter); toDegrees(bytes, value.speedX, value.speedY, value.pcmX, value.pcmY, value.refCorr); std::format_to(std::back_inserter(bytes), "{}", _delimiter); - MccPointingTargetSerializer{}(value.target, bytes); + pt_ser.setFormat(_currentFormat); + pt_ser.setPrecision(_currentPrec); + pt_ser(value.target, bytes); + + // MccPointingTargetSerializer{}(value.target, bytes); } }; diff --git a/mcc/mcc_generic_mount.h b/mcc/mcc_generic_mount.h index 85e2350..46ef8e8 100644 --- a/mcc/mcc_generic_mount.h +++ b/mcc/mcc_generic_mount.h @@ -275,7 +275,7 @@ public: error_t trackTarget() { - auto err = TrackModelT::traclTarget(); + auto err = TrackModelT::trackTarget(); if (err) { *_mountStatus = mount_status_t::ERROR; @@ -486,7 +486,7 @@ protected: struct MccGenericFsmMountIdleState : MccGenericFsmMountBaseState // IDLE state: mount is stopped, wait for client commands { - static constexpr std::string_view ID{"GENERIC-MOUNT-IDLDE-STATE"}; + static constexpr std::string_view ID{"GENERIC-MOUNT-IDLE-STATE"}; using transition_t = fsm::fsm_transition_table_t< std::pair>, @@ -584,23 +584,23 @@ protected: std::pair>; - void exit(MccGenericFsmMountSlewEvent& event) - { - if constexpr (mcc_generic_log_mount_c) { - event.mount()->logWarn( - "It seems re-entering to slewing state was asked! Do not stop the current slewing process, just " - "ignore this event!"); - } - } + // void exit(MccGenericFsmMountSlewEvent& event) + // { + // if constexpr (mcc_generic_log_mount_c) { + // event.mount()->logWarn( + // "It seems re-entering to slewing state was asked! Do not stop the current slewing process, just " + // "ignore this event!"); + // } + // } - void enter(MccGenericFsmMountSlewEvent& event) - { - if constexpr (mcc_generic_log_mount_c) { - event.mount()->logWarn( - "It seems re-entering to slewing state was asked! Do not start a new slewing process, just ignore " - "this event!"); - } - } + // void enter(MccGenericFsmMountSlewEvent& event) + // { + // if constexpr (mcc_generic_log_mount_c) { + // event.mount()->logWarn( + // "It seems re-entering to slewing state was asked! Do not start a new slewing process, just ignore + // " "this event!"); + // } + // } void exit(fsm::traits::fsm_event_c auto& event) { @@ -613,10 +613,17 @@ protected: auto* mount_ptr = event.mount(); + if (event.mount()->previousStateID() == ID) { + event.mount()->logWarn( + "It seems re-entering to slewing state was asked! Do not start a new slewing process, just ignore " + "this event!"); + return; + } + // call base-class stopMount method! auto err = static_cast(mount_ptr)->slewToTarget(); if (err) { - mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr}); + mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr, err}); return; } @@ -642,23 +649,23 @@ protected: std::pair>; - void exit(MccGenericFsmMountTrackEvent& event) - { - if constexpr (mcc_generic_log_mount_c) { - event.mount()->logWarn( - "It seems re-entering to tracking state was asked! Do not stop the current tracking process, just " - "ignore this event!"); - } - } + // void exit(MccGenericFsmMountTrackEvent& event) + // { + // if constexpr (mcc_generic_log_mount_c) { + // event.mount()->logWarn( + // "It seems re-entering to tracking state was asked! Do not stop the current tracking process, just + // " "ignore this event!"); + // } + // } - void enter(MccGenericFsmMountTrackEvent& event) - { - if constexpr (mcc_generic_log_mount_c) { - event.mount()->logWarn( - "It seems re-entering to tracking state was asked! Do not start a new tracking process, just " - "ignore this event!"); - } - } + // void enter(MccGenericFsmMountTrackEvent& event) + // { + // if constexpr (mcc_generic_log_mount_c) { + // event.mount()->logWarn( + // "It seems re-entering to tracking state was asked! Do not start a new tracking process, just " + // "ignore this event!"); + // } + // } void exit(fsm::traits::fsm_event_c auto& event) { @@ -671,10 +678,17 @@ protected: auto* mount_ptr = event.mount(); + if (mount_ptr->previousStateID() == ID) { + mount_ptr->logWarn( + "It seems re-entering to tracking state was asked! Do not start a new tracking process, just " + "ignore this event!"); + return; + } + // call base-class stopMount method! auto err = static_cast(mount_ptr)->trackTarget(); if (err) { - mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr}); + mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr, err}); return; } @@ -696,21 +710,21 @@ protected: std::pair>; - void exit(MccGenericFsmMountStopEvent& event) - { - if constexpr (mcc_generic_log_mount_c) { - event.mount()->logWarn("It seems a re-entering to the stop state was asked! Ignore the event!"); - } - } + // void exit(MccGenericFsmMountStopEvent& event) + // { + // if constexpr (mcc_generic_log_mount_c) { + // event.mount()->logWarn("It seems a re-entering to the stop state was asked! Ignore the event!"); + // } + // } - void enter(MccGenericFsmMountStopEvent& event) - { - if constexpr (mcc_generic_log_mount_c) { - event.mount()->logWarn( - "It seems a re-entering to the stop state was asked! Ignore the event and wait for the mount to " - "stop!"); - } - } + // void enter(MccGenericFsmMountStopEvent& event) + // { + // if constexpr (mcc_generic_log_mount_c) { + // event.mount()->logWarn( + // "It seems a re-entering to the stop state was asked! Ignore the event and wait for the mount to " + // "stop!"); + // } + // } void exit(fsm::traits::fsm_event_c auto& event) { @@ -723,10 +737,17 @@ protected: auto* mount_ptr = event.mount(); + if (mount_ptr->previousStateID() == ID) { + mount_ptr->logWarn( + "It seems a re-entering to the stop state was asked! Ignore the event and wait for the mount to " + "stop!"); + return; + } + // call base-class stopMount method! auto err = static_cast(mount_ptr)->stopMount(); if (err) { - mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr}); + mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr, err}); return; } diff --git a/mcc/mcc_netserver.h b/mcc/mcc_netserver.h index eeb0e75..8942fe6 100644 --- a/mcc/mcc_netserver.h +++ b/mcc/mcc_netserver.h @@ -1064,6 +1064,16 @@ protected: _coordFormat, _coordPrec, cp); } } + } else if (input_msg.withKey(MCC_COMMPROTO_KEYWORD_TELEMETRY_STR)) { + MccTelemetryData tdata; + + auto t_err = mount_ptr->telemetryData(&tdata); + if (t_err) { + err = mcc_deduce_error_code(t_err, MccGenericMountNetworkServerErrorCode::ERROR_MOUNT_GET_TELEMETRY); + } else { + output_msg.construct(MCC_COMMPROTO_KEYWORD_SERVER_ACK_STR, MCC_COMMPROTO_KEYWORD_TELEMETRY_STR, + _coordFormat, _coordPrec, tdata); + } } else if (input_msg.withKey(mcc::network::MCC_COMMPROTO_KEYWORD_STATUS_STR)) { auto st = mount_ptr->mountStatus(); // according to mcc_generic_mount_c 'st' is formattable using st_t = decltype(st);