...
This commit is contained in:
parent
3c4045e620
commit
37b33d4ff7
@ -162,6 +162,13 @@ struct MccMountEventStop : public MccMountEventBase<MountT> {
|
|||||||
return _reason;
|
return _reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string_view reason() const
|
||||||
|
{
|
||||||
|
return _reason == EVENT_STOP_BUTTON ? "Hardware stop-button"
|
||||||
|
: _reason == EVENT_STOP_CLIENT ? "Stop from client"
|
||||||
|
: "UNKNOWN";
|
||||||
|
}
|
||||||
|
|
||||||
MccMountEventStop(MountT& mount, event_data_t reason) : base_t(mount), _reason(reason) {}
|
MccMountEventStop(MountT& mount, event_data_t reason) : base_t(mount), _reason(reason) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -236,7 +243,7 @@ struct MccMountStateError;
|
|||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_mount_c MountT>
|
||||||
struct MccMountStateSlew;
|
struct MccMountStateSlew;
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_mount_c MountT, fsm::traits::fsm_event_c TrEvT = MccMountEventStop<MountT>>
|
||||||
struct MccMountStateStop;
|
struct MccMountStateStop;
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_mount_c MountT>
|
||||||
@ -246,6 +253,49 @@ template <traits::mcc_mount_c MountT>
|
|||||||
struct MccMountStateShutdown;
|
struct MccMountStateShutdown;
|
||||||
|
|
||||||
|
|
||||||
|
// stop state
|
||||||
|
|
||||||
|
template <traits::mcc_mount_c MountT, fsm::traits::fsm_event_c TrEvT>
|
||||||
|
struct MccMountStateStop : MccMountStateBase<MountT> {
|
||||||
|
static constexpr std::string_view ID = "MCC-MOUNT-STOP-STATE";
|
||||||
|
|
||||||
|
using transition_t = fsm::fsm_transition_table_t<std::pair<MccMountEventIDLE<MountT>, MccMountStateIDLE<MountT>>>;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void exitImpl(MccMountEventIDLE<MountT>& event)
|
||||||
|
{
|
||||||
|
// normal exit from the state
|
||||||
|
}
|
||||||
|
|
||||||
|
// normal bihavior (transit to IDLE state after stopping)
|
||||||
|
void enterImpl(MccMountEventStop<MountT>& event)
|
||||||
|
{
|
||||||
|
auto mount = event.mount();
|
||||||
|
mount.stopMount();
|
||||||
|
|
||||||
|
// switch to IDLE state
|
||||||
|
mount.template dispatchEvent<MccMountEventIDLE<MountT>>({mount});
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::derived_from<MccMountEventBase<MountT>> EvT>
|
||||||
|
void enterImpl(EvT& event)
|
||||||
|
{
|
||||||
|
auto mount = event.mount();
|
||||||
|
|
||||||
|
mount.stopMount();
|
||||||
|
|
||||||
|
if constexpr (std::same_as<EvT, MccMountEventStop<MountT>>) {
|
||||||
|
mount.logInfo("Stop reason: {}", event.reason());
|
||||||
|
|
||||||
|
// normal bihavior (transit to IDLE state after stopping)
|
||||||
|
mount.template dispatchEvent<MccMountEventIDLE<MountT>>({mount});
|
||||||
|
} else {
|
||||||
|
mount.logInfo("Stop reason: special state");
|
||||||
|
mount.dispatchEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// initialization state
|
// initialization state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_mount_c MountT>
|
||||||
@ -263,14 +313,17 @@ protected:
|
|||||||
template <std::derived_from<MccMountEventBase<MountT>> EvT>
|
template <std::derived_from<MccMountEventBase<MountT>> EvT>
|
||||||
void enterImpl(EvT& event)
|
void enterImpl(EvT& event)
|
||||||
{
|
{
|
||||||
event.mount().initMount();
|
auto mount = event.mount();
|
||||||
|
mount.initMount();
|
||||||
|
|
||||||
// switch to IDLE state
|
// switch to IDLE state
|
||||||
event.mount().template dispatchEvent<MccMountEventIDLE<MountT>>();
|
mount.template dispatchEvent<MccMountEventIDLE<MountT>>({mount});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// error state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_mount_c MountT>
|
||||||
struct MccMountStateError : MccMountStateBase<MountT> {
|
struct MccMountStateError : MccMountStateBase<MountT> {
|
||||||
static constexpr std::string_view ID = "MCC-MOUNT-ERROR-STATE";
|
static constexpr std::string_view ID = "MCC-MOUNT-ERROR-STATE";
|
||||||
@ -288,7 +341,7 @@ protected:
|
|||||||
template <std::derived_from<MccMountEventBase<MountT>> EvT>
|
template <std::derived_from<MccMountEventBase<MountT>> EvT>
|
||||||
void exitImpl(EvT& event)
|
void exitImpl(EvT& event)
|
||||||
{
|
{
|
||||||
event.mount().logWarning(
|
event.mount().logWarn(
|
||||||
"The mount is in the error state!!! One must correct it before transit to any states! Event type is '{}'",
|
"The mount is in the error state!!! One must correct it before transit to any states! Event type is '{}'",
|
||||||
EvT::ID);
|
EvT::ID);
|
||||||
}
|
}
|
||||||
@ -314,6 +367,8 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// IDLE state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_mount_c MountT>
|
||||||
struct MccMountStateIDLE : MccMountStateBase<MountT> {
|
struct MccMountStateIDLE : MccMountStateBase<MountT> {
|
||||||
static constexpr std::string_view ID = "MCC-MOUNT-IDLE-STATE";
|
static constexpr std::string_view ID = "MCC-MOUNT-IDLE-STATE";
|
||||||
@ -328,17 +383,55 @@ struct MccMountStateIDLE : MccMountStateBase<MountT> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// shutdown state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_mount_c MountT>
|
||||||
struct MccMountStateShutdown : MccMountStateBase<MountT> {
|
struct MccMountStateShutdown : MccMountStateBase<MountT> {
|
||||||
static constexpr std::string_view ID = "MCC-MOUNT-SHUTDOWN-STATE";
|
static constexpr std::string_view ID = "MCC-MOUNT-SHUTDOWN-STATE";
|
||||||
|
|
||||||
|
// only initialization
|
||||||
|
using transition_t = fsm::fsm_transition_table_t<std::pair<MccMountEventInit<MountT>, MccMountStateInit<MountT>>>;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void exitImpl(MccMountEventInit<MountT>& event)
|
||||||
|
{
|
||||||
|
// normal exit from the state
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::derived_from<MccMountEventBase<MountT>> EvT>
|
||||||
|
void enterImpl(EvT& event)
|
||||||
|
{
|
||||||
|
event.mount().shutdownMount();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// slew state
|
||||||
|
|
||||||
|
template <traits::mcc_mount_c MountT>
|
||||||
|
struct MccMountStateSlew : MccMountStateBase<MountT> {
|
||||||
|
static constexpr std::string_view ID = "MCC-MOUNT-SLEW-STATE";
|
||||||
|
|
||||||
|
// only initialization
|
||||||
using transition_t =
|
using transition_t =
|
||||||
fsm::fsm_transition_table_t<std::pair<MccMountEventInit<MountT>, MccMountStateInit<MountT>>,
|
fsm::fsm_transition_table_t<std::pair<MccMountEventInit<MountT>, MccMountStateInit<MountT>>,
|
||||||
std::pair<MccMountEventError<MountT>, MccMountStateError<MountT>>,
|
std::pair<MccMountEventError<MountT>, MccMountStateStop<MountT>>,
|
||||||
std::pair<MccMountEventSlew<MountT>, MccMountStateSlew<MountT>>,
|
// std::pair<MccMountEventSlew<MountT>, MccMountStateSlew<MountT>>,
|
||||||
std::pair<MccMountEventGuiding<MountT>, MccMountStateGuiding<MountT>>,
|
std::pair<MccMountEventGuiding<MountT>, MccMountStateStop<MountT>>,
|
||||||
std::pair<MccMountEventStop<MountT>, MccMountStateIDLE<MountT>>,
|
std::pair<MccMountEventStop<MountT>, MccMountStateStop<MountT>>,
|
||||||
std::pair<MccMountEventShutdown<MountT>, MccMountStateShutdown<MountT>>>;
|
std::pair<MccMountEventShutdown<MountT>, MccMountStateStop<MountT>>>;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
template <std::derived_from<MccMountEventBase<MountT>> EvT>
|
||||||
|
void exitImpl(EvT& event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::derived_from<MccMountEventSlew<MountT>> EvT>
|
||||||
|
void enterImpl(EvT& event)
|
||||||
|
{
|
||||||
|
event.mount().startSlew(/* params here ...*/);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mcc
|
} // namespace mcc
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user