162 lines
4.0 KiB
C++
162 lines
4.0 KiB
C++
#pragma once
|
|
|
|
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
|
|
|
|
|
/* MCC LIBRARY DEFAULT IMPLEMENTATION OF SOME CLASSES */
|
|
|
|
// #include <compare>
|
|
|
|
#include "mcc_generics.h"
|
|
|
|
namespace mcc
|
|
{
|
|
|
|
|
|
/* DEFAULT TIME-RELATED CLASSES */
|
|
|
|
typedef std::chrono::system_clock::time_point MccTimePoint;
|
|
|
|
|
|
typedef std::chrono::duration<double> MccTimeDuration; // seconds as floating-point value
|
|
|
|
template <traits::mcc_time_duration_c DT>
|
|
static constexpr DT mcc_infinite_duration_v =
|
|
std::floating_point<typename DT::rep> ? DT{std::numeric_limits<typename DT::rep>::infinity()}
|
|
: DT{std::numeric_limits<typename DT::rep>::max()};
|
|
|
|
|
|
/* DEFAULT JULIAN DAY CLASS */
|
|
|
|
struct MccJulianDay {
|
|
static constexpr double MJD0 = 2400000.5;
|
|
|
|
MccJulianDay() = default;
|
|
|
|
MccJulianDay(double jd) : mjd(jd - MJD0) {}
|
|
|
|
constexpr operator double() const
|
|
{
|
|
return MccJulianDay::MJD0 + mjd;
|
|
}
|
|
|
|
MccJulianDay& operator=(double jd)
|
|
{
|
|
mjd = jd - MJD0;
|
|
|
|
return *this;
|
|
}
|
|
|
|
double MJD() const
|
|
{
|
|
return mjd;
|
|
}
|
|
|
|
constexpr auto operator<=>(const MccJulianDay&) const = default;
|
|
|
|
constexpr auto operator<=>(double v) const
|
|
{
|
|
return v <=> (MccJulianDay::MJD0 + mjd);
|
|
};
|
|
|
|
protected:
|
|
double mjd{51544.5}; // J2000.0
|
|
};
|
|
|
|
|
|
/* DEFAULT CELESTIAL POINT CLASS */
|
|
|
|
|
|
template <mcc_angle_c CoordT>
|
|
struct MccGenericCelestialPoint {
|
|
typedef CoordT coord_t;
|
|
|
|
MccCoordPairKind pair_kind{MccCoordPairKind::COORDS_KIND_RADEC_ICRS};
|
|
|
|
// MccTimePoint time_point{std::chrono::sys_days(std::chrono::year_month_day{std::chrono::January / 1 / 2000}) +
|
|
// std::chrono::hours(12)}; // J2000.0
|
|
|
|
MccTimePoint time_point{std::chrono::sys_days(std::chrono::year_month_day(
|
|
std::chrono::January / std::chrono::day(1) / std::chrono::year(2000))) +
|
|
std::chrono::hours(11) + std::chrono::minutes(58) +
|
|
std::chrono::milliseconds(55816)}; // J2000.0 UTC
|
|
|
|
|
|
coord_t X{}, Y{};
|
|
};
|
|
|
|
|
|
typedef MccGenericCelestialPoint<double> MccCelestialPoint;
|
|
|
|
|
|
template <mcc_angle_c CoordT>
|
|
struct MccGenericEqtHrzCoords : MccGenericCelestialPoint<CoordT> {
|
|
using typename MccGenericCelestialPoint<CoordT>::coord_t;
|
|
|
|
using MccGenericCelestialPoint<CoordT>::time_point;
|
|
|
|
coord_t RA_APP{}, DEC_APP{}, HA{}, AZ{}, ZD{}, ALT{};
|
|
};
|
|
|
|
typedef MccGenericEqtHrzCoords<MccCelestialPoint::coord_t> MccEqtHrzCoords;
|
|
|
|
|
|
template <mcc_angle_c CoordT>
|
|
struct MccGenericPointingTarget : MccGenericEqtHrzCoords<CoordT> {
|
|
using typename MccGenericEqtHrzCoords<CoordT>::coord_t;
|
|
|
|
coord_t RA_ICRS{}, DEC_ICRS{};
|
|
};
|
|
|
|
|
|
typedef MccGenericPointingTarget<MccCelestialPoint::coord_t> MccPointingTarget;
|
|
|
|
|
|
|
|
template <mcc_angle_c CoordT>
|
|
struct MccGenericPCMResult {
|
|
CoordT pcmX, pcmY;
|
|
};
|
|
|
|
|
|
typedef MccGenericPCMResult<double> MccPCMResult;
|
|
|
|
|
|
/* DEFAULT TELEMETRY DATA CLASS */
|
|
|
|
template <mcc_angle_c CoordT>
|
|
struct MccGenericTelemetryData : MccGenericEqtHrzCoords<CoordT> {
|
|
using typename MccGenericEqtHrzCoords<CoordT>::coord_t;
|
|
|
|
MccJulianDay JD;
|
|
coord_t LST; // local apparent sideral time
|
|
|
|
MccGenericPointingTarget<coord_t> target{};
|
|
|
|
coord_t speedX, speedY;
|
|
|
|
coord_t pcmX, pcmY;
|
|
|
|
coord_t refCorr;
|
|
};
|
|
|
|
|
|
typedef MccGenericTelemetryData<MccCelestialPoint::coord_t> MccTelemetryData;
|
|
|
|
|
|
|
|
template <mcc_ccte_c CCTE_T, mcc_hardware_c HARDWARE_T, mcc_PCM_c PCM_T>
|
|
struct MccPositionControls : CCTE_T, HARDWARE_T, PCM_T {
|
|
virtual ~MccPositionControls() = default;
|
|
};
|
|
|
|
|
|
/* JUST CHECK FOR CONCEPT CONSISTENCY */
|
|
|
|
static_assert(mcc_julday_c<MccJulianDay>, "");
|
|
static_assert(mcc_celestial_point_c<MccCelestialPoint>, "");
|
|
static_assert(mcc_telemetry_data_c<MccTelemetryData>, "");
|
|
|
|
|
|
} // namespace mcc
|