...
This commit is contained in:
@@ -136,6 +136,9 @@ public:
|
||||
|
||||
using fsm::MccFiniteStateMachine::currentStateID;
|
||||
|
||||
using typename MOUNT_T::slewing_params_t;
|
||||
using typename MOUNT_T::tracking_params_t;
|
||||
|
||||
protected:
|
||||
/* default events implementation */
|
||||
|
||||
@@ -333,6 +336,120 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
MccGenericFsmMount::slewing_params_t params;
|
||||
mount_ptr->getSlewingParams(¶ms);
|
||||
if (params.slewAndStop) { // 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"};
|
||||
@@ -420,9 +537,9 @@ protected:
|
||||
|
||||
|
||||
public:
|
||||
MccGenericFsmMount(
|
||||
MOUNT_T mount,
|
||||
fsm::traits::fsm_state_c auto start_state = MccGenericFsmMountStartState<MccGenericFsmMountErrorState>{})
|
||||
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))
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user