This commit is contained in:
Timur A. Fatkhullin
2025-05-20 01:05:31 +03:00
parent 88d4b30a58
commit f03e38466e
2 changed files with 165 additions and 9 deletions

View File

@@ -36,9 +36,12 @@ public:
static constexpr auto mcc_noop_callback = [](const mount_state_error_t&) {};
MccMountAbstractState(traits::mcc_mount_c auto* mount_ptr,
std::convertible_to<enter_callback_t> auto&& enter_callback,
std::convertible_to<exit_callback_t> auto&& exit_callback,
std::convertible_to<error_callback_t> auto&& error_callback)
std::convertible_to<enter_callback_t> auto&& enter_callback = mcc_noop_callback,
std::convertible_to<exit_callback_t> auto&& exit_callback = mcc_noop_callback,
std::convertible_to<error_callback_t> auto&& error_callback = mcc_noop_callback)
: _enterCallback(std::forward<enter_callback_t>(enter_callback)),
_exitCallback(std::forward<exit_callback_t>(exit_callback)),
_errorCallback(std::forward<error_callback_t>(error_callback))
{
_getMountDataFunc = [&mount_ptr, this]() { auto mstate = mount_ptr->getMountData(); };
}
@@ -81,26 +84,108 @@ public:
};
/* */
class MccMountStateStoping
{
public:
typedef std::string state_data_t;
MccMountStateStoping(traits::mcc_input_char_range auto const& reason) : _reason({reason.begin(), reason.end()}) {}
MccMountStateStoping(const char* reason) : MccMountStateStoping(std::string_view{reason}) {}
std::string_view ident() const
{
return "MCC-MOUNT-STATE-STOPING";
}
void enter() {}
void exit() {}
void stop() {}
state_data_t stateData()
{
return _reason;
}
protected:
std::string _reason;
};
/* */
class MccMountStateStopped
{
public:
typedef std::string state_data_t;
MccMountStateStopped(traits::mcc_input_char_range auto const& reason) : _reason({reason.begin(), reason.end()}) {}
MccMountStateStopped(const char* reason) : MccMountStateStopped(std::string_view{reason}) {}
std::string_view ident() const
{
return "MCC-MOUNT-STATE-STOPPED";
}
void enter() {}
void exit() {}
void stop() {}
state_data_t stateData()
{
return _reason;
}
protected:
std::string _reason;
};
/* */
class MccMountStateSlew
{
public:
enum coords_kind_t { COORDS_KIND_RADEC_IRCS, COORDS_KIND_RADEC_APP, COORDS_KIND_HADEC_APP, COORDS_KIND_AZALT };
struct slew_state_params_t {
coords_kind_t coordKind{COORDS_KIND_RADEC_APP};
MccCoordPairKind coordKind{MccCoordPairKind::COORDS_KIND_RADEC_APP};
MccAngle x, y; // according to 'coordKind'
bool stop{false}; // stop after
};
MccMountStateSlew() {}
MccMountStateSlew(traits::mcc_mount_c auto& mount,
const slew_state_params_t& params,
std::string_view ident = "MCC-MOUNT-STATE-SLEW")
: _ident(ident)
{
_stopFunc = [&mount]() {
//
mount.setMountState(MccMountStateStopped("stop pointing"));
};
}
std::string_view ident() const
{
return "MCC-MOUNT-STATE-SLEW";
return _ident;
}
void enter() {}
void exit() {}
void stop() {}
protected:
std::string_view _ident;
std::function<void()> _stopFunc;
};
} // namespace mcc