#pragma once /* MOUNT CONTROL COMPONENTS LIBRARY */ #include #include #include #include #include namespace mcc { enum class MccMountType : uint8_t { GERMAN_TYPE, FORK_TYPE, CROSSAXIS_TYPE, ALTAZ_TYPE }; // mount state type concept template concept mcc_mount_state_c = requires(T t, const T t_const) { { t_const.ident() } -> std::same_as; typename T::context_t; { t.enter(std::declval()) } -> std::same_as; { t.exit(std::declval()) } -> std::same_as; }; // implements a Finite State Machine Pattern template class MccMount { typedef double mnt_coord_t; typedef double mnt_speed_t; typedef double time_point_t; public: static constexpr MccMountType mountType = MOUNT_TYPE; /* mount main-cycle variable quantities */ struct mount_state_t { // time-related time_point_t siderTime; // sideral time // target (user-input) current coordinates (in radians) mnt_coord_t tagRA, tagDEC; mnt_coord_t tagHA; mnt_coord_t tagAZ, tagZD; // encoder-measured current mount coordinates (in radians) mnt_coord_t mntRA, mntDEC; mnt_coord_t mntHA; mnt_coord_t mntAZ, mntZD; // encoder-measured current mount moving speed (in radians/s) mnt_speed_t mntSpeedX, mntSpeedY; // X - HA, Y - DEC for equatorial-type mount; X - AZ, Y - ZD for horizontal-type one // current refraction coefficient mnt_coord_t currRefr; // PCS (pointing correction system) corrections mnt_coord_t pcsX, pcsY; // X - HA, Y - DEC for equatorial-type mount; X - AZ, Y - ZD for horizontal-type one // mount current state }; MccMount() { _exitCurrentState = []() {}; // do nothing } virtual ~MccMount() {} template void setMountState(StateT& state) { _exitCurrentState(); // exit from current state _exitCurrentState = [&state, this]() { state.exit(this); }; state.enter(this); } protected: std::function _exitCurrentState; std::atomic _mountCurrentState; void updateMountState() {} }; } // namespace mcc