mountcontrol/mcc/mcc_generic_mount.h
2025-10-06 17:52:41 +03:00

799 lines
26 KiB
C++

#pragma once
/* MOUNT CONTROL COMPONENTS LIBRARY */
/* GENERIC MOUNT REFERENCE IMPLEMENTATION */
#include "mcc_defaults.h"
#include "mcc_generics.h"
namespace mcc
{
enum class MccGenericMountErrorCode : int {
ERROR_OK,
ERROR_HW_INIT,
ERROR_HW_STOP,
ERROR_HW_GETSTATE,
ERROR_SET_TARGET,
ERROR_MOUNT_SLEW
};
enum class MccGenericFsmMountErrorCode : int { ERROR_OK, ERROR_INVALID_OPERATION, ERROR_UNKNOWN_EVENT };
} // namespace mcc
namespace std
{
template <>
class is_error_code_enum<mcc::MccGenericMountErrorCode> : public true_type
{
};
template <>
class is_error_code_enum<mcc::MccGenericFsmMountErrorCode> : public true_type
{
};
} // namespace std
namespace mcc
{
// error category
struct MccGenericMountCategory : public std::error_category {
MccGenericMountCategory() : std::error_category() {}
const char* name() const noexcept
{
return "MCC-GENERIC-MOUNT";
}
std::string message(int ec) const
{
MccGenericMountErrorCode err = static_cast<MccGenericMountErrorCode>(ec);
switch (err) {
case MccGenericMountErrorCode::ERROR_OK:
return "OK";
case MccGenericMountErrorCode::ERROR_HW_INIT:
return "an error occured while initializing mount";
case MccGenericMountErrorCode::ERROR_HW_STOP:
return "an error occured while stopping mount";
case MccGenericMountErrorCode::ERROR_HW_GETSTATE:
return "cannot get state of hardware";
default:
return "UNKNOWN";
}
}
static const MccGenericMountCategory& get()
{
static const MccGenericMountCategory constInst;
return constInst;
}
};
struct MccGenericFsmMountCategory : public std::error_category {
MccGenericFsmMountCategory() : std::error_category() {}
const char* name() const noexcept
{
return "MCC-GENERIC-FSM-MOUNT";
}
std::string message(int ec) const
{
MccGenericFsmMountErrorCode err = static_cast<MccGenericFsmMountErrorCode>(ec);
switch (err) {
case MccGenericFsmMountErrorCode::ERROR_OK:
return "OK";
case MccGenericFsmMountErrorCode::ERROR_INVALID_OPERATION:
return "requested operation is not allowed";
case MccGenericFsmMountErrorCode::ERROR_UNKNOWN_EVENT:
return "unexpected finite-state-machine event";
default:
return "UNKNOWN";
}
}
static const MccGenericFsmMountCategory& get()
{
static const MccGenericFsmMountCategory constInst;
return constInst;
}
};
inline std::error_code make_error_code(MccGenericMountErrorCode ec)
{
return std::error_code(static_cast<int>(ec), MccGenericMountCategory::get());
}
inline std::error_code make_error_code(MccGenericFsmMountErrorCode ec)
{
return std::error_code(static_cast<int>(ec), MccGenericFsmMountCategory::get());
}
template <mcc_hardware_c HardwareT,
mcc_telemetry_c TelemetryT,
mcc_pzone_container_c PZoneContT,
mcc_slewing_model_c SlewModelT,
mcc_tracking_model_c TrackModelT,
mcc_logger_c LoggerT = MccNullLogger>
class MccGenericMount : public HardwareT,
public TelemetryT,
public PZoneContT,
public SlewModelT,
public TrackModelT,
public LoggerT
{
public:
typedef std::error_code error_t;
using LoggerT::logDebug;
using LoggerT::logError;
using LoggerT::logInfo;
using LoggerT::logWarn;
using typename SlewModelT::slewing_params_t;
using typename TrackModelT::tracking_params_t;
MccGenericMount(HardwareT hardware,
TelemetryT telemetry,
PZoneContT pzone_cont,
SlewModelT slew_model,
TrackModelT track_model,
LoggerT logger = MccNullLogger{})
: HardwareT(std::move(hardware)),
TelemetryT(std::move(telemetry)),
PZoneContT(std::move(pzone_cont)),
SlewModelT(std::move(slew_model)),
TrackModelT(std::move(track_model)),
LoggerT(std::move(logger))
{
}
MccGenericMount(MccGenericMount&&) = default;
MccGenericMount(const MccGenericMount&) = delete;
MccGenericMount& operator=(MccGenericMount&&) = default;
MccGenericMount& operator=(const MccGenericMount&) = delete;
virtual ~MccGenericMount() = default;
error_t stopMount()
{
logInfo("Stop any movements ...");
this->stopTracking();
this->stopSlewing();
auto hw_err = this->hardwareStop();
if (hw_err) {
return mcc_deduce_error_code(hw_err, MccGenericMountErrorCode::ERROR_HW_STOP);
}
logInfo("Stop command was sent");
return MccGenericMountErrorCode::ERROR_OK;
}
error_t initMount()
{
logInfo("Start generic mount initialization ...");
auto hw_err = this->hardwareInit();
if (hw_err) {
return mcc_deduce_error_code(hw_err, MccGenericMountErrorCode::ERROR_HW_STOP);
}
logInfo("Generic mount initialization was performed");
return MccGenericMountErrorCode::ERROR_OK;
}
// re-implements TelemetryT::setPointingTarget to hold target coordinates
// in some intermediate buffer
error_t setPointingTarget(mcc_celestial_point_c auto pt)
{
mcc_copy_celestial_point(std::move(pt), &_enteredTargetCoordiniates);
std::string xstr;
if (_enteredTargetCoordiniates.pair_kind == MccCoordPairKind::COORDS_KIND_RADEC_ICRS ||
_enteredTargetCoordiniates.pair_kind == MccCoordPairKind::COORDS_KIND_RADEC_APP ||
_enteredTargetCoordiniates.pair_kind == MccCoordPairKind::COORDS_KIND_HADEC_APP) {
xstr = MccAngle(_enteredTargetCoordiniates.X).sexagesimal(true);
} else {
MccAngle(_enteredTargetCoordiniates.X).sexagesimal();
}
logInfo(std::format("Set entered target coordinates to: {} {} {}", xstr,
MccAngle(_enteredTargetCoordiniates.Y).sexagesimal(),
MccCoordPairKindStr<_enteredTargetCoordiniates.pair_kind>));
return MccGenericMountErrorCode::ERROR_OK;
}
// re-implements SlewModelT::slewToTarget to fetch input target coordinates from intermediate buffer
error_t slewToTarget(bool slew_and_stop = false)
{
auto err = TelemetryT::setPointingTarget(_enteredTargetCoordiniates);
if (err) {
return mcc_deduce_error_code(err, MccGenericMountErrorCode::ERROR_SET_TARGET);
}
return mcc_deduce_error_code(SlewModelT::slewToTarget(slew_and_stop),
MccGenericMountErrorCode::ERROR_MOUNT_SLEW);
}
protected:
MccCelestialPoint _enteredTargetCoordiniates;
};
/* GENERIC FINITE-STATE-MACHINE MOUNT REFERENCE IMPLEMENTATION */
template <mcc_generic_mount_c MOUNT_T>
class MccGenericFsmMount : public MOUNT_T, protected fsm::MccFiniteStateMachine
{
public:
typedef std::error_code error_t;
using fsm::MccFiniteStateMachine::currentStateID;
using typename MOUNT_T::slewing_params_t;
using typename MOUNT_T::tracking_params_t;
protected:
error_t _lastError;
/* default events implementation */
struct MccGenericFsmMountBaseEvent {
virtual ~MccGenericFsmMountBaseEvent() = default;
MccGenericFsmMount* mount() const
{
return _mount;
}
protected:
MccGenericFsmMount* _mount;
MccGenericFsmMountBaseEvent(MccGenericFsmMount* mount) : _mount(mount) {}
};
struct MccGenericFsmMountInitEvent : MccGenericFsmMountBaseEvent {
static constexpr std::string_view ID{"GENERIC-MOUNT-INIT-EVENT"};
MccGenericFsmMountInitEvent(MccGenericFsmMount* mount) : MccGenericFsmMountBaseEvent(mount) {}
};
struct MccGenericFsmMountIdleEvent : MccGenericFsmMountBaseEvent {
static constexpr std::string_view ID{"GENERIC-MOUNT-IDLE-EVENT"};
MccGenericFsmMountIdleEvent(MccGenericFsmMount* mount) : MccGenericFsmMountBaseEvent(mount) {}
};
struct MccGenericFsmMountStopEvent : MccGenericFsmMountBaseEvent {
static constexpr std::string_view ID{"GENERIC-MOUNT-STOP-EVENT"};
MccGenericFsmMountStopEvent(MccGenericFsmMount* mount) : MccGenericFsmMountBaseEvent(mount) {}
};
struct MccGenericFsmMountErrorEvent : MccGenericFsmMountBaseEvent {
static constexpr std::string_view ID{"GENERIC-MOUNT-ERROR-EVENT"};
MccGenericFsmMountErrorEvent(MccGenericFsmMount* mount, const MccGenericFsmMount::error_t& err)
: MccGenericFsmMountBaseEvent(mount), _err(err)
{
}
MccGenericFsmMount::error_t eventData() const noexcept
{
return _err;
}
protected:
MccGenericFsmMount::error_t _err;
};
struct MccGenericFsmMountSlewEvent : MccGenericFsmMountBaseEvent {
static constexpr std::string_view ID{"GENERIC-MOUNT-SLEW-EVENT"};
MccGenericFsmMountSlewEvent(MccGenericFsmMount* mount, bool slew_and_stop)
: MccGenericFsmMountBaseEvent(mount), _slewAndStop(slew_and_stop)
{
}
bool eventData() const noexcept
{
return _slewAndStop;
}
protected:
bool _slewAndStop{};
};
struct MccGenericFsmMountTrackEvent : MccGenericFsmMountBaseEvent {
static constexpr std::string_view ID{"GENERIC-MOUNT-TRACK-EVENT"};
MccGenericFsmMountTrackEvent(MccGenericFsmMount* mount) : MccGenericFsmMountBaseEvent(mount) {}
};
/* default states implementation */
struct MccGenericFsmMountBaseState {
virtual ~MccGenericFsmMountBaseState() = default;
protected:
MccGenericFsmMountBaseState() = default;
template <fsm::traits::fsm_event_c EvT>
void exitLog(this auto&& self, EvT& event)
{
using self_t = std::remove_cvref_t<decltype(self)>;
if constexpr (mcc_generic_log_mount_c<MOUNT_T> && std::derived_from<EvT, MccGenericFsmMountBaseEvent>) {
event.mount()->logDebug(std::format("Exit from '{}' state due to '{}' event ...", self_t::ID, EvT::ID));
}
}
template <fsm::traits::fsm_event_c EvT>
void enterLog(this auto&& self, EvT& event)
{
using self_t = std::remove_cvref_t<decltype(self)>;
if constexpr (mcc_generic_log_mount_c<MOUNT_T> && std::derived_from<EvT, MccGenericFsmMountBaseEvent>) {
event.mount()->logDebug(std::format("Enter to '{}' state due to '{}' event ...", self_t::ID, EvT::ID));
}
}
};
struct MccGenericFsmMountErrorState; // default error-state class implementation (forward declaration)
// template <fsm::traits::fsm_state_c ERROR_STATE_T>
template <typename ERROR_STATE_T>
struct MccGenericFsmMountInitState;
template <fsm::traits::fsm_state_c ERROR_STATE_T>
struct MccGenericFsmMountStopState;
template <fsm::traits::fsm_state_c ERROR_STATE_T>
struct MccGenericFsmMountSlewState;
template <fsm::traits::fsm_state_c ERROR_STATE_T>
struct MccGenericFsmMountTrackState;
template <fsm::traits::fsm_state_c ERROR_STATE_T>
struct MccGenericFsmMountStartState
: MccGenericFsmMountBaseState // initial state after mount-class creation (uninitialized state)
{
static constexpr std::string_view ID{"GENERIC-MOUNT-START-STATE"};
// only initialization is allowed here
using transition_t = fsm::fsm_transition_table_t<
std::pair<MccGenericFsmMountInitEvent, MccGenericFsmMountInitState<ERROR_STATE_T>>>;
};
// template <fsm::traits::fsm_state_c ERROR_STATE_T>
template <typename ERROR_STATE_T>
struct MccGenericFsmMountIdleState
: MccGenericFsmMountBaseState // IDLE state: mount is stopped, wait for client commands
{
static constexpr std::string_view ID{"GENERIC-MOUNT-IDLDE-STATE"};
using transition_t = fsm::fsm_transition_table_t<
std::pair<MccGenericFsmMountIdleEvent, MccGenericFsmMountIdleState<ERROR_STATE_T>>,
std::pair<MccGenericFsmMountErrorEvent, ERROR_STATE_T>,
std::pair<MccGenericFsmMountInitEvent, MccGenericFsmMountInitState<ERROR_STATE_T>>,
std::pair<MccGenericFsmMountSlewEvent, MccGenericFsmMountSlewState<ERROR_STATE_T>>,
std::pair<MccGenericFsmMountTrackEvent, MccGenericFsmMountTrackState<ERROR_STATE_T>>,
std::pair<MccGenericFsmMountStopEvent, MccGenericFsmMountStopState<ERROR_STATE_T>>>;
void exit(fsm::traits::fsm_event_c auto& event)
{
exitLog(event);
}
void enter(fsm::traits::fsm_event_c auto& event)
{
enterLog(event);
}
};
// template <fsm::traits::fsm_state_c ERROR_STATE_T>
template <typename ERROR_STATE_T>
struct MccGenericFsmMountInitState : MccGenericFsmMountBaseState {
// static_assert(fsm::traits::fsm_state_c<ERROR_STATE_T>);
static constexpr std::string_view ID{"GENERIC-MOUNT-INIT-STATE"};
using transition_t = fsm::fsm_transition_table_t<
std::pair<MccGenericFsmMountIdleEvent, MccGenericFsmMountIdleState<ERROR_STATE_T>>,
std::pair<MccGenericFsmMountErrorEvent, ERROR_STATE_T>,
std::pair<MccGenericFsmMountInitEvent, MccGenericFsmMountInitState>>;
void exit(MccGenericFsmMountInitEvent& event)
{
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
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<MOUNT_T>) {
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)
{
exitLog(event);
}
void enter(fsm::traits::fsm_event_c auto& event)
{
enterLog(event);
auto* mount_ptr = event.mount();
// call base-class initMount method!
auto err = static_cast<MOUNT_T*>(mount_ptr)->initMount();
if (err) {
mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr});
return;
}
// after initialization switch to IDLE state
mount_ptr->dispatchEvent(MccGenericFsmMountIdleEvent{mount_ptr});
}
};
template <fsm::traits::fsm_state_c ERROR_STATE_T>
struct MccGenericFsmMountSlewState : MccGenericFsmMountBaseState {
static constexpr std::string_view ID{"GENERIC-MOUNT-SLEW-STATE"};
using transition_t = fsm::fsm_transition_table_t<
std::pair<MccGenericFsmMountIdleEvent, MccGenericFsmMountIdleState<ERROR_STATE_T>>,
std::pair<MccGenericFsmMountErrorEvent, ERROR_STATE_T>,
std::pair<MccGenericFsmMountTrackEvent, MccGenericFsmMountTrackState<ERROR_STATE_T>>,
std::pair<MccGenericFsmMountSlewEvent, MccGenericFsmMountSlewState>>;
void exit(MccGenericFsmMountSlewEvent& event)
{
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
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<MOUNT_T>) {
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)
{
exitLog(event);
}
void enter(fsm::traits::fsm_event_c auto& event)
{
enterLog(event);
auto* mount_ptr = event.mount();
// call base-class stopMount method!
auto err = static_cast<MOUNT_T*>(mount_ptr)->slewToTarget();
if (err) {
mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr});
return;
}
bool slew_and_stop = event.eventData();
if (slew_and_stop) { // after slewing switch to IDLE state
mount_ptr->dispatchEvent(MccGenericFsmMountIdleEvent{mount_ptr});
} else { // after slewing switch to tracking state
mount_ptr->dispatchEvent(MccGenericFsmMountTrackEvent{mount_ptr});
}
}
};
template <fsm::traits::fsm_state_c ERROR_STATE_T>
struct MccGenericFsmMountTrackState : MccGenericFsmMountBaseState {
static constexpr std::string_view ID{"GENERIC-MOUNT-TRACK-STATE"};
using transition_t = fsm::fsm_transition_table_t<
std::pair<MccGenericFsmMountIdleEvent, MccGenericFsmMountIdleState<ERROR_STATE_T>>,
std::pair<MccGenericFsmMountErrorEvent, ERROR_STATE_T>,
std::pair<MccGenericFsmMountTrackEvent, MccGenericFsmMountTrackState>>;
void exit(MccGenericFsmMountTrackEvent& event)
{
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
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<MOUNT_T>) {
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)
{
exitLog(event);
}
void enter(fsm::traits::fsm_event_c auto& event)
{
enterLog(event);
auto* mount_ptr = event.mount();
// call base-class stopMount method!
auto err = static_cast<MOUNT_T*>(mount_ptr)->trackTarget();
if (err) {
mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr});
return;
}
// after stop trackin switch to IDLE state
mount_ptr->dispatchEvent(MccGenericFsmMountIdleEvent{mount_ptr});
}
};
template <fsm::traits::fsm_state_c ERROR_STATE_T>
struct MccGenericFsmMountStopState : MccGenericFsmMountBaseState {
static constexpr std::string_view ID{"GENERIC-MOUNT-STOP-STATE"};
using transition_t = fsm::fsm_transition_table_t<
std::pair<MccGenericFsmMountIdleEvent, MccGenericFsmMountIdleState<ERROR_STATE_T>>,
std::pair<MccGenericFsmMountErrorEvent, ERROR_STATE_T>,
std::pair<MccGenericFsmMountStopEvent, MccGenericFsmMountStopState>>;
void exit(MccGenericFsmMountStopEvent& event)
{
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
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<MOUNT_T>) {
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)
{
exitLog(event);
}
void enter(fsm::traits::fsm_event_c auto& event)
{
enterLog(event);
auto* mount_ptr = event.mount();
// call base-class stopMount method!
auto err = static_cast<MOUNT_T*>(mount_ptr)->stopMount();
if (err) {
mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr});
return;
}
// after stopping switch to IDLE state
mount_ptr->dispatchEvent(MccGenericFsmMountIdleEvent{mount_ptr});
}
};
struct MccGenericFsmMountErrorState : MccGenericFsmMountBaseState // default error-state class implementation
// (just log error)
{
static constexpr std::string_view ID{"GENERIC-MOUNT-ERROR-STATE"};
using transition_t = fsm::fsm_transition_table_t<
std::pair<MccGenericFsmMountErrorEvent, MccGenericFsmMountErrorState>,
std::pair<MccGenericFsmMountIdleEvent, MccGenericFsmMountIdleState<MccGenericFsmMountErrorState>>,
std::pair<MccGenericFsmMountInitEvent, MccGenericFsmMountInitState<MccGenericFsmMountErrorState>>>;
void exit(fsm::traits::fsm_event_c auto& event)
{
// just reset error
event.mount()->_lastError = MccGenericFsmMountErrorCode::ERROR_OK;
exitLog(event);
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
event.mount()->logWarn(
std::format("The mount is in the error state!!! One must correct it before transit to any states! "
"Event type is '{}'",
decltype(event)::ID));
}
}
void enter(fsm::traits::fsm_event_c auto& event)
{
event.mount()->_lastError = event.eventData();
enterLog(event);
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
auto err = event.eventData();
event.mount()->logError(
std::format("The mount is in the error state: code = {}, category = {}, message = '{}'",
err.value(), err.category().name(), err.message()));
}
}
};
public:
template <fsm::traits::fsm_state_c ERROR_STATE_T = MccGenericFsmMountErrorState>
MccGenericFsmMount(MOUNT_T mount,
fsm::traits::fsm_state_c auto start_state = MccGenericFsmMountStartState<ERROR_STATE_T>{})
: MOUNT_T(std::move(mount)), fsm::MccFiniteStateMachine(std::move(start_state))
{
}
// reimplementation of base-class methods to adapt it to FSM-behavior
error_t initMount()
{
try {
this->dispatchEvent(MccGenericFsmMountInitEvent{this});
} catch (std::system_error const& exc) {
if (exc.code().category() == fsm::MccFiniteStateMachineCategory::get()) {
_lastError = MccGenericFsmMountErrorCode::ERROR_INVALID_OPERATION;
} else {
// return exc.code();
_lastError = exc.code();
}
}
// return MccGenericFsmMountErrorCode::ERROR_OK;
return _lastError;
}
auto stopMount()
{
try {
this->dispatchEvent(MccGenericFsmMountStopEvent{this});
} catch (std::system_error const& exc) {
if (exc.code().category() == fsm::MccFiniteStateMachineCategory::get()) {
_lastError = MccGenericFsmMountErrorCode::ERROR_INVALID_OPERATION;
} else {
// return exc.code();
_lastError = exc.code();
}
}
// return MccGenericFsmMountErrorCode::ERROR_OK;
return _lastError;
}
auto slewToTarget(bool slew_and_stop = false)
{
try {
this->dispatchEvent(MccGenericFsmMountSlewEvent{this, slew_and_stop});
} catch (std::system_error const& exc) {
if (exc.code().category() == fsm::MccFiniteStateMachineCategory::get()) {
_lastError = MccGenericFsmMountErrorCode::ERROR_INVALID_OPERATION;
} else {
// return exc.code();
_lastError = exc.code();
}
}
// return MccGenericFsmMountErrorCode::ERROR_OK;
return _lastError;
}
auto stopSlewing()
{
try {
this->dispatchEvent(MccGenericFsmMountStopEvent{this});
} catch (std::system_error const& exc) {
if (exc.code().category() == fsm::MccFiniteStateMachineCategory::get()) {
_lastError = MccGenericFsmMountErrorCode::ERROR_INVALID_OPERATION;
} else {
// return exc.code();
_lastError = exc.code();
}
}
// return MccGenericFsmMountErrorCode::ERROR_OK;
return _lastError;
}
auto trackTarget()
{
try {
this->dispatchEvent(MccGenericFsmMountTrackEvent{this});
} catch (std::system_error const& exc) {
if (exc.code().category() == fsm::MccFiniteStateMachineCategory::get()) {
_lastError = MccGenericFsmMountErrorCode::ERROR_INVALID_OPERATION;
} else {
// return exc.code();
_lastError = exc.code();
}
}
// return MccGenericFsmMountErrorCode::ERROR_OK;
return _lastError;
}
auto stopTracking()
{
try {
this->dispatchEvent(MccGenericFsmMountStopEvent{this});
} catch (std::system_error const& exc) {
if (exc.code().category() == fsm::MccFiniteStateMachineCategory::get()) {
_lastError = MccGenericFsmMountErrorCode::ERROR_INVALID_OPERATION;
} else {
// return exc.code();
_lastError = exc.code();
}
}
// return MccGenericFsmMountErrorCode::ERROR_OK;
return _lastError;
}
};
} // namespace mcc