This commit is contained in:
Timur A. Fatkhullin 2025-05-16 00:32:41 +03:00
parent 00cf1834e9
commit d0674d15a6
2 changed files with 22 additions and 57 deletions

View File

@ -14,6 +14,7 @@
#include "mcc_spdlog.h" #include "mcc_spdlog.h"
#include "mcc_traits.h" #include "mcc_traits.h"
#include "mount_astrom.h" #include "mount_astrom.h"
#include "mount_pz.h"
// low-level functions // low-level functions
// namespace lowlevel // namespace lowlevel
@ -271,31 +272,6 @@ public:
_geoLocation.store(st); _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) void setSiteElevation(MccMountSiteInfo::mnt_site_elev_t elev)
{ {
@ -327,6 +303,17 @@ public:
/* prohibited zone related methods */ /* prohibited zone related methods */
template <traits::mcc_prohibited_zone_c ZT>
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<typename ZT::pzcontext_t*>(ctx);
return zone.inZone(x, y, context);
});
return _pzInZoneFunc.size();
}
// returns a time to reach the prohibited area: // returns a time to reach the prohibited area:
// 0 - already in the zone // 0 - already in the zone
// std::chrono::duration<>::max() - never reach the zone // std::chrono::duration<>::max() - never reach the zone
@ -445,6 +432,8 @@ protected:
std::atomic<MccMountSiteInfo> _geoLocation; std::atomic<MccMountSiteInfo> _geoLocation;
std::atomic<MccMountMeteo> _currentMeteo; std::atomic<MccMountMeteo> _currentMeteo;
std::vector<std::function<bool(const MccAngle&, const MccAngle&, void*)>> _pzInZoneFunc;
// default implementation // default implementation
auto pzCheckImpl(const MccAngle& xcoord, auto pzCheckImpl(const MccAngle& xcoord,
const MccAngle& ycoord, const MccAngle& ycoord,

View File

@ -58,46 +58,22 @@ public:
MccAngle lat, lon; // site geographic coordinates MccAngle lat, lon; // site geographic coordinates
}; };
MccProhibitedZone(std::string_view name, std::string_view desc) : _name(name), _desc(desc) {}
virtual ~MccProhibitedZone() = default; virtual ~MccProhibitedZone() = default;
};
class MccMinAltPZ : public MccProhibitedZone std::string_view name() const
{
public:
MccMinAltPZ(const MccAngle& min_alt) : _minAlt(min_alt) {}
MccAngle minAlt() const
{ {
return _minAlt; return _name;
} }
private: std::string_view desc() const
double _minAlt;
bool inZoneImpl(const MccAngle& alt, const MccAngle&)
{ {
return alt <= _minAlt; return _desc;
}
};
class MccMaxAltPZ
{
public:
MccMaxAltPZ(double max_alt) : _maxAlt(max_alt) {}
double maxAlt() const
{
return _maxAlt;
} }
private: protected:
double _maxAlt; std::string_view _name, _desc;
bool inZoneImpl(const MccAngle& alt, const MccAngle&)
{
return alt >= _maxAlt;
}
}; };