...
This commit is contained in:
@@ -99,7 +99,7 @@ public:
|
||||
|
||||
auto hw_err = this->hardwareStop();
|
||||
if (hw_err) {
|
||||
return mcc_deduce_error(hw_err, MccGenericMountErrorCode::ERROR_HW_STOP);
|
||||
return mcc_deduce_error_code(hw_err, MccGenericMountErrorCode::ERROR_HW_STOP);
|
||||
}
|
||||
|
||||
logInfo("Stop command was sent");
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
|
||||
auto hw_err = this->hardwareInit();
|
||||
if (hw_err) {
|
||||
return mcc_deduce_error(hw_err, MccGenericMountErrorCode::ERROR_HW_STOP);
|
||||
return mcc_deduce_error_code(hw_err, MccGenericMountErrorCode::ERROR_HW_STOP);
|
||||
}
|
||||
|
||||
logInfo("Mount initialization was performed");
|
||||
@@ -140,6 +140,8 @@ public:
|
||||
using typename MOUNT_T::tracking_params_t;
|
||||
|
||||
protected:
|
||||
error_t _lastError;
|
||||
|
||||
/* default events implementation */
|
||||
|
||||
struct MccGenericFsmMountBaseEvent {
|
||||
@@ -236,7 +238,8 @@ protected:
|
||||
|
||||
struct MccGenericFsmMountErrorState; // default error-state class implementation (forward declaration)
|
||||
|
||||
template <fsm::traits::fsm_state_c ERROR_STATE_T>
|
||||
// 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>
|
||||
@@ -260,7 +263,8 @@ protected:
|
||||
std::pair<MccGenericFsmMountInitEvent, MccGenericFsmMountInitState<ERROR_STATE_T>>>;
|
||||
};
|
||||
|
||||
template <fsm::traits::fsm_state_c 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
|
||||
{
|
||||
@@ -285,8 +289,11 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
template <fsm::traits::fsm_state_c ERROR_STATE_T>
|
||||
// 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<
|
||||
@@ -512,6 +519,9 @@ protected:
|
||||
|
||||
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>) {
|
||||
@@ -524,6 +534,8 @@ protected:
|
||||
|
||||
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>) {
|
||||
@@ -546,15 +558,21 @@ public:
|
||||
|
||||
// reimplementation of base-class methods to adapt it to FSM-behavior
|
||||
|
||||
auto initMount()
|
||||
error_t initMount()
|
||||
{
|
||||
try {
|
||||
this->dispatchEvent(MccGenericFsmMountInitEvent{this});
|
||||
} catch (std::system_error const& exc) {
|
||||
return exc.code();
|
||||
if (exc.code().category() == fsm::MccFiniteStateMachineCategory::get()) {
|
||||
_lastError = MccGenericFsmMountErrorCode::ERROR_INVALID_OPERATION;
|
||||
} else {
|
||||
// return exc.code();
|
||||
_lastError = exc.code();
|
||||
}
|
||||
}
|
||||
|
||||
return MccGenericFsmMountErrorCode::ERROR_OK;
|
||||
// return MccGenericFsmMountErrorCode::ERROR_OK;
|
||||
return _lastError;
|
||||
}
|
||||
|
||||
auto stopMount()
|
||||
@@ -562,10 +580,16 @@ public:
|
||||
try {
|
||||
this->dispatchEvent(MccGenericFsmMountStopEvent{this});
|
||||
} catch (std::system_error const& exc) {
|
||||
return exc.code();
|
||||
if (exc.code().category() == fsm::MccFiniteStateMachineCategory::get()) {
|
||||
_lastError = MccGenericFsmMountErrorCode::ERROR_INVALID_OPERATION;
|
||||
} else {
|
||||
// return exc.code();
|
||||
_lastError = exc.code();
|
||||
}
|
||||
}
|
||||
|
||||
return MccGenericFsmMountErrorCode::ERROR_OK;
|
||||
// return MccGenericFsmMountErrorCode::ERROR_OK;
|
||||
return _lastError;
|
||||
}
|
||||
|
||||
auto slewToTarget()
|
||||
@@ -573,10 +597,16 @@ public:
|
||||
try {
|
||||
this->dispatchEvent(MccGenericFsmMountSlewEvent{this});
|
||||
} catch (std::system_error const& exc) {
|
||||
return exc.code();
|
||||
if (exc.code().category() == fsm::MccFiniteStateMachineCategory::get()) {
|
||||
_lastError = MccGenericFsmMountErrorCode::ERROR_INVALID_OPERATION;
|
||||
} else {
|
||||
// return exc.code();
|
||||
_lastError = exc.code();
|
||||
}
|
||||
}
|
||||
|
||||
return MccGenericFsmMountErrorCode::ERROR_OK;
|
||||
// return MccGenericFsmMountErrorCode::ERROR_OK;
|
||||
return _lastError;
|
||||
}
|
||||
|
||||
auto stopSlewing()
|
||||
@@ -584,10 +614,16 @@ public:
|
||||
try {
|
||||
this->dispatchEvent(MccGenericFsmMountStopEvent{this});
|
||||
} catch (std::system_error const& exc) {
|
||||
return exc.code();
|
||||
if (exc.code().category() == fsm::MccFiniteStateMachineCategory::get()) {
|
||||
_lastError = MccGenericFsmMountErrorCode::ERROR_INVALID_OPERATION;
|
||||
} else {
|
||||
// return exc.code();
|
||||
_lastError = exc.code();
|
||||
}
|
||||
}
|
||||
|
||||
return MccGenericFsmMountErrorCode::ERROR_OK;
|
||||
// return MccGenericFsmMountErrorCode::ERROR_OK;
|
||||
return _lastError;
|
||||
}
|
||||
|
||||
auto trackTarget()
|
||||
@@ -595,10 +631,16 @@ public:
|
||||
try {
|
||||
this->dispatchEvent(MccGenericFsmMountTrackEvent{this});
|
||||
} catch (std::system_error const& exc) {
|
||||
return exc.code();
|
||||
if (exc.code().category() == fsm::MccFiniteStateMachineCategory::get()) {
|
||||
_lastError = MccGenericFsmMountErrorCode::ERROR_INVALID_OPERATION;
|
||||
} else {
|
||||
// return exc.code();
|
||||
_lastError = exc.code();
|
||||
}
|
||||
}
|
||||
|
||||
return MccGenericFsmMountErrorCode::ERROR_OK;
|
||||
// return MccGenericFsmMountErrorCode::ERROR_OK;
|
||||
return _lastError;
|
||||
}
|
||||
|
||||
|
||||
@@ -607,47 +649,16 @@ public:
|
||||
try {
|
||||
this->dispatchEvent(MccGenericFsmMountStopEvent{this});
|
||||
} catch (std::system_error const& exc) {
|
||||
return exc.code();
|
||||
if (exc.code().category() == fsm::MccFiniteStateMachineCategory::get()) {
|
||||
_lastError = MccGenericFsmMountErrorCode::ERROR_INVALID_OPERATION;
|
||||
} else {
|
||||
// return exc.code();
|
||||
_lastError = exc.code();
|
||||
}
|
||||
}
|
||||
|
||||
return MccGenericFsmMountErrorCode::ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
// wrappers
|
||||
|
||||
auto _initMount()
|
||||
{
|
||||
return MOUNT_T::initMount();
|
||||
}
|
||||
|
||||
|
||||
auto _stopMount()
|
||||
{
|
||||
return MOUNT_T::stopMount();
|
||||
}
|
||||
|
||||
auto _slewToTarget()
|
||||
{
|
||||
return MOUNT_T::slewToTarget();
|
||||
}
|
||||
|
||||
|
||||
auto _trackTarget()
|
||||
{
|
||||
return MOUNT_T::trackTarget();
|
||||
}
|
||||
|
||||
|
||||
auto _startGuidingTarget()
|
||||
{
|
||||
return MOUNT_T::startGuidingTarget();
|
||||
}
|
||||
|
||||
auto _stopGuidingTarget()
|
||||
{
|
||||
return MOUNT_T::stopGuidingTarget();
|
||||
// return MccGenericFsmMountErrorCode::ERROR_OK;
|
||||
return _lastError;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user