...
This commit is contained in:
parent
faa57b22c3
commit
1b1f0b29a8
@ -125,43 +125,52 @@ public:
|
|||||||
|
|
||||||
auto zone_ptr = std::make_shared<ZT>(std::move(zone));
|
auto zone_ptr = std::make_shared<ZT>(std::move(zone));
|
||||||
|
|
||||||
|
// typename ZT::coord_t x, y;
|
||||||
|
|
||||||
if constexpr (ZT::preferedCoordKind == MccCoordPairKind::COORDS_KIND_AZALT) { // azimuth and altitude
|
if constexpr (ZT::preferedCoordKind == MccCoordPairKind::COORDS_KIND_AZALT) { // azimuth and altitude
|
||||||
_pzInZoneFunc.emplace_back([zone_ptr, this]() {
|
_pzFuncs.emplace_back({.coordPairKind = ZT::preferedCoordKind,
|
||||||
auto tmry_data = _mountTelemetry();
|
.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]() {
|
return zone_ptr->timeTo(tmry_data.mntAZ, tmry_data.mntALT, tmry_data.utc);
|
||||||
auto tmry_data = _mountTelemetry();
|
},
|
||||||
|
.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 ==
|
} else if constexpr (ZT::preferedCoordKind ==
|
||||||
MccCoordPairKind::COORDS_KIND_AZZD) { // azimuth and zenithal distance
|
MccCoordPairKind::COORDS_KIND_AZZD) { // azimuth and zenithal distance
|
||||||
_pzInZoneFunc.emplace_back([zone_ptr, this]() {
|
_pzFuncs.emplace_back(
|
||||||
auto tmry_data = _mountTelemetry();
|
{.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]() {
|
return zone_ptr->timeTo(tmry_data.mntAZ, pi2 - tmry_data.mntALT, tmry_data.utc);
|
||||||
auto tmry_data = _mountTelemetry();
|
},
|
||||||
|
.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_RADEC_APP) {
|
||||||
} else if constexpr (ZT::preferedCoordKind == MccCoordPairKind::COORDS_KIND_HADEC_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_RADEC_ICRS) {
|
||||||
@ -171,18 +180,16 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if constexpr (sizeof...(ZTs)) {
|
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
|
// delete all zones from mount control system
|
||||||
void pzClearZone()
|
void pzClearZone()
|
||||||
{
|
{
|
||||||
_pzInZoneFunc.clear();
|
_pzFuncs.clear();
|
||||||
_pzTimeToFunc.clear();
|
|
||||||
_pzTimeFromFunc.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::derived_from<MccAngle> XT, std::derived_from<MccAngle> YT>
|
template <std::derived_from<MccAngle> XT, std::derived_from<MccAngle> YT>
|
||||||
@ -197,10 +204,6 @@ protected:
|
|||||||
// a type to which the result of calling prohibited zone class methods 'timeTo' and 'timeFrom' will be converted
|
// a type to which the result of calling prohibited zone class methods 'timeTo' and 'timeFrom' will be converted
|
||||||
typedef std::chrono::duration<double> pz_duration_t; // seconds as floating-point number
|
typedef std::chrono::duration<double> pz_duration_t; // seconds as floating-point number
|
||||||
|
|
||||||
std::vector<std::function<bool()>> _pzInZoneFunc{};
|
|
||||||
std::vector<std::function<pz_duration_t()>> _pzTimeToFunc{};
|
|
||||||
std::vector<std::function<pz_duration_t()>> _pzTimeFromFunc{};
|
|
||||||
|
|
||||||
typedef std::function<bool()> pz_inzone_func_t;
|
typedef std::function<bool()> pz_inzone_func_t;
|
||||||
typedef std::function<pz_duration_t()> pz_timeto_func_t;
|
typedef std::function<pz_duration_t()> pz_timeto_func_t;
|
||||||
typedef std::function<pz_duration_t()> pz_timefrom_func_t;
|
typedef std::function<pz_duration_t()> pz_timefrom_func_t;
|
||||||
|
|||||||
@ -57,6 +57,8 @@ static consteval bool mccIsAltAzMount(const MccMountType type)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* MOUNT COMPONENTS CONCEPTS */
|
||||||
|
|
||||||
namespace mcc::traits
|
namespace mcc::traits
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -125,7 +127,7 @@ concept mcc_astrom_engine_c = requires(T t, const T t_const) {
|
|||||||
t.greg2jul(std::declval<typename T::time_point_t>(), std::declval<typename T::juldate_t&>())
|
t.greg2jul(std::declval<typename T::time_point_t>(), std::declval<typename T::juldate_t&>())
|
||||||
} -> std::same_as<typename T::error_t>;
|
} -> std::same_as<typename T::error_t>;
|
||||||
|
|
||||||
// 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
|
// if islocal == false then the method must return the Greenwich apparent sideral time, otherwise - local one
|
||||||
{
|
{
|
||||||
t.apparentSiderTime(std::declval<typename T::juldate_t>(), std::declval<typename T::sideral_time_t&>(),
|
t.apparentSiderTime(std::declval<typename T::juldate_t>(), std::declval<typename T::sideral_time_t&>(),
|
||||||
@ -182,7 +184,7 @@ concept mcc_mount_pec_c = requires(T t, const T t_const) {
|
|||||||
typename T::coord_t;
|
typename T::coord_t;
|
||||||
typename T::pec_data_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 requires(typename T::pec_result_t res) {
|
||||||
requires std::same_as<decltype(res.dx), typename T::coord_t>;
|
requires std::same_as<decltype(res.dx), typename T::coord_t>;
|
||||||
requires std::same_as<decltype(res.dy), typename T::coord_t>;
|
requires std::same_as<decltype(res.dy), typename T::coord_t>;
|
||||||
@ -203,26 +205,36 @@ concept mcc_mount_pec_c = requires(T t, const T t_const) {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
concept mcc_mount_telemetry_c = requires(T t, const T t_const) {
|
concept mcc_mount_telemetry_c = requires(T t, const T t_const) {
|
||||||
typename T::error_t;
|
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<decltype(telemetry.mntRA), typename T::mount_telemetry_data_t::coord_t>; // apparent RA
|
||||||
|
requires std::same_as<decltype(telemetry.mntDEC), typename T::mount_telemetry_data_t::coord_t>; // apparent DEC
|
||||||
|
requires std::same_as<decltype(telemetry.mntHA), typename T::mount_telemetry_data_t::coord_t>; // hour angle
|
||||||
|
requires std::same_as<decltype(telemetry.mntAZ), typename T::mount_telemetry_data_t::coord_t>; // azimuth
|
||||||
|
requires std::same_as<decltype(telemetry.mntALT), typename T::mount_telemetry_data_t::coord_t>; // altitude
|
||||||
|
};
|
||||||
|
|
||||||
{ t_const.errorString(std::declval<typename T::error_t>()) } -> mcc_formattable;
|
{ t_const.errorString(std::declval<typename T::error_t>()) } -> mcc_formattable;
|
||||||
|
|
||||||
{ t.update() } -> std::same_as<typename T::error_t>;
|
{ t.update() } -> std::same_as<typename T::error_t>;
|
||||||
|
|
||||||
{ t_const.data() } -> std::same_as<typename T::mount_telemetry_data_t>;
|
{ t.data() } -> std::same_as<typename T::mount_telemetry_data_t>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* MOUNT PROHIBITED ZONE */
|
/* MOUNT PROHIBITED ZONE */
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept mcc_prohibited_zone_c = std::movable<T> && requires(T t, const T t_const) {
|
concept mcc_prohibited_zone_c = std::movable<T> && requires(T t, const T t_const) {
|
||||||
typename T::coord_t;
|
typename T::coord_t;
|
||||||
typename T::time_point_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.
|
// 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 requires {
|
||||||
requires std::same_as<decltype(T::zoneCoordPairKind), const MccCoordPairKind>;
|
requires std::same_as<decltype(T::zoneCoordPairKind), const MccCoordPairKind>;
|
||||||
[]() {
|
[]() {
|
||||||
@ -234,14 +246,13 @@ concept mcc_prohibited_zone_c = std::movable<T> && requires(T t, const T t_const
|
|||||||
{ t_const.name() } -> mcc_formattable;
|
{ t_const.name() } -> mcc_formattable;
|
||||||
|
|
||||||
|
|
||||||
// check if given coordinates are in the zone at given time point
|
// check if given coordinates are in the zone
|
||||||
{
|
{ t.inZone(std::declval<typename T::coord_t>(), std::declval<typename T::coord_t>()) } -> std::convertible_to<bool>;
|
||||||
t.inZone(std::declval<typename T::coord_t>(), std::declval<typename T::coord_t>(),
|
|
||||||
std::declval<typename T::time_point_t>())
|
|
||||||
} -> std::convertible_to<bool>;
|
|
||||||
|
|
||||||
|
|
||||||
// for given coordinates and time the method computes a time to reach the zone
|
// 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<typename T::coord_t>(), std::declval<typename T::coord_t>(),
|
t.timeTo(std::declval<typename T::coord_t>(), std::declval<typename T::coord_t>(),
|
||||||
std::declval<typename T::time_point_t>())
|
std::declval<typename T::time_point_t>())
|
||||||
|
|||||||
@ -53,7 +53,7 @@ public:
|
|||||||
|
|
||||||
// mount current telemetry data: time, position and related quantities
|
// mount current telemetry data: time, position and related quantities
|
||||||
struct mount_telemetry_data_t {
|
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
|
// time-related
|
||||||
typename astrom_engine_t::time_point_t utc; // time point of measurements, UTC
|
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
|
// typename astrom_engine_t::time_point_t tt; // Terrestial time
|
||||||
|
|
||||||
// apparent target (user-input) current coordinates (in radians)
|
// apparent target (user-input) current coordinates (in radians)
|
||||||
mnt_coord_t tagRA, tagDEC;
|
coord_t tagRA, tagDEC;
|
||||||
mnt_coord_t tagHA;
|
coord_t tagHA;
|
||||||
mnt_coord_t tagAZ, tagALT;
|
coord_t tagAZ, tagALT;
|
||||||
mnt_coord_t tagPA; // paralactic angle
|
coord_t tagPA; // paralactic angle
|
||||||
|
|
||||||
// encoder-measured current mount coordinates (in radians)
|
// encoder-measured current mount coordinates (in radians)
|
||||||
mnt_coord_t mntRA, mntDEC;
|
coord_t mntRA, mntDEC;
|
||||||
mnt_coord_t mntHA;
|
coord_t mntHA;
|
||||||
mnt_coord_t mntAZ, mntALT;
|
coord_t mntAZ, mntALT;
|
||||||
typename astrom_engine_t::pa_t mntPA;
|
typename astrom_engine_t::pa_t mntPA;
|
||||||
|
|
||||||
// encoder-measured (non-corrected for PCS) current mount position and moving speed (in radians, radians/s)
|
// 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
|
// 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
|
// current refraction coefficients
|
||||||
typename pec_t::pec_result_t currRefrCoeffs;
|
typename pec_t::pec_result_t currRefrCoeffs;
|
||||||
// current refraction correction (for mntALT)
|
// current refraction correction (for mntALT)
|
||||||
mnt_coord_t currRefr;
|
coord_t currRefr;
|
||||||
|
|
||||||
// PEC (pointing error correction):
|
// PEC (pointing error correction):
|
||||||
// X - HA, Y - DEC for equatorial-type mount; X - AZ, Y - ALT for horizontal-type one
|
// 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)
|
MccMountTelemetry(astrom_engine_t& astrom_engine, pec_t& pec, hardware_t& hardware)
|
||||||
@ -189,13 +189,11 @@ public:
|
|||||||
return TEL_ERROR_OK;
|
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_t>(self)._updateMutex};
|
return std::move(_data);
|
||||||
|
|
||||||
return std::move(std::forward<self_t>(self)._data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user