...
This commit is contained in:
parent
00cf1834e9
commit
d0674d15a6
39
cxx/mount.h
39
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 <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:
|
||||
// 0 - already in the zone
|
||||
// std::chrono::duration<>::max() - never reach the zone
|
||||
@ -445,6 +432,8 @@ protected:
|
||||
std::atomic<MccMountSiteInfo> _geoLocation;
|
||||
std::atomic<MccMountMeteo> _currentMeteo;
|
||||
|
||||
std::vector<std::function<bool(const MccAngle&, const MccAngle&, void*)>> _pzInZoneFunc;
|
||||
|
||||
// default implementation
|
||||
auto pzCheckImpl(const MccAngle& xcoord,
|
||||
const MccAngle& ycoord,
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user