From a34d258b9425d2ed6033e26675bd172c90db67cb Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Mon, 14 Jul 2025 00:38:10 +0300 Subject: [PATCH] ... --- cxx/mcc_mount.h | 94 ++++++++++++++++++++------------------ cxx/mcc_mount_astro_erfa.h | 4 +- cxx/mcc_mount_concepts.h | 74 ++++++++++++++++++++++++++---- 3 files changed, 114 insertions(+), 58 deletions(-) diff --git a/cxx/mcc_mount.h b/cxx/mcc_mount.h index b7c25e3..3ff9919 100644 --- a/cxx/mcc_mount.h +++ b/cxx/mcc_mount.h @@ -111,7 +111,14 @@ public: mount_telemetry_data_t mountTelemetry() const { - return _mountTelemetry.data(); + mount_telemetry_data_t mnt_data; + + auto err = _mountTelemetry.data(mnt_data); + if (err) { + // log .... + } + + return mnt_data; } @@ -123,62 +130,61 @@ public: { static constexpr auto pi2 = std::numbers::pi / 2.0; + using tl_coord_t = typename mount_telemetry_data_t::coord_t; + using pz_coord_t = typename ZT::coord_t; + static_assert(std::convertible_to, + "TELEMETRY DATA AND PROHIBITED ZONE COORDINATES TYPES ARE NOT COMPATIBLE!"); + auto zone_ptr = std::make_shared(std::move(zone)); - // typename ZT::coord_t x, y; + pz_funcs_t funcs{.coordPairKind = ZT::zoneCoordPairKind, + .name = std::format("{}", zone_ptr->name()), + .timeToFunc = + [zone_ptr, this]() { + auto tmry_data = _mountTelemetry.data(); - if constexpr (ZT::preferedCoordKind == MccCoordPairKind::COORDS_KIND_AZALT) { // azimuth and altitude - _pzFuncs.emplace_back({.coordPairKind = ZT::preferedCoordKind, - .inZoneFunc = - [zone_ptr, this]() { - auto tmry_data = _mountTelemetry.data(); + return zone_ptr->timeTo(tmry_data.mntRA, tmry_data.mntDEC, tmry_data.utc); + }, + .timeFromFunc = + [zone_ptr, this]() { + auto tmry_data = _mountTelemetry.data(); - return zone_ptr->inZone(tmry_data.mntAZ, tmry_data.mntALT, tmry_data.utc); - }, - .timeToFunc = - [zone_ptr, this]() { - auto tmry_data = _mountTelemetry.data(); + return zone_ptr->timeFrom(tmry_data.mntRA, tmry_data.mntDEC, tmry_data.utc); + }}; - return zone_ptr->timeTo(tmry_data.mntAZ, tmry_data.mntALT, tmry_data.utc); - }, - .timeFromFunc = - [zone_ptr, this]() { - auto tmry_data = _mountTelemetry.data(); - return zone_ptr->timeFrom(tmry_data.mntAZ, tmry_data.mntALT, tmry_data.utc); - }}); + if constexpr (ZT::zoneCoordPairKind == MccCoordPairKind::COORDS_KIND_AZALT) { // azimuth and altitude + funcs.inZoneFunc = [zone_ptr, this]() { + auto tmry_data = _mountTelemetry.data(); - } else if constexpr (ZT::preferedCoordKind == + return zone_ptr->inZone(tmry_data.mntAZ, tmry_data.mntALT); + }; + } else if constexpr (ZT::zoneCoordPairKind == MccCoordPairKind::COORDS_KIND_AZZD) { // azimuth and zenithal distance - _pzFuncs.emplace_back( - {.coordPairKind = ZT::preferedCoordKind, - .inZoneFunc = - [zone_ptr, this]() { - auto tmry_data = _mountTelemetry.data(); + funcs.inZoneFunc = [zone_ptr, this]() { + auto tmry_data = _mountTelemetry.data(); - return zone_ptr->inZone(tmry_data.mntAZ, pi2 - tmry_data.mntALT, tmry_data.utc); - }, - .timeToFunc = - [zone_ptr, this]() { - auto tmry_data = _mountTelemetry.data(); + return zone_ptr->inZone(tmry_data.mntAZ, pi2 - tmry_data.mntALT); + }; - return zone_ptr->timeTo(tmry_data.mntAZ, pi2 - tmry_data.mntALT, tmry_data.utc); - }, - .timeFromFunc = - [zone_ptr, this]() { - auto tmry_data = _mountTelemetry.data(); + } else if constexpr (ZT::zoneCoordPairKind == MccCoordPairKind::COORDS_KIND_RADEC_APP) { + funcs.inZoneFunc = [zone_ptr, this]() { + auto tmry_data = _mountTelemetry.data(); - return zone_ptr->timeFrom(tmry_data.mntAZ, pi2 - tmry_data.mntALT, tmry_data.utc); - }}); + return zone_ptr->inZone(tmry_data.mntRA, tmry_data.mntDEC); + }; + } else if constexpr (ZT::zoneCoordPairKind == MccCoordPairKind::COORDS_KIND_HADEC_APP) { + funcs.inZoneFunc = [zone_ptr, this]() { + auto tmry_data = _mountTelemetry.data(); - } else if constexpr (ZT::preferedCoordKind == MccCoordPairKind::COORDS_KIND_RADEC_APP) { - } else if constexpr (ZT::preferedCoordKind == MccCoordPairKind::COORDS_KIND_HADEC_APP) { - } else if constexpr (ZT::preferedCoordKind == MccCoordPairKind::COORDS_KIND_RADEC_ICRS) { - } else if constexpr (ZT::preferedCoordKind == MccCoordPairKind::COORDS_KIND_XY) { + return zone_ptr->inZone(tmry_data.mntHA, tmry_data.mntDEC); + }; } else { static_assert(false, "UNKNOWN COORDINATE SYSTEM!!!"); } + _pzFuncs.emplace_back(funcs); + if constexpr (sizeof...(ZTs)) { pzAddZone(std::move(zones)...); } @@ -192,10 +198,6 @@ public: _pzFuncs.clear(); } - template XT, std::derived_from YT> - auto pzInZone(const XT& x, const YT& y, traits::mcc_time_duration_c auto const& utc) - { - } protected: mount_config_t _mountConfig; @@ -209,6 +211,7 @@ protected: typedef std::function pz_timefrom_func_t; struct pz_funcs_t { MccCoordPairKind coordPairKind; + std::string name; pz_inzone_func_t inZoneFunc; pz_timeto_func_t timeToFunc; pz_timefrom_func_t timeFromFunc; @@ -216,6 +219,7 @@ protected: std::vector _pzFuncs{}; + }; // end of MccMount class diff --git a/cxx/mcc_mount_astro_erfa.h b/cxx/mcc_mount_astro_erfa.h index a15ed00..6e601e7 100644 --- a/cxx/mcc_mount_astro_erfa.h +++ b/cxx/mcc_mount_astro_erfa.h @@ -70,9 +70,7 @@ public: AngleT lat = "00:00:00"_dms; // site latitude AngleT lon = "00:00:00"_dms; // site longitude - // MccAngle lat = "00:00:00"_dms; // site latitude - // MccAngle lon = "00:00:00"_dms; // site longitude - double elev = 0.0; // site elevation (in meters) + double elev = 0.0; // site elevation (in meters) mcc::astrom::iers::MccLeapSeconds _leapSeconds{}; mcc::astrom::iers::MccIersBulletinA _bulletinA{}; diff --git a/cxx/mcc_mount_concepts.h b/cxx/mcc_mount_concepts.h index f782e3c..9d496e8 100644 --- a/cxx/mcc_mount_concepts.h +++ b/cxx/mcc_mount_concepts.h @@ -184,6 +184,14 @@ concept mcc_mount_pec_c = requires(T t, const T t_const) { typename T::coord_t; typename T::pec_data_t; + // the 'T' class must contain static constexpr member of 'MccMountType' type + requires requires { + requires std::same_as; + []() { + static constexpr MccMountType val = T::mountType; + }(); // to ensure 'mountType' can be used in compile-time context + }; + // a class that contains at least .dx and .dy public fields requires requires(typename T::pec_result_t res) { requires std::same_as; @@ -202,25 +210,65 @@ concept mcc_mount_pec_c = requires(T t, const T t_const) { /* MOUNT STATE TELEMETRY */ +// a class that contains at least celestial (equatorial and horizontal) coordinates +template +concept mcc_mount_telemetry_data_c = requires(T telemetry) { + typename T::coord_t; + requires std::same_as; // apparent RA + requires std::same_as; // apparent DEC + requires std::same_as; // hour angle + requires std::same_as; // azimuth + requires std::same_as; // altitude +}; + + template concept mcc_mount_telemetry_c = requires(T t, const T t_const) { typename T::error_t; - // a class that at least contains celestial (equatorial and horizontal) coordinates - requires requires(typename T::mount_telemetry_data_t telemetry) { - typename T::mount_telemetry_data_t::coord_t; - requires std::same_as; // apparent RA - requires std::same_as; // apparent DEC - requires std::same_as; // hour angle - requires std::same_as; // azimuth - requires std::same_as; // altitude - }; + // // a class that at least contains celestial (equatorial and horizontal) coordinates + // requires requires(typename T::mount_telemetry_data_t telemetry) { + // typename T::mount_telemetry_data_t::coord_t; + // requires std::same_as; // apparent + // RA requires std::same_as; // + // apparent DEC requires std::same_as; + // // hour angle requires std::same_as; + // // azimuth requires std::same_as; // + // altitude + // }; + + requires mcc_mount_telemetry_data_c; { t_const.errorString(std::declval()) } -> mcc_formattable; { t.update() } -> std::same_as; - { t.data() } -> std::same_as; + { t.data(std::declval()) } -> std::same_as; +}; + + + +/* SLEW PARAMETERS */ + +template +concept mcc_slew_params_c = std::movable && requires(T t) { + // input coordinates pair type (e.g. IRCS RA,DEC, Az,Alt and so on) + requires std::same_as; + + typename T::coord_t; + + // co-longitude (e.g. RA or Az) + requires std::same_as; + + // co-latitude (e.g. DEC or ZD) + requires std::same_as; + + // stop after slewing + requires std::convertible_to; + + requires requires(typename T::slew_model_t t) { + { t.slew(std::declval(), std::declval()) }; + }; }; @@ -265,6 +313,12 @@ concept mcc_prohibited_zone_c = std::movable && requires(T t, const T t_const t.timeFrom(std::declval(), std::declval(), std::declval()) } -> mcc_time_duration_c; + + // requires for the methods above with the first argument of type 'const + // mcc_mount_telemetry_c::mcc_mount_telemetry_data_t&' (const lvalue reference) + // + // something like this: + requires mcc_mount_telemetry_data_c>; };