From 1b1f0b29a8c9c3aac26b6f9b477e48034ea05d4c Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Sat, 12 Jul 2025 13:43:53 +0300 Subject: [PATCH] ... --- cxx/mcc_mount.h | 73 ++++++++++++++++++++------------------- cxx/mcc_mount_concepts.h | 33 ++++++++++++------ cxx/mcc_mount_telemetry.h | 30 ++++++++-------- 3 files changed, 74 insertions(+), 62 deletions(-) diff --git a/cxx/mcc_mount.h b/cxx/mcc_mount.h index fb78b31..b7c25e3 100644 --- a/cxx/mcc_mount.h +++ b/cxx/mcc_mount.h @@ -125,43 +125,52 @@ public: auto zone_ptr = std::make_shared(std::move(zone)); + // typename ZT::coord_t x, y; + if constexpr (ZT::preferedCoordKind == MccCoordPairKind::COORDS_KIND_AZALT) { // azimuth and altitude - _pzInZoneFunc.emplace_back([zone_ptr, this]() { - auto tmry_data = _mountTelemetry(); + _pzFuncs.emplace_back({.coordPairKind = ZT::preferedCoordKind, + .inZoneFunc = + [zone_ptr, this]() { + auto tmry_data = _mountTelemetry.data(); - return zone_ptr->inZone(tmry_data.mntAZ, tmry_data.mntALT, tmry_data.utc); - }); + return zone_ptr->inZone(tmry_data.mntAZ, tmry_data.mntALT, tmry_data.utc); + }, + .timeToFunc = + [zone_ptr, this]() { + auto tmry_data = _mountTelemetry.data(); - _pzTimeToFunc.emplace_back([zone_ptr, this]() { - auto tmry_data = _mountTelemetry(); + 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->timeTo(tmry_data.mntAZ, tmry_data.mntALT, tmry_data.utc); - }); + return zone_ptr->timeFrom(tmry_data.mntAZ, tmry_data.mntALT, tmry_data.utc); + }}); - _pzTimeFromFunc.emplace_back([zone_ptr, this]() { - auto tmry_data = _mountTelemetry(); - - return zone_ptr->timeFrom(tmry_data.mntAZ, tmry_data.mntALT, tmry_data.utc); - }); } else if constexpr (ZT::preferedCoordKind == MccCoordPairKind::COORDS_KIND_AZZD) { // azimuth and zenithal distance - _pzInZoneFunc.emplace_back([zone_ptr, this]() { - auto tmry_data = _mountTelemetry(); + _pzFuncs.emplace_back( + {.coordPairKind = ZT::preferedCoordKind, + .inZoneFunc = + [zone_ptr, this]() { + auto tmry_data = _mountTelemetry.data(); - return zone_ptr->inZone(tmry_data.mntAZ, pi2 - tmry_data.mntALT, tmry_data.utc); - }); + return zone_ptr->inZone(tmry_data.mntAZ, pi2 - tmry_data.mntALT, tmry_data.utc); + }, + .timeToFunc = + [zone_ptr, this]() { + auto tmry_data = _mountTelemetry.data(); - _pzTimeToFunc.emplace_back([zone_ptr, this]() { - auto tmry_data = _mountTelemetry(); + return zone_ptr->timeTo(tmry_data.mntAZ, pi2 - tmry_data.mntALT, tmry_data.utc); + }, + .timeFromFunc = + [zone_ptr, this]() { + auto tmry_data = _mountTelemetry.data(); - return zone_ptr->timeTo(tmry_data.mntAZ, pi2 - tmry_data.mntALT, tmry_data.utc); - }); + return zone_ptr->timeFrom(tmry_data.mntAZ, pi2 - tmry_data.mntALT, tmry_data.utc); + }}); - _pzTimeFromFunc.emplace_back([zone_ptr, this]() { - auto tmry_data = _mountTelemetry(); - - return zone_ptr->timeFrom(tmry_data.mntAZ, pi2 - tmry_data.mntALT, tmry_data.utc); - }); } 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) { @@ -171,18 +180,16 @@ public: } if constexpr (sizeof...(ZTs)) { - psAddZone(std::move(zones)...); + pzAddZone(std::move(zones)...); } - return _pzInZoneFunc.size(); + return _pzFuncs.size(); } // delete all zones from mount control system void pzClearZone() { - _pzInZoneFunc.clear(); - _pzTimeToFunc.clear(); - _pzTimeFromFunc.clear(); + _pzFuncs.clear(); } template XT, std::derived_from YT> @@ -197,10 +204,6 @@ protected: // a type to which the result of calling prohibited zone class methods 'timeTo' and 'timeFrom' will be converted typedef std::chrono::duration pz_duration_t; // seconds as floating-point number - std::vector> _pzInZoneFunc{}; - std::vector> _pzTimeToFunc{}; - std::vector> _pzTimeFromFunc{}; - typedef std::function pz_inzone_func_t; typedef std::function pz_timeto_func_t; typedef std::function pz_timefrom_func_t; diff --git a/cxx/mcc_mount_concepts.h b/cxx/mcc_mount_concepts.h index 1cba03a..f9fa78c 100644 --- a/cxx/mcc_mount_concepts.h +++ b/cxx/mcc_mount_concepts.h @@ -57,6 +57,8 @@ static consteval bool mccIsAltAzMount(const MccMountType type) +/* MOUNT COMPONENTS CONCEPTS */ + namespace mcc::traits { @@ -125,7 +127,7 @@ concept mcc_astrom_engine_c = requires(T t, const T t_const) { t.greg2jul(std::declval(), std::declval()) } -> std::same_as; - // apparent sideral time: apparentSiderTime(jd, gst, islocal) + // apparent sideral time: apparentSiderTime(jd, st, islocal) // if islocal == false then the method must return the Greenwich apparent sideral time, otherwise - local one { t.apparentSiderTime(std::declval(), std::declval(), @@ -182,7 +184,7 @@ concept mcc_mount_pec_c = requires(T t, const T t_const) { typename T::coord_t; typename T::pec_data_t; - // at least contains .dx and .dy fields + // a class which contains at least .dx and .dy public fields requires requires(typename T::pec_result_t res) { requires std::same_as; requires std::same_as; @@ -203,26 +205,36 @@ concept mcc_mount_pec_c = requires(T t, const T t_const) { template concept mcc_mount_telemetry_c = requires(T t, const T t_const) { typename T::error_t; - typename T::mount_telemetry_data_t; + + // a class which 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 + }; { t_const.errorString(std::declval()) } -> mcc_formattable; { t.update() } -> std::same_as; - { t_const.data() } -> std::same_as; + { t.data() } -> std::same_as; }; /* MOUNT PROHIBITED ZONE */ + template concept mcc_prohibited_zone_c = std::movable && requires(T t, const T t_const) { typename T::coord_t; typename T::time_point_t; - // the type 'T' must define static constexpr member of type MccCoordPairKind + // the type 'T' must define a static constexpr member of type MccCoordPairKind // to declarate type of coordinate pair used to describe the zone. - // This coordinate pair must be used as input in the class methods. + // This coordinate pair must be used as input in the 'inZone' class method. requires requires { requires std::same_as; []() { @@ -234,14 +246,13 @@ concept mcc_prohibited_zone_c = std::movable && requires(T t, const T t_const { t_const.name() } -> mcc_formattable; - // check if given coordinates are in the zone at given time point - { - t.inZone(std::declval(), std::declval(), - std::declval()) - } -> std::convertible_to; + // check if given coordinates are in the zone + { t.inZone(std::declval(), std::declval()) } -> std::convertible_to; // for given coordinates and time the method computes a time to reach the zone + // implementation of the method must assume that input coordinates are apparent RA and DEC at given time point, + // while the time point is one from which computation must be performed (e.g. current time moment) { t.timeTo(std::declval(), std::declval(), std::declval()) diff --git a/cxx/mcc_mount_telemetry.h b/cxx/mcc_mount_telemetry.h index 18571fc..ca35dbf 100644 --- a/cxx/mcc_mount_telemetry.h +++ b/cxx/mcc_mount_telemetry.h @@ -53,7 +53,7 @@ public: // mount current telemetry data: time, position and related quantities struct mount_telemetry_data_t { - typedef typename astrom_engine_t::coord_t mnt_coord_t; + typedef typename astrom_engine_t::coord_t coord_t; // time-related typename astrom_engine_t::time_point_t utc; // time point of measurements, UTC @@ -63,29 +63,29 @@ public: // typename astrom_engine_t::time_point_t tt; // Terrestial time // apparent target (user-input) current coordinates (in radians) - mnt_coord_t tagRA, tagDEC; - mnt_coord_t tagHA; - mnt_coord_t tagAZ, tagALT; - mnt_coord_t tagPA; // paralactic angle + coord_t tagRA, tagDEC; + coord_t tagHA; + coord_t tagAZ, tagALT; + coord_t tagPA; // paralactic angle // encoder-measured current mount coordinates (in radians) - mnt_coord_t mntRA, mntDEC; - mnt_coord_t mntHA; - mnt_coord_t mntAZ, mntALT; + coord_t mntRA, mntDEC; + coord_t mntHA; + coord_t mntAZ, mntALT; typename astrom_engine_t::pa_t mntPA; // encoder-measured (non-corrected for PCS) current mount position and moving speed (in radians, radians/s) // X - HA, Y - DEC for equatorial-type mount; X - AZ, Y - ALT for horizontal-type one - mnt_coord_t mntPosX, mntPosY; + coord_t mntPosX, mntPosY; // current refraction coefficients typename pec_t::pec_result_t currRefrCoeffs; // current refraction correction (for mntALT) - mnt_coord_t currRefr; + coord_t currRefr; // PEC (pointing error correction): // X - HA, Y - DEC for equatorial-type mount; X - AZ, Y - ALT for horizontal-type one - mnt_coord_t pecX, pecY; + coord_t pecX, pecY; }; MccMountTelemetry(astrom_engine_t& astrom_engine, pec_t& pec, hardware_t& hardware) @@ -189,13 +189,11 @@ public: return TEL_ERROR_OK; } - mount_telemetry_data_t data(this auto&& self) + mount_telemetry_data_t data() { - using self_t = decltype(self); + std::lock_guard lock{_updateMutex}; - std::lock_guard lock{std::forward(self)._updateMutex}; - - return std::move(std::forward(self)._data); + return std::move(_data); }