...
This commit is contained in:
@@ -9,6 +9,74 @@
|
||||
|
||||
#include "mcc_mount_concepts.h"
|
||||
|
||||
namespace mcc
|
||||
{
|
||||
|
||||
enum class MccMountTelemetryAstromTransformErrorCode : int {
|
||||
ERROR_OK = 0,
|
||||
ERROR_COORD_PAIR_KIND,
|
||||
ERROR_ASTROMETRY_COMP,
|
||||
ERROR_PEC
|
||||
};
|
||||
|
||||
|
||||
/* error category definition */
|
||||
|
||||
// error category
|
||||
struct MccMountTelemetryAstromTransformCategory : public std::error_category {
|
||||
MccMountTelemetryAstromTransformCategory() : std::error_category() {}
|
||||
|
||||
const char* name() const noexcept
|
||||
{
|
||||
return "ADC_GENERIC_DEVICE";
|
||||
}
|
||||
|
||||
std::string message(int ec) const
|
||||
{
|
||||
MccMountTelemetryAstromTransformErrorCode err = static_cast<MccMountTelemetryAstromTransformErrorCode>(ec);
|
||||
|
||||
switch (err) {
|
||||
case MccMountTelemetryAstromTransformErrorCode::ERROR_OK:
|
||||
return "OK";
|
||||
case MccMountTelemetryAstromTransformErrorCode::ERROR_COORD_PAIR_KIND:
|
||||
return "unsupported coordinate pair kind";
|
||||
case MccMountTelemetryAstromTransformErrorCode::ERROR_ASTROMETRY_COMP:
|
||||
return "astrometry engine error";
|
||||
case MccMountTelemetryAstromTransformErrorCode::ERROR_PEC:
|
||||
return "PEC computation error";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
static const MccMountTelemetryAstromTransformCategory& get()
|
||||
{
|
||||
static const MccMountTelemetryAstromTransformCategory constInst;
|
||||
return constInst;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
inline std::error_code make_error_code(MccMountTelemetryAstromTransformErrorCode ec)
|
||||
{
|
||||
return std::error_code(static_cast<int>(ec), MccMountTelemetryAstromTransformCategory::get());
|
||||
}
|
||||
|
||||
|
||||
} // namespace mcc
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template <>
|
||||
class is_error_code_enum<mcc::MccMountTelemetryAstromTransformErrorCode> : public true_type
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
||||
|
||||
namespace mcc
|
||||
{
|
||||
|
||||
@@ -18,13 +86,23 @@ class MccMountTelemetryAstromTransform
|
||||
static typename ASTROM_ENGINE_T::coord_t dummyCoord{};
|
||||
|
||||
public:
|
||||
typedef ASTROM_ENGINE_T astrom_engine_t;
|
||||
typedef PEC_T pec_t;
|
||||
|
||||
// check for coordinate types consistency
|
||||
static_assert(
|
||||
requires(typename astrom_engine_t::coord_t ac, typename pec_t::coord_t pc) {
|
||||
// to compute PEC-corrected values
|
||||
{ ac += pc };
|
||||
{ ac = ac + pc };
|
||||
{ ac = ac - pc };
|
||||
},
|
||||
"ASTROMETRY ENGINE AND PEC COORDINATES TYPE MUST BE CONSISTENT!");
|
||||
|
||||
// deduce mount type
|
||||
static constexpr bool equatorialMount = mccIsEquatorialMount(PEC_T::mountType);
|
||||
static constexpr bool altAzMount = mccIsAltAzMount(PEC_T::mountType);
|
||||
|
||||
typedef ASTROM_ENGINE_T astrom_engine_t;
|
||||
typedef PEC_T pec_t;
|
||||
|
||||
typedef typename astrom_engine_t::coord_t coord_t;
|
||||
|
||||
typedef std::error_code error_t;
|
||||
@@ -153,14 +231,14 @@ public:
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return std::make_error_code(std::errc::operation_canceled);
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_COORD_PAIR_KIND;
|
||||
}
|
||||
|
||||
if (pec_err) {
|
||||
if constexpr (std::same_as<decltype(pec_err), error_t>) {
|
||||
return pec_err;
|
||||
} else {
|
||||
return std::make_error_code(std::errc::operation_canceled);
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_PEC;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,11 +246,11 @@ public:
|
||||
if constexpr (std::same_as<decltype(ast_err), error_t>) {
|
||||
return ast_err;
|
||||
} else {
|
||||
return std::make_error_code(std::errc::operation_canceled);
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_ASTROMETRY_COMP;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -211,9 +289,9 @@ public:
|
||||
RA = coord.x;
|
||||
DEC = coord.y;
|
||||
|
||||
return {};
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_OK;
|
||||
} else {
|
||||
return std::make_error_code(std::errc::operation_canceled);
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_COORD_PAIR_KIND;
|
||||
}
|
||||
|
||||
if (coord.coordPairKind != MccCoordPairKind::COORDS_KIND_RADEC_ICRS) {
|
||||
@@ -229,7 +307,7 @@ public:
|
||||
if constexpr (std::same_as<decltype(pec_err), error_t>) {
|
||||
return pec_err;
|
||||
} else {
|
||||
return std::make_error_code(std::errc::operation_canceled);
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_PEC;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,11 +315,11 @@ public:
|
||||
if constexpr (std::same_as<decltype(ast_err), error_t>) {
|
||||
return ast_err;
|
||||
} else {
|
||||
return std::make_error_code(std::errc::operation_canceled);
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_ASTROMETRY_COMP;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -277,7 +355,7 @@ public:
|
||||
X = coord.x;
|
||||
Y = coord.y;
|
||||
|
||||
return {};
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_OK;
|
||||
} else if (coord.coordPairKind == MccCoordPairKind::COORDS_KIND_RADEC_APP) { // from app RA-DEC
|
||||
ast_err = get_jd_lst_eo(jd, lst, eo);
|
||||
|
||||
@@ -296,7 +374,7 @@ public:
|
||||
X = coord.x - pec_res.dx;
|
||||
Y = coord.y - pec_res.dy;
|
||||
|
||||
return {};
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_OK;
|
||||
}
|
||||
} else if constexpr (altAzMount) {
|
||||
coord_t az, alt;
|
||||
@@ -312,20 +390,65 @@ public:
|
||||
static_assert(false, "UNSUPPORTED MOUNT TYPE!");
|
||||
}
|
||||
} else if (coord.coordPairKind == MccCoordPairKind::COORDS_KIND_AZALT) { // from app AZ-ALT
|
||||
} else if (coord.coordPairKind == MccCoordPairKind::COORDS_KIND_AZZD) { // from app AZ-ZD
|
||||
if constexpr (equatorialMount) {
|
||||
coord_t ha, dec;
|
||||
ast_err = _astromEngine.azalt2hadec(coord.x, coord.y, ha, dec);
|
||||
if (!ast_err) {
|
||||
coord.coordPairKind == MccCoordPairKind::COORDS_KIND_HADEC_APP;
|
||||
coord.x = ha;
|
||||
coord.y = dec;
|
||||
|
||||
ast_err = toHardware(std::move(coord), std::move(time_point), X, Y);
|
||||
}
|
||||
} else if constexpr (altAzMount) {
|
||||
typename pec_t::pec_result_t pec_res;
|
||||
|
||||
pec_err = _pec.compute(coord.x, coord.y, pec_res);
|
||||
if (!pec_err) {
|
||||
X = coord.x - pec_res.dx;
|
||||
Y = coord.y - pec_res.dy;
|
||||
|
||||
return {};
|
||||
}
|
||||
} else {
|
||||
static_assert(false, "UNSUPPORTED MOUNT TYPE!");
|
||||
}
|
||||
} else if (coord.coordPairKind == MccCoordPairKind::COORDS_KIND_AZZD) { // from app AZ-ZD
|
||||
coord.coordPairKind == MccCoordPairKind::COORDS_KIND_AZALT;
|
||||
coord.y = std::numbers::pi / 2.0 - coord.y;
|
||||
ast_err = toICRS(std::move(coord), std::move(time_point), X, Y);
|
||||
} else if (coord.coordPairKind == MccCoordPairKind::COORDS_KIND_RADEC_ICRS) { // from ICRS RA-DEC
|
||||
coord_t ra, dec, ha, az, alt;
|
||||
eo_t eo;
|
||||
|
||||
ast_err = _astromEngine.greg2jul(time_point, jd);
|
||||
if (!ast_err) {
|
||||
ast_err = icrs2obs(coord.x, coord.y, jd, ra, dec, ha, az, alt, eo);
|
||||
if (!ast_err) {
|
||||
if constexpr (equatorialMount) {
|
||||
coord.coordPairKind == MccCoordPairKind::COORDS_KIND_HADEC_APP;
|
||||
coord.x = ha;
|
||||
coord.y = dec;
|
||||
} else if constexpr (altAzMount) {
|
||||
coord.coordPairKind == MccCoordPairKind::COORDS_KIND_AZALT;
|
||||
coord.x = az;
|
||||
coord.y = alt;
|
||||
} else {
|
||||
static_assert(false, "UNSUPPORTED MOUNT TYPE!");
|
||||
}
|
||||
|
||||
ast_err = toHardware(std::move(coord), std::move(time_point), X, Y);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return std::make_error_code(std::errc::operation_canceled);
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_COORD_PAIR_KIND;
|
||||
}
|
||||
|
||||
if (pec_err) {
|
||||
if constexpr (std::same_as<decltype(pec_err), error_t>) {
|
||||
return pec_err;
|
||||
} else {
|
||||
return std::make_error_code(std::errc::operation_canceled);
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_PEC;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,11 +456,11 @@ public:
|
||||
if constexpr (std::same_as<decltype(ast_err), error_t>) {
|
||||
return ast_err;
|
||||
} else {
|
||||
return std::make_error_code(std::errc::operation_canceled);
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_ASTROMETRY_COMP;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
return MccMountTelemetryAstromTransformErrorCode::ERROR_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user