From d0674d15a6f9ffe5d8da6acc3ae422c2148f7978 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Fri, 16 May 2025 00:32:41 +0300 Subject: [PATCH] ... --- cxx/mount.h | 39 ++++++++++++++------------------------- cxx/mount_pz.h | 40 ++++++++-------------------------------- 2 files changed, 22 insertions(+), 57 deletions(-) diff --git a/cxx/mount.h b/cxx/mount.h index 4fbdc4d..d14e4b4 100644 --- a/cxx/mount.h +++ b/cxx/mount.h @@ -14,6 +14,7 @@ #include "mcc_spdlog.h" #include "mcc_traits.h" #include "mount_astrom.h" +#include "mount_pz.h" // low-level functions // namespace lowlevel @@ -271,31 +272,6 @@ public: _geoLocation.store(st); } - // void setSiteLatitude(auto const& lat) - // { - // auto v = utils::parsAngleString(lat); - // if (v.has_value()) { - // auto st = _geoLocation.load(); - // st.latitude = v.value() * utils::deg2radCoeff; // to radians - // logInfo("Set current site latitude to {} radians", st.latitude); - // _geoLocation.store(st); - // } else { - // logError("Invalid user latitude value! Do not change the current value!"); - // } - // } - - // void setSiteLongitude(auto const& lon) - // { - // auto v = utils::parsAngleString(lon); - // if (v.has_value()) { - // auto st = _geoLocation.load(); - // st.longitude = v.value() * utils::deg2radCoeff; // to radians - // logInfo("Set current site longitude to {} radians", st.longitude); - // _geoLocation.store(st); - // } else { - // logError("Invalid user longitude value! Do not change the current value!"); - // } - // } void setSiteElevation(MccMountSiteInfo::mnt_site_elev_t elev) { @@ -327,6 +303,17 @@ public: /* prohibited zone related methods */ + template + size_t pzAddZone(ZT zone) + { + _pzInZoneFunc.emplace_back([zone = std::move(zone)](const MccAngle& x, const MccAngle& y, void* ctx) mutable { + auto context = *static_cast(ctx); + return zone.inZone(x, y, context); + }); + + return _pzInZoneFunc.size(); + } + // returns a time to reach the prohibited area: // 0 - already in the zone // std::chrono::duration<>::max() - never reach the zone @@ -445,6 +432,8 @@ protected: std::atomic _geoLocation; std::atomic _currentMeteo; + std::vector> _pzInZoneFunc; + // default implementation auto pzCheckImpl(const MccAngle& xcoord, const MccAngle& ycoord, diff --git a/cxx/mount_pz.h b/cxx/mount_pz.h index 9dd7bdb..85c9943 100644 --- a/cxx/mount_pz.h +++ b/cxx/mount_pz.h @@ -58,46 +58,22 @@ public: MccAngle lat, lon; // site geographic coordinates }; + MccProhibitedZone(std::string_view name, std::string_view desc) : _name(name), _desc(desc) {} + virtual ~MccProhibitedZone() = default; -}; -class MccMinAltPZ : public MccProhibitedZone -{ -public: - MccMinAltPZ(const MccAngle& min_alt) : _minAlt(min_alt) {} - - MccAngle minAlt() const + std::string_view name() const { - return _minAlt; + return _name; } -private: - double _minAlt; - - bool inZoneImpl(const MccAngle& alt, const MccAngle&) + std::string_view desc() const { - return alt <= _minAlt; - } -}; - - -class MccMaxAltPZ -{ -public: - MccMaxAltPZ(double max_alt) : _maxAlt(max_alt) {} - - double maxAlt() const - { - return _maxAlt; + return _desc; } -private: - double _maxAlt; - - bool inZoneImpl(const MccAngle& alt, const MccAngle&) - { - return alt >= _maxAlt; - } +protected: + std::string_view _name, _desc; };