This commit is contained in:
Timur A. Fatkhullin
2025-08-28 00:43:55 +03:00
parent 45f655dc90
commit 2e5e1918e1
5 changed files with 271 additions and 143 deletions

View File

@@ -323,6 +323,125 @@ concept mcc_ccte_c = std::derived_from<T, mcc_CCTE_interface_t<typename T::error
/* POINTING CORRECTION MODEL CLASS CONCEPT */
template <typename T>
concept mcc_PCM_result_c = requires(T t) {
requires mcc_angle_c<decltype(t.dx)>;
requires mcc_angle_c<decltype(t.dy)>;
};
template <mcc_error_c RetT, mcc_PCM_result_c ResT>
struct mcc_PCM_interface_t {
virtual ~mcc_PCM_interface_t() = default;
template <std::derived_from<mcc_PCM_interface_t> SelfT>
RetT computePCM(this SelfT&& self, mcc_celestial_point_c auto pt, ResT* result)
{
return std::forward<SelfT>(self).computePCM(std::move(pt), result);
}
protected:
mcc_PCM_interface_t() = default;
};
template <typename T>
concept mcc_PCM_c =
std::derived_from<T, mcc_PCM_interface_t<typename T::error_t, typename T::pcm_result_t>> && requires {
// the 'T' class must contain static constexpr member of 'MccMountType' type
requires std::same_as<decltype(T::mountType), const MccMountType>;
[]() {
static constexpr MccMountType val = T::mountType;
return val;
}(); // to ensure 'mountType' can be used in compile-time context
};
/* MOUNT HARDWARE ABSTRACTION CLASS CONCEPT */
template <typename T>
concept mcc_hardware_c = requires(T t, const T t_const) {
requires mcc_error_c<typename T::error_t>;
{ t_const.hardwareName() } -> std::formattable<char>;
// a type that defines at least HW_MOVE_STOPPED, HW_MOVE_SLEWING, HW_MOVE_ADJUSTING, HW_MOVE_TRACKING
// and HW_MOVE_GUIDING compile-time constants. The main purpose of this type is a
// possible tunning of hardware hardwareSetState-related commands and detect stop-state
//
// e.g. an implementations can be as follows:
// enum class hardware_moving_state_t: int {HW_MOVE_STOPPED, HW_MOVE_SLEWING, HW_MOVE_ADJUSTING,
// HW_MOVE_TRACKING, HW_MOVE_GUIDING}
//
// struct hardware_moving_state_t {
// uint16_t HW_MOVE_STOPPED = 0;
// uint16_t HW_MOVE_SLEWING = 111;
// uint16_t HW_MOVE_ADJUSTING = 222;
// uint16_t HW_MOVE_TRACKING = 333;
// uint16_t HW_MOVE_GUIDING = 444;
// }
requires requires(typename T::hardware_moving_state_t type) {
[]() {
// mount axes were stopped
static constexpr auto v0 = T::hardware_moving_state_t::HW_MOVE_STOPPED;
// hardware was asked for slewing (move to given celestial point)
static constexpr auto v1 = T::hardware_moving_state_t::HW_MOVE_SLEWING;
// hardware was asked for adjusting after slewing
// (adjusting actual mount position to align with target celestial point at the end of slewing process)
static constexpr auto v2 = T::hardware_moving_state_t::HW_MOVE_ADJUSTING;
// hardware was asked for tracking (track target celestial point)
static constexpr auto v3 = T::hardware_moving_state_t::HW_MOVE_TRACKING;
// hardware was asked for guiding
// (small corrections to align actual mount position with target celestial point)
static constexpr auto v4 = T::hardware_moving_state_t::HW_MOVE_GUIDING;
}();
};
// a class that contains at least time point of measurement, coordinates for x,y axes, its moving rates and moving
// type
requires requires(typename T::hardware_state_t state) {
requires mcc_time_point_c<decltype(state.time_point)>; // time point
requires mcc_angle_c<decltype(state.X)>; // target or current co-longitude coordinate
requires mcc_angle_c<decltype(state.Y)>; // target or current co-latitude coordinate
requires mcc_angle_c<decltype(state.speedX)>; // moving speed along co-longitude coordinate
requires mcc_angle_c<decltype(state.speedY)>; // moving speed along co-latitude coordinate
requires std::same_as<typename T::hardware_moving_state_t, decltype(state.moving_type)>;
};
// set hardware state:
// i.g. set positions (angles) of mount axes with given speeds
// NOTE: exact interpretation (or even ignoring) of the given moving speeds is subject of a hardware-class
// implementation, e.g. it can be maximal speeds at slewing ramp
{ t.hardwareSetState(std::declval<typename T::hardware_state_t>()) } -> std::same_as<typename T::error_t>;
// get current state
{ t.hardwareGetState(std::declval<typename T::hardware_state_t*>()) } -> std::same_as<typename T::error_t>;
{ t.hardwareStop() } -> std::same_as<typename T::error_t>; // stop any moving
{ t.hardwareInit() } -> std::same_as<typename T::error_t>; // initialize hardware
};
/* AUXILIARY COORDINATE-TRANSFORMATON CLASS CONCEPT */
// a concept of class that consist of the full set of coordinate transformation mount control components
// (celestial coordinate transformation engine, mount hardware encoders readings and pointing correction model)
// the set of methods of this class is enough to transform coordinates from ICRS to hardware and back
template <typename T>
concept mcc_coord_trfm_controls_c = mcc_ccte_c<T> && mcc_hardware_c<T> && mcc_PCM_c<T>;
/* MOUNT TELEMETRY DATA CLASS CONCEPT */
template <typename T>
@@ -493,116 +612,6 @@ concept mcc_telemetry_c = std::derived_from<T, mcc_telemetry_interface_t<typenam
/* POINTING CORRECTION MODEL CLASS CONCEPT */
template <typename T>
concept mcc_PCM_result_c = requires(T t) {
requires mcc_angle_c<decltype(t.dx)>;
requires mcc_angle_c<decltype(t.dy)>;
};
template <mcc_error_c RetT, mcc_PCM_result_c ResT>
struct mcc_PCM_interface_t {
virtual ~mcc_PCM_interface_t() = default;
template <std::derived_from<mcc_PCM_interface_t> SelfT>
RetT computePCM(this SelfT&& self, mcc_celestial_point_c auto pt, ResT* result)
{
return std::forward<SelfT>(self).computePCM(std::move(pt), result);
}
protected:
mcc_PCM_interface_t() = default;
};
template <typename T>
concept mcc_PCM_c =
std::derived_from<T, mcc_PCM_interface_t<typename T::error_t, typename T::pcm_result_t>> && requires {
// the 'T' class must contain static constexpr member of 'MccMountType' type
requires std::same_as<decltype(T::mountType), const MccMountType>;
[]() {
static constexpr MccMountType val = T::mountType;
return val;
}(); // to ensure 'mountType' can be used in compile-time context
};
/* MOUNT HARDWARE ABSTRACTION CLASS CONCEPT */
template <typename T>
concept mcc_hardware_c = requires(T t, const T t_const) {
requires mcc_error_c<typename T::error_t>;
{ t_const.hardwareName() } -> std::formattable<char>;
// a type that defines at least HW_MOVE_STOPPED, HW_MOVE_SLEWING, HW_MOVE_ADJUSTING, HW_MOVE_TRACKING
// and HW_MOVE_GUIDING compile-time constants. The main purpose of this type is a
// possible tunning of hardware hardwareSetState-related commands and detect stop-state
//
// e.g. an implementations can be as follows:
// enum class hardware_moving_state_t: int {HW_MOVE_STOPPED, HW_MOVE_SLEWING, HW_MOVE_ADJUSTING,
// HW_MOVE_TRACKING, HW_MOVE_GUIDING}
//
// struct hardware_moving_state_t {
// uint16_t HW_MOVE_STOPPED = 0;
// uint16_t HW_MOVE_SLEWING = 111;
// uint16_t HW_MOVE_ADJUSTING = 222;
// uint16_t HW_MOVE_TRACKING = 333;
// uint16_t HW_MOVE_GUIDING = 444;
// }
requires requires(typename T::hardware_moving_state_t type) {
[]() {
// mount axes were stopped
static constexpr auto v0 = T::hardware_moving_state_t::HW_MOVE_STOPPED;
// hardware was asked for slewing (move to given celestial point)
static constexpr auto v1 = T::hardware_moving_state_t::HW_MOVE_SLEWING;
// hardware was asked for adjusting after slewing
// (adjusting actual mount position to align with target celestial point at the end of slewing process)
static constexpr auto v2 = T::hardware_moving_state_t::HW_MOVE_ADJUSTING;
// hardware was asked for tracking (track target celestial point)
static constexpr auto v3 = T::hardware_moving_state_t::HW_MOVE_TRACKING;
// hardware was asked for guiding
// (small corrections to align actual mount position with target celestial point)
static constexpr auto v4 = T::hardware_moving_state_t::HW_MOVE_GUIDING;
}();
};
// a class that contains at least time point of measurement, coordinates for x,y axes, its moving rates and moving
// type
requires requires(typename T::hardware_state_t state) {
requires mcc_time_point_c<decltype(state.time_point)>; // time point
requires mcc_angle_c<decltype(state.X)>; // target or current co-longitude coordinate
requires mcc_angle_c<decltype(state.Y)>; // target or current co-latitude coordinate
requires mcc_angle_c<decltype(state.speedX)>; // moving speed along co-longitude coordinate
requires mcc_angle_c<decltype(state.speedY)>; // moving speed along co-latitude coordinate
requires std::same_as<typename T::hardware_moving_state_t, decltype(state.moving_type)>;
};
// set hardware state:
// i.g. set positions (angles) of mount axes with given speeds
// NOTE: exact interpretation (or even ignoring) of the given moving speeds is subject of a hardware-class
// implementation, e.g. it can be maximal speeds at slewing ramp
{ t.hardwareSetState(std::declval<typename T::hardware_state_t>()) } -> std::same_as<typename T::error_t>;
// get current state
{ t.hardwareGetState(std::declval<typename T::hardware_state_t*>()) } -> std::same_as<typename T::error_t>;
{ t.hardwareStop() } -> std::same_as<typename T::error_t>; // stop any moving
{ t.hardwareInit() } -> std::same_as<typename T::error_t>; // initialize hardware
};
/* PROHIBITED ZONE CLASS CONCEPT */
template <mcc_error_c RetT>
@@ -831,6 +840,7 @@ concept mcc_guiding_model_c = requires(T t) {
// = std::derived_from<T, mcc_generic_mount_interface_t<typename T::error_t, typename T::stop_reason_t>>
// && mcc_telemetry_c<T> && mcc_pzone_container_c<T>;
template <typename T>
concept mcc_generic_mount_c = mcc_hardware_c<T> && mcc_telemetry_c<T> && mcc_pzone_container_c<T> && requires(T t) {
requires mcc_error_c<typename T::error_t>;